Ensure dedicated resources in D3D12 buffer allocator don't get reused

* If we don't call SubAlloc (which will consume the whole resource) then it is
  pushed into the same free list as is used to allocate non-dedicated buffers
  from.
This commit is contained in:
baldurk
2024-11-11 18:20:37 +00:00
parent bd2f8a5d14
commit ec8bfeafb3
+7 -4
View File
@@ -2342,10 +2342,13 @@ bool D3D12GpuBufferAllocator::D3D12GpuBufferPool::Alloc(WrappedID3D12Device *wra
wrappedDevice, m_bufferPoolHeapType, size, &newBufferResource))
{
m_bufferResourceList.push_back(newBufferResource);
*gpuBuffer = new D3D12GpuBuffer(
allocator, m_bufferPoolHeapType, D3D12GpuBufferHeapMemoryFlag::Dedicated, size,
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
newBufferResource->Resource()->GetGPUVirtualAddress(), newBufferResource->Resource());
D3D12_GPU_VIRTUAL_ADDRESS gpuAddress = 0;
if(newBufferResource->SubAlloc(size, alignment, gpuAddress))
{
*gpuBuffer = new D3D12GpuBuffer(
allocator, m_bufferPoolHeapType, D3D12GpuBufferHeapMemoryFlag::Dedicated, size,
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, gpuAddress, newBufferResource->Resource());
}
return true;
}
}