[Bf-blender-cvs] [e97237892c8] blender2.8: Merge branch 'master' into blender2.8

Bastien Montagne noreply at git.blender.org
Mon Jun 25 12:51:00 CEST 2018


Commit: e97237892c804a0ea82fe430cf0e1f4d16039dc4
Author: Bastien Montagne
Date:   Mon Jun 25 12:50:32 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBe97237892c804a0ea82fe430cf0e1f4d16039dc4

Merge branch 'master' into blender2.8

Conflicts:
	source/blender/editors/sculpt_paint/paint_image.c
	source/blender/editors/space_view3d/view3d_draw.c
	source/blender/editors/space_view3d/view3d_view.c
	source/blender/gpu/GPU_draw.h
	source/blender/gpu/GPU_material.h
	source/blender/gpu/intern/gpu_draw.c
	source/blender/gpu/intern/gpu_material.c
	source/blender/makesrna/intern/rna_userdef.c
	source/blender/windowmanager/intern/wm_files_link.c
	source/blender/windowmanager/intern/wm_init_exit.c
	source/creator/creator_args.c
	source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
	source/gameengine/Ketsji/KX_PythonInit.cpp
	source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

===================================================================



===================================================================

diff --cc source/blender/draw/intern/draw_manager.c
index 7a6771ae058,00000000000..002333e5d34
mode 100644,000000..100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@@ -1,2239 -1,0 +1,2239 @@@
 +/*
 + * Copyright 2016, Blender Foundation.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * Contributor(s): Blender Institute
 + *
 + */
 +
 +/** \file blender/draw/intern/draw_manager.c
 + *  \ingroup draw
 + */
 +
 +#include <stdio.h>
 +
 +#include "BLI_listbase.h"
 +#include "BLI_mempool.h"
 +#include "BLI_rect.h"
 +#include "BLI_string.h"
 +#include "BLI_threads.h"
 +
 +#include "BLF_api.h"
 +
 +#include "BKE_global.h"
 +#include "BKE_mesh.h"
 +#include "BKE_object.h"
 +#include "BKE_particle.h"
 +#include "BKE_pointcache.h"
 +#include "BKE_workspace.h"
 +
 +#include "draw_manager.h"
 +#include "DNA_camera_types.h"
 +#include "DNA_mesh_types.h"
 +#include "DNA_meshdata_types.h"
 +
 +#include "ED_space_api.h"
 +#include "ED_screen.h"
 +#include "ED_particle.h"
 +#include "ED_view3d.h"
 +
 +#include "GPU_draw.h"
 +#include "GPU_extensions.h"
 +#include "GPU_framebuffer.h"
 +#include "GPU_immediate.h"
 +#include "GPU_uniformbuffer.h"
 +#include "GPU_viewport.h"
 +#include "GPU_matrix.h"
 +
 +#include "IMB_colormanagement.h"
 +
 +#include "RE_engine.h"
 +#include "RE_pipeline.h"
 +
 +#include "UI_interface.h"
 +#include "UI_resources.h"
 +
 +#include "WM_api.h"
 +#include "wm_window.h"
 +
 +#include "draw_manager_text.h"
 +#include "draw_manager_profiling.h"
 +
 +/* only for callbacks */
 +#include "draw_cache_impl.h"
 +
 +#include "draw_mode_engines.h"
 +#include "engines/eevee/eevee_engine.h"
 +#include "engines/basic/basic_engine.h"
 +#include "engines/workbench/workbench_engine.h"
 +#include "engines/external/external_engine.h"
 +
 +#include "../../../intern/gawain/gawain/gwn_context.h"
 +
 +#include "DEG_depsgraph.h"
 +#include "DEG_depsgraph_query.h"
 +
 +#ifdef USE_GPU_SELECT
 +#  include "GPU_select.h"
 +#endif
 +
 +/** Render State: No persistent data between draw calls. */
 +DRWManager DST = {NULL};
 +
 +ListBase DRW_engines = {NULL, NULL};
 +
 +extern struct GPUUniformBuffer *view_ubo; /* draw_manager_exec.c */
 +
 +static void drw_state_prepare_clean_for_draw(DRWManager *dst)
 +{
 +	memset(dst, 0x0, offsetof(DRWManager, gl_context));
 +}
 +
 +/* This function is used to reset draw manager to a state
 + * where we don't re-use data by accident across different
 + * draw calls.
 + */
 +#ifdef DEBUG
 +static void drw_state_ensure_not_reused(DRWManager *dst)
 +{
 +	memset(dst, 0xff, offsetof(DRWManager, gl_context));
 +}
 +#endif
 +
 +/* -------------------------------------------------------------------- */
 +
 +void DRW_draw_callbacks_pre_scene(void)
 +{
 +	RegionView3D *rv3d = DST.draw_ctx.rv3d;
 +
 +	gpuLoadProjectionMatrix(rv3d->winmat);
 +	gpuLoadMatrix(rv3d->viewmat);
 +}
 +
 +void DRW_draw_callbacks_post_scene(void)
 +{
 +	RegionView3D *rv3d = DST.draw_ctx.rv3d;
 +
 +	gpuLoadProjectionMatrix(rv3d->winmat);
 +	gpuLoadMatrix(rv3d->viewmat);
 +}
 +
 +struct DRWTextStore *DRW_text_cache_ensure(void)
 +{
 +	BLI_assert(DST.text_store_p);
 +	if (*DST.text_store_p == NULL) {
 +		*DST.text_store_p = DRW_text_cache_create();
 +	}
 +	return *DST.text_store_p;
 +}
 +
 +
 +/* -------------------------------------------------------------------- */
 +
 +/** \name Settings
 + * \{ */
 +
 +bool DRW_object_is_renderable(Object *ob)
 +{
 +	BLI_assert(BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE));
 +
 +	if (ob->type == OB_MESH) {
 +		if ((ob == DST.draw_ctx.object_edit) || BKE_object_is_in_editmode(ob)) {
 +			View3D *v3d = DST.draw_ctx.v3d;
 +			const int mask = (V3D_OVERLAY_EDIT_OCCLUDE_WIRE | V3D_OVERLAY_EDIT_WEIGHT);
 +
 +			if (v3d && v3d->overlay.edit_flag & mask) {
 +				return false;
 +			}
 +		}
 +	}
 +
 +	return true;
 +}
 +
 +/**
 + * Return whether this object is visible depending if
 + * we are rendering or drawing in the viewport.
 + */
 +bool DRW_check_object_visible_within_active_context(Object *ob)
 +{
 +	const eObjectVisibilityCheck mode = DRW_state_is_scene_render() ?
 +	                                     OB_VISIBILITY_CHECK_FOR_RENDER :
 +	                                     OB_VISIBILITY_CHECK_FOR_VIEWPORT;
 +	return BKE_object_is_visible(ob, mode);
 +}
 +
 +bool DRW_object_is_flat_normal(const Object *ob)
 +{
 +	if (ob->type == OB_MESH) {
 +		const Mesh *me = ob->data;
 +		if (me->mpoly && me->mpoly[0].flag & ME_SMOOTH) {
 +			return false;
 +		}
 +	}
 +	return true;
 +}
 +
 +bool DRW_check_psys_visible_within_active_context(
 +        Object *object,
 +        struct ParticleSystem *psys)
 +{
 +	const DRWContextState *draw_ctx = DRW_context_state_get();
 +	const Scene *scene = draw_ctx->scene;
 +	if (object == draw_ctx->object_edit) {
 +		return false;
 +	}
 +	const ParticleSettings *part = psys->part;
 +	const ParticleEditSettings *pset = &scene->toolsettings->particle;
 +	if (object->mode == OB_MODE_PARTICLE_EDIT) {
 +		if (psys_in_edit_mode(draw_ctx->depsgraph, psys)) {
 +			if ((pset->flag & PE_DRAW_PART) == 0) {
 +				return false;
 +			}
 +			if ((part->childtype == 0) &&
 +			    (psys->flag & PSYS_HAIR_DYNAMICS &&
 +			     psys->pointcache->flag & PTCACHE_BAKED) == 0)
 +			{
 +				return false;
 +			}
 +		}
 +	}
 +	return true;
 +}
 +
 +/** \} */
 +
 +
 +/* -------------------------------------------------------------------- */
 +
 +/** \name Color Management
 + * \{ */
 +
 +/* Use color management profile to draw texture to framebuffer */
 +void DRW_transform_to_display(GPUTexture *tex)
 +{
 +	drw_state_set(DRW_STATE_WRITE_COLOR);
 +
 +	Gwn_VertFormat *vert_format = immVertexFormat();
 +	uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +	uint texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +
 +	const float dither = 1.0f;
 +
 +	bool use_ocio = false;
 +
 +	/* View transform is already applied for offscreen, don't apply again, see: T52046 */
 +	if (!(DST.options.is_image_render && !DST.options.is_scene_render)) {
 +		Scene *scene = DST.draw_ctx.scene;
 +		use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(
 +		        &scene->view_settings, &scene->display_settings, NULL, dither, false);
 +	}
 +
 +	if (!use_ocio) {
 +		/* View transform is already applied for offscreen, don't apply again, see: T52046 */
 +		if (DST.options.is_image_render && !DST.options.is_scene_render) {
 +			immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
 +			immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
 +		}
 +		else {
 +			immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB);
 +		}
 +		immUniform1i("image", 0);
 +	}
 +
 +	GPU_texture_bind(tex, 0); /* OCIO texture bind point is 0 */
 +
 +	float mat[4][4];
 +	unit_m4(mat);
 +	immUniformMatrix4fv("ModelViewProjectionMatrix", mat);
 +
 +	/* Full screen triangle */
 +	immBegin(GWN_PRIM_TRIS, 3);
 +	immAttrib2f(texco, 0.0f, 0.0f);
 +	immVertex2f(pos, -1.0f, -1.0f);
 +
 +	immAttrib2f(texco, 2.0f, 0.0f);
 +	immVertex2f(pos, 3.0f, -1.0f);
 +
 +	immAttrib2f(texco, 0.0f, 2.0f);
 +	immVertex2f(pos, -1.0f, 3.0f);
 +	immEnd();
 +
 +	GPU_texture_unbind(tex);
 +
 +	if (use_ocio) {
 +		IMB_colormanagement_finish_glsl_draw();
 +	}
 +	else {
 +		immUnbindProgram();
 +	}
 +}
 +
 +/** \} */
 +
 +
 +/* -------------------------------------------------------------------- */
 +
 +/** \name Multisample Resolve
 + * \{ */
 +
 +/* Use manual multisample resolve pass.
 + * Much quicker than blitting back and forth.
 + * Assume destination fb is bound*/
 +void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color)
 +{
 +	drw_state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL |
 +	              DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
 +
 +	int samples = GPU_texture_samples(src_depth);
 +
 +	BLI_assert(samples > 0);
 +	BLI_assert(GPU_texture_samples(src_color) == samples);
 +
 +	Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
 +
 +	int builtin;
 +	switch (samples) {
 +		case 2:  builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2; break;
 +		case 4:  builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_4; break;
 +		case 8:  builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_8; break;
 +		case 16: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_16; break;
 +		default:
 +			BLI_assert(0);
 +			builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2;
 +			break;
 +	}
 +
 +	GWN_batch_program_set_builtin(geom, builtin);
 +
 +	GPU_texture_bind(src_depth, 0);
 +	GPU_texture_bind(src_color, 1);
 +	GWN_batch_uniform_1i(geom, "depthMulti", 0);
 +	GWN_batch_uniform_1i(geom, "colorMulti", 1);
 +
 +	float mat[4][4];
 +	unit_m4(mat);
 +	GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat);
 +
 +	/* avoid gpuMatrix calls */
 +	GWN_batch_program_use_begin(geom);
 +	GWN_batch_draw_range_ex(geom, 0, 0, false);
 +	GWN_batch_program_use_end(geom);
 +}
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +
 +/** \name Viewport (DRW_viewport)
 + * \{ */
 +
 +void *drw_viewport_engine_data_ensure(void *engine_type)
 +{
 +	void *data = GPU_viewport_engine_data_get(DST.viewport, engine_type);
 +
 +	if (data == NULL) {
 +		data = GPU_viewport_engine_data_create(DST.viewport, engine_type);
 +	}
 +	return data;
 +}
 +
 +void DRW_engine_viewport_data_size_get(
 +        const void *engine_type_v,
 +        int *r_fbl_len, int *r_txl_len, int *r_psl_len, int *r_stl_len)
 +{
 +	const DrawEngineType *engine_type = engine_type_v;
 +
 +	if (r_fbl_len)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list