[Perf] (DirectVulkan): skip pending-clear probes through a lock-free empty check

This commit is contained in:
2026-07-30 07:02:03 -04:00
parent 76b8957b99
commit 2d4d6e9cfb
2 changed files with 28 additions and 0 deletions
@@ -14,6 +14,7 @@
#include "MG_Util/Math/VectorTypes.h"
#include <Includes.h>
#include <atomic>
#include <unordered_map>
namespace MobileGL::MG_Backend::DirectVulkan {
@@ -121,6 +122,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
Uint8 m_gcCounter = 0;
mutable std::mutex m_mutex;
// Lock-free mirror of m_pendingClears.size(), maintained under m_mutex
// by every mutation. The per-draw probes (HasPendingClear/GetPending*)
// read it before taking the lock: during draw batches the pending set
// is almost always empty, so this turns several locked map probes per
// draw into one relaxed load.
std::atomic<Uint32> m_pendingCount{0};
std::unordered_map<PendingClearKey, ClearAttachmentPayload, PendingClearKeyHash> m_pendingClears;
std::unordered_map<TextureIdentity, WeakPtr<MG_State::GLState::ITextureObject>, TextureIdentityHash> m_aliveObjects;
};