From c937948f8f898b5534638f54faec5af306a0d343 Mon Sep 17 00:00:00 2001 From: myT <> Date: Mon, 15 Apr 2024 04:43:10 +0200 Subject: [PATCH] fixed delayed RHI buffer deletions --- code/renderer/rhi_d3d12.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/renderer/rhi_d3d12.cpp b/code/renderer/rhi_d3d12.cpp index 37d55a5..4f8b308 100644 --- a/code/renderer/rhi_d3d12.cpp +++ b/code/renderer/rhi_d3d12.cpp @@ -3738,6 +3738,8 @@ namespace RHI backEnd.renderFrame = qtrue; } + rhi.buffersToDelete.Clear(); + if(!destroyWindow) { WaitUntilDeviceIsIdle(); @@ -3918,7 +3920,7 @@ namespace RHI for(uint32_t b = 0; b < rhi.buffersToDelete.count; ) { - if(rhi.buffersToDelete[b].beginFrameCounter >= rhi.beginFrameCounter) + if(rhi.beginFrameCounter >= rhi.buffersToDelete[b].beginFrameCounter) { DestroyBuffer(rhi.buffersToDelete[b].buffer); rhi.buffersToDelete.Remove(b); @@ -4120,7 +4122,7 @@ namespace RHI } BufferToDelete b = {}; - b.beginFrameCounter = rhi.beginFrameCounter + 2; + b.beginFrameCounter = rhi.beginFrameCounter + FrameCount + 1; b.buffer = buffer; rhi.buffersToDelete.Add(b); }