Mesa (staging/21.0): radv: don't shrink image stores for The Surge 2

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Mar 5 19:46:08 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: 0a825d34fbeb9d222a2eb6450b9bf015e5c0a6e5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a825d34fbeb9d222a2eb6450b9bf015e5c0a6e5

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Tue Feb 23 19:33:02 2021 +0000

radv: don't shrink image stores for The Surge 2

The game seems to declare the wrong format.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Fixes: e4d75c22 ("nir/opt_shrink_vectors: shrink image stores using the format")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4347
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9229>
(cherry picked from commit 21697082ec92c7c83d03d9dc42c938d3b5f483c3)

---

 .pick_status.json              |  2 +-
 src/amd/vulkan/radv_device.c   |  5 +++++
 src/amd/vulkan/radv_pipeline.c |  8 +++++---
 src/amd/vulkan/radv_private.h  |  1 +
 src/amd/vulkan/radv_shader.c   | 11 ++++++-----
 src/amd/vulkan/radv_shader.h   |  4 ++--
 src/util/00-mesa-defaults.conf |  4 ++++
 src/util/driconf.h             |  4 ++++
 8 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 308ff14f9ef..8b66a618597 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -922,7 +922,7 @@
         "description": "radv: don't shrink image stores for The Surge 2",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "e4d75c22beba5533b499f7f8f8be6ab0a110ecbc"
     },
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 13a6ca49aa3..9e57f235d47 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -640,6 +640,10 @@ radv_handle_per_app_options(struct radv_instance *instance,
 		driQueryOptionb(&instance->dri_options,
 				"radv_enable_mrt_output_nan_fixup");
 
+	instance->disable_shrink_image_store =
+		driQueryOptionb(&instance->dri_options,
+				"radv_disable_shrink_image_store");
+
 	if (driQueryOptionb(&instance->dri_options, "radv_no_dynamic_bounds"))
 		instance->debug_flags |= RADV_DEBUG_NO_DYNAMIC_BOUNDS;
 }
@@ -652,6 +656,7 @@ static const driOptionDescription radv_dri_options[] = {
 		DRI_CONF_VK_X11_ENSURE_MIN_IMAGE_COUNT(false)
 		DRI_CONF_RADV_REPORT_LLVM9_VERSION_STRING(false)
 		DRI_CONF_RADV_ENABLE_MRT_OUTPUT_NAN_FIXUP(false)
+		DRI_CONF_RADV_DISABLE_SHRINK_IMAGE_STORE(false)
 		DRI_CONF_RADV_NO_DYNAMIC_BOUNDS(false)
 		DRI_CONF_RADV_OVERRIDE_UNIFORM_OFFSET_ALIGNMENT(0)
 	DRI_CONF_SECTION_END
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 8a20b547f9a..c00f83b4f77 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -2361,7 +2361,8 @@ radv_link_shaders(struct radv_pipeline *pipeline, nir_shader **shaders,
 			if (nir_lower_io_to_scalar_early(ordered_shaders[i], mask)) {
 				/* Optimize the new vector code and then remove dead vars */
 				nir_copy_prop(ordered_shaders[i]);
-				nir_opt_shrink_vectors(ordered_shaders[i], true);
+				nir_opt_shrink_vectors(ordered_shaders[i],
+						       !pipeline->device->instance->disable_shrink_image_store);
 
 		                if (ordered_shaders[i]->info.stage != last) {
 					/* Optimize swizzled movs of load_const for
@@ -3303,7 +3304,7 @@ VkResult radv_create_shaders(struct radv_pipeline *pipeline,
 	for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
 		if (nir[i]) {
 			radv_start_feedback(stage_feedbacks[i]);
-			radv_optimize_nir(nir[i], optimize_conservatively, false);
+			radv_optimize_nir(device, nir[i], optimize_conservatively, false);
 			radv_stop_feedback(stage_feedbacks[i], false);
 		}
 	}
@@ -3349,7 +3350,8 @@ VkResult radv_create_shaders(struct radv_pipeline *pipeline,
 
 			radv_lower_io(device, nir[i]);
 
-			lower_to_scalar |= nir_opt_shrink_vectors(nir[i], true);
+			lower_to_scalar |= nir_opt_shrink_vectors(nir[i],
+								  !device->instance->disable_shrink_image_store);
 
 			if (lower_to_scalar)
 				nir_lower_alu_to_scalar(nir[i], NULL, NULL);
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index c58dd2f6ee8..e1543e87151 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -361,6 +361,7 @@ struct radv_instance {
 	 */
 	bool enable_mrt_output_nan_fixup;
 	bool disable_tc_compat_htile_in_general;
+	bool disable_shrink_image_store;
 };
 
 VkResult radv_init_wsi(struct radv_physical_device *physical_device);
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 9a1308ab6fe..13bc03cbb26 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -172,8 +172,8 @@ void radv_DestroyShaderModule(
 }
 
 void
-radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively,
-                  bool allow_copies)
+radv_optimize_nir(const struct radv_device *device, struct nir_shader *shader,
+		  bool optimize_conservatively, bool allow_copies)
 {
         bool progress;
         unsigned lower_flrp =
@@ -243,7 +243,8 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively,
                 }
 
                 NIR_PASS(progress, shader, nir_opt_undef);
-                NIR_PASS(progress, shader, nir_opt_shrink_vectors, true);
+                NIR_PASS(progress, shader, nir_opt_shrink_vectors,
+                         !device->instance->disable_shrink_image_store);
                 if (shader->options->max_unroll_iterations) {
                         NIR_PASS(progress, shader, nir_opt_loop_unroll, 0);
                 }
@@ -650,7 +651,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
 	nir_lower_load_const_to_scalar(nir);
 
 	if (!(flags & VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT))
-		radv_optimize_nir(nir, false, true);
+		radv_optimize_nir(device, nir, false, true);
 
 	/* call radv_nir_lower_ycbcr_textures() late as there might still be
 	 * tex with undef texture/sampler before first optimization */
@@ -697,7 +698,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
 	    !(flags & VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT) &&
 	    nir->info.stage != MESA_SHADER_COMPUTE) {
 		/* Optimize the lowered code before the linking optimizations. */
-		radv_optimize_nir(nir, false, false);
+		radv_optimize_nir(device, nir, false, false);
 	}
 
 	return nir;
diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h
index 5e25261361f..175c99aa211 100644
--- a/src/amd/vulkan/radv_shader.h
+++ b/src/amd/vulkan/radv_shader.h
@@ -422,8 +422,8 @@ struct radv_shader_slab {
 };
 
 void
-radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively,
-		  bool allow_copies);
+radv_optimize_nir(const struct radv_device *device, struct nir_shader *shader,
+		  bool optimize_conservatively, bool allow_copies);
 bool
 radv_nir_lower_ycbcr_textures(nir_shader *shader,
                              const struct radv_pipeline_layout *layout);
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index fc4dd2fcd42..b58b22f6a22 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -732,6 +732,10 @@ TODO: document the other workarounds.
             <option name="radv_no_dynamic_bounds" value="true" />
         </application>
 
+        <application name="The Surge 2" application_name_match="Fledge">
+            <option name="radv_disable_shrink_image_store" value="true" />
+        </application>
+
 	<application name="World War Z" application_name_match="WWZ">
             <option name="radv_override_uniform_offset_alignment" value="16" />
         </application>
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 299f55f9f3a..d2576127d26 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -450,6 +450,10 @@
    DRI_CONF_OPT_B(radv_no_dynamic_bounds, def, \
                   "Disabling bounds checking for dynamic buffer descriptors")
 
+#define DRI_CONF_RADV_DISABLE_SHRINK_IMAGE_STORE(def) \
+   DRI_CONF_OPT_B(radv_disable_shrink_image_store, def, \
+                  "Disabling shrinking of image stores based on the format")
+
 #define DRI_CONF_RADV_OVERRIDE_UNIFORM_OFFSET_ALIGNMENT(def) \
    DRI_CONF_OPT_I(radv_override_uniform_offset_alignment, def, 0, 128, \
                   "Override the minUniformBufferOffsetAlignment exposed to the application. (0 = default)")



More information about the mesa-commit mailing list