10#include "evan/EvanPlatform.hpp"
47 void add(uint64_t ns)
noexcept
95 , _start(phase !=
nullptr ? Clock::now() : TimePoint {})
104 if (_phase ==
nullptr) {
107 _phase->
add(
static_cast<uint64_t
>(
108 std::chrono::duration_cast<std::chrono::nanoseconds>(
109 Clock::now() - _start)
119 using Clock = std::chrono::steady_clock;
120 using TimePoint = Clock::time_point;
163 std::array<PhaseStats, MAX_SWAPCHAINS>
165 std::array<PhaseStats, MAX_SWAPCHAINS>
167 std::array<PhaseStats, MAX_SWAPCHAINS>
169 std::array<PhaseStats, MAX_SWAPCHAINS>
237 void setEnabledForTesting(std::optional<
bool> state) noexcept;
242 void countSync() noexcept;
247 void countSyncSkip() noexcept;
252 void countMeshCreation() noexcept;
257 void countMeshDestruction() noexcept;
263 void countUploadWait() noexcept;
287 [[nodiscard]] inline uint64_t maskTimestamp(uint64_t value,
288 uint32_t validBits) noexcept
290 if (validBits >= 64) {
293 if (validBits == 0) {
296 return value & ((uint64_t { 1 } << validBits) - 1);
312 uint64_t &deltaNs)
noexcept
314 if (end < begin || !(period > 0.0f)) {
317 deltaNs =
static_cast<uint64_t
>(
static_cast<double>(end - begin)
318 *
static_cast<double>(period));
RAII timer feeding one PhaseStats.
~ScopedTimer() noexcept
Adds the elapsed time to the destination phase.
ScopedTimer(PhaseStats *phase) noexcept
Starts measuring into phase.
bool timestampDeltaNs(uint64_t begin, uint64_t end, float period, uint64_t &deltaNs) noexcept
Converts a timestamp delta to nanoseconds.
Per-frame instrumentation data (CPU phases and counters).
uint64_t uploadWaits
Blocking upload fence waits.
bool gpuAvailable
Whether GPU timestamp queries were created and are readable.
uint64_t drawCalls
vkCmdDrawIndexed(Indirect) count.
uint64_t totalMeshes
Meshes registered at draw time.
std::array< PhaseStats, MAX_SWAPCHAINS > submitView
submit, per view slot.
uint64_t pipelineBinds
vkCmdBindPipeline count.
std::array< PhaseStats, MAX_SWAPCHAINS > updateUniformView
updateUniform, per view slot.
PhaseStats record
Per-view command recording.
PhaseStats inFlightWait
Slot-reuse fence wait.
PhaseStats updateUniform
Per-view uniform buffer updates.
uint64_t culledMeshes
Meshes removed by culling.
uint64_t descriptorBinds
vkCmdBindDescriptorSets count.
uint64_t meshCreations
GPUMesh constructions.
PhaseStats submit
Per-view queue submissions.
ScopedTimer timer(PhaseStats &phase) noexcept
Creates a scoped timer for phase.
PhaseStats renderWait
OpenXR end-of-frame fence wait.
uint64_t frames
Frames in the window.
PhaseStats postprocess
OpenXR frame postprocess.
std::array< PhaseStats, MAX_SWAPCHAINS > recordView
record, per view slot.
PhaseStats transferFlush
Renderer::drawFrame: upload flush.
bool enabled
Whether CPU timers and the interval log are active.
uint64_t instancedDraws
Draws with instanceCount > 1.
uint64_t syncSkips
sync() calls short-circuited.
uint64_t syncCalls
RessourceManager::sync() calls.
uint64_t meshDestructions
GPUMesh destructions.
PhaseStats present
Present/composition (all sets).
void resetWindow() noexcept
Starts a new report window.
uint64_t visibleMeshes
Meshes surviving culling.
std::array< PhaseStats, MAX_SWAPCHAINS > gpuPass
GPU pass time, per view slot.
PhaseStats preprocess
OpenXR frame preprocess.
uint64_t skippedMeshes
Meshes skipped (bad state).
PhaseStats acquire
Swapchain image acquire (all sets).
One accumulated CPU phase, in nanoseconds.
void add(uint64_t ns) noexcept
Records one sample.
uint64_t averageNs() const noexcept
Average duration of the window.
uint32_t samples
Number of samples of the current window.
uint64_t totalNs
Sum of the samples of the current window, in nanoseconds.
uint64_t lastNs
Most recent sample, in nanoseconds.
void resetWindow() noexcept
Starts a new window.