gpu(native): VICTORY_TRACE_PASSES_AFTER opens the pass trace at a shader's first work (#575) #580

Open
github-bot wants to merge 1 commit from github-bot/gh-576 into main AGit
Owner

@⁠alexballvideos-netizen on GitHub · 2026-11-28 05:52 UTC · original
alexballvideos-netizen:trace-passes-after → main · +68 −22 · 3 files · 1 commits · draft

Refs #579

VICTORY_TRACE_PASSES opened its window only after a count of world presents, so work that runs rarely, or only once its pipeline exists, was missed (the ray-traced passes in #545).

What changes

  • VICTORY_TRACE_PASSES_AFTER=<hash>[,<hash>...]: once <skip> world presents have gone by (0 for none), the next draw or dispatch of a pipeline holding one of those shaders opens the window. It opens before that work is noted, so the work is the window's first PASS line, whether it runs or is dropped. A PASSWINDOW start after=<hash> line says which shader opened it. The window then lasts <presents> presents more.
  • glue::pass_arm is called at the start of graphics and skipped_dispatch, so direct, thread-count and indirect dispatches and every draw are covered. With the variable unset it costs two reads of a set-once value.
  • The window's state (PASS_LEFT, PASS_WORLD) and the VICTORY_TRACE_PASSES settings move from statics inside pass_present to module level, so pass_arm can read them.
  • pipeline::parse_skip_hashes takes the variable's name, so a bad hash in either list is warned about under the right name.
  • docs/native-host.md: the switch is documented in the VICTORY_TRACE_PASSES entry.
  • Test: pass_trace_reads_its_switch_and_stays_off_without_it also checks that with the variable unset a draw arms nothing.

Checked

cargo test -p victory-gpu (arm64), cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings and cargo xtask policy pass, and the change adds no warnings to the macOS build.

Two headless runs on main 2f4d81e0, Series X, M3 Max, VICTORY_DEPTH_TWINS=0:

  1. VICTORY_TRACE_PASSES=<dir>,100,2, …_AFTER= eee76bf6 and the four ray-traced shaders. The window opened at eee76bf6's first dispatch, in the world's first frame (frame 2005). All five are dispatched in that frame (the ray-traced ones are indirect) and all are dropped as "a dispatch without a host compute pipeline". eee76bf6 is refused (the divergent cross-lane case #545 lifts). The ray-traced ones log no refusal; they were first bound in that frame, so their pipelines weren't built yet.
  2. …,20,2, …_AFTER= the four ray-traced shaders. The window opened at 0af6bb55 after 20 world presents and lasted 3 presents:
shader PASS lines outcome writes
0af6bb55 3 ran DXGI 57, 1280x720
52f01bcb 3 ran same texture
67662685 3 ran same, + DXGI 26 1280x720
caa50df7 3 ran same texture
eee76bf6 2 dropped (no pipeline) DXGI 57 1280x720, DXGI 41 2560x1440, buffers

So the ray-traced passes do run on main once their pipelines are built. But at the window's last present, the R16_UINT target all four write is 0.0000 non-zero. The DXGI 26 target 67662685 also writes is 1.7% non-zero (max 10.6). eee76bf6's R16_UINT output is also all zero, as expected while it's dropped. Whether an all-zero result is right for this scene (e.g. no ray hits) or a sign the traversal finds nothing is the next question. I haven't looked into it here.

Both runs ended in the usual 0xc0000005 at image+0x55e56f8, which is seen with and without the trace. Run 1 hit it before the window's last present, so it wrote no images.

**@⁠alexballvideos-netizen** on GitHub · 2026-11-28 05:52 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/576) `alexballvideos-netizen:trace-passes-after` → `main` · +68 −22 · 3 files · 1 commits · draft Refs #579 `VICTORY_TRACE_PASSES` opened its window only after a count of world presents, so work that runs rarely, or only once its pipeline exists, was missed (the ray-traced passes in #545). ## What changes - `VICTORY_TRACE_PASSES_AFTER=<hash>[,<hash>...]`: once `<skip>` world presents have gone by (`0` for none), the next draw or dispatch of a pipeline holding one of those shaders opens the window. It opens before that work is noted, so the work is the window's first `PASS` line, whether it runs or is dropped. A `PASSWINDOW start after=<hash>` line says which shader opened it. The window then lasts `<presents>` presents more. - `glue::pass_arm` is called at the start of `graphics` and `skipped_dispatch`, so direct, thread-count and indirect dispatches and every draw are covered. With the variable unset it costs two reads of a set-once value. - The window's state (`PASS_LEFT`, `PASS_WORLD`) and the `VICTORY_TRACE_PASSES` settings move from statics inside `pass_present` to module level, so `pass_arm` can read them. - `pipeline::parse_skip_hashes` takes the variable's name, so a bad hash in either list is warned about under the right name. - `docs/native-host.md`: the switch is documented in the `VICTORY_TRACE_PASSES` entry. - Test: `pass_trace_reads_its_switch_and_stays_off_without_it` also checks that with the variable unset a draw arms nothing. ## Checked `cargo test -p victory-gpu` (arm64), `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings` and `cargo xtask policy` pass, and the change adds no warnings to the macOS build. Two headless runs on main `2f4d81e0`, Series X, M3 Max, `VICTORY_DEPTH_TWINS=0`: 1. `VICTORY_TRACE_PASSES=<dir>,100,2`, `…_AFTER=` `eee76bf6` and the four ray-traced shaders. The window opened at `eee76bf6`'s first dispatch, in the world's first frame (frame 2005). All five are dispatched in that frame (the ray-traced ones are indirect) and all are dropped as "a dispatch without a host compute pipeline". `eee76bf6` is refused (the divergent cross-lane case #545 lifts). The ray-traced ones log no refusal; they were first bound in that frame, so their pipelines weren't built yet. 2. `…,20,2`, `…_AFTER=` the four ray-traced shaders. The window opened at `0af6bb55` after 20 world presents and lasted 3 presents: | shader | PASS lines | outcome | writes | |---|---|---|---| | `0af6bb55` | 3 | ran | DXGI 57, 1280x720 | | `52f01bcb` | 3 | ran | same texture | | `67662685` | 3 | ran | same, + DXGI 26 1280x720 | | `caa50df7` | 3 | ran | same texture | | `eee76bf6` | 2 | dropped (no pipeline) | DXGI 57 1280x720, DXGI 41 2560x1440, buffers | So the ray-traced passes do run on main once their pipelines are built. But at the window's last present, the R16_UINT target all four write is **0.0000 non-zero**. The DXGI 26 target `67662685` also writes is 1.7% non-zero (max 10.6). `eee76bf6`'s R16_UINT output is also all zero, as expected while it's dropped. Whether an all-zero result is right for this scene (e.g. no ray hits) or a sign the traversal finds nothing is the next question. I haven't looked into it here. Both runs ended in the usual `0xc0000005` at `image+0x55e56f8`, which is seen with and without the trace. Run 1 hit it before the window's last present, so it wrote no images.
The pass trace's window opened after a count of world presents, so work
that runs rarely or late was missed. With VICTORY_TRACE_PASSES_AFTER set
to shader hashes, the window opens, once <skip> world presents have gone
by, at the next draw or dispatch of a pipeline holding one of them,
before that work is noted, and lasts <presents> presents more. The
hash-list parser now names the variable it warns about.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 05:52:34 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 17:09 UTC · original · approved these changes

Read the diff: VICTORY_TRACE_PASSES_AFTER=<hashes> arms the pass-trace window at the first draw/dispatch of a listed shader after <skip> world presents, via pass_arm (two set-once reads when unset) with a PASSWINDOW start after=<hash> line; the existing present-count logic is unchanged and now shares PASS_LEFT/pass_settings(). Wired into the draw/dispatch path (pass_arm call sites present). Verified on the head 2acbdfc6: darwin pass_ tests 3/3, host -p victory-gpu --lib pass 7/7, windows clippy -D warnings clean. Approving.

**@⁠AnastasisKon** on GitHub · 2026-11-28 17:09 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/576#pullrequestreview-6099202079) · **approved these changes** Read the diff: `VICTORY_TRACE_PASSES_AFTER=<hashes>` arms the pass-trace window at the first draw/dispatch of a listed shader after `<skip>` world presents, via `pass_arm` (two set-once reads when unset) with a `PASSWINDOW start after=<hash>` line; the existing present-count logic is unchanged and now shares `PASS_LEFT`/`pass_settings()`. Wired into the draw/dispatch path (pass_arm call sites present). Verified on the head 2acbdfc6: darwin `pass_` tests 3/3, host `-p victory-gpu --lib pass` 7/7, windows clippy `-D warnings` clean. Approving.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 18:22 UTC · original · approved these changes

Reviewed and verified locally on head 2acbdfc6 (worktree /private/tmp/review-576):

  • cargo test -p victory-gpu --locked -- --test-threads=1: all green, including the extended pass_trace_reads_its_switch_and_stays_off_without_it (with the variable unset a draw arms nothing, PASS_LEFT stays i64::MIN).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: exit 0.
  • cargo xtask policy: exit 0.

The change is tight: the window state moves from statics inside pass_present to module level so pass_arm can read it; pass_arm is called at the top of graphics and skipped_dispatch so draws, direct/thread-count and indirect dispatches are all covered; the window opens once via compare_exchange before the work is noted, so the opening work is the window's first PASS line; and with AFTER set, the present-count opening is disabled so the hash list alone decides. Cost when unset is two reads of set-once values, as the PR says. The two headless run tables (window opening at eee76bf6's first dispatch in frame 2005; the 20-present window catching all four ray-traced shaders) are exactly the evidence this needs for #579. Approving.

**@⁠AnastasisKon** on GitHub · 2026-11-28 18:22 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/576#pullrequestreview-6099530814) · **approved these changes** Reviewed and verified locally on head 2acbdfc6 (worktree /private/tmp/review-576): - cargo test -p victory-gpu --locked -- --test-threads=1: all green, including the extended pass_trace_reads_its_switch_and_stays_off_without_it (with the variable unset a draw arms nothing, PASS_LEFT stays i64::MIN). - cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: exit 0. - cargo xtask policy: exit 0. The change is tight: the window state moves from statics inside pass_present to module level so pass_arm can read it; pass_arm is called at the top of graphics and skipped_dispatch so draws, direct/thread-count and indirect dispatches are all covered; the window opens once via compare_exchange before the work is noted, so the opening work is the window's first PASS line; and with AFTER set, the present-count opening is disabled so the hash list alone decides. Cost when unset is two reads of set-once values, as the PR says. The two headless run tables (window opening at eee76bf6's first dispatch in frame 2005; the 20-present window catching all four ray-traced shaders) are exactly the evidence this needs for #579. Approving.
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/580/head:github-bot/gh-576'
git switch 'github-bot/gh-576'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-576'
git switch 'github-bot/gh-576'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-576'
git switch 'github-bot/gh-576'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-576'
git switch 'main'
git merge --squash 'github-bot/gh-576'
git switch 'main'
git merge --ff-only 'github-bot/gh-576'
git switch 'main'
git merge 'github-bot/gh-576'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.