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

Open
0xkn0wh3r3 wants to merge 4 commits from upstream-pr/2171 into main
0xkn0wh3r3 commented 2026-11-25 06:53:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:53:29Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5486666124 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2171). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T06:53:29Z. --- 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`.
DenRakEiw commented 2026-11-25 07:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T07:03:15Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib overlay:: — 4 passed, 0 failed (1 ignored) on RTX 5090
  • cargo clippy -p victory-gpu -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok (184 files ok)

Clean Alt+Z in-frame debug overlay implementation with unit tests and zero clippy warnings across victory-gpu and victory-hle. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6053208378 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2171#pullrequestreview-6053208378). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T07:03:15Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib overlay::` — 4 passed, 0 failed (1 ignored) on RTX 5090 - `cargo clippy -p victory-gpu -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok (`184 files ok`) Clean Alt+Z in-frame debug overlay implementation with unit tests and zero clippy warnings across `victory-gpu` and `victory-hle`. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 07:17:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T07:17:33Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Debug overlay (Alt+Z) drawn into presented frame — debug UI; mixed gpu+hle, Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053350479 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2171#pullrequestreview-6053350479). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T07:17:33Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Debug overlay (Alt+Z) drawn into presented frame — debug UI; mixed gpu+hle, Windows-only.
0xkn0wh3r3 commented 2026-11-25 08:06:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T07:23:39Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155810159 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2171#issuecomment-7155810159). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T07:23:39Z. --- 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.
AwkGrep256 commented 2026-11-27 12:50:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AwkGrep256 on 2026-11-27T12:50:32Z.


@0xkn0wh3r3 I’m working on native Graphics settings, and I think these fit together well. Players could choose their graphics options in the game menu, then use Alt+Z to see what changed while they play. One thing I’d like to compare is rendered FPS versus presented FPS with frame generation enabled. If you’re interested, I can share the counters we already use for those tests.

Native Graphics PR · Design discussion

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218739178 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2171#issuecomment-7218739178). Originally posted by [AwkGrep256](https://github.com/AwkGrep256) on 2026-11-27T12:50:32Z. --- @0xkn0wh3r3 I’m working on native Graphics settings, and I think these fit together well. Players could choose their graphics options in the game menu, then use Alt+Z to see what changed while they play. One thing I’d like to compare is rendered FPS versus presented FPS with frame generation enabled. If you’re interested, I can share the counters we already use for those tests. [Native Graphics PR](https://github.com/Marvisak/VIctory/pull/2863) · [Design discussion](https://github.com/Marvisak/VIctory/issues/2862)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2171:upstream-pr/2171'
git switch 'upstream-pr/2171'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2171'
git switch 'upstream-pr/2171'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2171'
git switch 'upstream-pr/2171'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2171'
git switch 'main'
git merge --squash 'upstream-pr/2171'
git switch 'main'
git merge --ff-only 'upstream-pr/2171'
git switch 'main'
git merge 'upstream-pr/2171'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2169
No description provided.