Shaders: name the instruction that ended a whole-wave section #2365

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

@⁠Calvix2k on GitHub · 2026-11-25 11:57 UTC · original
Calvix2k:codex/shader-wave-section-step → main · +73 −8 · 2 files · 2 commits · closed without merging

A whole-wave section (s_or_saveexec -1 … s_and_saveexec, the console's way of running one operation with every lane active) is simulated lane by lane to know what its wave operations mean once the host runs them. The simulation follows EXEC when it is set to a constant (s_mov_b*), and stops at anything else; every value read after that point is refused with

a whole-wave section step the simulation does not follow

which names nothing, so each case had to be found by hand — three compute shaders of this title (the once-per-frame post-processing passes) are stuck behind it.

What this does

wave::Section records the instruction that ended the simulation (ended: Option<&'static str>), and Lower::section_inst uses it as the reason a shapeless value is refused. The message becomes the instruction name — s_and_b32 or whatever it was — which is the one thing a reader needs before teaching the simulation that step.

No behaviour changes: the same programs translate and fail as before, with a better reason.

Verification

  • victory translate --list over shaders.rpf (26,503 containers): same program set, the reasons now name the instruction.
  • cargo test -p victory-shader --lib: 247 passed, 0 failed, 3 ignored; clippy -D warnings clean.
**@⁠Calvix2k** on GitHub · 2026-11-25 11:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2365) `Calvix2k:codex/shader-wave-section-step` → `main` · +73 −8 · 2 files · 2 commits · closed without merging A whole-wave section (`s_or_saveexec -1 … s_and_saveexec`, the console's way of running one operation with every lane active) is simulated lane by lane to know what its wave operations mean once the host runs them. The simulation follows `EXEC` when it is set to a constant (`s_mov_b*`), and stops at anything else; every value read after that point is refused with ``` a whole-wave section step the simulation does not follow ``` which names nothing, so each case had to be found by hand — three compute shaders of this title (the once-per-frame post-processing passes) are stuck behind it. ### What this does `wave::Section` records the instruction that ended the simulation (`ended: Option<&'static str>`), and `Lower::section_inst` uses it as the reason a shapeless value is refused. The message becomes the instruction name — `s_and_b32` or whatever it was — which is the one thing a reader needs before teaching the simulation that step. No behaviour changes: the same programs translate and fail as before, with a better reason. ### Verification - `victory translate --list` over `shaders.rpf` (26,503 containers): same program set, the reasons now name the instruction. - `cargo test -p victory-shader --lib`: 247 passed, 0 failed, 3 ignored; clippy `-D warnings` clean.
A whole-wave section is simulated lane by lane to know what its wave
operations mean once the host runs them. A value it cannot shape is refused
with "a whole-wave section step the simulation does not follow", which names
nothing: not the instruction that wrote the value, not the one that ended
the simulation. Each case had to be found by hand, and three compute shaders
of this title (its once-per-frame post-processing passes) are stuck behind
it.

Record, per section, the last instruction that wrote each value the
simulation left without a shape (`Section::reasons`), and use it as the
reason a read of that value gets — falling back to the instruction that
ended the simulation (`ended`, #2365's first half) and then to the generic
text. The log now says `v_cmp_lt_f32`, `s_and_b32` or whatever it was, which
is what a reader needs before teaching the simulation that step.

No behaviour changes: the same programs translate and fail as before, with a
reason that names the step.
Review feedback on #2365: a bare instruction name is what the lowering
already returns for "instruction not lowered", so in `translate --list` a
section step the simulation does not follow looked the same as an
unimplemented instruction and the two would be counted together.

`wave::section_step` turns a name into "a whole-wave section step: <name>",
made once per instruction name (the names are static; the table is small and
bounded by the opcode set). `Section::ended` and `Section::reasons` hold
that form, so both the value read after the simulation stopped and a value
it left unshaped say what they are.

`a_section_step_keeps_its_category` builds a section whose EXEC write is
`s_not_b32` (not a constant set) and pins the reason.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:03:37 +00:00
github-bot closed this pull request 2026-11-26 05:03:38 +00:00
Author
Owner

@⁠welisonzika14-jpg on GitHub · 2026-11-25 12:25 UTC · original

First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head c3435ec merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

The PR adds no test that runs here, so this only shows it breaks nothing. The rest is the same as main on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in victory-gpu, 3 in victory-shader), nothing new.

One run, unit tests only, title not run.

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

**@⁠welisonzika14-jpg** on GitHub · 2026-11-25 12:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2365#issuecomment-7162345595) First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head `c3435ec` merged onto `main` `940d32f`, `cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast`. The PR adds no test that runs here, so this only shows it breaks nothing. The rest is the same as `main` on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in `victory-gpu`, 3 in `victory-shader`), nothing new. One run, unit tests only, title not run. Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 14:49 UTC · original · edited 2026-11-25 16:47 UTC

Automated triage for the maintainers.

Merge candidate.

When a whole-wave section leaves a value with no shape, the shader translator now names the step that caused it. simulate in crates/victory-shader/src/emit/wave.rs returns the step that stopped the simulation, and sections records the last writer of each unshaped value. Lower::section_inst in lower.rs puts these in the refusal instead of the generic reason.

Changed since the last review (new head 1c94500, rebased onto 67e8ae1): the reason keeps its category. section_step builds "a whole-wave section step: ", made once per name and cached, so the table can only be as large as the opcode set. A translate --list line can no longer be mistaken for a bare unlowered instruction. The new test a_section_step_keeps_its_category pins the reason for an s_not_b32 EXEC write. It also merges cleanly with #2382, which edits the same simulate.

On your reply: confirmed, that was the change asked for.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2365#issuecomment-7165862011) · edited 2026-11-25 16:47 UTC <!-- victory-triage v1 head=1c94500fb80b7ffbfaa9eff1ea7ad31ecb8aa186 verdict=merge-candidate at=2026-11-25T16:44:54Z --> Automated triage for the maintainers. **Merge candidate.** When a whole-wave section leaves a value with no shape, the shader translator now names the step that caused it. `simulate` in `crates/victory-shader/src/emit/wave.rs` returns the step that stopped the simulation, and `sections` records the last writer of each unshaped value. `Lower::section_inst` in `lower.rs` puts these in the refusal instead of the generic reason. Changed since the last review (new head `1c94500`, rebased onto `67e8ae1`): the reason keeps its category. `section_step` builds "a whole-wave section step: <name>", made once per name and cached, so the table can only be as large as the opcode set. A `translate --list` line can no longer be mistaken for a bare unlowered instruction. The new test `a_section_step_keeps_its_category` pins the reason for an `s_not_b32` EXEC write. It also merges cleanly with #2382, which edits the same `simulate`. On your reply: confirmed, that was the change asked for. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 16:17 UTC · original

The category is back in the reason, in 1c94500 (rebased onto main 67e8ae1): wave::section_step turns the step's name into "a whole-wave section step: ", made once per name (the names are static, so the table is bounded by the opcode set). Section::ended and Section::reasons store that form, so neither path can be mistaken for a bare "instruction not lowered" again.

a_section_step_keeps_its_category builds a section whose EXEC write is s_not_b32 and pins "a whole-wave section step: s_not_b32". It fails on the old form, which stored the bare name. Local wave tests 7/7 and clippy clean; the rest of the shader suite's GPU cases need SM 6.6 and run in CI.

**@⁠Calvix2k** on GitHub · 2026-11-25 16:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2365#issuecomment-7167755668) The category is back in the reason, in `1c94500` (rebased onto `main 67e8ae1`): `wave::section_step` turns the step's name into "a whole-wave section step: <name>", made once per name (the names are static, so the table is bounded by the opcode set). `Section::ended` and `Section::reasons` store that form, so neither path can be mistaken for a bare "instruction not lowered" again. `a_section_step_keeps_its_category` builds a section whose EXEC write is `s_not_b32` and pins `"a whole-wave section step: s_not_b32"`. It fails on the old form, which stored the bare name. Local wave tests 7/7 and clippy clean; the rest of the shader suite's GPU cases need SM 6.6 and run in CI.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:08 UTC · original

Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing in favour of #2344, which does the same job with fixed classes for every kind of step. Here the per-value reasons are attached only to values that never leave the section, which nothing reads, so the only step ever named is an EXEC write that stopped the simulation, and values that were already unknown before it are attributed to it.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 22:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2365#issuecomment-7175997642) Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing in favour of #2344, which does the same job with fixed classes for every kind of step. Here the per-value reasons are attached only to values that never leave the section, which nothing reads, so the only step ever named is an EXEC write that stopped the simulation, and values that were already unknown before it are attributed to it. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

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/Marvisak--VIctory!2365
No description provided.