From b469cfac0b91cb0256a6274e2bb5cffbc7ce3826 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 3 Mar 2018 20:59:17 +0100 Subject: [PATCH] [d3d11] Implemented FinishCommandList/ExecuteCommandList --- src/d3d11/d3d11_cmdlist.cpp | 2 +- src/d3d11/d3d11_cmdlist.h | 2 +- src/d3d11/d3d11_context.cpp | 5 +++++ src/d3d11/d3d11_context.h | 2 ++ src/d3d11/d3d11_context_def.cpp | 18 ++++++++++++++---- src/d3d11/d3d11_context_imm.cpp | 16 ++++++++-------- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/d3d11/d3d11_cmdlist.cpp b/src/d3d11/d3d11_cmdlist.cpp index 64f910121..794552d01 100644 --- a/src/d3d11/d3d11_cmdlist.cpp +++ b/src/d3d11/d3d11_cmdlist.cpp @@ -48,7 +48,7 @@ namespace dxvk { } - void D3D11CommandList::EmitToCsThread(const Rc& CsThread) { + void D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) { for (auto chunk : m_chunks) CsThread->dispatchChunk(Rc(chunk)); } diff --git a/src/d3d11/d3d11_cmdlist.h b/src/d3d11/d3d11_cmdlist.h index f8c265429..199588556 100644 --- a/src/d3d11/d3d11_cmdlist.h +++ b/src/d3d11/d3d11_cmdlist.h @@ -29,7 +29,7 @@ namespace dxvk { ID3D11CommandList* pCommandList); void EmitToCsThread( - const Rc& CsThread); + DxvkCsThread* CsThread); private: diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 5f3ba55ff..960681239 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -2321,6 +2321,11 @@ namespace dxvk { } + void D3D11DeviceContext::RestoreState() { + Logger::err("D3D11DeviceContext::RestoreState: Not implemented"); + } + + DxvkDataSlice D3D11DeviceContext::AllocUpdateBufferSlice(size_t Size) { constexpr size_t UpdateBufferSize = 4 * 1024 * 1024; diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index a2ca649ee..e7f6e6402 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -562,6 +562,8 @@ namespace dxvk { void ApplyViewportState(); + void RestoreState(); + DxvkDataSlice AllocUpdateBufferSlice(size_t Size); template diff --git a/src/d3d11/d3d11_context_def.cpp b/src/d3d11/d3d11_context_def.cpp index d527078cc..55764ced8 100644 --- a/src/d3d11/d3d11_context_def.cpp +++ b/src/d3d11/d3d11_context_def.cpp @@ -9,7 +9,7 @@ namespace dxvk { : D3D11DeviceContext(pParent, Device), m_contextFlags(ContextFlags), m_commandList (CreateCommandList()) { - + ClearState(); } @@ -31,15 +31,25 @@ namespace dxvk { void STDMETHODCALLTYPE D3D11DeferredContext::ExecuteCommandList( ID3D11CommandList* pCommandList, WINBOOL RestoreContextState) { - Logger::err("D3D11DeferredContext::ExecuteCommandList: Not implemented"); + static_cast(pCommandList)->EmitToCommandList(m_commandList.ptr()); + + if (RestoreContextState) + RestoreState(); + else + ClearState(); } HRESULT STDMETHODCALLTYPE D3D11DeferredContext::FinishCommandList( WINBOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList) { - Logger::err("D3D11DeferredContext::FinishCommandList: Not implemented"); - return E_NOTIMPL; + *ppCommandList = m_commandList.ref(); + m_commandList = CreateCommandList(); + + if (!RestoreDeferredContextState) + ClearState(); + + return S_OK; } diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index cccbafc30..7a7bfad7c 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -1,3 +1,4 @@ +#include "d3d11_cmdlist.h" #include "d3d11_context_imm.h" #include "d3d11_device.h" #include "d3d11_texture.h" @@ -64,7 +65,12 @@ namespace dxvk { void STDMETHODCALLTYPE D3D11ImmediateContext::ExecuteCommandList( ID3D11CommandList* pCommandList, WINBOOL RestoreContextState) { - Logger::err("D3D11ImmediateContext::ExecuteCommandList: Not implemented"); + static_cast(pCommandList)->EmitToCsThread(&m_csThread); + + if (RestoreContextState) + RestoreState(); + else + ClearState(); } @@ -142,13 +148,7 @@ namespace dxvk { // Mapping an image is sadly not as simple as mapping a buffer // because applications tend to ignore row and layer strides. // We use a buffer instead and then perform a copy. - D3D11TextureInfo* textureInfo - = GetCommonTextureInfo(pResource); - - if (textureInfo->imageBuffer == nullptr) { - Logger::err("D3D11DeviceContext: Cannot map a device-local image"); - return E_INVALIDARG; - } + D3D11TextureInfo* textureInfo = GetCommonTextureInfo(pResource); if (pMappedResource == nullptr) return S_FALSE;