radv: enable zero VRAM for all VKD3D (DX12->VK) games
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 29 May 2020 18:26:00 +0000 (20:26 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 3 Jun 2020 06:00:19 +0000 (08:00 +0200)
To fix rendering issues with Metro Exodus, RE2 and 3 and probably
more titles. It seems the default behaviour of DX12 anyways.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3064
Cc: <mesa-stable@lists.freedesktop.org>
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/5262>

src/amd/vulkan/radv_device.c

index 3ce3d9c3760f7101e77b52b15d44b6f50049313c..c6845c5c494701f03bf3c14863cc476a0a82cea4 100644 (file)
@@ -554,43 +554,52 @@ radv_handle_per_app_options(struct radv_instance *instance,
                            const VkApplicationInfo *info)
 {
        const char *name = info ? info->pApplicationName : NULL;
+       const char *engine_name = info ? info->pEngineName : NULL;
+
+       if (name) {
+               if (!strcmp(name, "DOOM_VFR")) {
+                       /* Work around a Doom VFR game bug */
+                       instance->debug_flags |= RADV_DEBUG_NO_DYNAMIC_BOUNDS;
+               } else if (!strcmp(name, "MonsterHunterWorld.exe")) {
+                       /* Workaround for a WaW hazard when LLVM moves/merges
+                        * load/store memory operations.
+                        * See https://reviews.llvm.org/D61313
+                        */
+                       if (LLVM_VERSION_MAJOR < 9)
+                               instance->debug_flags |= RADV_DEBUG_NO_LOAD_STORE_OPT;
+               } else if (!strcmp(name, "Wolfenstein: Youngblood")) {
+                       if (!(instance->debug_flags & RADV_DEBUG_NO_SHADER_BALLOT) &&
+                           !(instance->perftest_flags & RADV_PERFTEST_ACO)) {
+                               /* Force enable VK_AMD_shader_ballot because it looks
+                                * safe and it gives a nice boost (+20% on Vega 56 at
+                                * this time). It also prevents corruption on LLVM.
+                                */
+                               instance->perftest_flags |= RADV_PERFTEST_SHADER_BALLOT;
+                       }
+               } else if (!strcmp(name, "Fledge")) {
+                       /*
+                        * Zero VRAM for "The Surge 2"
+                        *
+                        * This avoid a hang when when rendering any level. Likely
+                        * 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;
+               } else if (!strcmp(name, "DOOMEternal")) {
+                       /* Zero VRAM for Doom Eternal to fix rendering issues. */
+                       instance->debug_flags |= RADV_DEBUG_ZERO_VRAM;
+               }
+       }
 
-       if (!name)
-               return;
-
-       if (!strcmp(name, "DOOM_VFR")) {
-               /* Work around a Doom VFR game bug */
-               instance->debug_flags |= RADV_DEBUG_NO_DYNAMIC_BOUNDS;
-       } else if (!strcmp(name, "MonsterHunterWorld.exe")) {
-               /* Workaround for a WaW hazard when LLVM moves/merges
-                * load/store memory operations.
-                * See https://reviews.llvm.org/D61313
-                */
-               if (LLVM_VERSION_MAJOR < 9)
-                       instance->debug_flags |= RADV_DEBUG_NO_LOAD_STORE_OPT;
-       } else if (!strcmp(name, "Wolfenstein: Youngblood")) {
-               if (!(instance->debug_flags & RADV_DEBUG_NO_SHADER_BALLOT) &&
-                   !(instance->perftest_flags & RADV_PERFTEST_ACO)) {
-                       /* Force enable VK_AMD_shader_ballot because it looks
-                        * safe and it gives a nice boost (+20% on Vega 56 at
-                        * this time). It also prevents corruption on LLVM.
+       if (engine_name) {
+               if (!strcmp(engine_name, "vkd3d")) {
+                       /* Zero VRAM for all VKD3D (DX12->VK) games to fix
+                        * rendering issues.
                         */
-                       instance->perftest_flags |= RADV_PERFTEST_SHADER_BALLOT;
+                       instance->debug_flags |= RADV_DEBUG_ZERO_VRAM;
                }
-       } else if (!strcmp(name, "Fledge")) {
-               /*
-                * Zero VRAM for "The Surge 2"
-                *
-                * This avoid a hang when when rendering any level. Likely
-                * 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;
-       } else if (!strcmp(name, "DOOMEternal")) {
-               /* Zero VRAM for Doom Eternal to fix rendering issues. */
-               instance->debug_flags |= RADV_DEBUG_ZERO_VRAM;
        }
 }