From 234f3ea071489c51c66982d8e19c23cfa29b2367 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 22 Feb 2024 15:36:58 +0100 Subject: [PATCH] [d3d11] Add option to hide native command list support --- dxvk.conf | 12 ++++++++++++ src/d3d11/d3d11_device.cpp | 6 +++--- src/d3d11/d3d11_features.cpp | 12 +++++++----- src/d3d11/d3d11_features.h | 2 ++ src/d3d11/d3d11_options.cpp | 3 ++- src/d3d11/d3d11_options.h | 7 ++++++- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 09f5dfbaf..110d2d55b 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -292,6 +292,18 @@ # d3d11.enableContextLock = False +# Exposes or hides support for driver command lists +# +# Some games use the feature flag to decide whether to use deferred +# contexts or not. We enable this by default, but in some situations +# this can lead to issues if games detect an AMD GPU where command +# lists are not natively supported on Windows. +# +# Supported values: True, False + +# d3d11.exposeDriverCommandLists = True + + # Sets number of pipeline compiler threads. # # If the graphics pipeline library feature is enabled, the given diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 9398e4842..2b9a82b9e 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -45,10 +45,10 @@ namespace dxvk { m_dxvkDevice (pContainer->GetDXVKDevice()), m_dxvkAdapter (m_dxvkDevice->adapter()), m_d3d11Formats (m_dxvkDevice), - m_d3d11Options (m_dxvkDevice->instance()->config(), m_dxvkDevice), + m_d3d11Options (m_dxvkDevice->instance()->config()), m_dxbcOptions (m_dxvkDevice, m_d3d11Options), m_maxFeatureLevel (GetMaxFeatureLevel(m_dxvkDevice->instance(), m_dxvkDevice->adapter())), - m_deviceFeatures (m_dxvkDevice->instance(), m_dxvkDevice->adapter(), m_featureLevel) { + m_deviceFeatures (m_dxvkDevice->instance(), m_dxvkDevice->adapter(), m_d3d11Options, m_featureLevel) { m_initializer = new D3D11Initializer(this); m_context = new D3D11ImmediateContext(this, m_dxvkDevice); m_d3d10Device = new D3D10Device(this, m_context.ptr()); @@ -1348,7 +1348,7 @@ namespace dxvk { m_deviceFeatures = D3D11DeviceFeatures( m_dxvkDevice->instance(), m_dxvkDevice->adapter(), - m_featureLevel); + m_d3d11Options, m_featureLevel); } if (pChosenFeatureLevel) diff --git a/src/d3d11/d3d11_features.cpp b/src/d3d11/d3d11_features.cpp index bbaf697f4..6b1816c27 100644 --- a/src/d3d11/d3d11_features.cpp +++ b/src/d3d11/d3d11_features.cpp @@ -12,6 +12,7 @@ namespace dxvk { D3D11DeviceFeatures::D3D11DeviceFeatures( const Rc& Instance, const Rc& Adapter, + const D3D11Options& Options, D3D_FEATURE_LEVEL FeatureLevel) : m_features (Adapter->features()), m_properties (Adapter->devicePropertiesExt()) { @@ -118,11 +119,11 @@ namespace dxvk { m_shaderMinPrecision.PixelShaderMinPrecision = 0; m_shaderMinPrecision.AllOtherShaderStagesMinPrecision = 0; - // Report native support for command lists here so that we do not actually have - // to re-implement the UpdateSubresource bug from the D3D11 runtime, see MSDN: - // https://msdn.microsoft.com/en-us/library/windows/desktop/ff476486(v=vs.85).aspx) + // Report native support for command lists by default. Deferred context + // usage can be beneficial for us as ExecuteCommandList has low overhead, + // and we avoid having to deal with known UpdateSubresource bugs this way. m_threading.DriverConcurrentCreates = TRUE; - m_threading.DriverCommandLists = TRUE; + m_threading.DriverCommandLists = Options.exposeDriverCommandLists; } @@ -182,7 +183,8 @@ namespace dxvk { D3D_FEATURE_LEVEL D3D11DeviceFeatures::GetMaxFeatureLevel( const Rc& Instance, const Rc& Adapter) { - D3D11DeviceFeatures features(Instance, Adapter, D3D_FEATURE_LEVEL_12_1); + D3D11Options options(Instance->config()); + D3D11DeviceFeatures features(Instance, Adapter, options, D3D_FEATURE_LEVEL_12_1); return features.GetMaxFeatureLevel(); } diff --git a/src/d3d11/d3d11_features.h b/src/d3d11/d3d11_features.h index 9bdd7c318..905f77b2b 100644 --- a/src/d3d11/d3d11_features.h +++ b/src/d3d11/d3d11_features.h @@ -1,6 +1,7 @@ #pragma once #include "d3d11_include.h" +#include "d3d11_options.h" #include "../dxvk/dxvk_adapter.h" #include "../dxvk/dxvk_instance.h" @@ -21,6 +22,7 @@ namespace dxvk { D3D11DeviceFeatures( const Rc& Instance, const Rc& Adapter, + const D3D11Options& Options, D3D_FEATURE_LEVEL FeatureLevel); ~D3D11DeviceFeatures(); diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index edb2272b1..bce1a713a 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -12,7 +12,7 @@ namespace dxvk { #endif } - D3D11Options::D3D11Options(const Config& config, const Rc& device) { + D3D11Options::D3D11Options(const Config& config) { this->dcSingleUseMode = config.getOption("d3d11.dcSingleUseMode", true); this->zeroInitWorkgroupMemory = config.getOption("d3d11.zeroInitWorkgroupMemory", false); this->forceVolatileTgsmAccess = config.getOption("d3d11.forceVolatileTgsmAccess", false); @@ -31,6 +31,7 @@ namespace dxvk { this->numBackBuffers = config.getOption("dxgi.numBackBuffers", 0); this->maxFrameLatency = config.getOption("dxgi.maxFrameLatency", 0); this->maxFrameRate = config.getOption("dxgi.maxFrameRate", 0); + this->exposeDriverCommandLists = config.getOption("d3d11.exposeDriverCommandLists", true); // Clamp LOD bias so that people don't abuse this in unintended ways this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f); diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 0da7b9e2a..fe9a2ab69 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -11,7 +11,7 @@ namespace dxvk { struct D3D11Options { - D3D11Options(const Config& config, const Rc& device); + D3D11Options(const Config& config); /// Enables speed hack for mapping on deferred contexts /// @@ -113,6 +113,11 @@ namespace dxvk { /// race conditions. bool enableContextLock; + /// Whether to expose the driver command list feature. Enabled by + /// default and generally beneficial, but some games may assume that + /// this is not supported when running on an AMD GPU. + bool exposeDriverCommandLists; + /// Shader dump path std::string shaderDumpPath; };