Shaders: split comparison and non-comparison immediate static samplers #1108
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1108"
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 mgunes1311-lab on 2026-11-24T15:47:58Z.
Summary
Split immediate/constant samplers by
(words, comparison)so a single GPU sampler descriptor used for both standard and comparison sampling gets separate D3D12 static sampler slots rather than forcing a shared sampler into comparison mode.Fixes
Lower::samplersby([u32; 4], bool)instead of[u32; 4]alone, and passcomparisondirectly toShader::sampler_handle. This prevents non-comparisonimage_sample_*operations from being bound to aSamplerComparisonStatestatic sampler.cmp_samplers: u64inLoweredandShaderwithVec<bool>(Shader::samplers: Vec<bool>), avoiding bit-shift overflow when a shader uses more than 64 immediate samplers.build_static_samplersinemit/mod.rsand sets.filter = (s.filter & !0x180) | 0x80for comparison samplers instead of|= 0x80, soMINIMUM(0x100) becomesCOMPARISON(0x80) rather thanMAXIMUM(0x180).Files Changed
crates/victory-shader/src/emit/lower.rscrates/victory-shader/src/emit/shader.rscrates/victory-shader/src/emit/mod.rsTests Added
emit::tests::constant_sampler_used_with_and_without_comparison_splits_into_two_static_samplers(covers bothcmp_first = false/true, DXIL validation + WARP dispatch on Windows, andMINIMUMreduction override)emit::tests::more_than_64_immediate_samplers_do_not_overflow(66 immediate samplers)Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T15:50:51Z.
We extended the 66-sampler test on
a0206d1through compute dispatch and readback on an RTX 4090 under Wine/GE 3.2. With one R32_FLOAT texel set to 0.5, every ordinary sample returned 0.5 and every comparison sample returned 1.0. We checked all 66 output words, including slots 64 and 65 beyond the old mask.The mixed-use shader also validated and returned [0.5, 1.0, 0.0] in both declaration orders. These are test-only fixture changes. The MINIMUM-to-COMPARISON filter conversion was checked in the emitted sampler metadata. Title use remains unmeasured.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:50Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
a0206d1:cargo test -p victory-shaderpasses, 122 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:25Z.
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1477. One immediate sampler used with and without comparison gets two static samplers: the same fix as #1477 (clean, 104 lines; also #1493), here with a Vec refactor and unrelated reformatting.
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.
Pull request closed