[Mesa-dev] [PATCH 01/11] r600: handle writes_memory properly

Dave Airlie airlied at gmail.com
Wed Nov 15 00:11:02 UTC 2017


From: Dave Airlie <airlied at redhat.com>

This implements proper handling for shaders with side effects.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/drivers/r600/evergreen_state.c | 10 +++++++---
 src/gallium/drivers/r600/evergreend.h      |  6 ++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index b02d7ee..6920b74 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -3168,8 +3168,12 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
 	db_shader_control |= S_02880C_STENCIL_EXPORT_ENABLE(stencil_export);
 	db_shader_control |= S_02880C_MASK_EXPORT_ENABLE(mask_export);
 
-	if (shader->selector->info.properties[TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL])
-		db_shader_control |= S_02880C_DEPTH_BEFORE_SHADER(1);
+	if (shader->selector->info.properties[TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL]) {
+		db_shader_control |= S_02880C_DEPTH_BEFORE_SHADER(1) |
+			S_02880C_EXEC_ON_NOOP(shader->selector->info.writes_memory);
+	} else if (shader->selector->info.writes_memory) {
+		db_shader_control |= S_02880C_EXEC_ON_HIER_FAIL(1);
+	}
 
 	switch (rshader->ps_conservative_z) {
 	default: /* fall through */
@@ -3487,7 +3491,7 @@ void evergreen_update_db_shader_control(struct r600_context * rctx)
 	 * get a hang unless you flush the DB in between.  For now just use
 	 * LATE_Z.
 	 */
-	if (rctx->alphatest_state.sx_alpha_test_control) {
+	if (rctx->alphatest_state.sx_alpha_test_control || rctx->ps_shader->info.writes_memory) {
 		db_shader_control |= S_02880C_Z_ORDER(V_02880C_LATE_Z);
 	} else {
 		db_shader_control |= S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z);
diff --git a/src/gallium/drivers/r600/evergreend.h b/src/gallium/drivers/r600/evergreend.h
index af79bb7..f8a256c 100644
--- a/src/gallium/drivers/r600/evergreend.h
+++ b/src/gallium/drivers/r600/evergreend.h
@@ -988,6 +988,12 @@
 #define   S_02880C_DUAL_EXPORT_ENABLE(x)               (((unsigned)(x) & 0x1) << 9)
 #define   G_02880C_DUAL_EXPORT_ENABLE(x)               (((x) >> 9) & 0x1)
 #define   C_02880C_DUAL_EXPORT_ENABLE                  0xFFFFFDFF
+#define   S_02880C_EXEC_ON_HIER_FAIL(x)                (((unsigned)(x) & 0x1) << 10)
+#define   G_02880C_EXEC_ON_HIER_FAIL(x)                (((x) >> 10) & 0x1)
+#define   C_02880C_EXEC_ON_HIER_FAIL                   0xFFFFFBFF
+#define   S_02880C_EXEC_ON_NOOP(x)                     (((unsigned)(x) & 0x1) << 11)
+#define   G_02880C_EXEC_ON_NOOP(x)                     (((x) >> 11) & 0x1)
+#define   C_02880C_EXEC_ON_NOOP                        0xFFFFF7FF
 #define   S_02880C_DB_SOURCE_FORMAT(x)                 (((unsigned)(x) & 0x3) << 13)
 #define   G_02880C_DB_SOURCE_FORMAT(x)                 (((x) >> 13) & 0x3)
 #define   C_02880C_DB_SOURCE_FORMAT                    0xFFFF9FFF
-- 
2.9.5



More information about the mesa-dev mailing list