Reorder active descriptor set slots to end of list

Speeds up allocations by significantly reducing the number of needed atomic ops per alloc. Could be optimised further in the future if needed.
This commit is contained in:
Billy Laws 2022-09-23 22:06:50 +01:00
parent 128b68d8b2
commit f3184cdff1

View File

@ -94,9 +94,13 @@ namespace skyline::gpu {
vk::Result lastResult{};
if (it != pool->layoutSlots.end()) {
auto &slots{it->second};
for (auto &slot : it->second)
if (!slot.active.test_and_set(std::memory_order_acq_rel))
return ActiveDescriptorSet{pool, &slot};
for (auto slotIt{it->second.begin()} ; slotIt != it->second.end() ; slotIt++) {
if (!slotIt->active.test_and_set(std::memory_order_acq_rel)) {
// Move active slots to end of list to reduce search time
it->second.splice(it->second.end(), it->second, slotIt);
return ActiveDescriptorSet{pool, &*slotIt};
}
}
// If we couldn't find an available slot, we need to allocate a new one
auto set{AllocateVkDescriptorSet(layout)};