[Perf] (Magma): the wire vertex-input layout is kept on its vertex-elements record and buffer handles resolve through a slot-indexed front.

This commit is contained in:
2026-10-07 14:58:22 -04:00
parent c1497bb83e
commit 032dcd240e
5 changed files with 101 additions and 21 deletions
@@ -184,13 +184,17 @@ namespace MobileGL::MG_Backend::DirectVulkan {
} // namespace
VkBufferManager::WireBufferResource* VkBufferManager::FindWireBuffer(MG_Pipe::MGPipeHandle res) {
const Uint64 key = WireBufferKey(res);
auto& lookup = m_wireBufferLookup[key % kWireBufferLookupEntries];
if (lookup.resource != nullptr && lookup.key == key && lookup.eraseCount == m_wireBufferEraseCount)
return lookup.resource;
const auto found = m_wireBuffers.find(key);
const SizeT slot = res.Slot;
if (slot < m_wireBufferLookup.size()) {
const auto& lookup = m_wireBufferLookup[slot];
if (lookup.resource != nullptr && lookup.gen == res.Gen) return lookup.resource;
}
const auto found = m_wireBuffers.find(WireBufferKey(res));
if (found == m_wireBuffers.end()) return nullptr;
lookup = {key, m_wireBufferEraseCount, &found->second};
if (slot < kWireBufferLookupMaxSlots) {
if (slot >= m_wireBufferLookup.size()) m_wireBufferLookup.resize(slot + 1);
m_wireBufferLookup[slot] = {res.Gen, &found->second};
}
return &found->second;
}
@@ -998,7 +1002,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
DeferWireRelease(std::move(found->second.buffer),
found->second.imported ? T0ReleaseSerial(found->second.lastUseSerial)
: found->second.lastUseSerial); // P11 B2, as Respecify
++m_wireBufferEraseCount;
ForgetWireBufferLookup(found->first);
m_wireBuffers.erase(found);
PublishWireReclaimGauges();
}
@@ -1170,7 +1174,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// DestroyAllDeferredReleases above emptied the parked list; this destroys the stores the
// records still hold, so nothing this arm minted outlives the count.
if (!m_wireBuffers.empty()) ++m_wireStoreDestroyEpoch;
++m_wireBufferEraseCount;
m_wireBufferLookup.clear();
m_wireBuffers.clear();
m_wireStoreCount = 0;
m_wireStoreCountPeak = 0;