Shaders: refuse the image instructions DXIL has no form of #2068
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2070"
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 0xkn0wh3r3 on 2026-11-25T04:21:35Z.
The problem
Four kinds of console image instruction were translated into DXIL operations that the validator rejects, and that a driver may refuse or run wrongly. DXIL has no form of them, so refusing them is the right outcome:
image_gather4_lz,_l,_lz_o,_l_o) from a 1D or 3D image_o) from a cube or cube arrayimage_sample_c_lzand the like) of a 3D imageimage_load_mipfrom a UAV, which is one level of its resourceFound by validating random programs (the generator of #1335, with a validation pass, validator 1.6): 5 of 16,207 programs that translated out of 200,000. The 3D comparison sample (second commit) was found over 2,000,000 more random programs. With this and #2056 every one of them validates.
The fix
In
emit/lower.rs, each case is now refused before anything is emitted, as the gathers DXIL cannot do already are ("a gather with implicit level", "a gather of several channels"):image_load_mipnot from a UAV: otherwise "a load at a mip level from a UAV".Testing
emit::lower::tests::image_instructions_dxil_lacks_are_refused. It lowers each refused instruction with its result written to LDS, so the refusal ends the translation, and checks the refusal reason. Next to them, the 2D gather, the 2D comparison sample and the plain UAV load still lower. It fails onmain, and with any one of the new checks removed.cargo test --release -p victory-shader --libon an RTX 5070 Ti: 245 passed; the 3 failures (emit::stride_tests::*x2,emit::synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way onmainon this GPU (#1835).cargo clippy -p victory-shader --all-targets --features host: clean.Not covered
Not checked against title shaders (no game data here); real compilers are unlikely to emit these forms.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:31:08Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib image_instructions_dxil_lacks_are_refused— passedcargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean explicit refusal of gather and UAV image load forms that DXIL lacks, with targeted regression test coverage. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:33:53Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.145 passed / 0 failed / 2 ignored. Gathers and UAV loads DXIL has no form of refused (+1 test) — explicit rejection instead of silent miscompile; good defensive lowering.
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:25:40Z.
Triage verdict — Ready on the reviewed DXIL boundaries (
0cd10cd)Evidence
Checks and limits
Next step
This verification was AI-assisted.
[PR #2070] Shaders: refuse the gathers and UAV loads DXIL has no form ofto [PR #2070] Shaders: refuse the image instructions DXIL has no form ofImported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:16:10Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
01a09f6contomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:26:15Z.
Automated triage for the maintainers.
Merge candidate (re-checked on
1f14099). The checks incrates/victory-shader/src/emit/lower.rs(image lowering) are unchanged. They refuse four forms:image_load_mipfrom a UAV.The kind numbers match the
dim-> DXIL kind mapping in the same function and DXIL's resource kinds. The only change is that the test now lives in its own file,emit/lower/tests/image_refusals.rs, loaded bymod image_refusals;insidelower.rs's inlinemod tests. The test checks each refusal reason and that the 2D gather, the 2D comparison sample and the plain UAV load still lower. A tester reports it passing on RDNA2 and RDNA3 at the previous head.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by bvtterbroot on 2026-11-25T18:40:14Z.
AMD check at
01a09f6(base940d32f), on an RDNA3 and an RDNA2 GPU:cargo test -p victory-shader -p victory-gpu --locked: 391 passed, 0 failed, 5 ignored, on both GPUs. That includes its new test (image_instructions_dxil_lacks_are_refused).Synthetic tests only, no game files. Tested with AI assistance (Claude Code).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:06:51Z.
Review: APPROVED
Verified locally merged onto
origin/main(63bcca43, Windows 11 x64, Rust 1.98.1 MSVC, RTX 5090 & WARP +dxil.dll):cargo test --locked -p victory-shader --lib emit::lower::tests::(VICTORY_WARP=0andVICTORY_WARP=1) — 34 passed, 0 failed on both adapters (includingimage_refusals::image_instructions_dxil_lacks_are_refused)cargo test --locked -p victory-shader --lib constant_color_validates— 1 passed, 0 failedcargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features) — 0 warningsrustfmt --edition 2024 --check crates/victory-shader/src/emit/lower/tests/image_refusals.rs— cleancargo xtask policy— ok (192 files ok)Review notes
image_refusals.rsdecode as documented, andemit/lower.rssits at 521,420 B (< 524,288 B).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.