From f6cb4aedfc01d8e8421122643ea668ae71a6abf5 Mon Sep 17 00:00:00 2001 From: Snooozs <0randale196@gmail.com> Date: Wed, 25 Nov 2026 23:28:38 +0100 Subject: runtime: LEONIDA_DEV_OVERLAY shows what the runtime is doing over the title's window (RT-DEV-OVERLAY) A click-through window of its own with its own thread: frame and submission rate, a submission's CPU time by phase, the phase running now, pipeline builds in flight, indirect draws, cores and memory. Off by default. submit_phases keeps per-phase counts of the threads inside a phase, so overlapping submissions of several queues leave none behind. Co-Authored-By: Claude Opus 5.5 --- runtime/src/dev_status.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 runtime/src/dev_status.h (limited to 'runtime/src/dev_status.h') diff --git a/runtime/src/dev_status.h b/runtime/src/dev_status.h new file mode 100644 index 000000000..3efc9bf4f --- /dev/null +++ b/runtime/src/dev_status.h @@ -0,0 +1,51 @@ +#pragma once +// What the runtime is building now, for the dev overlay (dev_overlay.h). Always on: two relaxed atomics a build, and a +// short copy under a lock for the name. +#include +#include +#include +#include +#include +#include + +namespace leonida::dev_status { + +struct Builds { + std::atomic active{0}; + std::atomic done{0}; + + std::string last() { + std::lock_guard lock(mutex_); + return name_; + } + void name(const char* text) { + std::lock_guard lock(mutex_); + const std::size_t n = std::min(std::strlen(text), sizeof name_ - 1); + std::memcpy(name_, text, n); + name_[n] = 0; + } + +private: + std::mutex mutex_; + char name_[96]{}; +}; +inline Builds& builds() { + static Builds instance; + return instance; +} + +// One pipeline build, from construction to destruction. +struct Build { + explicit Build(const char* name) { + builds().name(name); + builds().active.fetch_add(1, std::memory_order_relaxed); + } + ~Build() { + builds().active.fetch_sub(1, std::memory_order_relaxed); + builds().done.fetch_add(1, std::memory_order_relaxed); + } + Build(const Build&) = delete; + Build& operator=(const Build&) = delete; +}; + +} // namespace leonida::dev_status -- cgit v1.2.3