diff --git a/MobileGL/MG_Impl/Pipe/VertexInputEmit.h b/MobileGL/MG_Impl/Pipe/VertexInputEmit.h index 388178f5..4960ad5f 100644 --- a/MobileGL/MG_Impl/Pipe/VertexInputEmit.h +++ b/MobileGL/MG_Impl/Pipe/VertexInputEmit.h @@ -487,9 +487,9 @@ namespace MobileGL::MG_Pipe { VaoMemo& MemoFor(const VertexArrayObject& vao) { const Uint64 lifetimeId = vao.GetLifetimeId(); const Uint64 epoch = MGPipeSlots().ResetEpoch(); - // A per-array hint survives switching arrays. Growth and erasure can move entries, - // so the slot is only a candidate until both identity and the allocator epoch match. - SizeT& hint = vao.PipeVertexInputMemoHint(); + // Keep recent slots in the emitter across array switches. Collisions, growth and + // erasure can stale a hint, so check the lifetime and epoch before using it. + SizeT& hint = m_vaoMemoHints[lifetimeId & (m_vaoMemoHints.size() - 1)]; if (hint < m_vaoMemo.size() && m_vaoMemo[hint].LifetimeId == lifetimeId && m_vaoMemo[hint].SlotEpoch == epoch) return m_vaoMemo[hint]; @@ -528,6 +528,7 @@ namespace MobileGL::MG_Pipe { } Vector m_vaoMemo; SizeT m_vaoMemoUsed = 0; + Array m_vaoMemoHints{}; public: // The VAO died (MGPipeEmitVertexElementsDestroyAndFree): its entry goes, by backward-shift diff --git a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h index a6143268..97b176cb 100644 --- a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h +++ b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h @@ -69,8 +69,6 @@ namespace MobileGL { // DirectVulkan's VulkanRenderer). Uint64 GetLifetimeId() const { return m_lifetimeId; } - SizeT& PipeVertexInputMemoHint() const { return m_pipeVertexInputMemoHint; } - void SetAttributeDivisor(Uint index, Uint divisor); Uint GetAttributeDivisor(Uint index) const; @@ -136,7 +134,6 @@ namespace MobileGL { const Uint m_externalIndex = 0; const Uint64 m_lifetimeId = AllocateLifetimeId(); - mutable SizeT m_pipeVertexInputMemoHint = ~SizeT{0}; Array m_attributes; Array m_attributeVersions; BindingSlot m_indexBufferBindingSlot;