From 78aca86902971a93638f907aebc7e37470214fbf Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 28 Jun 2017 10:54:29 +0100 Subject: [PATCH] Add an extra GPU sync between submissions on different queues * If the application did some CPU side synchronisation that's not visible in the capture (unlike a queue Wait() which we replay as a GPU sync) then there might be overlap that causes simultaneous use problems. So instead we sync between submissions on different queues to ensure we don't overlap by accident. --- renderdoc/driver/d3d12/d3d12_command_queue.h | 1 + renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_command_queue.h b/renderdoc/driver/d3d12/d3d12_command_queue.h index 1aaab31d2..adcd8f301 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue.h +++ b/renderdoc/driver/d3d12/d3d12_command_queue.h @@ -96,6 +96,7 @@ class WrappedID3D12CommandQueue : public ID3D12CommandQueue, // command recording/replay data shared between queues and lists D3D12CommandData m_Cmd; + ResourceId m_PrevQueueId; ResourceId m_BackbufferID; void ProcessChunk(uint64_t offset, D3D12ChunkType context); diff --git a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp index 6673be4d1..74dcf560f 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp @@ -143,8 +143,20 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis ID3D12CommandQueue *real = NULL; if(m_State <= EXECUTING) + { real = Unwrap(GetResourceManager()->GetLiveAs(queueId)); + if(m_PrevQueueId != queueId) + { + RDCDEBUG("Previous queue execution was on queue %llu, now executing %llu, syncing GPU", + m_PrevQueueId, queueId); + if(m_PrevQueueId != ResourceId()) + m_pDevice->GPUSync(GetResourceManager()->GetLiveAs(m_PrevQueueId)); + + m_PrevQueueId = queueId; + } + } + if(m_State == READING) { for(uint32_t i = 0; i < numCmds; i++)