From b0ba60adfb78a9553f19babde810a70fde3615c4 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 29 Oct 2024 01:21:59 +0100 Subject: [PATCH] [dxvk] Disable defragmentation on ANV --- dxvk.conf | 3 ++- src/dxvk/dxvk_memory.cpp | 8 +++++++- src/dxvk/dxvk_options.cpp | 2 +- src/dxvk/dxvk_options.h | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 75b2041d52c..2529e023eb1 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -390,9 +390,10 @@ # # Supported values: # - True: Enable defragmentation +# - Auto: Enable defragmentation, except on blocked drivers # - False: Disable defragmentation -# dxvk.enableMemoryDefrag = True +# dxvk.enableMemoryDefrag = Auto # Sets enabled HUD elements diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index a0b9c3c1585..efc862fff36 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -2316,7 +2316,13 @@ namespace dxvk { m_memTypes[i].sharedCache->cleanupUnusedFromLockedAllocator(currentTime); } - if (m_device->config().enableMemoryDefrag) { + // For unknown reasons, defragmentation seems to break Genshin Impact and + // possibly other games on ANV while working fine on other drivers even in + // a stress-test scenario, see https://github.com/doitsujin/dxvk/issues/4395. + bool enableDefrag = !m_device->adapter()->matchesDriver(VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA); + applyTristate(enableDefrag, m_device->config().enableMemoryDefrag); + + if (enableDefrag) { // Periodically defragment device-local memory types. We cannot // do anything about mapped allocations since we rely on pointer // stability there. diff --git a/src/dxvk/dxvk_options.cpp b/src/dxvk/dxvk_options.cpp index 9d7d4d54ae6..44be3f3d173 100644 --- a/src/dxvk/dxvk_options.cpp +++ b/src/dxvk/dxvk_options.cpp @@ -5,7 +5,7 @@ namespace dxvk { DxvkOptions::DxvkOptions(const Config& config) { enableDebugUtils = config.getOption ("dxvk.enableDebugUtils", false); enableStateCache = config.getOption ("dxvk.enableStateCache", true); - enableMemoryDefrag = config.getOption ("dxvk.enableMemoryDefrag", true); + enableMemoryDefrag = config.getOption("dxvk.enableMemoryDefrag", Tristate::Auto); numCompilerThreads = config.getOption ("dxvk.numCompilerThreads", 0); enableGraphicsPipelineLibrary = config.getOption("dxvk.enableGraphicsPipelineLibrary", Tristate::Auto); trackPipelineLifetime = config.getOption("dxvk.trackPipelineLifetime", Tristate::Auto); diff --git a/src/dxvk/dxvk_options.h b/src/dxvk/dxvk_options.h index 7f64ddcb73f..b2b65f4ae98 100644 --- a/src/dxvk/dxvk_options.h +++ b/src/dxvk/dxvk_options.h @@ -15,7 +15,7 @@ namespace dxvk { bool enableStateCache = true; /// Enable memory defragmentation - bool enableMemoryDefrag = true; + Tristate enableMemoryDefrag = Tristate::Auto; /// Number of compiler threads /// when using the state cache