fix: index buffer crashes

This commit is contained in:
Samuliak 2025-01-18 17:22:28 +01:00
parent 97b806f16f
commit d086eb3db5
No known key found for this signature in database
2 changed files with 2 additions and 8 deletions

View file

@ -224,7 +224,7 @@ void MetalSynchronizedHeapAllocator::CleanupBuffer(MTL::CommandBuffer* latestFin
// release allocations // release allocations
for (auto& addr : it->second) for (auto& addr : it->second)
m_chunkedHeap.free(addr); m_chunkedHeap.free(addr);
it = m_releaseQueue.erase(it); m_releaseQueue.erase(it);
} }
void MetalSynchronizedHeapAllocator::GetStats(uint32& numBuffers, size_t& totalBufferSize, size_t& freeBufferSize) const void MetalSynchronizedHeapAllocator::GetStats(uint32& numBuffers, size_t& totalBufferSize, size_t& freeBufferSize) const

View file

@ -1816,7 +1816,6 @@ void MetalRenderer::CommitCommandBuffer()
void MetalRenderer::ProcessFinishedCommandBuffers() void MetalRenderer::ProcessFinishedCommandBuffers()
{ {
// Check for finished command buffers // Check for finished command buffers
bool atLeastOneCompleted = false;
for (auto it = m_executingCommandBuffers.begin(); it != m_executingCommandBuffers.end();) for (auto it = m_executingCommandBuffers.begin(); it != m_executingCommandBuffers.end();)
{ {
auto commandBuffer = *it; auto commandBuffer = *it;
@ -1825,17 +1824,12 @@ void MetalRenderer::ProcessFinishedCommandBuffers()
m_memoryManager->CleanupBuffers(commandBuffer); m_memoryManager->CleanupBuffers(commandBuffer);
commandBuffer->release(); commandBuffer->release();
it = m_executingCommandBuffers.erase(it); it = m_executingCommandBuffers.erase(it);
atLeastOneCompleted = true;
} }
else else
{ {
++it; ++it;
} }
} }
// Invalidate indices if at least one command buffer has completed
if (atLeastOneCompleted)
LatteIndices_invalidateAll();
} }
bool MetalRenderer::AcquireDrawable(bool mainWindow) bool MetalRenderer::AcquireDrawable(bool mainWindow)