upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/dev_overlay.h
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 18:16:25 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 18:18:57 -0500
commit38385762bd400e8260c7b3c8a80bb0c03fcc44c4 (patch)
treee0d983ce74468edfde736ab699a695b80702ddbf /runtime/src/dev_overlay.h
parentd4fb292344088e7925ddeb3bbceb5a9ac46de8c2 (diff)
dev overlay: the title HUD's VRAM and private memory figures
LEONIDA_DEV_OVERLAY (#2137) showed the working set and free RAM, with no GPU memory and no private memory. It now shows both, from the same code as the title HUD: - src/memory_figures.h holds VramBudget, the private-bytes choice (the larger of PrivateUsage and PagefileUsage, since Wine fills only the latter), the "RAM ..." and "VRAM ..." text with "n/a" where there is no figure, and a publisher for the device's GPU memory figure. No Vulkan, and Win32 only under _WIN32, so the overlay's test still builds on every host. - A device with VK_EXT_memory_budget publishes a reader when it is created and withdraws it first thing when it is destroyed (the lock is held during a read, so a reader never outlives its device). latest_vram() calls the reader at most once per 500 ms for both views. The HUD reads it instead of its own per-device lambda. - The overlay's last line is now "RAM 2.5 GB (ws 1.0) VRAM 3.5/16.0 GB +0.5 shared"; cores and free RAM keep their own line. Tests: dev_overlay_test checks the text with and without figures, the private-bytes fallback, and the publisher (one read per refresh, only the publishing device withdraws). title_hud_test checks that a HUD without its own source shows the published figure. d3d12_vram_budget_test checks that the device publishes its figure while it lives and withdraws it on release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/dev_overlay.h')
-rw-r--r--runtime/src/dev_overlay.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/src/dev_overlay.h b/runtime/src/dev_overlay.h
index fe38031db..1eecfc366 100644
--- a/runtime/src/dev_overlay.h
+++ b/runtime/src/dev_overlay.h
@@ -3,11 +3,13 @@
3// window that says how the boot is doing: frames and submissions a second, where a submission's CPU time goes and which 3// window that says how the boot is doing: frames and submissions a second, where a submission's CPU time goes and which
4// phase runs now, pipeline builds, indirect draws, CPU, memory. It is its own window with its own thread and GDI text, 4// phase runs now, pipeline builds, indirect draws, CPU, memory. It is its own window with its own thread and GDI text,
5// so it keeps counting while the title shows no frames for seconds (pipeline builds, a stalled submission), it is in no 5// so it keeps counting while the title shows no frames for seconds (pipeline builds, a stalled submission), it is in no
6// captured frame, and it changes nothing the GPU does. It only reads counters: submit_phases.h, indirect_draw_stats.h 6// captured frame, and it changes nothing the GPU does. It only reads counters: submit_phases.h, indirect_draw_stats.h,
7// and dev_status.h. LEONIDA_TITLE_HUD (shims/title_hud.h) is the other view: frame times, memory and compile time in the 7// dev_status.h, and memory_figures.h for the private memory and the device's GPU memory, which LEONIDA_TITLE_HUD
8// (shims/title_hud.h) shows with the same text. The HUD is the other view: frame times, memory and compile time in the
8// window's title bar. 9// window's title bar.
9#include "dev_status.h" 10#include "dev_status.h"
10#include "indirect_draw_stats.h" 11#include "indirect_draw_stats.h"
12#include "memory_figures.h"
11#include "submit_phases.h" 13#include "submit_phases.h"
12 14
13#ifdef _WIN32 15#ifdef _WIN32
@@ -50,7 +52,9 @@ struct Sample {
50 std::uint64_t built = 0; 52 std::uint64_t built = 0;
51 std::string build; // the last one started 53 std::string build; // the last one started
52 unsigned long long drawn = 0, skipped = 0; // indirect draws so far 54 unsigned long long drawn = 0, skipped = 0; // indirect draws so far
53 double cores = 0, process_gb = 0, free_gb = 0; 55 double cores = 0, free_gb = 0;
56 memory_figures::ProcessMemory ram; // private memory and working set
57 VramBudget vram; // the device's VK_EXT_memory_budget; "n/a" without it
54}; 58};
55 59
56// The text of one sample: pure, for the test. 60// The text of one sample: pure, for the test.
@@ -82,8 +86,9 @@ inline std::vector<std::string> lines(const Sample& s, double age) {
82 out.emplace_back(text); 86 out.emplace_back(text);
83 std::snprintf(text, sizeof text, "indirect draws: %llu drawn, %llu skipped", s.drawn, s.skipped); 87 std::snprintf(text, sizeof text, "indirect draws: %llu drawn, %llu skipped", s.drawn, s.skipped);
84 out.emplace_back(text); 88 out.emplace_back(text);
85 std::snprintf(text, sizeof text, "%.1f cores, %.1f GB used, %.1f GB RAM free", s.cores, s.process_gb, s.free_gb); 89 std::snprintf(text, sizeof text, "%.1f cores, %.1f GB RAM free", s.cores, s.free_gb);
86 out.emplace_back(text); 90 out.emplace_back(text);
91 out.emplace_back(memory_figures::ram_text(s.ram) + " " + memory_figures::vram_text(s.vram));
87 return out; 92 return out;
88} 93}
89 94
@@ -206,9 +211,8 @@ private:
206 const std::uint64_t used = grown(ticks(kernel) + ticks(user), cpu_); 211 const std::uint64_t used = grown(ticks(kernel) + ticks(user), cpu_);
207 if (s.seconds > 0) s.cores = double(used) * 1e-7 / s.seconds; 212 if (s.seconds > 0) s.cores = double(used) * 1e-7 / s.seconds;
208 } 213 }
209 PROCESS_MEMORY_COUNTERS memory{sizeof memory}; 214 s.ram = memory_figures::process_memory();
210 if (GetProcessMemoryInfo(GetCurrentProcess(), &memory, sizeof memory)) 215 s.vram = memory_figures::latest_vram(); // reads the device at most once per 500 ms
211 s.process_gb = double(memory.WorkingSetSize) / double(1u << 30);
212 MEMORYSTATUSEX status{sizeof status}; 216 MEMORYSTATUSEX status{sizeof status};
213 if (GlobalMemoryStatusEx(&status)) s.free_gb = double(status.ullAvailPhys) / double(1u << 30); 217 if (GlobalMemoryStatusEx(&status)) s.free_gb = double(status.ullAvailPhys) / double(1u << 30);
214 lines_ = lines(s, sp::process_age()); 218 lines_ = lines(s, sp::process_age());