From 26b319b29bdf8fa65b57cde93981beda5a0c78f9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 14 May 2018 02:40:17 +0200 Subject: [PATCH] [d3d11] Fallout 4: Force Flush on GetData calls --- src/d3d11/d3d11_context.cpp | 10 ++++++++-- src/d3d11/d3d11_options.cpp | 1 + src/d3d11/d3d11_options.h | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index b53e8b2a9..9e922901c 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -203,9 +203,9 @@ namespace dxvk { void STDMETHODCALLTYPE D3D11DeviceContext::End(ID3D11Asynchronous *pAsync) { if (pAsync == nullptr) return; - + Com query; - + if (SUCCEEDED(pAsync->QueryInterface(__uuidof(ID3D11Query), reinterpret_cast(&query)))) { Com queryPtr = static_cast(query.ptr()); @@ -242,6 +242,12 @@ namespace dxvk { return E_INVALIDARG; } + // Fallout 4 never actually calls this function without + // D3D11_ASYNC_GETDATA_DONOTFLUSH set, which may cause + // the game to freeze in certain situations. + if (m_parent->TestOption(D3D11Option::DisableGetDataFlagDoNotFlush)) + GetDataFlags &= ~D3D11_ASYNC_GETDATA_DONOTFLUSH; + // Flush in order to make sure the query commands get dispatched if ((GetDataFlags & D3D11_ASYNC_GETDATA_DONOTFLUSH) == 0) Flush(); diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 0482e2e8e..613a27c14 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -6,6 +6,7 @@ namespace dxvk { const static std::unordered_map g_d3d11AppOptions = {{ { "Dishonored2.exe", D3D11OptionSet(D3D11Option::AllowMapFlagNoWait) }, + { "Fallout4.exe", D3D11OptionSet(D3D11Option::DisableGetDataFlagDoNotFlush) }, }}; diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 6d1c2c886..97e8a6038 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -14,6 +14,15 @@ namespace dxvk { * operation succeeds when that flag is set. */ AllowMapFlagNoWait = 0, + + /** + * \brief Ignore D3D11_ASYNC_GETDATA_DONOTFLUSH + * + * This can cause significant slowdowns, but some games + * expect the implementation to flush the context even + * when passing the \c DONOTFLUSH flag. + */ + DisableGetDataFlagDoNotFlush = 1, }; using D3D11OptionSet = Flags;