From bdd7587414441920743fe476270560722b6beb18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 4 Mar 2020 17:35:26 +0100 Subject: [PATCH] radv: use nir_lower_discard_to_demote to work around game bugs Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_debug.h | 1 + src/amd/vulkan/radv_device.c | 3 +++ src/amd/vulkan/radv_shader.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h index 545eaa51caf..979b448c6ad 100644 --- a/src/amd/vulkan/radv_debug.h +++ b/src/amd/vulkan/radv_debug.h @@ -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 { diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index d59f791cba1..c55e219e6c8 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -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; } } diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 40fa3d783d4..37b8ee45e34 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -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 */ -- 2.30.2