From bb781df527776075d616815dab9e355b9ace6ae3 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sun, 6 Sep 2026 10:25:25 -0400 Subject: [PATCH] [Fix] (Pipe): count the render-state CSO binds the cache has always declared and never incremented - Counters::Binds was declared, documented as one of the three numbers P13's capacity retune reads, and incremented nowhere: the retune would have read a permanent zero, and the unit tests counted binds in a local of their own - counted in Acquire, which has exactly one caller and is followed by a bind_render_state every time, so the count cannot drift from the emitter forgetting to tick it --- MobileGL/MG_Impl/Pipe/CsoCache.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MobileGL/MG_Impl/Pipe/CsoCache.h b/MobileGL/MG_Impl/Pipe/CsoCache.h index b1374594..2f742745 100644 --- a/MobileGL/MG_Impl/Pipe/CsoCache.h +++ b/MobileGL/MG_Impl/Pipe/CsoCache.h @@ -56,7 +56,13 @@ namespace MobileGL::MG_Pipe { public: struct Counters { Uint64 Mints = 0; // create_render_state emissions - Uint64 Binds = 0; // bind_render_state emissions, mint or reuse + // bind_render_state emissions, mint or reuse. Counted in Acquire because Acquire + // has exactly ONE caller (PipeFill.cpp's EmitRenderState) and that caller binds + // immediately after every call - so "acquisitions" and "binds" are the same + // number, and counting it here keeps the count from depending on an emitter + // remembering to tick it. mints/binds is the cache's hit rate and it is the + // number the CSO content-addressing negative control moves. + Uint64 Binds = 0; Uint64 Hits = 0; // a probe that found a live entry and passed the memcmp Uint64 Collisions = 0; // a hash hit the memcmp REJECTED - the reason it exists Uint64 Evictions = 0; // LRU evictions, each one a delete_render_state @@ -68,6 +74,7 @@ namespace MobileGL::MG_Pipe { MGPipeHandle Acquire(const RenderStateParameters& params, Uint64& payloadBytes) { Array bytes; MGPipeGatherPipelineBytes(params, bytes.data()); + ++m_counters.Binds; const Bool contentAddressed = (MG_Config::Features.PipePush & kMGPipeBehaviourNoCsoContentAddressing) == 0;