Shaders: hidden descriptor words joined with data are an undefined path (+494 programs, stacked on #1402) #1597
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1597
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1597/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@sinan-cmyk on GitHub · 2026-11-24 19:40 UTC · original
sinan-cmyk:shader-hidden-descriptor-join→main· +2190 −158 · 10 files · 35 commits · closed without mergingStacked on #1402. Until #1402 lands, the diff here shows #1402 too. The change itself is the last commit, 2d2a697: one file,
emit/lower.rs, +93 lines including 2 tests.Summary: This PR handles the 772 programs that reach "a descriptor's address or format read as data" through a join with data. On a retail dump it gains 435 programs on top of #1402 and loses none. With #1402, that failure is the largest one: 809 programs (measurement).
What the 809 programs do
I instrumented the translator on all 809 programs and recorded the first instruction that consumes the missing dword:
v_writelane_b32)v_mov_b32At those joins, another reachable edge brings real data (
s_buffer_loadresults, for example), and the code after the join uses the value as a number (s_and_b32,s_cmp_*,s_lshl_b32,s_bfe_u32). The descriptor's registers are simply reused on one path. In a traced example, the read sits behind a branch that is taken only when the value came over the data edge.Change
descriptor_datamarks the dwords that no HLSL program can read as hidden.GetDimensionsreads an image's sizes and levels (dwords 1–4), a buffer's record count (dword 2) and a structured buffer's stride (dword 1). It never reads these dwords:At a join where a reachable edge brings data, a hidden dword on another edge is a register that a path left undefined.
fill_phistakes 0 for it, which is the existing treatment of an unread join. What stays refused:The assumption to review (marked
shortcut:in the code): a program that really reads such a dword on that path now gets 0. Plain HLSL cannot express such a read, so the console compiler can only produce it for a value that is undefined in the source. If an Xbox-specific intrinsic exposes raw descriptor words, programs that use it would get 0 on that path.Measurement
victory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11, compared program by program (25,889 programs):2310409Of the 809, 435 now validate. 53 more move on to later failures:
321 still fail with this reason. Most of them are image dwords 0 and 5 that reach the read without a data edge, plus the spills.
Checks
s_buffer_loaddata now lowers. With the new rule turned off, this test fails with exactly the target error.cargo test --locked -p victory-shader --lib: 139 passed, 0 failed, 1 ignored. The run used an RTX 4070 SUPER as the default adapter.cargo clippy -p victory-shader --all-targets: clean.Overlap: #1376 and #1230 also work on descriptor and missing-value joins. Both conflict with #1402 in
emit/lower.rs, and I have not measured them stacked.AI-assisted (Claude Code). No shader names or data are included, per the asset policy.
The console compiler spills scalars, lane-mask pairs among them, with v_writelane_b32 into constant lanes of a VGPR and restores them with v_readlane_b32 of the same lane. The restored pair was an opaque mask, so the selects, EXEC writes and joins that used it refused ("a select on an untracked mask", "an opaque lane mask", "a lane-mask join of an untracked mask"). structure now follows a constant-lane readlane back through a plain chain of writelanes to the scalar written to that lane, and gives the restored pair that scalar pair's mask. A chain with a phi or another write of the VGPR stays opaque (shortcut noted in code). Offline corpus, against fix/mask-phi-ballot (neither branch carries #585): vertex/pixel programs emitted 12250 -> 12269, compute 1443 -> 1452, "a lane-mask join of an untracked mask" 20 -> 0, "an opaque lane mask" 29 -> 8, "a conditional export" 8 -> 0. Synthetic pixel program fails before, lowers after. Stacked on fix/mask-phi-ballot (shares its test helper). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>Fixes 5 shader emission and DXIL container/validator issues in `victory-shader`, raising validated shaders across the test corpus from 21,983 to 22,159 (+176; 100% of emitted VS/PS/CS shaders now validate cleanly): 1. Biased 16-bit image samples (`emit/lower.rs`): - Remove the `a16` rejection on `image_sample_b` and separate 32-bit prefix operands (offsets, bias, comparison reference) from `a16`-packed tail operands (gradients, coordinates, explicit LOD) starting at `regs[first]`, matching GFX10 MIMG hardware operand layout. 2. Conservative depth `SV_Position` interpolation (`emit/mod.rs`): - Declare `SV_Position` with `linear_noperspective_centroid` (5) instead of `linear_noperspective` (4) in pixel shaders outputting `SV_DepthLessEqual` or `SV_DepthGreaterEqual` (kinds 18/19). 3. Per-row interpolation mode consistency (`emit/mod.rs`, `emit/lower.rs`): - Add `harmonize_row_interp()` so elements sharing a signature row always declare the same interpolation mode: rows containing integer attributes or `SV_IsFrontFace` propagate `nointerpolation` (1) to sibling elements, and after pixel-shader lowering unread siblings inherit the actual read mode of sibling elements in the same row. 4. Container signature row ordering (`emit/container.rs`): - Sort `ISG1`/`OSG1` rows stably by register only (`row`) rather than `(row, col)`, preserving DXIL element-ID order within a row so the container signature matches DXIL validator expectations byte for byte. 5. SM 6.6 compute-shader implicit derivatives (`emit/shader.rs`, `emit/container.rs`, `emit/lower.rs`): - Track compute shaders emitting implicit-derivative sampling ops and emit `dx.valver = 1.8` with `PSVRuntimeInfo3` (52 bytes, carrying `EntryFunctionName`), enabling validation and D3D12 compute PSO creation. Adds 5 unit + `dxil.dll` validation (+ D3D12 compute PSO) tests in `emit::tests`.A constant buffer descriptor that the program also reads as numbers was refused as a whole ("a constant buffer's descriptor read as data"), even when the words reach the code only through a join with data. HLSL can read no word of a constant buffer's descriptor (there is no GetDimensions for one), so all four are hidden words: a direct read is still refused under the same reason, and at a join with data they are the undefined path, as for the other hidden descriptor words. Words of the load past this descriptor stay without a host value. On a retail dump: 21 more programs validate, none lost; the other 33 that stopped here move on to later failures.@sinan-cmyk on GitHub · 2026-11-24 20:10 UTC · original
Follow-up commit 6a94bb3: +38 more programs, 0 lost (+473 over #1402 in total).
This commit traced the 321 programs that still stopped at "a descriptor's address or format read as data" after 2d2a697, and handles two more paths. In both, the direct read stays refused.
v_writelane_b32at a constant lane stays marked, andv_readlane_b32of that lane gives the hidden word back.I also tried counting a lane-mask edge (one whose ballot the join uses) as data. It gained no program, so I left it out to keep the assumption narrow.
2310409About 48 programs still fail with this reason. Most of them read the hidden field on every path, so refusing them is correct. Two new synthetic tests (
a_join_of_hidden_words_is_hidden,a_spilled_hidden_word_comes_back_hidden) each fail when their rule is turned off.cargo test -p victory-shader --lib: 141 passed, 0 failed. clippy: clean.AI-assisted (Claude Code). No shader names or data are included, per the asset policy.
@sinan-cmyk on GitHub · 2026-11-24 20:57 UTC · original
Rebased onto the updated #1402 head
119b763. That commit is test-only: it skips two of #306's tests on older validators. My two commits are unchanged:81f2545(was 2d2a697) and6c428a2(was 6a94bb3).emit/lower.rsis byte-identical to before, so the measurement still holds: +473 over #1402, 0 lost.cargo test --locked -p victory-shader --libon the rebased head: 141 passed, 0 failed.AI-assisted (Claude Code).
@sinan-cmyk on GitHub · 2026-11-24 21:12 UTC · original
Third commit
f4e166a: a constant buffer's descriptor words are hidden too. +21 programs, 0 lost (+494 over #1402).descriptor_datarefused the whole load as soon as a descriptor whose use is a constant buffer had a word read as data. Plain HLSL can read no word of a CBV descriptor (GetDimensionshas no cbuffer form), so all four words are hidden words now. A direct read is still refused under the same reason ("a constant buffer's descriptor read as data"). At a join with data, the words take the undefined path, as the first commit does for other hidden words. Words of the load beyond the descriptor stay "address or format" and are not hidden.119b7636c428a2(the two earlier commits, rebased)f4e166aNo program fails with the CBV reason any more. 22 programs move on to "a descriptor's address or format read as data" (load words beyond the descriptor), and 9 to "a descriptor read only as data". New test:
a_constant_buffers_descriptor_words_are_hidden. It fails at the join when the old refusal is put back.cargo test --locked -p victory-shader --lib: 142 passed, 0 failed.No open PR targets this reason. AI-assisted (Claude Code). No shader names or data are included, per the asset policy.
@Marvisak on GitHub · 2026-11-25 01:21 UTC · original
Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.
Stacked on bundle #1402; its own change zero-fills stale descriptor words at joins with data ('shortcut: zero for the undefined path'), the policy main dropped as unsound (
3dd467c), and main now proves such edges dead instead (a7fc47afdead_on_edge/live_edges).If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
@Marvisak on GitHub · 2026-11-25 01:31 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,crates/victory-shader/src/emit/shader.rs,crates/victory-shader/src/emit/valu_tests.rs,crates/victory-shader/src/structure.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 01:45 UTC · original
Fourth commit cc7d30a: a structured buffer's dword 1 is hidden at a join too.
Why. I merged #995 by hand on top of this PR, and the result lost 21 programs. #995 turns some raw views into structured ones. This PR treated a raw view's dword 1 as hidden, but not a structured view's dword 1.
descriptor_datagives that word no value: its low half is the address, its high half the stride. So programs that the raw-view rule had covered fell back to "a descriptor's address or format read as data". The fix: a direct read of a structured view's dword 1 stays refused, and at a join with data the word now takes the undefined path, as for a raw view.f4e166aTotal for this PR: +495 over #1402 (
119b763), 0 lost.cargo test --locked -p victory-shader --lib: 142 passed, 0 failed.Method:
victory translate --validate --listonshaders.rpf(1.0.2.1), dxil.dll 1.8.2502.11, compared program by program (25,889 programs). AI-assisted (Claude Code). No shader names or data are included, per the asset policy.@sinan-cmyk on GitHub · 2026-11-25 01:59 UTC · original
Thanks for the explanation. Understood:
mainproves those edges dead instead of zero-filling them, so this PR is superseded, and I won't reopen it.To check whether anything was missed, I measured the current
main(940d32f) on the dump. Method:translate --validate --listonshaders.rpf1.0.2.1, dxil.dll 1.8.2502.11, program by program.Over
ffe310e, this PR made 2,183 more programs validate.mainnow validates 1,782 of them.Of the other 401,
mainrefuses 36 ("a descriptor read only as data"). The remaining 365 are emitted but rejected by the validator:So they are not proven-dead refusals.
Separately, 808 programs that validated on
ffe310efail onmainwith "Flags must match usage". I'm bisecting that now and will file it as its own issue with the commit.AI-assisted (Claude Code). No shader names or data are included, per the asset policy.
Pull request closed