[Bf-blender-cvs] [bb9355e7031] blender2.8: View3D: Remove v3d->zbuf

Clément Foucault noreply at git.blender.org
Tue Jul 3 19:36:36 CEST 2018


Commit: bb9355e7031404a4e0374ad49928e0fcad1f0aaa
Author: Clément Foucault
Date:   Tue Jul 3 19:22:00 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBbb9355e7031404a4e0374ad49928e0fcad1f0aaa

View3D: Remove v3d->zbuf

This is because depth test is set before drawing anything now. There is no
case where we want to draw without depth test that is not selection and
this case is not handle by v3d->zbuf anymore.

UI assume depth test is off by default. The DRWManager assume it's on.

This should fix T55623.

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

M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/intern/draw_manager_text.c
M	source/blender/draw/intern/draw_manager_text.h
M	source/blender/draw/intern/draw_view.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/mesh/editmesh_loopcut.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_snap.c
M	source/blender/makesdna/DNA_view3d_types.h

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

diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index b7326ca5842..ea25739e52d 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -877,7 +877,7 @@ static void drw_engines_draw_text(void)
 		PROFILE_START(stime);
 
 		if (data->text_draw_cache) {
-			DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.v3d, DST.draw_ctx.ar, false);
+			DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.ar);
 		}
 
 		PROFILE_END_UPDATE(data->render_time, stime);
@@ -1237,9 +1237,7 @@ void DRW_draw_render_loop_ex(
 	RegionView3D *rv3d = ar->regiondata;
 
 	DST.draw_ctx.evil_C = evil_C;
-
 	DST.viewport = viewport;
-	v3d->zbuf = true;
 
 	/* Setup viewport */
 	GPU_viewport_engines_data_validate(DST.viewport, DRW_engines_get_hash());
@@ -1658,8 +1656,6 @@ void DRW_draw_select_loop(
 	GPU_viewport_size_set(viewport, (const int[2]){BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)});
 
 	DST.viewport = viewport;
-	v3d->zbuf = true;
-
 	DST.options.is_select = true;
 
 	/* Get list of enabled engines */
@@ -1853,10 +1849,7 @@ void DRW_draw_depth_loop(
 	GPU_framebuffer_bind(g_select_buffer.framebuffer);
 	GPU_framebuffer_clear_depth(g_select_buffer.framebuffer, 1.0f);
 
-	bool cache_is_dirty;
 	DST.viewport = viewport;
-	v3d->zbuf = true;
-
 	DST.options.is_depth = true;
 
 	/* Get list of enabled engines */
@@ -1866,7 +1859,6 @@ void DRW_draw_depth_loop(
 	}
 
 	/* Setup viewport */
-	cache_is_dirty = true;
 
 	/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
 	DST.draw_ctx = (DRWContextState){
@@ -1885,10 +1877,7 @@ void DRW_draw_depth_loop(
 	drw_engines_init();
 	DRW_hair_init();
 
-	/* TODO : tag to refresh by the dependency graph */
-	/* ideally only refresh when objects are added/removed */
-	/* or render properties / materials change */
-	if (cache_is_dirty) {
+	{
 		drw_engines_cache_init();
 
 		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c
index 56255af98ce..1f385b958b8 100644
--- a/source/blender/draw/intern/draw_manager_text.c
+++ b/source/blender/draw/intern/draw_manager_text.c
@@ -111,9 +111,7 @@ void DRW_text_cache_add(
 	}
 }
 
-void DRW_text_cache_draw(
-        DRWTextStore *dt,
-        View3D *v3d, ARegion *ar, bool depth_write)
+void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar)
 {
 	RegionView3D *rv3d = ar->regiondata;
 	ViewCachedString *vos;
@@ -149,13 +147,6 @@ void DRW_text_cache_draw(
 		gpuPushMatrix();
 		gpuLoadIdentity();
 
-		if (depth_write) {
-			if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-		}
-		else {
-			glDepthMask(GL_FALSE);
-		}
-
 		const int font_id = BLF_default();
 
 		const uiStyle *style = UI_style_get();
@@ -171,7 +162,7 @@ void DRW_text_cache_draw(
 
 				BLF_position(
 				        font_id,
-				        (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1]), (depth_write) ? 0.0f : 2.0f);
+				        (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1]), 2.0f);
 
 				((vos->flag & DRW_TEXT_CACHE_ASCII) ?
 				 BLF_draw_ascii :
@@ -182,13 +173,6 @@ void DRW_text_cache_draw(
 			}
 		}
 
-		if (depth_write) {
-			if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-		}
-		else {
-			glDepthMask(GL_TRUE);
-		}
-
 		gpuPopMatrix();
 		gpuLoadProjectionMatrix(original_proj);
 
diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h
index a58e167be0d..a675a200924 100644
--- a/source/blender/draw/intern/draw_manager_text.h
+++ b/source/blender/draw/intern/draw_manager_text.h
@@ -36,9 +36,7 @@ void DRW_text_cache_add(
         short xoffs, short flag,
         const unsigned char col[4]);
 
-void DRW_text_cache_draw(
-        struct DRWTextStore *dt,
-        struct View3D *v3d, struct ARegion *ar, bool depth_write);
+void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *ar);
 
 enum {
 	DRW_TEXT_CACHE_ASCII        = (1 << 0),
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index a666ec5395f..347932619b9 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -744,8 +744,6 @@ void DRW_draw_cursor(void)
 void DRW_draw_manipulator_3d(void)
 {
 	const DRWContextState *draw_ctx = DRW_context_state_get();
-	View3D *v3d = draw_ctx->v3d;
-	v3d->zbuf = false;
 	ARegion *ar = draw_ctx->ar;
 
 	/* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */
@@ -760,8 +758,6 @@ void DRW_draw_manipulator_3d(void)
 void DRW_draw_manipulator_2d(void)
 {
 	const DRWContextState *draw_ctx = DRW_context_state_get();
-	View3D *v3d = draw_ctx->v3d;
-	v3d->zbuf = false;
 	ARegion *ar = draw_ctx->ar;
 
 	WM_manipulatormap_draw(
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index e679b04f25d..5e3fec93340 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -373,7 +373,6 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 		return;
 	}
 
-	View3D *v3d = cdd->vc.v3d;
 	Object *obedit = cdd->vc.obedit;
 	Curve *cu = obedit->data;
 
@@ -434,37 +433,29 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 			unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 			immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 
+			GPU_depth_test(false);
 			GPU_blend(true);
 			GPU_line_smooth(true);
+			GPU_line_width(3.0f);
 
 			imm_cpack(0x0);
 			immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
-			GPU_line_width(3.0f);
-
-			if (v3d->zbuf) {
-				GPU_depth_test(false);
-			}
-
 			for (int i = 0; i < stroke_len; i++) {
 				immVertex3fv(pos, coord_array[i]);
 			}
-
 			immEnd();
 
-			imm_cpack(0xffffffff);
-			immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
 			GPU_line_width(1.0f);
 
+			imm_cpack(0xffffffff);
+			immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
 			for (int i = 0; i < stroke_len; i++) {
 				immVertex3fv(pos, coord_array[i]);
 			}
-
 			immEnd();
 
-			if (v3d->zbuf) {
-				GPU_depth_test(true);
-			}
-
+			/* Reset defaults */
+			GPU_depth_test(true);
 			GPU_blend(false);
 			GPU_line_smooth(false);
 
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index a511100ff4e..8f8400e2d20 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1037,12 +1037,11 @@ static void knife_init_colors(KnifeColors *colors)
 }
 
 /* modal loop selection drawing callback */
-static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
+static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
 {
-	View3D *v3d = CTX_wm_view3d(C);
 	const KnifeTool_OpData *kcd = arg;
 
-	if (v3d->zbuf) GPU_depth_test(false);
+	GPU_depth_test(false);
 
 	glPolygonOffset(1.0f, 1.0f);
 
@@ -1196,7 +1195,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
 	gpuPopMatrix();
 
-	if (v3d->zbuf) GPU_depth_test(true);
+	/* Reset default */
+	GPU_depth_test(true);
 }
 
 /**
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 8493d15a3b1..b437bdca111 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -106,14 +106,12 @@ typedef struct RingSelOpData {
 } RingSelOpData;
 
 /* modal loop selection drawing callback */
-static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
+static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
 {
-	View3D *v3d = CTX_wm_view3d(C);
 	RingSelOpData *lcd = arg;
 
 	if ((lcd->totedge > 0) || (lcd->totpoint > 0)) {
-		if (v3d && v3d->zbuf)
-			GPU_depth_test(false);
+		GPU_depth_test(false);
 
 		gpuPushMatrix();
 		gpuMultMatrix(lcd->ob->obmat);
@@ -150,8 +148,8 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
 		gpuPopMatrix();
 
-		if (v3d && v3d->zbuf)
-			GPU_depth_test(true);
+		/* Reset default */
+		GPU_depth_test(true);
 	}
 }
 
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0d5240d8e86..a428b60643d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -703,7 +703,6 @@ void ED_view3d_draw_depth(
 	Scene *scene = DEG_get_evaluated_scene(depsgraph);
 	RegionView3D *rv3d = ar->regiondata;
 
-	short zbuf = v3d->zbuf;
 	short flag = v3d->flag;
 	float glalphaclip = U.glalphaclip;
 	int obcenter_dia = U.obcenter_dia;
@@ -727,7 +726,6 @@ void ED_view3d_draw_depth(
 	/* get surface depth without bias */
 	rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
 
-	v3d->zbuf = true;
 	GPU_depth_test(true);
 
 	DRW_draw_depth_loop(depsgraph, ar, v3d);
@@ -737,8 +735,8 @@ void ED_view3d_draw_depth(
 	}
 	rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED;
 
-	v3d->zbuf = zbuf;
-	if (!v3d->zbuf) GPU_depth_test(false);
+	/* Reset default for UI */
+	GPU_depth_test(false);
 
 	U.glalphaclip = glalphaclip;
 	v3d->flag = flag;
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 06cdba3f537..cfeb199de15 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -210,7 +210,9 @@ static void backdrawview3d(
 	}
 #endif
 
+#if 0 /* v3d->zbuf deprecated */
 	if (v3d->drawtype > OB_WIRE) v3d->zbuf = true;
+#endif
 
 	/* dithering and AA break color coding, so disable */
 	glDisable(GL_DITHER);
@@ -249,14 +251,8 @@ static void backdrawview3d(
 		GPU_scissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
 
 	GPU_clear_color(0.0, 0.0, 0.0, 0.0);
-	if (v3d->zbuf) {
-		GPU_depth_test(true);
-		GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
-	}
-	else {
-		GPU_clear(GPU_COLOR_BIT);
-		GPU_depth_test(false);
-	}
+	GPU_depth_test(true)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list