Shaders: a refusal names the instruction that made its missing value #1425

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

@⁠ThomasSAMP on GitHub · 2026-11-24 17:57 UTC · original
ThomasSAMP:shader/missing-value-origin → main · +241 −41 · 4 files · 1 commits · open

What

A value the emitter has no DXIL form for is kept as missing and only stops the program where something with an effect needs it (a branch, an export, a store). The refusal is reported there. So victory translate --list names the consumer, an s_cbranch_execz or a v_mul_legacy_f32, rather than the cause, which can be hundreds of instructions earlier. Two reasons in #293's table look unclaimed for that reason, and both are already covered by open PRs:

  • "a cross-lane operation outside compute" (46 programs). Every one of them is an SGPR spilled to VGPR lanes in a pixel program: 35 v_writelane_b32 and 11 v_readlane_b32 with a constant lane. That is #309's subject.
  • "a descriptor's address or format read as data" (92). All of them are descriptor dwords from an s_load_dwordx4/x8 carried through joins into a branch. That is the territory of #1230 and #699.

This PR makes the refusal name the instruction that made the missing value:

  • emit::lower records an origin for every missing value. It is the instruction whose own refusal made the value missing. If that instruction only read a missing value, the origin is that value's origin. Phis refused on retry keep the origin of their incoming value, and lane masks whose compare failed keep theirs. Inputs and lane-mask joins have none.
  • emit::emit_traced returns a Refusal { error, from: Option<Origin> }. emit, ShaderError and the runtime path are unchanged, so no other PR's constructors or matches need touching.
  • victory translate --list appends from <instruction> at <offset> to the example of an emit refusal. Under each reason it prints a made by breakdown. Reason keys and every count are unchanged, so existing tables (#293, #1247) stay comparable.

On the retail shaders.rpf this gives, for example:

      272  emit: a lane mask holding lanes elsewhere read as data  (e.g. ...)
           made by 266 v_writelane_b32, 3 s_cmp_lt_u32, 3 v_cmp_eq_u32
       46  emit: a cross-lane operation outside compute  (e.g. <file>@<offset> <name> Ps at <offset> from v_writelane_b32 at <offset>)
           made by 35 v_writelane_b32, 11 v_readlane_b32
       92  emit: a descriptor's address or format read as data  (e.g. ...)
           made by 53 s_load_dwordx8, 39 s_load_dwordx4

Of 3,436 emit refusals, 2,698 now carry an origin. The 738 without one are refusals whose instruction is itself the cause: 653 × "a 64-bit image atomic", LDS byte writes, conditional exports. The rest are inputs (hardware SGPRs, barycentrics) and lane-mask joins.

Measured

victory translate --validate --list over the title's files, on main (ffe310e) and on this branch. dxil.dll 1.7.2308 from Windows SDK 10.0.26100. The game was only read; nothing derived from it is in this PR.

main this
programs translated 26,148 / 26,148 26,148 / 26,148
VS + PS emitted / validated 12,243 / 2,692 12,243 / 2,692
CS emitted / validated 1,441 / 1,441 1,441 / 1,441
MS emitted / validated 8,214 / 2,573 8,214 / 2,573
  • Unchanged by design. The reason table is identical line for line. The per-program outcome list is identical once the new from ... suffix is stripped.
  • The low validated counts come from this validator version rejecting PSV0: 15,054 × "Pipeline State Validation does not match". That is #1208.

Tests

  • Two new tests in emit::lower::tests:
    • a_refusal_names_the_instruction_that_made_its_missing_value reuses #604's timestamp program. The refusal at the branch names s_memtime at 0x0, both when the value is read directly and when it goes through two joins. Like the existing test, it tolerates timestamps lowering one day.
    • a_refusal_for_an_input_names_no_instruction checks that a branch on SCC at entry is refused with no origin.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • cargo test --workspace --locked: 344 passed, 0 failed, 6 ignored.
  • cargo xtask policy: 154 files ok. git diff --check: clean.
  • Machine: Windows 11 Pro (build 26300), AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32029.2010) plus the Ryzen 5 9600X iGPU, Rust 1.98.1. The GPU tests use the default adapter and WARP; I did not record which hardware adapter the helper picked.
  • Formatting: the changed lines are rustfmt-clean. rustfmt --check still reports 4 hunks in these files that are already on main, in test code this PR does not touch; I left them alone.

No coordination-issue item: I found no open "Coordinating who works on what" issue. Depends on: none.

AI-assisted: written with Claude Code (Claude Opus 5.5) and reviewed by me. No game data in the diff, the tests or this description beyond shader-reason counts and instruction names.

🤖 Generated with Claude Code

**@⁠ThomasSAMP** on GitHub · 2026-11-24 17:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1425) `ThomasSAMP:shader/missing-value-origin` → `main` · +241 −41 · 4 files · 1 commits · open ## What A value the emitter has no DXIL form for is kept as missing and only stops the program where something with an effect needs it (a branch, an export, a store). The refusal is reported there. So `victory translate --list` names the consumer, an `s_cbranch_execz` or a `v_mul_legacy_f32`, rather than the cause, which can be hundreds of instructions earlier. Two reasons in #293's table look unclaimed for that reason, and both are already covered by open PRs: - **"a cross-lane operation outside compute" (46 programs).** Every one of them is an SGPR spilled to VGPR lanes in a pixel program: 35 `v_writelane_b32` and 11 `v_readlane_b32` with a constant lane. That is #309's subject. - **"a descriptor's address or format read as data" (92).** All of them are descriptor dwords from an `s_load_dwordx4`/`x8` carried through joins into a branch. That is the territory of #1230 and #699. This PR makes the refusal name the instruction that made the missing value: - `emit::lower` records an origin for every missing value. It is the instruction whose own refusal made the value missing. If that instruction only read a missing value, the origin is that value's origin. Phis refused on retry keep the origin of their incoming value, and lane masks whose compare failed keep theirs. Inputs and lane-mask joins have none. - `emit::emit_traced` returns a `Refusal { error, from: Option<Origin> }`. **`emit`, `ShaderError` and the runtime path are unchanged**, so no other PR's constructors or matches need touching. - `victory translate --list` appends `from <instruction> at <offset>` to the example of an emit refusal. Under each reason it prints a `made by` breakdown. **Reason keys and every count are unchanged**, so existing tables (#293, #1247) stay comparable. On the retail `shaders.rpf` this gives, for example: ``` 272 emit: a lane mask holding lanes elsewhere read as data (e.g. ...) made by 266 v_writelane_b32, 3 s_cmp_lt_u32, 3 v_cmp_eq_u32 46 emit: a cross-lane operation outside compute (e.g. <file>@<offset> <name> Ps at <offset> from v_writelane_b32 at <offset>) made by 35 v_writelane_b32, 11 v_readlane_b32 92 emit: a descriptor's address or format read as data (e.g. ...) made by 53 s_load_dwordx8, 39 s_load_dwordx4 ``` Of 3,436 emit refusals, 2,698 now carry an origin. The 738 without one are refusals whose instruction is itself the cause: 653 × "a 64-bit image atomic", LDS byte writes, conditional exports. The rest are inputs (hardware SGPRs, barycentrics) and lane-mask joins. ## Measured `victory translate --validate --list` over the title's files, on `main` (`ffe310e`) and on this branch. `dxil.dll` 1.7.2308 from Windows SDK 10.0.26100. The game was only read; nothing derived from it is in this PR. | | main | this | |---|---:|---:| | programs translated | 26,148 / 26,148 | 26,148 / 26,148 | | VS + PS emitted / validated | 12,243 / 2,692 | 12,243 / 2,692 | | CS emitted / validated | 1,441 / 1,441 | 1,441 / 1,441 | | MS emitted / validated | 8,214 / 2,573 | 8,214 / 2,573 | - **Unchanged by design.** The reason table is identical line for line. The per-program outcome list is identical once the new `from ...` suffix is stripped. - **The low validated counts** come from this validator version rejecting PSV0: 15,054 × "Pipeline State Validation does not match". That is #1208. ## Tests - Two new tests in `emit::lower::tests`: - `a_refusal_names_the_instruction_that_made_its_missing_value` reuses #604's timestamp program. The refusal at the branch names `s_memtime at 0x0`, both when the value is read directly and when it goes through two joins. Like the existing test, it tolerates timestamps lowering one day. - `a_refusal_for_an_input_names_no_instruction` checks that a branch on SCC at entry is refused with no origin. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `cargo test --workspace --locked`: 344 passed, 0 failed, 6 ignored. - `cargo xtask policy`: 154 files ok. `git diff --check`: clean. - **Machine:** Windows 11 Pro (build 26300), AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32029.2010) plus the Ryzen 5 9600X iGPU, Rust 1.98.1. The GPU tests use the default adapter and WARP; I did not record which hardware adapter the helper picked. - **Formatting:** the changed lines are rustfmt-clean. `rustfmt --check` still reports 4 hunks in these files that are already on `main`, in test code this PR does not touch; I left them alone. No coordination-issue item: I found no open "Coordinating who works on what" issue. Depends on: none. AI-assisted: written with Claude Code (Claude Opus 5.5) and reviewed by me. No game data in the diff, the tests or this description beyond shader-reason counts and instruction names. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A value the emitter has no DXIL form for is kept as missing and only
stops the program where something with an effect needs it: a branch, an
export, a store. The refusal was reported there, so `translate --list`
named the consumer (an s_cbranch_execz, a v_mul_legacy_f32) rather than
the cause (a v_writelane_b32 spilling an SGPR, a descriptor dword carried
through joins).

Lowering now records, for every missing value, the instruction that made
it: the one whose refusal made it missing, or, when that instruction only
read a missing value, that value's origin. Phis refused on retry keep the
origin of their incoming value, and lane masks whose compare failed keep
theirs. Inputs and lane-mask joins have none.

`emit::emit_traced` returns the refusal with its origin; `emit` and
`ShaderError` are unchanged. `victory translate --list` appends
`from <instruction> at <offset>` to the example of an emit refusal and
prints a `made by` breakdown under each reason. Reason keys and every
count stay the same.

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

@⁠Marvisak on GitHub · 2026-11-25 01:27 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/mod.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1425#issuecomment-7149562014) <!-- victory-triage v1 head=06a543e8a9d381836679ffad3f1efc6a51d4e721 verdict=needs-rebase at=2026-11-25T01:27:10Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/mod.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • apps/victory/src/translate.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.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/1425/head:github-bot/gh-1425'
git switch 'github-bot/gh-1425'

Merge

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