From ad5688764c3cdb4649fcc59804c2367a38051f44 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 20 Nov 2018 10:44:04 +0100 Subject: [PATCH] [d3d11] Use single-use submission mode for CS chunks where possible --- src/d3d11/d3d11_context.cpp | 8 +++++--- src/d3d11/d3d11_context.h | 6 ++++-- src/d3d11/d3d11_context_def.cpp | 10 +++++++++- src/d3d11/d3d11_context_def.h | 3 +++ src/d3d11/d3d11_context_imm.cpp | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 6ac4c4a51..f69c3d16a 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -10,11 +10,13 @@ namespace dxvk { D3D11DeviceContext::D3D11DeviceContext( - D3D11Device* pParent, - const Rc& Device) + D3D11Device* pParent, + const Rc& Device, + DxvkCsChunkFlags CsFlags) : m_parent (pParent), m_annotation(this), m_device (Device), + m_csFlags (CsFlags), m_csChunk (AllocCsChunk()) { // Create default state objects. We won't ever return them // to the application, but we'll use them to apply state. @@ -3350,7 +3352,7 @@ namespace dxvk { DxvkCsChunkRef D3D11DeviceContext::AllocCsChunk() { - return m_parent->AllocCsChunk(0); + return m_parent->AllocCsChunk(m_csFlags); } } diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 615e47d24..052c552ba 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -18,8 +18,9 @@ namespace dxvk { public: D3D11DeviceContext( - D3D11Device* pParent, - const Rc& Device); + D3D11Device* pParent, + const Rc& Device, + DxvkCsChunkFlags CsFlags); ~D3D11DeviceContext(); HRESULT STDMETHODCALLTYPE QueryInterface( @@ -650,6 +651,7 @@ namespace dxvk { Rc m_device; Rc m_updateBuffer; + DxvkCsChunkFlags m_csFlags; DxvkCsChunkRef m_csChunk; Com m_defaultBlendState; diff --git a/src/d3d11/d3d11_context_def.cpp b/src/d3d11/d3d11_context_def.cpp index a4048ca30..6f77ca945 100644 --- a/src/d3d11/d3d11_context_def.cpp +++ b/src/d3d11/d3d11_context_def.cpp @@ -7,7 +7,7 @@ namespace dxvk { D3D11Device* pParent, const Rc& Device, UINT ContextFlags) - : D3D11DeviceContext(pParent, Device), + : D3D11DeviceContext(pParent, Device, GetCsChunkFlags(pParent)), m_contextFlags(ContextFlags), m_commandList (CreateCommandList()) { ClearState(); @@ -298,4 +298,12 @@ namespace dxvk { m_commandList->AddChunk(std::move(chunk)); } + + DxvkCsChunkFlags D3D11DeferredContext::GetCsChunkFlags( + D3D11Device* pDevice) { + return pDevice->GetOptions()->dcMapSpeedHack + ? DxvkCsChunkFlags(DxvkCsChunkFlag::SingleUse) + : DxvkCsChunkFlags(); + } + } \ No newline at end of file diff --git a/src/d3d11/d3d11_context_def.h b/src/d3d11/d3d11_context_def.h index 3dfc80020..514f1dc3e 100644 --- a/src/d3d11/d3d11_context_def.h +++ b/src/d3d11/d3d11_context_def.h @@ -98,6 +98,9 @@ namespace dxvk { Com CreateCommandList(); void EmitCsChunk(DxvkCsChunkRef&& chunk); + + static DxvkCsChunkFlags GetCsChunkFlags( + D3D11Device* pDevice); auto FindMapEntry(ID3D11Resource* pResource, UINT Subresource) { return std::find_if(m_mappedResources.rbegin(), m_mappedResources.rend(), diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 5315203d3..d332290cb 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -11,7 +11,7 @@ namespace dxvk { D3D11ImmediateContext::D3D11ImmediateContext( D3D11Device* pParent, const Rc& Device) - : D3D11DeviceContext(pParent, Device), + : D3D11DeviceContext(pParent, Device, DxvkCsChunkFlag::SingleUse), m_csThread(Device->createContext()) { EmitCs([cDevice = m_device] (DxvkContext* ctx) { ctx->beginRecording(cDevice->createCommandList());