diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index f264162fd..d049e92dc 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -1460,6 +1460,8 @@ void D3D12DebugManager::GetBufferData(ID3D12Resource *buffer, uint64_t offset, u if(buffer == NULL) return; + m_pDevice->GPUSyncAllQueues(); + D3D12_RESOURCE_DESC desc = buffer->GetDesc(); D3D12_HEAP_PROPERTIES heapProps = {}; // can't call GetHeapProperties on sparse resources diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 3adac38e1..e68413109 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -3766,14 +3766,21 @@ void WrappedID3D12Device::GPUSync(ID3D12CommandQueue *queue, ID3D12Fence *fence) void WrappedID3D12Device::GPUSyncAllQueues() { + if(m_GPUSynced) + return; + for(size_t i = 0; i < m_QueueFences.size(); i++) GPUSync(m_Queues[i], m_QueueFences[i]); + + m_GPUSynced = true; } ID3D12GraphicsCommandListX *WrappedID3D12Device::GetNewList() { ID3D12GraphicsCommandListX *ret = NULL; + m_GPUSynced = false; + if(!m_InternalCmds.freecmds.empty()) { ret = m_InternalCmds.freecmds.back(); @@ -4444,6 +4451,8 @@ void WrappedID3D12Device::ReplayLog(uint32_t startEventID, uint32_t endEventID, { bool partial = true; + m_GPUSynced = false; + if(startEventID == 0 && (replayType == eReplay_WithoutDraw || replayType == eReplay_Full)) { startEventID = 1; diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index c680f663d..bf21fa388 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -591,6 +591,9 @@ private: rdcarray m_Queues; rdcarray m_QueueFences; + // if we've called GPUSyncAllQueues since the last replay + bool m_GPUSynced = false; + // list of queues and buffers kept alive during capture artificially even if the user destroys // them, so we can use them in the capture. Storing this separately prevents races where a // queue/buffer is added between us transitioning away from active capturing (so we don't addref diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index ecf7bc368..32754cd12 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -301,7 +301,11 @@ void D3D12Replay::ReplayLog(uint32_t endEventID, ReplayLogType replayType) if(replayed) return; } + m_pDevice->ReplayLog(0, endEventID, replayType); + + if(replayType == eReplay_WithoutDraw) + m_pDevice->GPUSyncAllQueues(); } SDFile *D3D12Replay::GetStructuredFile() @@ -3521,6 +3525,8 @@ void D3D12Replay::GetTextureData(ResourceId tex, const Subresource &sub, bool wasms = false; bool resolve = params.resolve; + m_pDevice->GPUSyncAllQueues(); + ID3D12Resource *resource = NULL; {