Shaders: key immediate sampler slots by descriptor and comparison mode #1476
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1477"
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 geiyiliyabumo on 2026-11-24T18:18:17Z.
Summary
Fixes immediate/static sampler slot reuse when the same immediate descriptor words are used by both non-comparison (\image_sample) and comparison (\image_sample_c\ / \image_sample_c_lz) instructions in one shader (tracking issue #1242, \VIC-BT-009).
Previously, \Lower::resource_handle\ keyed \self.samplers\ only on the 4 descriptor words and set \self.s.cmp_samplers |= 1 << n\ after emitting handles. If a non-comparison sample ran first, its \dx.op.annotateHandle\ encoded \SamplerKind = 0\ (\14), while a later comparison sample flipped the slot bit so \dx.resources\ declared \SamplerKind = 1\ (\Comparison), producing invalid DXIL. It also performed an unchecked \1u64 << n\ shift.
Changes
Verification
AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T18:42:12Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e),cargo test -p victory-shader --locked→ 97 passed, 0 failed. Execution/valu tests are#[cfg(all(test, windows))]and were not run here; lowering/structure coverage only.Immediate sampler slots are now keyed by (words, comparison-mode) instead of reusing one slot and OR-ing the comparison bit afterwards, so plain
image_sample*andimage_sample_c*on the same immediate sampler words get two static samplers (plain +filter | 0x80). The 64-slot guard is in place, and the in-tree test asserts[sampler, comparison]static samplers for the mixed-use shader (validator gated#[cfg(windows)], macOS-safe). 97 passed on macOS.Note: this overlaps with #1493 (same problem statement) — #1493 currently breaks macOS compilation; whichever lands second should rebase.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:13:32Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
2286e03ontomainffe310e(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: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).