Named-bucket GPU timing collector. More...
Detailed Description
Named-bucket GPU timing collector.
QRhi exposes only a single QRhiCommandBuffer::lastCompletedGpuTime() value — the elapsed GPU time of the most recently COMPLETED frame on that CB. Internally QRhi wraps the CB with a timestamp query pair and returns the delta in milliseconds. RenderList::renderInternal feeds that value in under the "frame" bucket; other buckets ("pso_compile") are recorded by whoever measures them.
Results are always one frame late (the GPU must complete, then the CPU reads back the resolved timestamp). Callers expecting live numbers should treat the read as "previous frame's time".
The collector is per-RenderList. It accumulates a rolling mean over the last N frames and exposes a copy via snapshot() for the observability panel.
Thread model: all public methods are called from the Gfx thread. The panel's read path takes a shared lock; writers hold an exclusive lock during update. Lock contention is negligible (one update/frame, one read/ui-tick).
Classes | |
| struct | Entry |
Public Member Functions | |
| GpuTimings (const GpuTimings &)=delete | |
| GpuTimings & | operator= (const GpuTimings &)=delete |
| void | record (std::string_view name, double ms) noexcept |
| Record an observation for a named pass. | |
| void | tickFrame () noexcept |
Tick once per frame. Entries not observed for more than kStaleThreshold frames are dropped. | |
| std::vector< Entry > | snapshot () const |
| Snapshot of all entries for the observability panel. | |
| void | reset () noexcept |
| Reset all state. Called on RenderList re-init. | |
Static Public Attributes | |
| static constexpr int | kHistorySize = 64 |
Member Function Documentation
◆ record()
|
noexcept |
Record an observation for a named pass.
ms may be 0 when caps.timestamps is false or when the backend hasn't resolved a timestamp yet. Zero samples skip the rolling mean update.
◆ snapshot()
| std::vector< GpuTimings::Entry > score::gfx::GpuTimings::snapshot | ( | ) | const |
Snapshot of all entries for the observability panel.
Returns a copy so the caller doesn't need to hold a lock while iterating. Cost: O(n_entries); typical n ≤ 32.
The documentation for this class was generated from the following files:
- GpuTiming.hpp
- GpuTiming.cpp