fix: replace runtime waitIdle calls with a deletion queue

This commit is contained in:
2026-10-19 00:45:24 +02:00
parent 36341bb5e0
commit 997844eaa7
29 changed files with 290 additions and 101 deletions
+39
View File
@@ -0,0 +1,39 @@
#include <destrum/Graphics/DeletionQueue.h>
#include <cassert>
#include <exception>
#include <spdlog/spdlog.h>
void DeletionQueue::push(std::uint64_t retiredInFrame, std::function<void()>&& deleter)
{
// entries stay sorted by frame, flush only has to look at the front
assert(entries.empty() || entries.back().frame <= retiredInFrame);
entries.push_back(Entry{retiredInFrame, std::move(deleter)});
}
void DeletionQueue::flush(std::uint64_t lastCompletedFrame)
{
while (!entries.empty() && entries.front().frame <= lastCompletedFrame) {
auto deleter = std::move(entries.front().deleter);
entries.pop_front();
try {
deleter();
} catch (const std::exception& e) {
spdlog::error("DeletionQueue: deleter threw: {}", e.what());
}
}
}
void DeletionQueue::flushAll()
{
while (!entries.empty()) {
auto deleter = std::move(entries.front().deleter);
entries.pop_front();
try {
deleter();
} catch (const std::exception& e) {
spdlog::error("DeletionQueue: deleter threw: {}", e.what());
}
}
}