GPU: a debug overlay, Alt+Z, drawn into the presented frame #2171

Open
github-bot wants to merge 4 commits from github-bot/gh-2171 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 06:53 UTC · original
0xkn0wh3r3:tools/overlay → main · +2219 −5 · 6 files · 4 commits · draft

A small debug overlay drawn into each presented frame, toggled with Alt+Z.

The overlay panel at 1080 lines

The panel at 1080 lines, as the ignored preview test renders it from sample data (compute left out, A and RB held). It has not been captured from a running title. At 1440 lines: overlay-1440.png.

What it shows

Four sections, each with a header; labels on the left, values right-aligned with their units.

  • Performance:
    • frame rate (green, yellow or red), mean frame time and the 1% low over the last 240 frames;
    • a frame-time graph: y axis in ms (0, 16.7, 33.3, 50, 66.7+) with gridlines named 60, 30 and 20 FPS; x axis from 240 frames ago to now, with ticks and a caption; bars coloured by threshold;
    • from the presenter's existing Meter second: draws per frame, time preparing submissions, and time waiting for the GPU;
    • GPU busy time: while the panel shows, each host submission runs between two small lists that write a GPU timestamp each, read back right after the submission (which is waited for anyway). Shown per frame and as a share of the frame time;
    • input to present: from the title's first input read of a frame (GameInput's current reading) to the present that ends it; mean and slowest of the last 60 frames. It does not include the display's own latency.
  • System, sampled once a second while it shows:
    • process CPU use (GetProcessTimes against the processor count);
    • private and in-use memory, and the machine's memory;
    • video memory against its budget, plus shared memory (QueryVideoMemoryInfo on the device's adapter);
    • a 60-second graph of CPU use, GPU busy time (share of frame time) and video memory used of its budget, 0 to 100 %, with a legend and a labelled time axis.
  • Controller, from gameinput (the keyboard's stand-in pad when none is connected): a box per stick with its position, bars for the triggers, and the buttons lit while held.
  • Draw toggles: keys 1–4, while it shows, leave out compute dispatches, mesh draws, vertex draws or indirect execution, to see what draws what. Each shows whether its work is drawn or left out, and each change is logged.

While the panel shows, the title reads neutral pads and no keys.

Switches

  • Alt+Z, while our window has focus, shows and hides it. Not Shift+Tab: the keyboard stand-in pad uses Tab for View.
  • VICTORY_OVERLAY=1 shows it from the start; VICTORY_OVERLAY=0 turns it off.

How it is drawn

On the CPU, into upload memory in the back buffer's format (RGBA8, BGRA8, RGB10A2 or RGBA16F, the four the presenter makes), then copied into the back buffer's corner after the frame, before the present, with one CopyTextureRegion.

  • Text: Consolas, antialiased in grey, drawn through GDI into a coverage mask and blended over the panel. Where GDI makes no device context, our own 5×7 font stands in.
  • Size: the panel scales with the back buffer: 1 at 1080 lines, 0.75 at 720, up to 2 at 2160.
  • Cost: it is redrawn at most every 250 ms. No shaders or pipelines. While it shows, each submission carries two timestamp lists; while hidden it only times the frame and polls the keys.

Relation to #130

#130 is the full opt-in profiler (CSV, Perfetto trace, and a panel behind F3). This one is smaller and independent: a live panel with controller input and work toggles, and no new crate. If #130 lands first, this panel could take its numbers instead.

Changes

  • crates/victory-gpu/src/overlay.rs (new): the panel, its drawing, the keys, and the submission timer;
  • host.rs: the presenter records the panel's copy, Meter hands over its second, and Host::execute submits through the timer while the panel shows;
  • list.rs: the four toggle gates at the draw, dispatch, mesh and indirect entry points;
  • victory-hle gameinput.rs: publishes the pad, notes the title's input reads, and gives the title neutral input while the panel shows;
  • the Win32_UI_Input_KeyboardAndMouse feature for victory-gpu.

Testing

  • overlay::tests (9):
    • frame statistics (mean, rate, 1% low);
    • GPU busy percent over the last second of frames, and recent means that skip unmeasured frames;
    • the panel fits 720, 1080 and 2160 lines in either font and draws each of its colours;
    • GDI text is antialiased;
    • coverage blending;
    • colours encoded per back buffer format;
    • the keys map to their bits, and are read on a thread of their own;
    • on the host GPU: a shown panel copied into a 1920×1080 back buffer lands at the margin with text inside it, the rest of the frame untouched, and the submission's GPU time is measured.
  • RTX 5070 Ti, driver 621.24:
    • cargo test --workspace --exclude victory-shader: 571 passed. The only failures are the 2 known NVIDIA heap-limit tests (#1835), which fail the same way on main.
    • cargo clippy --workspace --all-targets, with and without --features diagnostics: clean.
  • Not checked in a running title.

Rebased onto f3578e3

  • #1997 (multiple PresentX planes) reworked the present: the panel's copy is recorded in both of its paths. Overlay::record now takes the back buffer's state and returns the state it leaves it in, so the composited path moves the back buffer to the copy destination only when the panel is copied.
  • #1430 (all-zero XInput slots) and the scripted keys moving into State::poll: the overlay's pad and input capture now run inside State::poll, after both, so the panel shows the pad the title actually reads.
  • cargo test -p victory-gpu --lib: all pass but the two known NVIDIA heap-cap tests; overlay::tests and gameinput tests pass. host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame (--features diagnostics) exits abnormally here on main as well. Clippy clean for victory-gpu and victory-hle, with and without --features diagnostics.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 06:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2171) `0xkn0wh3r3:tools/overlay` → `main` · +2219 −5 · 6 files · 4 commits · draft A small debug overlay drawn into each presented frame, toggled with **Alt+Z**. ![The overlay panel at 1080 lines](https://raw.githubusercontent.com/0xkn0wh3r3/VIctory/pr-assets/overlay-v3-1080.png) *The panel at 1080 lines, as the ignored `preview` test renders it from sample data (compute left out, A and RB held). It has not been captured from a running title. At 1440 lines: [overlay-1440.png](https://raw.githubusercontent.com/0xkn0wh3r3/VIctory/pr-assets/overlay-v3-1440.png).* ### What it shows Four sections, each with a header; labels on the left, values right-aligned with their units. - **Performance:** - frame rate (green, yellow or red), mean frame time and the 1% low over the last 240 frames; - a **frame-time graph**: y axis in ms (0, 16.7, 33.3, 50, 66.7+) with gridlines named 60, 30 and 20 FPS; x axis from 240 frames ago to now, with ticks and a caption; bars coloured by threshold; - from the presenter's existing `Meter` second: draws per frame, time preparing submissions, and time waiting for the GPU; - **GPU busy time:** while the panel shows, each host submission runs between two small lists that write a GPU timestamp each, read back right after the submission (which is waited for anyway). Shown per frame and as a share of the frame time; - **input to present:** from the title's first input read of a frame (GameInput's current reading) to the present that ends it; mean and slowest of the last 60 frames. It does not include the display's own latency. - **System**, sampled once a second while it shows: - process CPU use (`GetProcessTimes` against the processor count); - private and in-use memory, and the machine's memory; - video memory against its budget, plus shared memory (`QueryVideoMemoryInfo` on the device's adapter); - a **60-second graph** of CPU use, GPU busy time (share of frame time) and video memory used of its budget, 0 to 100 %, with a legend and a labelled time axis. - **Controller**, from `gameinput` (the keyboard's stand-in pad when none is connected): a box per stick with its position, bars for the triggers, and the buttons lit while held. - **Draw toggles:** keys 1–4, while it shows, leave out compute dispatches, mesh draws, vertex draws or indirect execution, to see what draws what. Each shows whether its work is drawn or left out, and each change is logged. While the panel shows, the title reads neutral pads and no keys. ### Switches - **Alt+Z**, while our window has focus, shows and hides it. Not Shift+Tab: the keyboard stand-in pad uses Tab for View. - `VICTORY_OVERLAY=1` shows it from the start; `VICTORY_OVERLAY=0` turns it off. ### How it is drawn On the CPU, into upload memory in the back buffer's format (RGBA8, BGRA8, RGB10A2 or RGBA16F, the four the presenter makes), then copied into the back buffer's corner after the frame, before the present, with one `CopyTextureRegion`. - **Text:** Consolas, antialiased in grey, drawn through GDI into a coverage mask and blended over the panel. Where GDI makes no device context, our own 5×7 font stands in. - **Size:** the panel scales with the back buffer: 1 at 1080 lines, 0.75 at 720, up to 2 at 2160. - **Cost:** it is redrawn at most every 250 ms. No shaders or pipelines. While it shows, each submission carries two timestamp lists; while hidden it only times the frame and polls the keys. ### Relation to #130 #130 is the full opt-in profiler (CSV, Perfetto trace, and a panel behind F3). This one is smaller and independent: a live panel with controller input and work toggles, and no new crate. If #130 lands first, this panel could take its numbers instead. ### Changes - `crates/victory-gpu/src/overlay.rs` (new): the panel, its drawing, the keys, and the submission timer; - `host.rs`: the presenter records the panel's copy, `Meter` hands over its second, and `Host::execute` submits through the timer while the panel shows; - `list.rs`: the four toggle gates at the draw, dispatch, mesh and indirect entry points; - `victory-hle` `gameinput.rs`: publishes the pad, notes the title's input reads, and gives the title neutral input while the panel shows; - the `Win32_UI_Input_KeyboardAndMouse` feature for `victory-gpu`. ### Testing - `overlay::tests` (9): - frame statistics (mean, rate, 1% low); - GPU busy percent over the last second of frames, and recent means that skip unmeasured frames; - the panel fits 720, 1080 and 2160 lines in either font and draws each of its colours; - GDI text is antialiased; - coverage blending; - colours encoded per back buffer format; - the keys map to their bits, and are read on a thread of their own; - on the host GPU: a shown panel copied into a 1920×1080 back buffer lands at the margin with text inside it, the rest of the frame untouched, and the submission's GPU time is measured. - RTX 5070 Ti, driver 621.24: - `cargo test --workspace --exclude victory-shader`: 571 passed. The only failures are the 2 known NVIDIA heap-limit tests (#1835), which fail the same way on `main`. - `cargo clippy --workspace --all-targets`, with and without `--features diagnostics`: clean. - **Not checked in a running title.** ### Rebased onto f3578e3 - #1997 (multiple PresentX planes) reworked the present: the panel's copy is recorded in both of its paths. `Overlay::record` now takes the back buffer's state and returns the state it leaves it in, so the composited path moves the back buffer to the copy destination only when the panel is copied. - #1430 (all-zero XInput slots) and the scripted keys moving into `State::poll`: the overlay's pad and input capture now run inside `State::poll`, after both, so the panel shows the pad the title actually reads. - `cargo test -p victory-gpu --lib`: all pass but the two known NVIDIA heap-cap tests; `overlay::tests` and `gameinput` tests pass. `host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame` (`--features diagnostics`) exits abnormally here on `main` as well. Clippy clean for `victory-gpu` and `victory-hle`, with and without `--features diagnostics`.
Alt+Z, while our window has focus, shows and hides a panel in the top
left corner of each presented frame (`VICTORY_OVERLAY=0` turns it off,
`VICTORY_OVERLAY=1` shows it from the start):

- frame rate and frame time over the last 240 frames, the 1% low, and a
  graph of the frame times with the 30 fps line;
- the presenter's last second per frame: draws, time preparing
  submissions and waiting for the GPU (`Meter`);
- the process's CPU use (`GetProcessTimes` against the processors), its
  private and in-use memory, the machine's memory, and video memory
  against its budget and shared memory (`QueryVideoMemoryInfo` on the
  device's adapter), sampled once a second while it shows;
- the controller as the title reads it (sticks, triggers, buttons; the
  keyboard's stand-in pad where none is connected), published by
  `gameinput`;
- toggles, keys 1-4 while it shows, that leave out compute dispatches,
  mesh draws, vertex draws or indirect execution (logged when changed),
  to see what draws what.

While it shows, the title reads neutral pads and no keys.

It is drawn on the CPU, our own 5x7 font, into upload memory in the back
buffer's format (the four the presenter makes: RGBA8, BGRA8, RGB10A2 and
RGBA16F), redrawn at most every 250 ms and copied into the back buffer
after the frame, before the present: no shaders or pipelines, and
nothing while it is hidden but a frame time and a key poll.

Tests: the panel's lines fit and every character has a glyph; the frame
rate and 1% low; colours per format; on the host GPU, a shown panel
copied into a 640x400 back buffer lands at the margin with its text,
the rest untouched. An ignored test (`preview`) writes a sample panel
to the BMP file `VICTORY_OVERLAY_PREVIEW` names.
The keys were looked at once per presented frame. A world frame takes a
second or more, so Alt+Z or 1-4 pressed and let go between two frames was
never seen, and the toggles seemed blocked exactly when they are needed.

A thread now looks at them every 15 ms and flips the switches; the
presenter only redraws the panel when one changed. If the thread cannot
start, the presenter reads the keys once a frame, as before.
The panel was a 5x7 bitmap font in capitals with an unlabelled bar graph.
It is now easier to read and says what each number and graph is:

- Text is Consolas, antialiased in grey, drawn through GDI into a
  coverage mask and blended over the panel (the 5x7 font stands in where
  GDI makes no device context). Mixed case, with units on every value.
- The panel scales with the back buffer: 1 at 1080 lines, 0.75 at 720,
  up to 2 at 2160 (it was 1, 2 or 3 by whole steps).
- Sections with headers: performance, system, controller, draw toggles;
  labels left, values right-aligned.
- Frame time graph: a titled y axis in ms (0, 16.7, 33.3, 50, 66.7+),
  gridlines named 60, 30 and 20 FPS, an x axis from 240 frames ago to
  now with ticks and a caption, bars coloured by threshold.
- A new graph: CPU use and video memory used of its budget, percent,
  over the last 60 s (a sample a second), with a legend and labelled
  axes.
- The controller drawn: a box per stick with its position, bars for the
  triggers, and the buttons lit while held.
- The toggles as check boxes, each saying whether its work is drawn or
  left out.

Tests: frame statistics; the panel fits 720, 1080 and 2160 lines in
either font and draws each colour; GDI text is antialiased; coverage
blending; colours per format; the GPU copy test now at 1920x1080 checks
the panel's border at the margin and text inside it. The ignored
`preview` test writes the panel at 1080 and 1440 lines.
- GPU busy time: while the overlay shows, each host submission runs
  between two small lists that write a timestamp each, the second
  resolving both into a read-back buffer (`overlay::time_lists`,
  `time_read`, around `ExecuteCommandLists` in `Host::execute`; every
  submission is waited for, so the timestamps are read right after).
  The frame's submissions add up to its GPU busy time, shown per frame
  and as a share of the frame time, and as a third line (GPU busy, %)
  in the 60 s graph. Hidden, nothing is timed.
- Input to present: from the title's first input read of a frame
  (GameInput's current reading, `overlay::note_input_read`) to the
  present that ends it; the mean and slowest of the last 60 frames that
  read input. It does not include the display's own latency.

Tests: the busy percent is over the last second of frames and the
recent mean and slowest skip frames not measured; the GPU copy test
now keeps the panel shown through its submission and checks GPU time
was measured on the host GPU.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:15 +00:00
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 07:23 UTC · original

Moving this back to draft. There is a lot more I want to add and I found some bugs with how it interacts with in-game controls.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 07:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2171#issuecomment-7155810159) Moving this back to draft. There is a lot more I want to add and I found some bugs with how it interacts with in-game controls.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2171/head:github-bot/gh-2171'
git switch 'github-bot/gh-2171'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2171'
git switch 'github-bot/gh-2171'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2171'
git switch 'github-bot/gh-2171'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2171'
git switch 'main'
git merge --squash 'github-bot/gh-2171'
git switch 'main'
git merge --ff-only 'github-bot/gh-2171'
git switch 'main'
git merge 'github-bot/gh-2171'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2171
No description provided.