Wave64 folded translator, upload guard and placed-view twins: hair, beards and trails right on NVIDIA #1296

Closed
github-bot wants to merge 1 commit from github-bot/gh-1296 into main AGit
Owner

@⁠aventureroestelar-source on GitHub · 2026-11-28 17:02 UTC · original
aventureroestelar-source:wave64-folded-hair-trails → main · +4650 −89 · 28 files · 1 commits · closed without merging

Summary

This PR brings fixes developed and measured on an RTX 5070 Ti (Series S profile, no ray tracing). They were tested on the opening cutscene (police station, social worker, Lucía, beach, boat) and the first gameplay, using fast burst captures of the game window (about 20 frames/s), side-by-side comparisons and repeated runs. Each change is behind a switch.

What improves

Problem seen on NVIDIA Before After
Wave64 compute programs that cannot run on 32-lane cards ("no wave32 lowering": hair shadow masks, tiled cascade shadows, screen-space hair, water…) 22 refused, plus many in approximate per-half forms 1 refused; 175 run exactly
Staircase/pixelated shadows on characters present gone
Moving characters leave a trail of dots in cutscenes (boat man's arm, Lucía's chin) in every run gone (it comes back with VICTORY_WAVE_FOLDED=0)
Beards and curly hair drawn in rectangular patches that change every frame in every run dense and steady in every frame
A face in noise or black for a whole scene (decoration bake: make-up, stubble) about 1 launch in 3 none in the runs since (the guard skips 15–50 such uploads per run)
Seconds above 50 ms/frame in 180 s of the cutscene (scene changes) 18.7 s 16.0 s with the switches below (residency waits ~10.5 s → ~7.6 s)
Clippy, both CI builds, current toolchain 4 lints on main clean

Changes

Folded wave64 translator (fold.rs, emit/mod.rs folded(), lower.rs, ir.rs, gfx10/*; VICTORY_WAVE_FOLDED, on)

Each host lane runs two console lanes, so 64-lane waves are exact on 32-lane hardware. Ballots, readlane, mbcnt, LDS within a group and lane masks all behave as on the console. VICTORY_WAVE_FOLDED_SKIP / _ONLY choose the programs it applies to, by name or hash prefix, for bisection.

Two faults found with the hair, both fixed and covered by GPU tests:

  • A VALU writing the SGPR pair it reads. v_cmp_eq_i32 s[0:1], s0, v0 wrote the mask into s[0:1] while reading s0: the low half's copy overwrote s0 before the high half read it. The high half now goes first; if both halves would overwrite each other's input, the program is not folded.
  • EXEC reopened after lanes left. s_or_saveexec_b64 -1 reopened EXEC after lanes had left through v_cmpx / s_cbranch_execz. Those lanes were taken as finished, so the wave-wide OR read lane 0's unset value. Branches on EXEC are now taken wave-wide when the program sets EXEC back to all lanes.

CS_HairTileClassify had both faults: half of each 8x8 hair tile was classified wrong, which drew beards and curly hair in rectangular patches.

Upload guard (texture.rs, list.rs; VICTORY_UPLOAD_GUARD, on)

The title records lists on several threads. A list recorded a moment before the decoration bake's copy into a character's make-up texture could hold an upload of that texture from title memory (noise) and be submitted after it. Every upload from title memory now runs under a D3D12 predicate that is set to skip at submission if a host write of the same texture was submitted before. Prelude uploads (PreludeUpload::finish_refresh) make the same check at submission.

Placed views over host-written textures (resource.rs, texture.rs, list.rs, draw.rs; VICTORY_PLACED_COPIED, on)

A view the title places at the address of a texture the host copied into now reads that texture, not a copy filled from title memory, which the copy never reached. Views of another block format placed there before (BC3 written, BC7 sampled) take its levels at their first use, and later copies reach them too. A host-written texture is never re-made from title memory by want_level.

Upload pool (upload.rs)

The pool is reserved top-down in [4 GiB, 2^37), so its first piece ended on the last page of the memory-by-address directory. That entry is never filled, so shaders read zeros there. Allocations now stop one page below it. VICTORY_UPLOAD_SPACE=0 runs without the pool, for tests.

Scene changes (switches, off by default)

  • VICTORY_RANGE_LOCK (rangelock.rs, watch.rs, xmem.rs Physical::touched): a read of title memory waits only for a remap whose pages meet its range, instead of for every remap.
  • VICTORY_BUFFER_POOL (host/recycle.rs): per-recording buffers are taken again once only our reference is left, instead of being made, made resident and waited for (about 8,000 reused and 50 made per run).
  • VICTORY_REFRESH_EARLY (host.rs): not fit for use. Together with the range lock it made beards shimmer. Three faults are fixed and kept: it no longer consumes the exact/once marks, reads only fully mapped textures, and only textures never uploaded. It stays off.

Also

Four clippy lints that the current toolchain reports on main are fixed, in descriptor.rs, shadow.rs and gameinput.rs. Both CI clippy builds are clean.

Tests

cargo test --workspace --locked: 1,149 passed, 1 failed. The passing tests include 14 GPU tests for the folded form, one of them running the real code of CS_HairTileClassify on synthetic tiles: it returned zeros before the fixes and is correct now.

The failure is xtask repository_passes_policy, which fails on main too: bindings.ini (added in 4715a42) is not a file type on the asset policy's allowlist. It is not touched here.

Known, not fixed here

  • In gameplay, the character still leaves a faint trail when the camera turns. The TAA2 passes are not wave64 and translate directly; they are not involved.
  • Distant vegetation washes out for single frames now and then. This is not caused by the switches above.
  • In the first gameplay (boat at sea), the boat man's face is not drawn. It is drawn in the cutscene before it; whether main without this PR draws it in that gameplay has not been checked yet.

🤖 Generated with Claude Code

**@⁠aventureroestelar-source** on GitHub · 2026-11-28 17:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1296) `aventureroestelar-source:wave64-folded-hair-trails` → `main` · +4650 −89 · 28 files · 1 commits · closed without merging ## Summary This PR brings fixes developed and measured on an RTX 5070 Ti (Series S profile, no ray tracing). They were tested on the opening cutscene (police station, social worker, Lucía, beach, boat) and the first gameplay, using fast burst captures of the game window (about 20 frames/s), side-by-side comparisons and repeated runs. Each change is behind a switch. ## What improves | Problem seen on NVIDIA | Before | After | |---|---|---| | Wave64 compute programs that cannot run on 32-lane cards ("no wave32 lowering": hair shadow masks, tiled cascade shadows, screen-space hair, water…) | 22 refused, plus many in approximate per-half forms | 1 refused; 175 run exactly | | Staircase/pixelated shadows on characters | present | gone | | Moving characters leave a trail of dots in cutscenes (boat man's arm, Lucía's chin) | in every run | gone (it comes back with `VICTORY_WAVE_FOLDED=0`) | | Beards and curly hair drawn in rectangular patches that change every frame | in every run | dense and steady in every frame | | A face in noise or black for a whole scene (decoration bake: make-up, stubble) | about 1 launch in 3 | none in the runs since (the guard skips 15–50 such uploads per run) | | Seconds above 50 ms/frame in 180 s of the cutscene (scene changes) | 18.7 s | 16.0 s with the switches below (residency waits ~10.5 s → ~7.6 s) | | Clippy, both CI builds, current toolchain | 4 lints on `main` | clean | ## Changes ### Folded wave64 translator (`fold.rs`, `emit/mod.rs` `folded()`, `lower.rs`, `ir.rs`, `gfx10/*`; `VICTORY_WAVE_FOLDED`, on) Each host lane runs two console lanes, so 64-lane waves are exact on 32-lane hardware. Ballots, `readlane`, `mbcnt`, LDS within a group and lane masks all behave as on the console. `VICTORY_WAVE_FOLDED_SKIP` / `_ONLY` choose the programs it applies to, by name or hash prefix, for bisection. Two faults found with the hair, both fixed and covered by GPU tests: - **A VALU writing the SGPR pair it reads.** `v_cmp_eq_i32 s[0:1], s0, v0` wrote the mask into `s[0:1]` while reading `s0`: the low half's copy overwrote `s0` before the high half read it. The high half now goes first; if both halves would overwrite each other's input, the program is not folded. - **EXEC reopened after lanes left.** `s_or_saveexec_b64 -1` reopened EXEC after lanes had left through `v_cmpx` / `s_cbranch_execz`. Those lanes were taken as finished, so the wave-wide OR read lane 0's unset value. Branches on EXEC are now taken wave-wide when the program sets EXEC back to all lanes. `CS_HairTileClassify` had both faults: half of each 8x8 hair tile was classified wrong, which drew beards and curly hair in rectangular patches. ### Upload guard (`texture.rs`, `list.rs`; `VICTORY_UPLOAD_GUARD`, on) The title records lists on several threads. A list recorded a moment before the decoration bake's copy into a character's make-up texture could hold an upload of that texture from title memory (noise) and be submitted after it. Every upload from title memory now runs under a D3D12 predicate that is set to skip at submission if a host write of the same texture was submitted before. Prelude uploads (`PreludeUpload::finish_refresh`) make the same check at submission. ### Placed views over host-written textures (`resource.rs`, `texture.rs`, `list.rs`, `draw.rs`; `VICTORY_PLACED_COPIED`, on) A view the title places at the address of a texture the host copied into now reads that texture, not a copy filled from title memory, which the copy never reached. Views of another block format placed there before (BC3 written, BC7 sampled) take its levels at their first use, and later copies reach them too. A host-written texture is never re-made from title memory by `want_level`. ### Upload pool (`upload.rs`) The pool is reserved top-down in [4 GiB, 2^37), so its first piece ended on the last page of the memory-by-address directory. That entry is never filled, so shaders read zeros there. Allocations now stop one page below it. `VICTORY_UPLOAD_SPACE=0` runs without the pool, for tests. ### Scene changes (switches, off by default) - `VICTORY_RANGE_LOCK` (`rangelock.rs`, `watch.rs`, `xmem.rs` `Physical::touched`): a read of title memory waits only for a remap whose pages meet its range, instead of for every remap. - `VICTORY_BUFFER_POOL` (`host/recycle.rs`): per-recording buffers are taken again once only our reference is left, instead of being made, made resident and waited for (about 8,000 reused and 50 made per run). - `VICTORY_REFRESH_EARLY` (`host.rs`): not fit for use. Together with the range lock it made beards shimmer. Three faults are fixed and kept: it no longer consumes the `exact`/`once` marks, reads only fully mapped textures, and only textures never uploaded. It stays off. ### Also Four clippy lints that the current toolchain reports on `main` are fixed, in `descriptor.rs`, `shadow.rs` and `gameinput.rs`. Both CI clippy builds are clean. ## Tests `cargo test --workspace --locked`: 1,149 passed, 1 failed. The passing tests include 14 GPU tests for the folded form, one of them running the real code of `CS_HairTileClassify` on synthetic tiles: it returned zeros before the fixes and is correct now. The failure is `xtask` `repository_passes_policy`, which fails on `main` too: `bindings.ini` (added in 4715a42) is not a file type on the asset policy's allowlist. It is not touched here. ## Known, not fixed here - In gameplay, the character still leaves a faint trail when the camera turns. The TAA2 passes are not wave64 and translate directly; they are not involved. - Distant vegetation washes out for single frames now and then. This is not caused by the switches above. - In the first gameplay (boat at sea), the boat man's face is not drawn. It is drawn in the cutscene before it; whether `main` without this PR draws it in that gameplay has not been checked yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Picture (measured on the opening cutscene, Series S, RTX 5070 Ti):
- Folded wave64 translator (fold.rs, emit/mod.rs, lower.rs; VICTORY_WAVE_FOLDED,
  on): two console lanes per host lane, exact. "no wave32 lowering" refusals
  22 -> 1. Moving characters no longer leave dotted trails (gone with folding,
  back with VICTORY_WAVE_FOLDED=0). Two folding faults in CS_HairTileClassify
  fixed (a VALU writing the mask pair it reads; EXEC reopened with
  s_or_saveexec -1 after lanes left): beards and hair no longer in patches.
- Upload guard (texture.rs, list.rs; VICTORY_UPLOAD_GUARD, on): an upload from
  title memory is skipped when a host write of the texture was submitted
  before it (predicated copy, and the prelude upload decided at submission).
- Placed-view twins (resource.rs, texture.rs, list.rs, draw.rs;
  VICTORY_PLACED_COPIED, on): views placed over a texture the host copied into
  read that texture or get the copies too.
- Upload pool kept below the page directory's last, never-filled entry
  (upload.rs; VICTORY_UPLOAD_SPACE=0 tests without the pool).

Scene changes (switches, off in code; the launcher sets the first two):
- VICTORY_RANGE_LOCK (rangelock.rs, watch.rs, xmem.rs), VICTORY_BUFFER_POOL
  (host/recycle.rs): 18.7 -> 16.0 s above 50 ms/frame with VICTORY_REFRESH_EARLY.
- VICTORY_REFRESH_EARLY: not fit for use (beard shimmer with RANGE_LOCK);
  its read is now only of fully mapped, never-uploaded, non-exact textures.

Also: clippy clean in both CI builds (four lints in descriptor.rs, shadow.rs and
gameinput.rs that the current toolchain reports on main).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 17:03:41 +00:00
Author
Owner

@⁠jptorres96 on GitHub · 2026-11-28 18:25 UTC · original

Checked at 9da16ec (on 9ce3cf9, current main) on a second 32-lane card: RTX 4080 SUPER (driver 621.01), Windows build 26300, rustc 1.98.1, DXC 1.9 validator. All synthetic.

Check Result
emit::folded_tests (the 14 GPU tests, including the real CS_HairTileClassify on synthetic tiles) 14/14
cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features clean (both red on main)
victory-shader lib, by default and with VICTORY_SHADER_OPT=255 307/307 each
victory-gpu lib, --test-threads=1 460/460
victory-hle lib 191/191
cargo test --workspace --locked 1,149 passed, 1 failed: xtask repository_passes_policy, as you note (bindings.ini, also on main; #1290 adds it)

Since this touches watch.rs: victory-gpu's lib tests in parallel, as CI runs them, 15 runs each, interleaved with main. Watch tests failed 0 times here and 3 times on main. The save_share failures in both (5 here, 1 on main) are the OS error 32 one, outside this diff and fixed by #819 or #594 (counts in #1138).

Two thoughts on landing it:

  • It is several changes in one commit: the folded translator, the upload guard, placed views over host-written textures, the upload pool's last page, three off-by-default switches, and the clippy fixes. About 4,800 lines. They don't depend on each other as far as I can see, and the maintainer can't take one without the rest. The folded translator alone (fold.rs, emit/mod.rs, lower.rs, ir.rs, gfx10/*, folded_tests.rs) would be the easiest to review and test on its own. The clippy part is also in #957, #1160 and #1290.
  • VICTORY_REFRESH_EARLY: it is marked "not fit for use" and stays off. It might be better out of this PR, so the code that lands is code that runs.

Also: #1138 section 3 lists ten PRs for 64-lane programs refused on 32-lane cards. Saying which of main's refused programs (the five hashes there, plus the 22 you count) each of them runs would help the maintainer choose. Yours says 1 refused, 175 exact.

**@⁠jptorres96** on GitHub · 2026-11-28 18:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1296#issuecomment-7243781764) Checked at `9da16ec` (on `9ce3cf9`, current `main`) on a second 32-lane card: RTX 4080 SUPER (driver 621.01), Windows build 26300, rustc 1.98.1, DXC 1.9 validator. All synthetic. | Check | Result | | --- | --- | | `emit::folded_tests` (the 14 GPU tests, including the real `CS_HairTileClassify` on synthetic tiles) | 14/14 | | `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features` | clean (both red on `main`) | | `victory-shader` lib, by default and with `VICTORY_SHADER_OPT=255` | 307/307 each | | `victory-gpu` lib, `--test-threads=1` | 460/460 | | `victory-hle` lib | 191/191 | | `cargo test --workspace --locked` | 1,149 passed, 1 failed: `xtask` `repository_passes_policy`, as you note (`bindings.ini`, also on `main`; #1290 adds it) | Since this touches `watch.rs`: `victory-gpu`'s lib tests in parallel, as CI runs them, 15 runs each, interleaved with `main`. Watch tests failed 0 times here and 3 times on `main`. The `save_share` failures in both (5 here, 1 on `main`) are the OS error 32 one, outside this diff and fixed by #819 or #594 (counts in #1138). Two thoughts on landing it: - **It is several changes in one commit:** the folded translator, the upload guard, placed views over host-written textures, the upload pool's last page, three off-by-default switches, and the clippy fixes. About 4,800 lines. They don't depend on each other as far as I can see, and the maintainer can't take one without the rest. The folded translator alone (`fold.rs`, `emit/mod.rs`, `lower.rs`, `ir.rs`, `gfx10/*`, `folded_tests.rs`) would be the easiest to review and test on its own. The clippy part is also in #957, #1160 and #1290. - **`VICTORY_REFRESH_EARLY`:** it is marked "not fit for use" and stays off. It might be better out of this PR, so the code that lands is code that runs. Also: #1138 section 3 lists ten PRs for 64-lane programs refused on 32-lane cards. Saying which of `main`'s refused programs (the five hashes there, plus the 22 you count) each of them runs would help the maintainer choose. Yours says 1 refused, 175 exact.
github-bot closed this pull request 2026-11-28 19:24:53 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-28 19:22 UTC · original

Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

**@⁠trustno1-coder** on GitHub · 2026-11-28 19:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1296#issuecomment-7244496408) Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

Pull request closed

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/trustno1-coder--VIctory-NVIDIA!1296
No description provided.