From 1ecb25d31468a9a164c382887eabb3a15c93c428 Mon Sep 17 00:00:00 2001 From: johannes Date: Sat, 9 Nov 2024 13:30:20 +0100 Subject: [PATCH] - missing locks for range allocator and resident flag initialization --- code/foundation/memory/rangeallocator.h | 1 + code/render/coregraphics/vk/vkgraphicsdevice.cc | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/foundation/memory/rangeallocator.h b/code/foundation/memory/rangeallocator.h index a0d4d6248..77451d6b6 100644 --- a/code/foundation/memory/rangeallocator.h +++ b/code/foundation/memory/rangeallocator.h @@ -360,6 +360,7 @@ RangeAllocator::InsertNode(uint size, uint offset) newNode.offset = offset; newNode.binNext = headNodeIndex; newNode.binPrev = RangeAllocatorNode::END; + newNode.resident = false; this->freeStorage += size; diff --git a/code/render/coregraphics/vk/vkgraphicsdevice.cc b/code/render/coregraphics/vk/vkgraphicsdevice.cc index 4b9507db2..ca160da4a 100644 --- a/code/render/coregraphics/vk/vkgraphicsdevice.cc +++ b/code/render/coregraphics/vk/vkgraphicsdevice.cc @@ -2240,6 +2240,7 @@ UploadInternal(const CoreGraphics::BufferId buffer, const uint offset, const voi void FreeUploads(const Util::Array& allocations) { + Threading::CriticalScope _0(&UploadLock); for (const auto& alloc : allocations) { state.uploadAllocator.Dealloc(alloc); @@ -2363,12 +2364,14 @@ NewFrame() { state.queries[state.currentBufferedFrameIndex].queryFreeCount[i] = 0; } - - for (const auto& alloc : state.uploadAllocationsToFree[state.currentBufferedFrameIndex]) { - state.uploadAllocator.Dealloc(alloc); + Threading::CriticalScope _0(&UploadLock); + for (const auto& alloc : state.uploadAllocationsToFree[state.currentBufferedFrameIndex]) + { + state.uploadAllocator.Dealloc(alloc); + } + state.uploadAllocationsToFree[state.currentBufferedFrameIndex].Clear(); } - state.uploadAllocationsToFree[state.currentBufferedFrameIndex].Clear(); // update constant buffer offsets Vulkan::GraphicsDeviceState::ConstantsRingBuffer& nextCboRing = state.constantBufferRings[state.currentBufferedFrameIndex];