Shaders: descriptors joined by nested control flow #1012

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

@⁠ThiagoAlexsander on GitHub · 2026-11-24 15:01 UTC · original
ThiagoAlexsander:shader/nested-descriptor-joins → main · +85 −21 · 1 files · 1 commits · open

A descriptor every lane shares, chosen by an if/else nested in another, reaches the outer join with one edge that is itself a join (Source::Phi inside Source::Phi). handle took only heap loads on a join's edges and refused this with a descriptor chosen by control flow. In the title this stops indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays.

Change

  • New uniform_heap_index: a load's heap index, or, for a join, a phi of the index each predecessor computes at its end, recursively. It is the old loop of the Source::Phi arm with the edge's source traced instead of required to be a load.
  • handle's Source::Phi arm calls it. A join whose edges are all loads emits the same DXIL as before.
  • Other edge kinds (a constant, a built descriptor, a select) are still refused with the same message.

Results

victory translate --validate over the title's files (main ffe310e against this branch, Windows SDK dxil.dll 10.0.26100), compared program by program: compute validated goes from 1,417 to 1,418 (CS_ScreenProbes_ActivateRays). No other program changes.

Testing

  • New descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle in emit/lower.rs: hand-written words choosing between two texture descriptors of the view table through nested if/else on a root constant. It lowers to one uniform image handle and passes dxil.dll. On main it fails with Unsupported { "a descriptor chosen by control flow" }.
  • cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored (342 on main plus the new test).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean. rustfmt --edition 2024 --check emit/lower.rs: no new hunks (the three in the v_perm test are on main too). cargo xtask policy: 154 files ok.
  • Not run on a GPU, and the program's host pipeline was not created.

Independent of #1008, which handles immediate samplers chosen by control flow; the two touch different arms of handle.

AI use: Claude Code (Claude Opus 5.5) found the case with the census, wrote the change and the test, and ran everything above. I reviewed the diff and the results.

🤖 Generated with Claude Code

**@⁠ThiagoAlexsander** on GitHub · 2026-11-24 15:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1012) `ThiagoAlexsander:shader/nested-descriptor-joins` → `main` · +85 −21 · 1 files · 1 commits · open A descriptor every lane shares, chosen by an if/else nested in another, reaches the outer join with one edge that is itself a join (`Source::Phi` inside `Source::Phi`). `handle` took only heap loads on a join's edges and refused this with `a descriptor chosen by control flow`. In the title this stops `indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays`. ## Change - New `uniform_heap_index`: a load's heap index, or, for a join, a phi of the index each predecessor computes at its end, recursively. It is the old loop of the `Source::Phi` arm with the edge's source traced instead of required to be a load. - `handle`'s `Source::Phi` arm calls it. A join whose edges are all loads emits the same DXIL as before. - Other edge kinds (a constant, a built descriptor, a select) are still refused with the same message. ## Results `victory translate --validate` over the title's files (`main` `ffe310e` against this branch, Windows SDK `dxil.dll` 10.0.26100), compared program by program: compute validated goes from 1,417 to 1,418 (`CS_ScreenProbes_ActivateRays`). No other program changes. ## Testing - New `descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle` in `emit/lower.rs`: hand-written words choosing between two texture descriptors of the view table through nested if/else on a root constant. It lowers to one uniform image handle and passes `dxil.dll`. On `main` it fails with `Unsupported { "a descriptor chosen by control flow" }`. - `cargo test --workspace --locked`: 343 passed, 0 failed, 6 ignored (342 on `main` plus the new test). - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. `rustfmt --edition 2024 --check emit/lower.rs`: no new hunks (the three in the `v_perm` test are on `main` too). `cargo xtask policy`: 154 files ok. - Not run on a GPU, and the program's host pipeline was not created. Independent of #1008, which handles immediate samplers chosen by control flow; the two touch different arms of `handle`. AI use: Claude Code (Claude Opus 5.5) found the case with the census, wrote the change and the test, and ran everything above. I reviewed the diff and the results. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A descriptor every lane shares, chosen by an if/else nested in another,
reaches the outer join with an edge that is itself a join. Such an edge
was refused with "a descriptor chosen by control flow": each edge had to
be a heap load. The heap index is now computed recursively: a load's
index, or a phi at the join of what each predecessor computes at its end.

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

@⁠ThomasHFWright on GitHub · 2026-11-24 15:18 UTC · original

Independent validation of 0ba5b998e6df758d31d853b333b4dc423463e3b3 on base ffe310e: the nested-descriptor shader creates a hardware compute pipeline under Wine/vkd3d-proton, but the new test breaks the native Linux shader test build.

cargo test -p victory-shader --locked --offline fails with E0433 at lower.rs:7327–7328: validator is Windows-only, while the new test references it unconditionally. The same command on the base passes 96 tests, 1 ignored. Adding #[cfg(windows)] directly above the new if let Ok(mut v) = ...Validator::load(...) block makes this PR pass 97 tests, 1 ignored, keeping the lowering assertions active on Linux. This was a local verification change and is not included in the full Windows run below.

For the missing GPU check, I temporarily extended the new regression to construct a HostShader with its emitted root/descriptor layout and require Host::new(false) plus compute_pipeline. It passed on an RTX 5090 with NVIDIA 620.73.04, Wine 11.22 and vkd3d-proton 30b0eb9bc12dc9f. The resulting SPIR-V also passes spirv-val --target-env vulkan1.3. This checks pipeline creation, not dispatch/output correctness. The instrumentation was removed afterward.

Full workspace unit/integration suite, all features, all 14 generated Windows MSVC test executables, Rust 1.98.1:

Tree Passed Failed Ignored
ffe310e baseline 341 5 6
This PR, unmodified 342 5 6

All five failures match baseline: empty pipeline library (#347), missing Wine Winsock export (#217), the shader-checksum rejection expectation, the nested Cargo fixture build, and Windows xtask attempting to launch host Git. Native Linux xtask separately passes all 4 tests. Windows-target workspace Clippy, all targets/features with -D warnings, and native cargo xtask policy pass.

Tests ran offline and offscreen, with native d3dcompiler_47 supplied for GPU shader fixtures and identical runtime DLLs to baseline. No game data was used. Gameplay, native Windows/WARP and Wine doctests were not tested. Aggregate counts include existing early-return tests when optional console compilers or the DXIL validator are unavailable; the instrumented pipeline check required real hardware and could not silently skip.

AI-assisted testing with Codex.

**@⁠ThomasHFWright** on GitHub · 2026-11-24 15:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1012#issuecomment-7135817221) Independent validation of `0ba5b998e6df758d31d853b333b4dc423463e3b3` on base `ffe310e`: the nested-descriptor shader creates a hardware compute pipeline under Wine/vkd3d-proton, but the new test breaks the native Linux shader test build. `cargo test -p victory-shader --locked --offline` fails with E0433 at `lower.rs:7327–7328`: `validator` is Windows-only, while the new test references it unconditionally. The same command on the base passes **96 tests, 1 ignored**. Adding `#[cfg(windows)]` directly above the new `if let Ok(mut v) = ...Validator::load(...)` block makes this PR pass **97 tests, 1 ignored**, keeping the lowering assertions active on Linux. This was a local verification change and is not included in the full Windows run below. For the missing GPU check, I temporarily extended the new regression to construct a `HostShader` with its emitted root/descriptor layout and require `Host::new(false)` plus `compute_pipeline`. It passed on an RTX 5090 with NVIDIA 620.73.04, Wine 11.22 and vkd3d-proton `30b0eb9bc12dc9f`. The resulting SPIR-V also passes `spirv-val --target-env vulkan1.3`. This checks pipeline creation, not dispatch/output correctness. The instrumentation was removed afterward. Full workspace unit/integration suite, all features, all 14 generated Windows MSVC test executables, Rust 1.98.1: | Tree | Passed | Failed | Ignored | | --- | ---: | ---: | ---: | | `ffe310e` baseline | 341 | 5 | 6 | | This PR, unmodified | 342 | 5 | 6 | All five failures match baseline: empty pipeline library (#347), missing Wine Winsock export (#217), the shader-checksum rejection expectation, the nested Cargo fixture build, and Windows xtask attempting to launch host Git. Native Linux xtask separately passes all 4 tests. Windows-target workspace Clippy, all targets/features with `-D warnings`, and native `cargo xtask policy` pass. Tests ran offline and offscreen, with native `d3dcompiler_47` supplied for GPU shader fixtures and identical runtime DLLs to baseline. No game data was used. Gameplay, native Windows/WARP and Wine doctests were not tested. Aggregate counts include existing early-return tests when optional console compilers or the DXIL validator are unavailable; the instrumented pipeline check required real hardware and could not silently skip. AI-assisted testing with Codex.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 15:40 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 0ba5b99: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 15:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1012#issuecomment-7136422391) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 0ba5b99: `cargo test -p victory-shader` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 17:15 UTC · original

Independent verification at 0ba5b99 on Windows 11, NVIDIA GeForce RTX 3080 (driver 621.24, 32-32 wave lanes) + WARP, Rust 1.98.1:

  • cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignored (including descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle).
  • cargo clippy -p victory-shader --all-targets -- -D warnings (default + --features diagnostics): 0 warnings.
  • cargo xtask policy: 154 files ok.
  • Offline full-corpus A/B (victory translate on retail 1.0.2.1, 26,084 programs, release build vs main ffe310e):
    • Compute emitted: 1,441 → 1,442 (+1, zero regressions on vertex/pixel 12,231 and mesh 8,214).
    • a descriptor chosen by control flow: 41 → 40 (unblocks the compute lighting shader while 40 other programs still hit this refusal).

Aggregate counts only; no game data posted. AI-assisted; all builds and tests executed on my machine.

**@⁠MartinIndra02** on GitHub · 2026-11-24 17:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1012#issuecomment-7138934902) Independent verification at `0ba5b99` on **Windows 11, NVIDIA GeForce RTX 3080 (driver `621.24`, 32-32 wave lanes) + WARP, Rust `1.98.1`**: - `cargo test -p victory-shader --lib -- --test-threads=1`: **121 passed, 0 failed, 1 ignored** (including `descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle`). - `cargo clippy -p victory-shader --all-targets -- -D warnings` (default + `--features diagnostics`): **0 warnings**. - `cargo xtask policy`: **154 files ok**. - Offline full-corpus A/B (`victory translate` on retail 1.0.2.1, 26,084 programs, release build vs `main` `ffe310e`): - Compute emitted: `1,441 → 1,442` (**`+1`**, zero regressions on vertex/pixel `12,231` and mesh `8,214`). - `a descriptor chosen by control flow`: `41 → 40` (unblocks the compute lighting shader while 40 other programs still hit this refusal). *Aggregate counts only; no game data posted. AI-assisted; all builds and tests executed on my machine.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:32 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1012#issuecomment-7148613789) <!-- victory-triage v1 head=0ba5b998e6df758d31d853b333b4dc423463e3b3 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-shader/src/emit/lower.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Venom2054 on GitHub · 2026-11-25 17:04 UTC · original

Isolated courtyard A/B on an RTX 5070 Ti, native Windows 11, driver 621.01. Both runs used the same local 940d32f-based build with the #2366 rectangle fix, save, initial pipeline cache, scripted input and stationary camera. The only source change in B was the recursive descriptor join from 0ba5b99, ported to the local lower.rs while retaining its buffer guard.

  • CS_ScreenProbes_ActivateRays (39f0e9aeb156a61c) went from one dropped dispatch per frame to a traced 3600x1x1 dispatch. The identical offline shader set gained one translation (25,635 → 25,636 of 25,985).
  • Thin magenta streaks on the lower-left part of the character’s shirt appeared in 20/20 baseline captures and 0/20 patched captures, about 199–289 s after launch. In the same 1920×1080 crop (x 4–23%, y 80–99%), the baseline had 163–519 pixels per capture with both R−G and B−G ≥12. The patched run had zero in every capture.
  • The character was still silhouetted. Mean head luminance was 6.6 → 6.5 on a 0–255 scale, taking the median of three matched late frames per run. Neither run logged device removal before its timed stop. One run per build.

AI-assisted local test.

**@⁠Venom2054** on GitHub · 2026-11-25 17:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1012#issuecomment-7168954281) Isolated courtyard A/B on an RTX 5070 Ti, native Windows 11, driver 621.01. Both runs used the same local `940d32f`-based build with the #2366 rectangle fix, save, initial pipeline cache, scripted input and stationary camera. The only source change in B was the recursive descriptor join from `0ba5b99`, ported to the local `lower.rs` while retaining its buffer guard. - `CS_ScreenProbes_ActivateRays` (`39f0e9aeb156a61c`) went from one dropped dispatch per frame to a traced `3600x1x1` dispatch. The identical offline shader set gained one translation (25,635 → 25,636 of 25,985). - Thin magenta streaks on the lower-left part of the character’s shirt appeared in 20/20 baseline captures and 0/20 patched captures, about 199–289 s after launch. In the same 1920×1080 crop (x 4–23%, y 80–99%), the baseline had 163–519 pixels per capture with both R−G and B−G ≥12. The patched run had zero in every capture. - The character was still silhouetted. Mean head luminance was 6.6 → 6.5 on a 0–255 scale, taking the median of three matched late frames per run. Neither run logged device removal before its timed stop. One run per build. AI-assisted local test.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1012/head:github-bot/gh-1012'
git switch 'github-bot/gh-1012'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1012'
git switch 'github-bot/gh-1012'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1012'
git switch 'github-bot/gh-1012'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1012'
git switch 'main'
git merge --squash 'github-bot/gh-1012'
git switch 'main'
git merge --ff-only 'github-bot/gh-1012'
git switch 'main'
git merge 'github-bot/gh-1012'
git push origin 'main'
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/Marvisak--VIctory!1012
No description provided.