From dc31be71180a6bc5b6a2e9a43558ee81027a7eac Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 7 Aug 2018 14:58:08 +0200 Subject: [PATCH] [d3d11] Use global user config for D3D11 options --- src/d3d11/d3d11_context_imm.cpp | 2 +- src/d3d11/d3d11_device.cpp | 7 +++-- src/d3d11/d3d11_device.h | 10 +++---- src/d3d11/d3d11_options.cpp | 19 ++----------- src/d3d11/d3d11_options.h | 50 +++++++++++++-------------------- 5 files changed, 33 insertions(+), 55 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index d76548755..07d41b24a 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -514,7 +514,7 @@ namespace dxvk { 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::AllowMapFlagNoWait)) + if (!m_parent->GetOptions()->allowMapFlagNoWait) MapFlags &= ~D3D11_MAP_FLAG_DO_NOT_WAIT; // Wait for the any pending D3D11 command to be executed diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 3abf50dc9..109cc2355 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1,6 +1,9 @@ #include #include +#include "../dxvk/dxvk_adapter.h" +#include "../dxvk/dxvk_instance.h" + #include "d3d11_buffer.h" #include "d3d11_class_linkage.h" #include "d3d11_context_def.h" @@ -93,7 +96,7 @@ namespace dxvk { m_featureFlags (FeatureFlags), m_dxvkDevice (pDxgiDevice->GetDXVKDevice()), m_dxvkAdapter (m_dxvkDevice->adapter()), - m_d3d11Options (D3D11GetAppOptions(env::getExeName())), + m_d3d11Options (m_dxvkAdapter->instance()->config()), m_dxbcOptions (getDxbcAppOptions(env::getExeName()) | getDxbcDeviceOptions(m_dxvkDevice)) { Com adapter; @@ -661,7 +664,7 @@ namespace dxvk { // Returning S_OK instead of an error fixes some issues // with Overwatch until this is properly implemented - return m_d3d11Options.test(D3D11Option::FakeStreamOutSupport) ? S_OK : E_NOTIMPL; + return m_d3d11Options.fakeStreamOutSupport ? S_OK : E_NOTIMPL; } diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index 907722bf8..59474fa7d 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -336,9 +336,9 @@ namespace dxvk { void FreeCounterSlice(const DxvkBufferSlice& Slice) { m_uavCounters->FreeSlice(Slice); } - - bool TestOption(D3D11Option Option) const { - return m_d3d11Options.test(Option); + + const D3D11Options* GetOptions() const { + return &m_d3d11Options; } static bool CheckFeatureLevelSupport( @@ -353,14 +353,14 @@ namespace dxvk { IDXGIObject* m_container; Com m_dxgiAdapter; - + const D3D_FEATURE_LEVEL m_featureLevel; const UINT m_featureFlags; const Rc m_dxvkDevice; const Rc m_dxvkAdapter; - const D3D11OptionSet m_d3d11Options; + const D3D11Options m_d3d11Options; const DxbcOptions m_dxbcOptions; D3D11Initializer* m_initializer = nullptr; diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 69528849d..88c385ad4 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -4,22 +4,9 @@ namespace dxvk { - const static std::unordered_map g_d3d11AppOptions = {{ - { "Dishonored2.exe", D3D11OptionSet(D3D11Option::AllowMapFlagNoWait) }, - { "FarCry5.exe", D3D11OptionSet(D3D11Option::AllowMapFlagNoWait) }, - { "ffxv_s.exe", D3D11OptionSet(D3D11Option::FakeStreamOutSupport) }, - { "Overwatch.exe", D3D11OptionSet(D3D11Option::FakeStreamOutSupport) }, - { "F1_2015.exe", D3D11OptionSet(D3D11Option::FakeStreamOutSupport) }, - { "Mafia3.exe", D3D11OptionSet(D3D11Option::FakeStreamOutSupport) }, - }}; - - - D3D11OptionSet D3D11GetAppOptions(const std::string& AppName) { - auto appOptions = g_d3d11AppOptions.find(AppName); - - return appOptions != g_d3d11AppOptions.end() - ? appOptions->second - : D3D11OptionSet(); + D3D11Options::D3D11Options(const Config& config) { + this->allowMapFlagNoWait = config.getOption("d3d11.allowMapFlagNoWait", false); + this->fakeStreamOutSupport = config.getOption("d3d11.fakeStreamOutSupport", false); } } \ No newline at end of file diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 0fbc78e45..459185660 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -1,40 +1,28 @@ #pragma once +#include "../util/config/config.h" + #include "d3d11_include.h" namespace dxvk { - enum class D3D11Option : uint64_t { - /** - * \brief Handle D3D11_MAP_FLAG_DO_NOT_WAIT properly - * - * This can offer substantial speedups, but some games - * (The Witcher 3, Elder Scrolls Online, possibly others) - * seem to make incorrect assumptions about when a map - * operation succeeds when that flag is set. - */ - AllowMapFlagNoWait = 0, - - /** - * \brief Fakes stream output support - * - * Temporary hack that fixes issues in some games - * which technically need stream output but work - * well enough without it. Will be removed once - * Stream Output is properly supported in DXVK. - */ - FakeStreamOutSupport = 63, + struct D3D11Options { + D3D11Options(const Config& config); + /// Handle D3D11_MAP_FLAG_DO_NOT_WAIT properly. + /// + /// This can offer substantial speedups, but some games + /// (The Witcher 3, Elder Scrolls Online, possibly others) + /// seem to make incorrect assumptions about when a map + /// operation succeeds when that flag is set. + bool allowMapFlagNoWait; + + /// Fakes stream output support. + /// + /// Temporary hack that fixes issues in some games + /// which technically need stream output but work + /// well enough without it. Will be removed once + /// Stream Output is properly supported in DXVK. + bool fakeStreamOutSupport; }; - using D3D11OptionSet = Flags; - - - /** - * \brief Retrieves per-app options - * - * \param [in] AppName Executable name - * \returns D3D11 options - */ - D3D11OptionSet D3D11GetAppOptions(const std::string& AppName); - } \ No newline at end of file