Mesa (master): radv: add new drirc option radv_enable_mrt_output_nan_fixup

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 12 13:09:09 UTC 2020


Module: Mesa
Branch: master
Commit: 6f21995f986a8f119c916bef3293991e34774678
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f21995f986a8f119c916bef3293991e34774678

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Fri Jun  5 14:24:33 2020 +0200

radv: add new drirc option radv_enable_mrt_output_nan_fixup

To replace NaN from FS with zeros to fix game bugs.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5359>

---

 src/amd/vulkan/radv_device.c  | 5 +++++
 src/amd/vulkan/radv_private.h | 5 +++++
 src/amd/vulkan/radv_shader.c  | 1 +
 src/amd/vulkan/radv_shader.h  | 1 +
 src/util/xmlpool/t_options.h  | 5 +++++
 5 files changed, 17 insertions(+)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 32a0458c4ee..6d86d88f615 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -590,6 +590,10 @@ radv_handle_per_app_options(struct radv_instance *instance,
 			instance->debug_flags |= RADV_DEBUG_ZERO_VRAM;
 		}
 	}
+
+	instance->enable_mrt_output_nan_fixup =
+		driQueryOptionb(&instance->dri_options,
+				"radv_enable_mrt_output_nan_fixup");
 }
 
 static const char radv_dri_options_xml[] =
@@ -599,6 +603,7 @@ DRI_CONF_BEGIN
 		DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0)
 		DRI_CONF_VK_X11_STRICT_IMAGE_COUNT("false")
 		DRI_CONF_RADV_REPORT_LLVM9_VERSION_STRING("false")
+		DRI_CONF_RADV_ENABLE_MRT_OUTPUT_NAN_FIXUP("false")
 	DRI_CONF_SECTION_END
 
 	DRI_CONF_SECTION_DEBUG
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 64a433ff10d..820644f5f8d 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -354,6 +354,11 @@ struct radv_instance {
 
 	struct driOptionCache dri_options;
 	struct driOptionCache available_dri_options;
+
+	/**
+	 * Workarounds for game bugs.
+	 */
+	bool enable_mrt_output_nan_fixup;
 };
 
 static inline
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index f6c09866113..eadb89be0ed 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -1116,6 +1116,7 @@ shader_variant_compile(struct radv_device *device,
 	options->address32_hi = device->physical_device->rad_info.address32_hi;
 	options->has_ls_vgpr_init_bug = device->physical_device->rad_info.has_ls_vgpr_init_bug;
 	options->use_ngg_streamout = device->physical_device->use_ngg_streamout;
+	options->enable_mrt_output_nan_fixup = device->instance->enable_mrt_output_nan_fixup;
 
 	struct radv_shader_args args = {};
 	args.options = options;
diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h
index 18d7b0cf9bd..7a621f732ef 100644
--- a/src/amd/vulkan/radv_shader.h
+++ b/src/amd/vulkan/radv_shader.h
@@ -139,6 +139,7 @@ struct radv_nir_compiler_options {
 	bool check_ir;
 	bool has_ls_vgpr_init_bug;
 	bool use_ngg_streamout;
+	bool enable_mrt_output_nan_fixup;
 	enum radeon_family family;
 	enum chip_class chip_class;
 	uint32_t tess_offchip_block_dw_size;
diff --git a/src/util/xmlpool/t_options.h b/src/util/xmlpool/t_options.h
index 0321becc49b..b99857c72ef 100644
--- a/src/util/xmlpool/t_options.h
+++ b/src/util/xmlpool/t_options.h
@@ -430,3 +430,8 @@ DRI_CONF_OPT_END
 DRI_CONF_OPT_BEGIN_B(radv_report_llvm9_version_string, def) \
         DRI_CONF_DESC(en,gettext("Report LLVM 9.0.1 for games that apply shader workarounds if missing (for ACO only)")) \
 DRI_CONF_OPT_END
+
+#define DRI_CONF_RADV_ENABLE_MRT_OUTPUT_NAN_FIXUP(def) \
+DRI_CONF_OPT_BEGIN_B(radv_enable_mrt_output_nan_fixup, def) \
+        DRI_CONF_DESC(en,gettext("Replace NaN outputs from fragment shaders with zeroes for floating point render target")) \
+DRI_CONF_OPT_END



More information about the mesa-commit mailing list