radv: add new drirc option radv_enable_mrt_output_nan_fixup
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 5 Jun 2020 12:24:33 +0000 (14:24 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 12 Jun 2020 12:43:31 +0000 (14:43 +0200)
To replace NaN from FS with zeros to fix game bugs.

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

src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_shader.c
src/amd/vulkan/radv_shader.h
src/util/xmlpool/t_options.h

index 32a0458c4ee5d8b293c1a8d632022d815ac15591..6d86d88f615ece334aaae94d1a44932a3edb8500 100644 (file)
@@ -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
index 64a433ff10dc6646bc4526fa7923a46deae46abc..820644f5f8d532703dcea501d98a4cb900b68b8a 100644 (file)
@@ -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
index f6c09866113a5e18690ed4993b7b022c695e879f..eadb89be0ed6e3b609407dc3949eb7fe23cd2536 100644 (file)
@@ -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;
index 18d7b0cf9bdfee3106e8cf733a86d0b9da15e3f5..7a621f732ef4ae5bff848fe17b407680ad9ea2e8 100644 (file)
@@ -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;
index 0321becc49b557a561f2c7ac644f699bccfbad50..b99857c72ef9b8212662ed186e4c5d9cb948c150 100644 (file)
@@ -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