Skip to content

Commit

Permalink
Ensure we create a sufficient heap for oversized resources
Browse files Browse the repository at this point in the history
* This heap will only have one resource, but the code handles that and bumps the
  next resource to a new heap.
  • Loading branch information
baldurk committed May 26, 2023
1 parent d132b57 commit 00dc732
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion renderdoc/driver/d3d12/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 00dc732

Please sign in to comment.