From b25d6ba615a8522f1d056413e837228cbcf682fa Mon Sep 17 00:00:00 2001 From: Liam Middlebrook Date: Wed, 3 Mar 2021 00:40:19 -0800 Subject: [PATCH] [dxvk] Add option to disable workaround for NVIDIA HVV bug Adds a new dxvk.halveNvidiaHVVHeap option. Reviewed-by: Arthur Huillet --- dxvk.conf | 14 ++++++++++++++ src/dxvk/dxvk_memory.cpp | 8 ++++++-- src/dxvk/dxvk_options.cpp | 3 ++- src/dxvk/dxvk_options.h | 8 +++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index f0fca3b1..56d62940 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -206,6 +206,20 @@ # dxvk.useEarlyDiscard = Auto +# Controls workaround for NVIDIA HVV Heap bug. +# +# Limits the budget of NVIDIA's HVV (host-visible, +# device-local) heap to be half of the reported size. This is +# needed to avoid NVIDIA driver bug 3114283, and defaults to +# being enabled on all affected drivers. +# +# Supported values: +# - Auto: Don't change the default +# - True, False: Always enable / disable + +# dxvk.halveNvidiaHVVHeap = Auto + + # Sets enabled HUD elements # # Behaves like the DXVK_HUD environment variable if the diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index 32b011b5..c7a9775d 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -180,7 +180,11 @@ namespace dxvk { /* Work around an issue on Nvidia drivers where using the entire * device_local | host_visible heap can cause crashes, presumably * due to subsequent internal driver allocations failing */ - if (m_device->properties().core.properties.vendorID == uint16_t(DxvkGpuVendor::Nvidia)) { + bool nvidiaBug3114283Active = true; + applyTristate(nvidiaBug3114283Active, device->config().halveNvidiaHVVHeap); + + if ((m_device->properties().core.properties.vendorID == uint16_t(DxvkGpuVendor::Nvidia)) + && (nvidiaBug3114283Active)) { for (uint32_t i = 0; i < m_memProps.memoryTypeCount; i++) { constexpr VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; @@ -432,4 +436,4 @@ namespace dxvk { return chunkSize; } -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_options.cpp b/src/dxvk/dxvk_options.cpp index 73dd69d1..9dd589f7 100644 --- a/src/dxvk/dxvk_options.cpp +++ b/src/dxvk/dxvk_options.cpp @@ -9,7 +9,8 @@ namespace dxvk { numCompilerThreads = config.getOption ("dxvk.numCompilerThreads", 0); useRawSsbo = config.getOption("dxvk.useRawSsbo", Tristate::Auto); useEarlyDiscard = config.getOption("dxvk.useEarlyDiscard", Tristate::Auto); + halveNvidiaHVVHeap = config.getOption("dxvk.halveNvidiaHVVHeap", Tristate::Auto); hud = config.getOption("dxvk.hud", ""); } -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_options.h b/src/dxvk/dxvk_options.h index 3c5dde91..ac5b2c68 100644 --- a/src/dxvk/dxvk_options.h +++ b/src/dxvk/dxvk_options.h @@ -25,8 +25,14 @@ namespace dxvk { Tristate useRawSsbo; Tristate useEarlyDiscard; + /// Workaround for NVIDIA driver + /// bug 3114283. Cut usable HVV + /// (Host-Visible Vidmem) heap + /// in half to avoid crash + Tristate halveNvidiaHVVHeap; + /// HUD elements std::string hud; }; -} \ No newline at end of file +}