From 00dc732f10cf1903d8884e041c37563d3c04f098 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 26 May 2023 18:59:53 +0100 Subject: [PATCH] Ensure we create a sufficient heap for oversized resources * This heap will only have one resource, but the code handles that and bumps the next resource to a new heap. --- renderdoc/driver/d3d12/d3d12_device.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 9dabe23ad0..b6b38f8767 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -1415,12 +1415,17 @@ HRESULT WrappedID3D12Device::CreateInitialStateBuffer(const D3D12_RESOURCE_DESC HRESULT ret = S_OK; + // if desc.Width is greater than InitialStateHeapSize this will forcibly be true, regardless of + // m_LastInitialStateHeapOffset + // it will create a dedicated heap for that resource, and then when m_LastInitialStateHeapOffset + // is updated the next resource (regardless of size) will go in a new heap because + // m_LastInitialStateHeapOffset >= InitialStateHeapSize will be true if(m_InitialStateHeaps.empty() || m_LastInitialStateHeapOffset >= InitialStateHeapSize || desc.Width > InitialStateHeapSize - m_LastInitialStateHeapOffset) { D3D12_HEAP_DESC heapDesc = {}; heapDesc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - heapDesc.SizeInBytes = InitialStateHeapSize; + heapDesc.SizeInBytes = RDCMAX(InitialStateHeapSize, desc.Width); heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS; heapDesc.Properties.Type = D3D12_HEAP_TYPE_READBACK; @@ -1435,6 +1440,9 @@ HRESULT WrappedID3D12Device::CreateInitialStateBuffer(const D3D12_RESOURCE_DESC if(FAILED(ret)) { + CheckHRESULT(ret); + RDCERR("Couldn't create new initial state heap #%zu: %s", m_InitialStateHeaps.size(), + ToStr(ret).c_str()); SAFE_RELEASE(heap); return ret; }