From 299249d7188de98014b4f3bc1d3ed0d393fa0c54 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 15 Sep 2020 13:16:57 +0100 Subject: [PATCH] Fix D3D12 command list reset not getting correct init parameters --- renderdoc/driver/d3d12/d3d12_command_list.h | 4 ++++ .../driver/d3d12/d3d12_command_list_wrap.cpp | 19 ++++++++++--------- renderdoc/driver/d3d12/d3d12_device_wrap.cpp | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_command_list.h b/renderdoc/driver/d3d12/d3d12_command_list.h index 76d02f76d..67a79290d 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list.h +++ b/renderdoc/driver/d3d12/d3d12_command_list.h @@ -161,6 +161,8 @@ private: D3D12_COMMAND_LIST_TYPE type; } m_Init; + bool m_FakeCreationReset = false; + static rdcstr GetChunkName(uint32_t idx); D3D12ResourceManager *GetResourceManager() { return m_pDevice->GetResourceManager(); } public: @@ -196,6 +198,8 @@ public: m_Init.nodeMask = nodeMask; m_Init.type = type; } + HRESULT ResetInternal(ID3D12CommandAllocator *pAllocator, ID3D12PipelineState *pInitialState, + bool fakeCreationReset); bool ValidateRootGPUVA(D3D12_GPU_VIRTUAL_ADDRESS buffer); diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index 3de5711a6..40e16c220 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -397,19 +397,18 @@ bool WrappedID3D12GraphicsCommandList::Serialise_Reset(SerialiserType &ser, HRESULT WrappedID3D12GraphicsCommandList::Reset(ID3D12CommandAllocator *pAllocator, ID3D12PipelineState *pInitialState) +{ + return ResetInternal(pAllocator, pInitialState, false); +} + +HRESULT WrappedID3D12GraphicsCommandList::ResetInternal(ID3D12CommandAllocator *pAllocator, + ID3D12PipelineState *pInitialState, + bool fakeCreationReset) { HRESULT ret = S_OK; if(IsCaptureMode(m_State)) { - // If this is the creation reset we won't have our init params yet and this reset is 'fake' to - // record the initial allocator and state. Don't actually call Reset(), just pretend it was so - // that we can pretend D3D12 doesn't have weird behaviour. - bool resetcall = true; - - if(m_Init.riid.Data1 == 0 && m_Init.riid.Data2 == 0 && m_Init.riid.Data3 == 0) - resetcall = false; - m_ListRecord->DisableChunkLocking(); // reset for new recording @@ -420,7 +419,9 @@ HRESULT WrappedID3D12GraphicsCommandList::Reset(ID3D12CommandAllocator *pAllocat if(m_ListRecord->bakedCommands) m_ListRecord->bakedCommands->Delete(GetResourceManager()); - if(resetcall) + // If this reset is 'fake' to record the initial allocator and state. Don't actually call + // Reset(), just pretend it was so that we can pretend D3D12 doesn't have weird behaviour. + if(!fakeCreationReset) { SERIALISE_TIME_CALL(ret = m_pList->Reset(Unwrap(pAllocator), Unwrap(pInitialState))); } diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index 712ee3960..9351d2559 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -340,9 +340,9 @@ HRESULT WrappedID3D12Device::CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST if(IsCaptureMode(m_State)) { - // we just serialise out command allocator creation as a reset, since it's equivalent. - wrapped->Reset(pCommandAllocator, pInitialState); wrapped->SetInitParams(riid, nodeMask, type); + // we just serialise out command allocator creation as a reset, since it's equivalent. + wrapped->ResetInternal(pCommandAllocator, pInitialState, true); { CACHE_THREAD_SERIALISER();