evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::stats Namespace Reference

Process-wide counter plumbing for the frame statistics. More...

Functions

bool enabled () noexcept
 Whether the global counters currently record.
 
void setEnabledForTesting (std::optional< bool > state) noexcept
 Overrides the counter gate.
 
void countSync () noexcept
 Counts one RessourceManager::sync() call.
 
void countSyncSkip () noexcept
 Counts one sync() call short-circuited on the version check.
 
void countMeshCreation () noexcept
 Counts one GPUMesh construction.
 
void countMeshDestruction () noexcept
 Counts one GPUMesh destruction.
 
void countUploadWait () noexcept
 Counts one blocking upload wait (staging or one-time submission fence).
 
void takeGlobalDeltas (FrameStats &stats) noexcept
 Folds the global counter deltas into stats.
 
uint64_t maskTimestamp (uint64_t value, uint32_t validBits) noexcept
 Masks a raw timestamp to the device's valid bits.
 
bool timestampDeltaNs (uint64_t begin, uint64_t end, float period, uint64_t &deltaNs) noexcept
 Converts a timestamp delta to nanoseconds.
 

Detailed Description

Process-wide counter plumbing for the frame statistics.

The counters live here because their increment sites (RessourceManager, GPUMesh, TransferManager, device backends) have no access to a Renderer's FrameStats. The renderer folds the deltas into its window once per frame through takeGlobalDeltas(). Increments are gated behind the EVAN_STATS flag, so with statistics off each site is one predictable branch.

Function Documentation

◆ enabled()

bool evan::stats::enabled ( )
noexcept

Whether the global counters currently record.

Returns
True when EVAN_STATS is set, unless a test overrode the gate.

◆ maskTimestamp()

uint64_t evan::stats::maskTimestamp ( uint64_t  value,
uint32_t  validBits 
)
inlinenoexcept

Masks a raw timestamp to the device's valid bits.

Devices whose timestamp counter is narrower than 64 bits leave the high bits undefined; only the low VkPhysicalDeviceLimits::timestampValidBits bits are meaningful.

Parameters
valueRaw timestamp counter value.
validBitsNumber of valid bits reported by the device.
Returns
The masked value.

Definition at line 287 of file FrameStats.hpp.

◆ setEnabledForTesting()

void evan::stats::setEnabledForTesting ( std::optional< bool >  state)
noexcept

Overrides the counter gate.

Unit-test hook only: the override is never set by engine code. Pass std::nullopt to fall back to the EVAN_STATS environment variable.

Parameters
stateForced gate value, or std::nullopt for the default.

◆ takeGlobalDeltas()

void evan::stats::takeGlobalDeltas ( FrameStats &  stats)
noexcept

Folds the global counter deltas into stats.

Adds (current value - last taken value) to the matching counters and moves the snapshot forward, so every increment is accounted exactly once whichever frame reports it.

Parameters
statsThe window to update.

◆ timestampDeltaNs()

bool evan::stats::timestampDeltaNs ( uint64_t  begin,
uint64_t  end,
float  period,
uint64_t &  deltaNs 
)
inlinenoexcept

Converts a timestamp delta to nanoseconds.

Parameters
beginFirst timestamp, already masked.
endSecond timestamp, already masked.
periodNanoseconds per tick (VkPhysicalDeviceLimits::timestampPeriod, may be fractional).
deltaNsReceives the converted duration.
Returns
False when the delta is unusable: the counter went backwards (wrap with a narrow counter) or the period is unknown.

Definition at line 310 of file FrameStats.hpp.

Here is the call graph for this function:
Here is the caller graph for this function: