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

Open
alexballvideos-netizen wants to merge 1 commit from upstream-pr/576 into main
alexballvideos-netizen commented 2026-11-28 05:52:08 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-28T05:52:08Z.


Refs #575

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 #541).

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 #541 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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5537223610 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/576). Originally posted by [alexballvideos-netizen](https://github.com/alexballvideos-netizen) on 2026-11-28T05:52:08Z. --- Refs #575 `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 #541). ## 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 #541 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.
AnastasisKon commented 2026-11-28 17:09:45 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T17:09:45Z.

Review: APPROVED


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6099202079 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/576#pullrequestreview-6099202079). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T17:09:45Z. **Review:** APPROVED --- 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 commented 2026-11-28 18:22:07 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T18:22:07Z.

Review: APPROVED


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 #575. Approving.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6099530814 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/576#pullrequestreview-6099530814). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T18:22:07Z. **Review:** APPROVED --- 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 #575. Approving.
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/576:upstream-pr/576'
git switch 'upstream-pr/576'

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/576'
git switch 'upstream-pr/576'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/576'
git switch 'upstream-pr/576'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/576'
git switch 'main'
git merge --squash 'upstream-pr/576'
git switch 'main'
git merge --ff-only 'upstream-pr/576'
git switch 'main'
git merge 'upstream-pr/576'
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
LakshanSivakumar/Native-Victory-macOS!576
No description provided.