Shaders: hidden descriptor words joined with data are an undefined path (+494 programs, stacked on #1402) #1596
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1597"
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?
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T19:40:17Z.
Stacked 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):23104092d2a697Of 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.
[PR #1597] Shaders: hidden descriptor words joined with data are an undefined path (+435 programs, stacked on #1402)to [PR #1597] Shaders: hidden descriptor words joined with data are an undefined path (+473 programs, stacked on #1402)Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:10:05Z.
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.
23104092d2a6976a94bb3About 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.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:57:52Z.
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(was2d2a697) and6c428a2(was6a94bb3).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).
[PR #1597] Shaders: hidden descriptor words joined with data are an undefined path (+473 programs, stacked on #1402)to [PR #1597] Shaders: hidden descriptor words joined with data are an undefined path (+494 programs, stacked on #1402)Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T21:12:42Z.
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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:21:24Z.
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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:31:41Z.
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
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:45:42Z.
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.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:59:49Z.
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