From bd69e843c22838060daa7488c4c176b17fd55dd8 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 24 Mar 2018 17:02:24 +0100 Subject: [PATCH] [d3d11] Added D3D11Options Includes a per-app knob for Witcher 3 to disable D3D11_MAP_FLAG_DO_NOT_WAIT. --- src/d3d11/d3d11_context_imm.cpp | 10 ++++++---- src/d3d11/d3d11_device.cpp | 1 + src/d3d11/d3d11_device.h | 6 ++++++ src/d3d11/meson.build | 1 + src/dxgi/dxgi_include.h | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 978b96799..a44e3d04e 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -220,10 +220,7 @@ namespace dxvk { if (pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) { const VkImageType imageType = mappedImage->info().type; - // Wait for the resource to become available. Forwarding - // DO_NOT_WAIT would break The Witcher 3 for some reason. - MapFlags &= ~D3D11_MAP_FLAG_DO_NOT_WAIT; - + // Wait for the resource to become available if (!WaitForResource(mappedImage, MapFlags)) return DXGI_ERROR_WAS_STILL_DRAWING; @@ -346,6 +343,11 @@ namespace dxvk { bool D3D11ImmediateContext::WaitForResource( const Rc& Resource, UINT MapFlags) { + // Some games (e.g. The Witcher 3) do not work correctly + // when a map fails with D3D11_MAP_FLAG_DO_NOT_WAIT set + if (m_parent->TestOption(D3D11Option::IgnoreMapFlagNoWait)) + MapFlags &= ~D3D11_MAP_FLAG_DO_NOT_WAIT; + // Wait for the any pending D3D11 command to be executed // on the CS thread so that we can determine whether the // resource is currently in use or not. diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 35c99132c..03f800990 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -25,6 +25,7 @@ namespace dxvk { m_featureFlags (featureFlags), m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()), m_dxvkAdapter (m_dxvkDevice->adapter()), + m_d3d11Options (D3D11GetAppOptions(env::getExeName())), m_dxbcOptions (m_dxvkDevice) { Com adapter; diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index 4bf7c1666..94f755b3e 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -10,6 +10,7 @@ #include "../util/com/com_private_data.h" #include "d3d11_interfaces.h" +#include "d3d11_options.h" #include "d3d11_state.h" #include "d3d11_util.h" @@ -283,6 +284,10 @@ namespace dxvk { DXGI_FORMAT format, DxgiFormatMode mode) const; + bool TestOption(D3D11Option Option) const { + return m_d3d11Options.test(Option); + } + static bool CheckFeatureLevelSupport( const Rc& adapter, D3D_FEATURE_LEVEL featureLevel); @@ -303,6 +308,7 @@ namespace dxvk { const Rc m_dxvkDevice; const Rc m_dxvkAdapter; + const D3D11OptionSet m_d3d11Options; const DxbcOptions m_dxbcOptions; D3D11ImmediateContext* m_context = nullptr; diff --git a/src/d3d11/meson.build b/src/d3d11/meson.build index 6503917fb..419640287 100644 --- a/src/d3d11/meson.build +++ b/src/d3d11/meson.build @@ -11,6 +11,7 @@ d3d11_src = [ 'd3d11_enums.cpp', 'd3d11_input_layout.cpp', 'd3d11_main.cpp', + 'd3d11_options.cpp', 'd3d11_present.cpp', 'd3d11_query.cpp', 'd3d11_rasterizer.cpp', diff --git a/src/dxgi/dxgi_include.h b/src/dxgi/dxgi_include.h index a07400bd7..bef395af4 100644 --- a/src/dxgi/dxgi_include.h +++ b/src/dxgi/dxgi_include.h @@ -19,6 +19,7 @@ #include "../util/util_enum.h" #include "../util/util_error.h" +#include "../util/util_flags.h" #include "../util/util_math.h" #include "../util/util_string.h"