shader: support dynamic view addresses and keep wave64 barriers opt-in #29

Closed
github-bot wants to merge 10 commits from gh-pr/29/head into gh-pr/29/base
Owner

@⁠walterboyexe on GitHub · 2026-11-26 18:21 UTC · original
walterboyexe:fix/dynamic-view-addresses-wave64-opt-in → main · +482 −102 · 16 files · 10 commits · closed without merging

What and why

Some ray-tracing compute shaders load a BVH address through a dynamically indexed table/resource-heap descriptor. The existing view_address lowering handled only static table accesses, preventing these shaders from translating on a wave32 host.

This change adds a per-view-slot GPU address table and extends lowering to read the low/high address dwords for dynamic indices. It also addresses repeated arbitrary PSV semantic names and preserves scalar values when lane-mask bits are consumed as data.

Changes

  • Add SLOT_VIEW_ADDRESSES, an 8-byte-per-slot address buffer, and bind it as a root SRV. Keep its GPU resource alive for command lists and clear/update entries along with descriptor-slot lifecycle changes.
  • Extend view_address for dynamically indexed Table and ResourceHeap accesses, clamping the heap index before loading the two address dwords.
  • Keep wave64-to-wave32 group-barrier insertion guarded by CFG lane-uniformity checks; reject a lowering when an inserted barrier would be reached divergently.
  • Keep general barrier-based wave-wide lowering opt-in rather than enabling it automatically, following the repository’s documented stability policy.
  • Emit repeated arbitrary PSV semantic names as distinct string entries so the resulting signature validates.

Verification

  • cargo test --locked -p victory-shader: 285 passed, 0 failed, 4 ignored on the clean origin/main-based patch.
  • cargo build --release --locked -p victory: passed.
  • With VICTORY_HOST_WAVE=32, translate --validate emitted and validated 2,655 of 2,682 compute programs. The remaining 27 are rejected because wave32 lowering is unavailable; emitted compute shaders had no DXIL validation failures.
  • The shader cache was regenerated in the conservative wave32 configuration: 25,667 available; 222 not translated (195 containers without a supported shader program and 27 wave64 programs without lowering). The generated cache is not part of this source diff.
  • git diff --check: clean. Workspace Clippy was not run.

In-game report

On my hardware, running on Windows 11 Pro, the first part of the first mission reaches approximately 18 FPS, with milder stutter than before. This is an observed gameplay result, not a controlled benchmark.

Hardware:
Ryzen 7 7700X;
32 GB RAM DDR5;
5060 TI 16 GB;
WD SN850X.

Stability / follow-up

A prior run reported GPU device removal after broad wave-wide lowering was enabled. The log did not identify a shader, so this change does not claim that the crash is conclusively fixed. Retest with the conservative cache; if the crash persists, compare with VICTORY_LIBRARY_TRIM=0 to help isolate the pipeline-library save/trim path and collect a D3D12/DRED diagnostic log.

AI assisted: yes

**@⁠walterboyexe** on GitHub · 2026-11-26 18:21 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/29) `walterboyexe:fix/dynamic-view-addresses-wave64-opt-in` → `main` · +482 −102 · 16 files · 10 commits · closed without merging ## What and why Some ray-tracing compute shaders load a BVH address through a dynamically indexed table/resource-heap descriptor. The existing `view_address` lowering handled only static table accesses, preventing these shaders from translating on a wave32 host. This change adds a per-view-slot GPU address table and extends lowering to read the low/high address dwords for dynamic indices. It also addresses repeated arbitrary PSV semantic names and preserves scalar values when lane-mask bits are consumed as data. ## Changes - Add `SLOT_VIEW_ADDRESSES`, an 8-byte-per-slot address buffer, and bind it as a root SRV. Keep its GPU resource alive for command lists and clear/update entries along with descriptor-slot lifecycle changes. - Extend `view_address` for dynamically indexed `Table` and `ResourceHeap` accesses, clamping the heap index before loading the two address dwords. - Keep wave64-to-wave32 group-barrier insertion guarded by CFG lane-uniformity checks; reject a lowering when an inserted barrier would be reached divergently. - Keep general barrier-based wave-wide lowering opt-in rather than enabling it automatically, following the repository’s documented stability policy. - Emit repeated arbitrary PSV semantic names as distinct string entries so the resulting signature validates. ## Verification - `cargo test --locked -p victory-shader`: 285 passed, 0 failed, 4 ignored on the clean `origin/main`-based patch. - `cargo build --release --locked -p victory`: passed. - With `VICTORY_HOST_WAVE=32`, `translate --validate` emitted and validated 2,655 of 2,682 compute programs. The remaining 27 are rejected because wave32 lowering is unavailable; emitted compute shaders had no DXIL validation failures. - The shader cache was regenerated in the conservative wave32 configuration: 25,667 available; 222 not translated (195 containers without a supported shader program and 27 wave64 programs without lowering). The generated cache is not part of this source diff. - `git diff --check`: clean. Workspace Clippy was not run. ## In-game report On my hardware, running on Windows 11 Pro, the first part of the first mission reaches approximately 18 FPS, with milder stutter than before. This is an observed gameplay result, not a controlled benchmark. Hardware: Ryzen 7 7700X; 32 GB RAM DDR5; 5060 TI 16 GB; WD SN850X. ## Stability / follow-up A prior run reported GPU device removal after broad wave-wide lowering was enabled. The log did not identify a shader, so this change does not claim that the crash is conclusively fixed. Retest with the conservative cache; if the crash persists, compare with `VICTORY_LIBRARY_TRIM=0` to help isolate the pipeline-library save/trim path and collect a D3D12/DRED diagnostic log. AI assisted: yes
The validator rejects a coordinate that is out of bounds and not undef.
An array-layer index was being passed into the third coordinate of a level
of detail query while the remaining slots were left as they came, which
the validator reads as an out-of-bounds coordinate rather than an unused
one. Writing undef there instead clears the error on all three programs
that reported it, and touches no other coordinate.

Verified on the three programs by hash: no validator error, all three
pipelines still created.
Keep the linear path for up to 32 ranges. Preserve the exact coverage of individual queries when switching to the ordered index.

Assisted-by: Codex (GPT-6.2 Sol)
Measured on an RTX 4060 Laptop (8 GB), Windows 11, game build 1.0.2.1:

- `--console series-s` drops the people's head and skin meshes in the world:
  eyes and teeth render, the head does not. With `--console series-x` the same
  scene draws the face. The launcher now starts Series X.
- `VICTORY_THIN=1` does the same to the head of people in play (the cutscene
  faces draw, the playable ones do not): eyes and teeth only. With THIN off the
  faces draw. The launcher now starts with THIN and JOIN_PARTS off; the reverse
  test (same build, only THIN on) shows the head gone again.
- `VICTORY_JOIN_PARTS=8` repeats frames of the opening video (every third frame
  or so). Off, the video plays in order.
- The ambient estimate follows the frame's radiance; walking into a bright
  doorway raised it and washed the whole room out. `VICTORY_AMBIENT=constant:0.8`
  keeps the light even and the room readable.
- A decoded video frame is a full-screen single-mip texture the title refills
  every frame. With THIN its copy was translated by our threads later, so the
  list read the frame before: the opening video stopped and went on. A copy into
  such a texture now flushes the recording to that call (`Front::flush`,
  `Recording::flush_to`, `resource::is_video_frame`); every other call stays
  asynchronous. Twelve samples of the opening two seconds apart are all
  different frames after the change.

Frame time in the world: 160-600 ms at 1280x720 (2-6 fps), no device loss.
With the guard on, a guard's forearms and the phone's frame read uninitialised
memory (colour noise) and some faces drew black; every check hashing the
texture again fixed the noise, so the launcher now sets VICTORY_TEXTURE_GUARD=0.
The ambient constant goes to 1.0: 1.2 fixed nothing faces-wise and 0.8 was a
touch dark in the cells.
Character skins that had not streamed in yet read zeros, the all-zero read
was skipped as no change, and the next look came 30 frames later: on an
8 GB card at 4-7 fps that is 4-8 seconds of black faces (the bar scene's
patrons, the waitress). A zero read now marks the texture and the next
look comes two frames later; other textures keep the 30-frame interval.
This reverts commit 0f2a6e4184.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 06:07:16 +00:00
github-bot closed this pull request 2026-11-27 06:07:16 +00:00
Author
Owner

@⁠DoubleGhosty on GitHub · 2026-11-26 20:11 UTC · original

Merged into main via 776b73e. Dynamic view address buffers and opt-in wave64 barriers verified with workspace clippy and full victory-shader test suite (286 passed).

**@⁠DoubleGhosty** on GitHub · 2026-11-26 20:11 UTC · [original](https://github.com/DoubleGhosty/cool_fox/pull/29#issuecomment-7202390551) Merged into main via 776b73e. Dynamic view address buffers and opt-in wave64 barriers verified with workspace clippy and full victory-shader test suite (286 passed).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.