From e173318de20dba2dff7c5b8b64089005ff168583 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 16 Sep 2016 17:10:22 +0200 Subject: [PATCH] Don't copy buffers that are already on a readback heap, read directly --- renderdoc/driver/d3d12/d3d12_manager.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/d3d12/d3d12_manager.cpp b/renderdoc/driver/d3d12/d3d12_manager.cpp index aaf5bc76e..c90eb986f 100644 --- a/renderdoc/driver/d3d12/d3d12_manager.cpp +++ b/renderdoc/driver/d3d12/d3d12_manager.cpp @@ -470,6 +470,15 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) if(desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { D3D12_HEAP_PROPERTIES heapProps; + r->GetHeapProperties(&heapProps, NULL); + + if(heapProps.Type == D3D12_HEAP_TYPE_READBACK) + { + // already on readback heap, just mark that we can map it directly and continue + SetInitialContents(GetResID(r), D3D12ResourceManager::InitialContentData(NULL, 1, NULL)); + return true; + } + heapProps.Type = D3D12_HEAP_TYPE_READBACK; heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; @@ -607,7 +616,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) return false; } -bool D3D12ResourceManager::Serialise_InitialState(ResourceId resid, ID3D12DeviceChild *) +bool D3D12ResourceManager::Serialise_InitialState(ResourceId resid, ID3D12DeviceChild *liveRes) { D3D12ResourceRecord *record = NULL; if(m_State >= WRITING) @@ -634,6 +643,11 @@ bool D3D12ResourceManager::Serialise_InitialState(ResourceId resid, ID3D12Device ID3D12Resource *copiedBuffer = (ID3D12Resource *)initContents.resource; + if(initContents.num == 1) + { + copiedBuffer = (ID3D12Resource *)liveRes; + } + byte dummy[4] = {}; byte *ptr = NULL; size_t size = 0;