invalidate index buffers when a command buffer finishes

This commit is contained in:
Samuliak 2024-11-14 19:10:36 +01:00
parent c9b18efc03
commit d732416569
No known key found for this signature in database

View File

@ -14,6 +14,8 @@ struct MetalBufferRange
constexpr size_t BASE_ALLOCATION_SIZE = 8 * 1024 * 1024; // 8 MB
constexpr size_t MAX_ALLOCATION_SIZE = 64 * 1024 * 1024; // 64 MB
void LatteIndices_invalidateAll();
template<typename BufferT>
class MetalBufferAllocator
{
@ -261,8 +263,10 @@ public:
}
}
// TODO: this function should be more more lightweight and leave the checking for completion to the caller, but this works fine for now, since there is always only one instance of this class
void CheckForCompletedCommandBuffers(/*MTL::CommandBuffer* commandBuffer, bool erase = true*/)
{
bool atLeastOneCompleted = false;
for (auto it = m_executingCommandBuffers.begin(); it != m_executingCommandBuffers.end();)
{
if (CommandBufferCompleted(it->first))
@ -280,6 +284,8 @@ public:
it->first->release();
it = m_executingCommandBuffers.erase(it);
atLeastOneCompleted = true;
}
else
{
@ -287,6 +293,9 @@ public:
}
}
if (atLeastOneCompleted)
LatteIndices_invalidateAll();
//if (erase)
// m_commandBuffersFrames.erase(commandBuffer);
}