radv: use nir_lower_discard_to_demote to work around game bugs
authorDaniel Schürmann <daniel@schuermann.dev>
Wed, 4 Mar 2020 16:35:26 +0000 (17:35 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 9 Mar 2020 12:29:32 +0000 (12:29 +0000)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4047>

src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_shader.c

index 545eaa51caf78be9b55de69897b2d1a5b0cd605d..979b448c6adc9f4bfc1940e5c273b71678348771 100644 (file)
@@ -56,6 +56,7 @@ enum {
        RADV_DEBUG_ALL_ENTRYPOINTS   = 0x2000000,
        RADV_DEBUG_DUMP_META_SHADERS = 0x4000000,
        RADV_DEBUG_NO_MEMORY_CACHE   = 0x8000000,
+       RADV_DEBUG_DISCARD_TO_DEMOTE = 0x10000000,
 };
 
 enum {
index d59f791cba17be8d2fbdf16f748364652abb91d5..c55e219e6c84bc66879ea7774cc0737ad4a67330 100644 (file)
@@ -599,6 +599,9 @@ radv_handle_per_app_options(struct radv_instance *instance,
                 * uninitialized data in an indirect draw.
                 */
                instance->debug_flags |= RADV_DEBUG_ZERO_VRAM;
+       } else if (!strcmp(name, "No Man's Sky")) {
+               /* Work around a NMS game bug */
+               instance->debug_flags |= RADV_DEBUG_DISCARD_TO_DEMOTE;
        }
 }
 
index 40fa3d783d48eb8fa2650afaeda3140a70392ea0..37b8ee45e3445c734212297665273c60bb5b4e4e 100644 (file)
@@ -445,6 +445,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
                NIR_PASS_V(nir, nir_lower_system_values);
                NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays);
                NIR_PASS_V(nir, radv_nir_lower_ycbcr_textures, layout);
+               if (device->instance->debug_flags & RADV_DEBUG_DISCARD_TO_DEMOTE)
+                       NIR_PASS_V(nir, nir_lower_discard_to_demote);
        }
 
        /* Vulkan uses the separate-shader linking model */