Shaders: split comparison and non-comparison immediate static samplers #1108

Closed
github-bot wants to merge 3 commits from gh-pr/1108/head into gh-pr/1108/base
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-24 15:47 UTC · original
mgunes1311-lab:shader-split-cmp-samplers → main · +273 −55 · 3 files · 3 commits · closed without merging

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

  • Separate comparison vs non-comparison static samplers: Key Lower::samplers by ([u32; 4], bool) instead of [u32; 4] alone, and pass comparison directly to Shader::sampler_handle. This prevents non-comparison image_sample_* operations from being bound to a SamplerComparisonState static sampler.
  • Remove the 64-sampler bitmask limit: Replace cmp_samplers: u64 in Lowered and Shader with Vec<bool> (Shader::samplers: Vec<bool>), avoiding bit-shift overflow when a shader uses more than 64 immediate samplers.
  • Preserve reduction-type bits cleanly: Extract build_static_samplers in emit/mod.rs and set s.filter = (s.filter & !0x180) | 0x80 for comparison samplers instead of |= 0x80, so MINIMUM (0x100) becomes COMPARISON (0x80) rather than MAXIMUM (0x180).

Files Changed

  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/shader.rs
  • crates/victory-shader/src/emit/mod.rs

Tests Added

  • emit::tests::constant_sampler_used_with_and_without_comparison_splits_into_two_static_samplers (covers both cmp_first = false/true, DXIL validation + WARP dispatch on Windows, and MINIMUM reduction override)
  • emit::tests::more_than_64_immediate_samplers_do_not_overflow (66 immediate samplers)
**@⁠mgunes1311-lab** on GitHub · 2026-11-24 15:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1108) `mgunes1311-lab:shader-split-cmp-samplers` → `main` · +273 −55 · 3 files · 3 commits · closed without merging ## 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 - **Separate comparison vs non-comparison static samplers:** Key `Lower::samplers` by `([u32; 4], bool)` instead of `[u32; 4]` alone, and pass `comparison` directly to `Shader::sampler_handle`. This prevents non-comparison `image_sample_*` operations from being bound to a `SamplerComparisonState` static sampler. - **Remove the 64-sampler bitmask limit:** Replace `cmp_samplers: u64` in `Lowered` and `Shader` with `Vec<bool>` (`Shader::samplers: Vec<bool>`), avoiding bit-shift overflow when a shader uses more than 64 immediate samplers. - **Preserve reduction-type bits cleanly:** Extract `build_static_samplers` in `emit/mod.rs` and set `s.filter = (s.filter & !0x180) | 0x80` for comparison samplers instead of `|= 0x80`, so `MINIMUM` (`0x100`) becomes `COMPARISON` (`0x80`) rather than `MAXIMUM` (`0x180`). ### Files Changed - `crates/victory-shader/src/emit/lower.rs` - `crates/victory-shader/src/emit/shader.rs` - `crates/victory-shader/src/emit/mod.rs` ### Tests Added - `emit::tests::constant_sampler_used_with_and_without_comparison_splits_into_two_static_samplers` (covers both `cmp_first = false/true`, DXIL validation + WARP dispatch on Windows, and `MINIMUM` reduction override) - `emit::tests::more_than_64_immediate_samplers_do_not_overflow` (66 immediate samplers)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:20:12 +00:00
github-bot closed this pull request 2026-11-26 04:20:12 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 15:50 UTC · original

We extended the 66-sampler test on a0206d1 through 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.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 15:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1108#issuecomment-7136712364) We extended the 66-sampler test on `a0206d1` through 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.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 18:01 UTC · original

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-shader passes, 122 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 18:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1108#issuecomment-7140055225) 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-shader` passes, 122 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:32 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1108#issuecomment-7148612376) 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<bool> 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1108
No description provided.