[Bf-blender-cvs] [404f5476833] greasepencil-object: Fi T51923: Crashes on selecting bone in edit mode

Antonio Vazquez noreply at git.blender.org
Wed Sep 20 10:27:56 CEST 2017


Commit: 404f54768336ca921b14d1ee2c57ee2888d135fd
Author: Antonio Vazquez
Date:   Wed Sep 20 10:27:18 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB404f54768336ca921b14d1ee2c57ee2888d135fd

Fi T51923: Crashes on selecting bone in edit mode

Need to verify FBO state before initialize framebuffer

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

M	source/blender/draw/engines/gpencil/gpencil_engine.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 7fbfb28e99b..1f9775442e1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -65,47 +65,48 @@ static void GPENCIL_engine_init(void *vedata)
 	GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
 	GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
 
-	const float *viewport_size = DRW_viewport_size_get();
-
-	DRWFboTexture tex_color[2] = {{
-			&e_data.temp_fbcolor_depth_tx, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
-			{ &e_data.temp_fbcolor_color_tx, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
-	};
-	/* init temp framebuffer */
-	DRW_framebuffer_init(
-		&fbl->temp_color_fb, &draw_engine_gpencil_type,
-		(int)viewport_size[0], (int)viewport_size[1],
-		tex_color, ARRAY_SIZE(tex_color));
-
-	/* vfx */
-	DRWFboTexture vfx_color_a[2] = { {
-			&e_data.vfx_fbcolor_depth_tx_a, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
-			{ &e_data.vfx_fbcolor_color_tx_a, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
-	};
-	DRW_framebuffer_init(
-		&fbl->vfx_color_fb_a, &draw_engine_gpencil_type,
-		(int)viewport_size[0], (int)viewport_size[1],
-		vfx_color_a, ARRAY_SIZE(vfx_color_a));
-
-	DRWFboTexture vfx_color_b[2] = { {
-			&e_data.vfx_fbcolor_depth_tx_b, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
-			{ &e_data.vfx_fbcolor_color_tx_b, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
-	};
-	DRW_framebuffer_init(
-		&fbl->vfx_color_fb_b, &draw_engine_gpencil_type,
-		(int)viewport_size[0], (int)viewport_size[1],
-		vfx_color_b, ARRAY_SIZE(vfx_color_b));
-
-	/* painting framebuffer to speed up drawing process */
-	DRWFboTexture tex_painting[2] = { {
-			&e_data.painting_depth_tx, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
-			{ &e_data.painting_color_tx, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
-	};
-	DRW_framebuffer_init(
-		&fbl->painting_fb, &draw_engine_gpencil_type,
-		(int)viewport_size[0], (int)viewport_size[1],
-		tex_painting, ARRAY_SIZE(tex_painting));
-
+	if (DRW_state_is_fbo()) {
+		const float *viewport_size = DRW_viewport_size_get();
+
+		DRWFboTexture tex_color[2] = { {
+				&e_data.temp_fbcolor_depth_tx, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
+				{ &e_data.temp_fbcolor_color_tx, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
+		};
+		/* init temp framebuffer */
+		DRW_framebuffer_init(
+			&fbl->temp_color_fb, &draw_engine_gpencil_type,
+			(int)viewport_size[0], (int)viewport_size[1],
+			tex_color, ARRAY_SIZE(tex_color));
+
+		/* vfx */
+		DRWFboTexture vfx_color_a[2] = { {
+				&e_data.vfx_fbcolor_depth_tx_a, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
+				{ &e_data.vfx_fbcolor_color_tx_a, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
+		};
+		DRW_framebuffer_init(
+			&fbl->vfx_color_fb_a, &draw_engine_gpencil_type,
+			(int)viewport_size[0], (int)viewport_size[1],
+			vfx_color_a, ARRAY_SIZE(vfx_color_a));
+
+		DRWFboTexture vfx_color_b[2] = { {
+				&e_data.vfx_fbcolor_depth_tx_b, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
+				{ &e_data.vfx_fbcolor_color_tx_b, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
+		};
+		DRW_framebuffer_init(
+			&fbl->vfx_color_fb_b, &draw_engine_gpencil_type,
+			(int)viewport_size[0], (int)viewport_size[1],
+			vfx_color_b, ARRAY_SIZE(vfx_color_b));
+
+		/* painting framebuffer to speed up drawing process */
+		DRWFboTexture tex_painting[2] = { {
+				&e_data.painting_depth_tx, DRW_TEX_DEPTH_24, DRW_TEX_TEMP },
+				{ &e_data.painting_color_tx, DRW_TEX_RGBA_16, DRW_TEX_TEMP }
+		};
+		DRW_framebuffer_init(
+			&fbl->painting_fb, &draw_engine_gpencil_type,
+			(int)viewport_size[0], (int)viewport_size[1],
+			tex_painting, ARRAY_SIZE(tex_painting));
+	}
 	/* normal fill shader */
 	if (!e_data.gpencil_fill_sh) {
 		e_data.gpencil_fill_sh = DRW_shader_create(datatoc_gpencil_fill_vert_glsl, NULL,
@@ -571,86 +572,87 @@ static void GPENCIL_draw_scene(void *vedata)
 	ToolSettings *ts = scene->toolsettings;
 	bool playing = (bool)stl->storage->playing;
 
-	/* attach temp textures */
-	DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_depth_tx, 0, 0);
-	DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_color_tx, 0, 0);
-
-	DRW_framebuffer_texture_attach(fbl->vfx_color_fb_a, e_data.vfx_fbcolor_depth_tx_a, 0, 0);
-	DRW_framebuffer_texture_attach(fbl->vfx_color_fb_a, e_data.vfx_fbcolor_color_tx_a, 0, 0);
+	if (DRW_state_is_fbo()) {
+		/* attach temp textures */
+		DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_depth_tx, 0, 0);
+		DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_color_tx, 0, 0);
 
-	DRW_framebuffer_texture_attach(fbl->vfx_color_fb_b, e_data.vfx_fbcolor_depth_tx_b, 0, 0);
-	DRW_framebuffer_texture_attach(fbl->vfx_color_fb_b, e_data.vfx_fbcolor_color_tx_b, 0, 0);
+		DRW_framebuffer_texture_attach(fbl->vfx_color_fb_a, e_data.vfx_fbcolor_depth_tx_a, 0, 0);
+		DRW_framebuffer_texture_attach(fbl->vfx_color_fb_a, e_data.vfx_fbcolor_color_tx_a, 0, 0);
 
-	DRW_framebuffer_texture_attach(fbl->painting_fb, e_data.painting_depth_tx, 0, 0);
-	DRW_framebuffer_texture_attach(fbl->painting_fb, e_data.painting_color_tx, 0, 0);
+		DRW_framebuffer_texture_attach(fbl->vfx_color_fb_b, e_data.vfx_fbcolor_depth_tx_b, 0, 0);
+		DRW_framebuffer_texture_attach(fbl->vfx_color_fb_b, e_data.vfx_fbcolor_color_tx_b, 0, 0);
 
-	/* if we have a painting session, we use fast viewport drawing method */
-	if (stl->g_data->session_flag & GP_DRW_PAINT_PAINTING) {
-		DRW_framebuffer_bind(dfbl->default_fb);
-		DRW_draw_pass(psl->painting_pass);
-		DRW_draw_pass(psl->drawing_pass);
-	}
-	else {
-		/* Draw all pending objects */
-		if (stl->g_data->gp_cache_used > 0) {
+		DRW_framebuffer_texture_attach(fbl->painting_fb, e_data.painting_depth_tx, 0, 0);
+		DRW_framebuffer_texture_attach(fbl->painting_fb, e_data.painting_color_tx, 0, 0);
 
-			/* sort by zdepth */
-			qsort(stl->g_data->gp_object_cache, stl->g_data->gp_cache_used,
-				sizeof(tGPencilObjectCache), gpencil_object_cache_compare_zdepth);
-
-			for (int i = 0; i < stl->g_data->gp_cache_used; ++i) {
-				cache = &stl->g_data->gp_object_cache[i];
-				Object *ob = cache->ob;
-				init_grp = cache->init_grp;
-				end_grp = cache->end_grp;
-				/* Render stroke in separated framebuffer */
-				DRW_framebuffer_bind(fbl->temp_color_fb);
-				DRW_framebuffer_clear(true, true, false, clearcol, 1.0f);
-
-				/* Stroke Pass: DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH
-				 * draw only a subset that usually start with a fill and end with stroke because the
-				 * shading groups are created by pairs */
-				if (G.debug_value == 668) {
-					printf("GPENCIL_draw_scene: %s %d->%d\n", ob->id.name, init_grp, end_grp);
-				}
-
-				if (end_grp >= init_grp) {
-					DRW_draw_pass_subset(psl->stroke_pass,
-						stl->shgroups[init_grp].shgrps_fill != NULL ? stl->shgroups[init_grp].shgrps_fill : stl->shgroups[init_grp].shgrps_stroke,
-						stl->shgroups[end_grp].shgrps_stroke);
-				}
-				/* Current buffer drawing */
-				if (ob->gpd->sbuffer_size > 0) {
-					DRW_draw_pass(psl->drawing_pass);
-				}
-
-				/* vfx modifiers passes
-				 * if any vfx modifier exist, the init_vfx_wave_sh will be not NULL.
-				 */
-				if ((cache->init_vfx_wave_sh) && (cache->end_vfx_wave_sh) && (!GP_SIMPLIFY_VFX(ts, playing))) {
-					/* add vfx and combine result with default framebuffer */
-					gpencil_vfx_passes(vedata, cache);
-					/* Combine with default scene buffer always using tx_a as source texture */
-					DRW_framebuffer_bind(dfbl->default_fb);
-					/* Mix VFX Pass */
-					DRW_draw_pass(psl->mix_vfx_pass);
-					/* prepare for fast drawing */	
-					gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_vfx_pass_noblend, clearcol);
-				}
-				else {
-					/* Combine with scene buffer without more passes */
-					DRW_framebuffer_bind(dfbl->default_fb);
-					/* Mix Pass: DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS */
-					DRW_draw_pass(psl->mix_pass);
-					/* prepare for fast drawing */
-					gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_pass_noblend, clearcol);
+		/* if we have a painting session, we use fast viewport drawing method */
+		if (stl->g_data->session_flag & GP_DRW_PAINT_PAINTING) {
+			DRW_framebuffer_bind(dfbl->default_fb);
+			DRW_draw_pass(psl->painting_pass);
+			DRW_draw_pass(psl->drawing_pass);
+		}
+		else {
+			/* Draw all pending objects */
+			if (stl->g_data->gp_cache_used > 0) {
+
+				/* sort by zdepth */
+				qsort(stl->g_data->gp_object_cache, stl->g_data->gp_cache_used,
+					sizeof(tGPencilObjectCache), gpencil_object_cache_compare_zdepth);
+
+				for (int i = 0; i < stl->g_data->gp_cache_used; ++i) {
+					cache = &stl->g_data->gp_object_cache[i];
+					Object *ob = cache->ob;
+					init_grp = cache->init_grp;
+					end_grp = cache->end_grp;
+					/* Render stroke in separated framebuffer */
+					DRW_framebuffer_bind(fbl->temp_color_fb);
+					DRW_framebuffer_clear(true, true, false, clearcol, 1.0f);
+
+					/* Stroke Pass: DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH
+					 * draw only a subset that usually start with a fill and end with stroke because the
+					 * shading groups are created by pairs */
+					if (G.debug_value == 668) {
+						printf("GPENCIL_draw_scene: %s %d->%d\n", ob->id.name, init_grp, end_grp);
+					}
+
+					if (end_grp >= init_grp) {
+						DRW_draw_pass_subset(psl->stroke_pass,
+							stl->shgroups[init_grp].shgrps_fill != NULL ? stl->shgroups[init_grp].shgrps_fill : stl->shgroups[init_grp].shgrps_stroke,
+							stl->shgroups[end_grp].shgrps_stroke);
+					}
+					/* Current buffer drawing */
+					if (ob->gpd->sbuffer_size > 0) {
+						DRW_draw_pass(psl->drawing_pass);
+					}
+
+					/* vfx modifiers passes
+					 * if any vfx modifier exist, the init_vfx_wave_sh will be not NULL.
+					 */
+					if ((cache->init_vfx_wave_sh) && (cache->end_vfx_wave_sh) && (!GP_SIMPLIFY_VFX(ts, playing))) {
+						/* add vfx and combine result with default framebuffer */
+						gpencil_vfx_passes(vedata, cache);
+						/* Combine with default scene buffer always using tx_a as source texture */
+						DRW_framebuffer_bind(dfbl->default_fb);
+						/* Mix VFX Pass */
+						DRW_draw_pass(psl->mix_vfx_pass);
+						/* 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list