[Mesa-dev] [PATCH] radeonsi: add a drirc workaround for HTILE corruption in ARK: Survival Evolved

Marek Olšák maraeo at gmail.com
Tue Oct 3 17:32:01 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeonsi/driinfo_radeonsi.h |  4 ++++
 src/gallium/drivers/radeonsi/si_blit.c          | 14 ++++++++++++++
 src/gallium/drivers/radeonsi/si_pipe.c          |  2 ++
 src/gallium/drivers/radeonsi/si_pipe.h          |  1 +
 src/util/drirc                                  |  5 +++++
 src/util/xmlpool/t_options.h                    |  5 +++++
 6 files changed, 31 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h
index 989e517..7f57b4e 100644
--- a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h
+++ b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h
@@ -1,6 +1,10 @@
 // DriConf options specific to radeonsi
 DRI_CONF_SECTION_PERFORMANCE
     DRI_CONF_RADEONSI_ENABLE_SISCHED("false")
     DRI_CONF_RADEONSI_ASSUME_NO_Z_FIGHTS("false")
     DRI_CONF_RADEONSI_COMMUTATIVE_BLEND_ADD("false")
 DRI_CONF_SECTION_END
+
+DRI_CONF_SECTION_DEBUG
+   DRI_CONF_RADEONSI_CLEAR_DB_CACHE_BEFORE_CLEAR("false")
+DRI_CONF_SECTION_END
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index 67972a2..44e5251 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -896,20 +896,34 @@ static void si_clear(struct pipe_context *ctx, unsigned buffers,
 			if (!zstex->stencil_cleared || zstex->stencil_clear_value != stencil) {
 				sctx->db_stencil_disable_expclear = true;
 			}
 
 			zstex->stencil_clear_value = stencil;
 			sctx->framebuffer.dirty_zsbuf = true;
 			si_mark_atom_dirty(sctx, &sctx->framebuffer.atom); /* updates DB_STENCIL_CLEAR */
 			sctx->db_stencil_clear = true;
 			si_mark_atom_dirty(sctx, &sctx->db_render_state);
 		}
+
+		/* TODO: Find out what's wrong here. Fast depth clear leads to
+		 * corruption in ARK: Survival Evolved, but that may just be
+		 * a coincidence and the root cause is elsewhere.
+		 *
+		 * The corruption can be fixed by putting the DB flush before
+		 * or after the depth clear. (suprisingly)
+		 *
+		 * https://bugs.freedesktop.org/show_bug.cgi?id=102955 (apitrace)
+		 *
+		 * This hack massively decreases back-to-back ClearDepth performance.
+		 */
+		if (sctx->screen->clear_db_cache_before_clear)
+			sctx->b.flags |= SI_CONTEXT_FLUSH_AND_INV_DB;
 	}
 
 	si_blitter_begin(ctx, SI_CLEAR);
 	util_blitter_clear(sctx->blitter, fb->width, fb->height,
 			   util_framebuffer_get_num_layers(fb),
 			   buffers, color, depth, stencil);
 	si_blitter_end(ctx);
 
 	if (sctx->db_depth_clear) {
 		sctx->db_depth_clear = false;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 79e4e1c..7039aab 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -1050,20 +1050,22 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,
 		 sscreen->b.info.pfp_fw_version >= 79 &&
 		 sscreen->b.info.me_fw_version >= 142);
 
 	sscreen->has_out_of_order_rast = sscreen->b.chip_class >= VI &&
 					 sscreen->b.info.max_se >= 2 &&
 					 !(sscreen->b.debug_flags & DBG_NO_OUT_OF_ORDER);
 	sscreen->assume_no_z_fights =
 		driQueryOptionb(config->options, "radeonsi_assume_no_z_fights");
 	sscreen->commutative_blend_add =
 		driQueryOptionb(config->options, "radeonsi_commutative_blend_add");
+	sscreen->clear_db_cache_before_clear =
+		driQueryOptionb(config->options, "radeonsi_clear_db_cache_before_clear");
 	sscreen->has_msaa_sample_loc_bug = (sscreen->b.family >= CHIP_POLARIS10 &&
 					    sscreen->b.family <= CHIP_POLARIS12) ||
 					   sscreen->b.family == CHIP_VEGA10 ||
 					   sscreen->b.family == CHIP_RAVEN;
 	sscreen->dpbb_allowed = sscreen->b.chip_class >= GFX9 &&
 				!(sscreen->b.debug_flags & DBG_NO_DPBB);
 	sscreen->dfsm_allowed = sscreen->dpbb_allowed &&
 				!(sscreen->b.debug_flags & DBG_NO_DFSM);
 
 	/* While it would be nice not to have this flag, we are constrained
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index b96bf9d..50f59b9 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -91,20 +91,21 @@ struct u_suballocator;
 struct si_screen {
 	struct r600_common_screen	b;
 	unsigned			gs_table_depth;
 	unsigned			tess_offchip_block_dw_size;
 	bool				has_clear_state;
 	bool				has_distributed_tess;
 	bool				has_draw_indirect_multi;
 	bool				has_out_of_order_rast;
 	bool				assume_no_z_fights;
 	bool				commutative_blend_add;
+	bool				clear_db_cache_before_clear;
 	bool				has_msaa_sample_loc_bug;
 	bool				dpbb_allowed;
 	bool				dfsm_allowed;
 	bool				llvm_has_working_vgpr_indexing;
 
 	/* Whether shaders are monolithic (1-part) or separate (3-part). */
 	bool				use_monolithic_shaders;
 	bool				record_llvm_ir;
 
 	mtx_t			shader_parts_mutex;
diff --git a/src/util/drirc b/src/util/drirc
index 0bedeef..8e36196 100644
--- a/src/util/drirc
+++ b/src/util/drirc
@@ -228,11 +228,16 @@ TODO: document the other workarounds.
     <device driver="vmwgfx">
         <application name="gnome-shell" executable="gnome-shell">
             <option name="glx_disable_ext_buffer_age" value="true" />
             <option name="glx_disable_oml_sync_control" value="true" />
         </application>
 	<application name="Compiz" executable="Compiz">
             <option name="glx_disable_ext_buffer_age" value="true" />
 	    <option name="glx_disable_oml_sync_control" value="true" />
         </application>
     </device>
+    <device driver="radeonsi">
+        <application name="ARK: Survival Evolved (and unintentionally the UE4 demo template)" executable="ShooterGame">
+            <option name="radeonsi_clear_db_cache_before_clear" value="true" />
+        </application>
+    </device>
 </driconf>
diff --git a/src/util/xmlpool/t_options.h b/src/util/xmlpool/t_options.h
index 214c7c3..f21ef57 100644
--- a/src/util/xmlpool/t_options.h
+++ b/src/util/xmlpool/t_options.h
@@ -441,10 +441,15 @@ DRI_CONF_OPT_END
 
 #define DRI_CONF_RADEONSI_ASSUME_NO_Z_FIGHTS(def) \
 DRI_CONF_OPT_BEGIN_B(radeonsi_assume_no_z_fights, def) \
         DRI_CONF_DESC(en,gettext("Assume no Z fights (enables aggressive out-of-order rasterization to improve performance; may cause rendering errors)")) \
 DRI_CONF_OPT_END
 
 #define DRI_CONF_RADEONSI_COMMUTATIVE_BLEND_ADD(def) \
 DRI_CONF_OPT_BEGIN_B(radeonsi_commutative_blend_add, def) \
         DRI_CONF_DESC(en,gettext("Commutative additive blending optimizations (may cause rendering errors)")) \
 DRI_CONF_OPT_END
+
+#define DRI_CONF_RADEONSI_CLEAR_DB_CACHE_BEFORE_CLEAR(def) \
+DRI_CONF_OPT_BEGIN_B(radeonsi_clear_db_cache_before_clear, def) \
+        DRI_CONF_DESC(en,"Clear DB cache before fast depth clear") \
+DRI_CONF_OPT_END
-- 
2.7.4



More information about the mesa-dev mailing list