Browse Source

Fix SDL GPU D3D12 Descriptor Heap leak

When descriptor leaks overflow, the D3D12 SDL GPU renderer fetches more from the pool, but never returns them, which eventually causes an "out of memory" crash.

(cherry picked from commit c74b406a4c813e8fa6d644de980d2265528b2d9e)
Edu Garcia 8 tháng trước cách đây
mục cha
commit
dd791f6838
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 7 0
      src/gpu/d3d12/SDL_gpu_d3d12.c

+ 7 - 0
src/gpu/d3d12/SDL_gpu_d3d12.c

@@ -4889,7 +4889,14 @@ static void D3D12_INTERNAL_SetGPUDescriptorHeaps(D3D12CommandBuffer *commandBuff
     viewHeap = D3D12_INTERNAL_AcquireGPUDescriptorHeapFromPool(commandBuffer, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
     samplerHeap = D3D12_INTERNAL_AcquireGPUDescriptorHeapFromPool(commandBuffer, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
 
+    if (commandBuffer->gpuDescriptorHeaps[0] != NULL) {
+        D3D12_INTERNAL_ReturnGPUDescriptorHeapToPool(commandBuffer->renderer, commandBuffer->gpuDescriptorHeaps[0]);
+    }
     commandBuffer->gpuDescriptorHeaps[0] = viewHeap;
+
+    if (commandBuffer->gpuDescriptorHeaps[1] != NULL) {
+        D3D12_INTERNAL_ReturnGPUDescriptorHeapToPool(commandBuffer->renderer, commandBuffer->gpuDescriptorHeaps[1]);
+    }
     commandBuffer->gpuDescriptorHeaps[1] = samplerHeap;
 
     heaps[0] = viewHeap->handle;