Shaders: declare SamplerComparisonState for immediate comparison samplers and add GPU test #1493

Open
github-bot wants to merge 1 commit from github-bot/gh-1493 into main AGit
Owner

@⁠piyonchu on GitHub · 2026-11-24 18:26 UTC · original
piyonchu:fix/immediate-sampler-cmp-key → main · +253 −5 · 3 files · 1 commits · open

Summary

Declares immediate comparison samplers with %struct.SamplerComparisonState* in DXIL dx.resources metadata and adds a View::RedTexture (R32_FLOAT) host/GPU execution test covering both declaration orders (cmp_first = false and true).

(Note: keying immediate samplers by (words, is_comparison) is already on main via #1477.)

Changes

  • crates/victory-shader/src/emit/shader.rs:
    • Allocate and reuse %struct.SamplerComparisonState* undef handles when self.cmp_samplers >> n & 1 != 0, and %struct.SamplerState* when plain, for DXIL dx.resources metadata (sampler list).
    • Preserve cmp_samplers bit flag (0x8000) when creating dx.op.createHandleForLib / sampler heap indexing.
  • crates/victory-shader/src/emit/host.rs:
    • Add View::RedTexture(u32, u32, &[f32]) (DXGI_FORMAT_R32_FLOAT SRV) so compute tests can exercise comparison sampling cleanly.
  • crates/victory-shader/src/emit/mod.rs:
    • Add immediate_sampler_used_with_and_without_comparison_validates_and_runs validating DXIL (dxil.dll) and executing both plain (image_sample_lz) and comparison (image_sample_c_lz) sampling across both sampler declaration orders on hardware/WARP (view_marks: false).

Verification

Rebased onto main (940d32f, commit 4f32381):

  • cargo clippy -p victory-shader --all-targets -- -D warnings -A clippy::needless_range_loop -A deprecated: pass.
  • cargo test -p victory-shader --lib immediate_sampler_: 2 passed, 0 failed.
  • cargo test -p xtask: 6 passed, 0 failed (repository_passes_policy passes).
  • git diff --check upstream/main..HEAD: clean.

AI-assisted; no proprietary game files used.

**@⁠piyonchu** on GitHub · 2026-11-24 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493) `piyonchu:fix/immediate-sampler-cmp-key` → `main` · +253 −5 · 3 files · 1 commits · open ### Summary Declares immediate comparison samplers with `%struct.SamplerComparisonState*` in DXIL `dx.resources` metadata and adds a `View::RedTexture` (`R32_FLOAT`) host/GPU execution test covering both declaration orders (`cmp_first = false` and `true`). *(Note: keying immediate samplers by `(words, is_comparison)` is already on `main` via `#1477`.)* ### Changes - **`crates/victory-shader/src/emit/shader.rs`**: - Allocate and reuse `%struct.SamplerComparisonState*` undef handles when `self.cmp_samplers >> n & 1 != 0`, and `%struct.SamplerState*` when plain, for DXIL `dx.resources` metadata (`sampler` list). - Preserve `cmp_samplers` bit flag (`0x8000`) when creating `dx.op.createHandleForLib` / sampler heap indexing. - **`crates/victory-shader/src/emit/host.rs`**: - Add `View::RedTexture(u32, u32, &[f32])` (`DXGI_FORMAT_R32_FLOAT` SRV) so compute tests can exercise comparison sampling cleanly. - **`crates/victory-shader/src/emit/mod.rs`**: - Add `immediate_sampler_used_with_and_without_comparison_validates_and_runs` validating DXIL (`dxil.dll`) and executing both plain (`image_sample_lz`) and comparison (`image_sample_c_lz`) sampling across both sampler declaration orders on hardware/WARP (`view_marks: false`). ### Verification Rebased onto `main` (`940d32f`, commit `4f32381`): - `cargo clippy -p victory-shader --all-targets -- -D warnings -A clippy::needless_range_loop -A deprecated`: pass. - `cargo test -p victory-shader --lib immediate_sampler_`: **2 passed, 0 failed**. - `cargo test -p xtask`: **6 passed, 0 failed** (`repository_passes_policy` passes). - `git diff --check upstream/main..HEAD`: clean. AI-assisted; no proprietary game files used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:33:55 +00:00
Author
Owner

@⁠piyonchu on GitHub · 2026-11-24 18:56 UTC · original · edited 2026-11-24 19:45 UTC

Added #[cfg(windows)] on immediate_sampler_used_with_and_without_comparison_validates_and_runs in 0308b8d so non-Windows builds do not reference validator, valu_tests, or host (also verified cargo test -p victory-shader --locked -- --skip v_med3_f32_matches_rdna2_with_nan and clippy --workspace --locked -- -D warnings). Also noted #1477 addresses the same issue.

**@⁠piyonchu** on GitHub · 2026-11-24 18:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7141369832) · edited 2026-11-24 19:45 UTC Added `#[cfg(windows)]` on `immediate_sampler_used_with_and_without_comparison_validates_and_runs` in `0308b8d` so non-Windows builds do not reference `validator`, `valu_tests`, or `host` (also verified `cargo test -p victory-shader --locked -- --skip v_med3_f32_matches_rdna2_with_nan` and `clippy --workspace --locked -- -D warnings`). Also noted #1477 addresses the same issue.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 20:14 UTC · original

The new test fails on NVIDIA (Ada) and passes on WARP

Result: immediate_sampler_used_with_and_without_comparison_validates_and_runs fails on NVIDIA and passes on WARP. I merged head 0308b8d onto main ffe310e. The test fails 2 out of 2 times on the RTX 4070 SUPER and passes with VICTORY_WARP=1.

assertion `left == right` failed: hardware cmp sample (cmp_first=false)
  left: 0.5
 right: 1.0

0.5 instead of 1.0 is what a comparison sample returns when the driver filters the comparison results (PCF-style averaging of passing and failing texels) instead of returning one texel's comparison. So on NVIDIA, either the sampler's filter is not point for the comparison case, or the texel layout in the test puts the sample position between a passing and a failing texel. WARP returns 1.0.

Offline. I merged the head onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11, compared program by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost, no failure reason changed. That is expected for a fix whose instructions sit behind earlier failures.

Machine: RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter; Windows 11 25H2; Rust 1.98.1. The rest of cargo test --locked -p victory-shader --lib passes. No game data. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 20:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7143235642) ### The new test fails on NVIDIA (Ada) and passes on WARP **Result: `immediate_sampler_used_with_and_without_comparison_validates_and_runs` fails on NVIDIA and passes on WARP.** I merged head 0308b8d onto `main` ffe310e. The test fails 2 out of 2 times on the RTX 4070 SUPER and passes with `VICTORY_WARP=1`. ``` assertion `left == right` failed: hardware cmp sample (cmp_first=false) left: 0.5 right: 1.0 ``` 0.5 instead of 1.0 is what a comparison sample returns when the driver filters the comparison results (PCF-style averaging of passing and failing texels) instead of returning one texel's comparison. So on NVIDIA, either the sampler's filter is not point for the comparison case, or the texel layout in the test puts the sample position between a passing and a failing texel. WARP returns 1.0. **Offline.** I merged the head onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11, compared program by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost, no failure reason changed. That is expected for a fix whose instructions sit behind earlier failures. Machine: RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter; Windows 11 25H2; Rust 1.98.1. The rest of `cargo test --locked -p victory-shader --lib` passes. No game data. AI-assisted (Claude Code).
Author
Owner

@⁠piyonchu on GitHub · 2026-11-24 20:33 UTC · original

Thanks for running that on Ada (32.0.16.1088), @⁠sinan-cmyk.

With a 1x1 texture (texel = 0.5) and Wrap/Mirror/Clamp addressing, any comparison filter (0.25 <= 0.5) can only evaluate to 1.0, so getting 0.5 means sampleCmpLevelZero read the raw texel without applying comparison (falling back to the plain SamplerState mode when cmp_first = false).

Inspecting the emitted DXIL against dxc -T cs_6_6 showed shader.rs was declaring comparison immediate samplers (kind == 1) in dx.resources with %struct.SamplerState* instead of %struct.SamplerComparisonState*. Updated crates/victory-shader/src/emit/shader.rs in the latest commit to emit %struct.SamplerComparisonState* when cmp_samplers sets bit n, re-verified DXIL validation (dxil.dll), RTX 4060 + WARP execution (120 passed; 0 failed; 1 ignored), clippy (default and --all-features), and xtask policy checks. Would you mind re-testing on 32.0.16.1088? (Also fine if maintainers prefer #1477 since it addresses the same sampler-keying bug.)

**@⁠piyonchu** on GitHub · 2026-11-24 20:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7143726625) Thanks for running that on Ada (`32.0.16.1088`), @⁠sinan-cmyk. With a `1x1` texture (`texel = 0.5`) and Wrap/Mirror/Clamp addressing, any comparison filter (`0.25 <= 0.5`) can only evaluate to `1.0`, so getting `0.5` means `sampleCmpLevelZero` read the raw texel without applying comparison (falling back to the plain `SamplerState` mode when `cmp_first = false`). Inspecting the emitted DXIL against `dxc -T cs_6_6` showed `shader.rs` was declaring comparison immediate samplers (`kind == 1`) in `dx.resources` with `%struct.SamplerState*` instead of `%struct.SamplerComparisonState*`. Updated `crates/victory-shader/src/emit/shader.rs` in the latest commit to emit `%struct.SamplerComparisonState*` when `cmp_samplers` sets bit `n`, re-verified DXIL validation (`dxil.dll`), RTX 4060 + WARP execution (`120 passed; 0 failed; 1 ignored`), `clippy` (default and `--all-features`), and `xtask` policy checks. Would you mind re-testing on `32.0.16.1088`? (Also fine if maintainers prefer `#1477` since it addresses the same sampler-keying bug.)
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-24 23:27 UTC · original

This PR doesn't compile against the new main (70564ae0), so I ported it and ran it on AMD. The fix itself, lower.rs and shader.rs at cc0f47a, merges as is. The test needed two changes:

  1. main's HostShader gained root_uavs, memory, memory_writes, view_addresses, heap and heap_writes, so the test's initializer now fills them from lowered.
  2. The test samples an RGBA32F texture with a comparison sampler. That format doesn't support comparison sampling, so drivers return the raw texel or zeros: the 0.5 @⁠sinan-cmyk saw on NVIDIA, and 0.0 on this AMD card before. I added a View::RedTexture (an R32_FLOAT SRV) to the test harness and switched the test to it, with the same texel 0.5.

Result on 70564ae0 + this, RX 6750 XT (RDNA2), Windows 11, Rust 1.98.1 MSVC:

  • immediate_sampler_used_with_and_without_comparison_validates_and_runs passes on the hardware adapter and WARP, with DXIL validation. Plain sample 0.5, comparison 1.0, both orders.
  • victory-shader: 210 passed, 0 failed (main alone: 209).
  • cargo clippy -p victory-shader --all-targets -- -D warnings is clean.

This removes main's shortcut: one sampler used with and without comparison would need two static samplers; it becomes a comparison one, which matters for shadow-map sampling.

Patch against 70564ae0 (the PR's lowering + the ported test + the R32_FLOAT view)
--- a/crates/victory-shader/src/emit/lower.rs
+++ b/crates/victory-shader/src/emit/lower.rs
@@ -4684,18 +4684,25 @@
                     .get(..4)
                     .and_then(|w| w.try_into().ok())
                     .ok_or("a sampler constant")?;
-                let n = match self.samplers.iter().position(|w| *w == words) {
+                // Plain and comparison samples require distinct DXIL/D3D12
+                // sampler bindings even when they share console sampler words.
+                let cmp = props.0 & 0x8000 != 0;
+                let n = match self.samplers.iter().enumerate().position(|(i, w)| {
+                    *w == words && (i < 64 && self.s.cmp_samplers >> i & 1 != 0) == cmp
+                }) {
                     Some(n) => n,
                     None => {
+                        let n = self.samplers.len();
+                        if cmp {
+                            if n >= 64 {
+                                return Err("too many immediate samplers");
+                            }
+                            self.s.cmp_samplers |= 1 << n;
+                        }
                         self.samplers.push(words);
-                        self.samplers.len() - 1
+                        n
                     }
                 };
-                if props.0 & 0x8000 != 0 {
-                    // shortcut: one sampler used with and without comparison
-                    // would need two static samplers; it becomes a comparison one.
-                    self.s.cmp_samplers |= 1 << n;
-                }
                 Ok(self.s.sampler_handle(self.cur, n as u32))
             }
             Source::Constant(_) => Err("a constant resource descriptor"),
--- a/crates/victory-shader/src/emit/shader.rs
+++ b/crates/victory-shader/src/emit/shader.rs
@@ -417,7 +417,7 @@
             217,
             &[bind, i, f],
         );
-        let cmp = if self.cmp_samplers >> n & 1 != 0 {
+        let cmp = if n < 64 && self.cmp_samplers >> n & 1 != 0 {
             0x8000
         } else {
             0
@@ -626,7 +626,7 @@
                 let u = self.m.undef(p);
                 let mut list = Vec::new();
                 for n in 0..self.samplers {
-                    let kind = (self.cmp_samplers >> n & 1) as u32;
+                    let kind = u32::from(n < 64 && self.cmp_samplers >> n & 1 != 0);
                     let ops = vec![
                         Some(i32c(&mut self, n)),
                         Some(self.m.md_value(u)),
--- a/crates/victory-shader/src/emit/mod.rs
+++ b/crates/victory-shader/src/emit/mod.rs
@@ -454,7 +454,7 @@
             .enumerate()
             .map(|(n, &w)| {
                 let mut s = StaticSampler::from_words(w);
-                if l.cmp_samplers >> n & 1 != 0 {
+                if n < 64 && l.cmp_samplers >> n & 1 != 0 {
                     s.filter |= 0x80;
                 }
                 s
@@ -1157,4 +1157,182 @@
         // Translated or refused with a reason; it must not panic.
         let _ = super::emit(&c, &native, &p, &st, &io, &res);
     }
+
+    #[cfg(windows)]
+    #[test]
+    fn immediate_sampler_used_with_and_without_comparison_validates_and_runs() {
+        let mut tested_orders = 0;
+        for cmp_first in [false, true] {
+            let plain = [0xF09C_0108, 0x0043_0503]; // image_sample_lz v5, v[3:4], s[12:19], s[8:11]
+            let cmp = [0xF0BC_0108, 0x0043_0602]; // image_sample_c_lz v6, v[2:4], s[12:19], s[8:11]
+            let (first_sample, second_sample) = if cmp_first {
+                (cmp, plain)
+            } else {
+                (plain, cmp)
+            };
+            let words: Vec<u32> = [
+                0xBE84_0300, // s_mov_b32 s4, s0
+                0xBE85_0380, // s_mov_b32 s5, 0
+                0xF40C_0302,
+                0xFA00_0000, // s_load_dwordx8 s[12:19], s[4:5], 0x0
+                0xF408_0502,
+                0xFA00_0020, // s_load_dwordx4 s[20:23], s[4:5], 0x20
+                0xBE88_03FF,
+                0x0000_3088, // s_mov_b32 s8, 0x3088
+                0xBE89_03FF,
+                0x0054_0100, // s_mov_b32 s9, 0x0054_0100
+                0xBE8A_03FF,
+                0x1400_0080, // s_mov_b32 s10, 0x1400_0080
+                0xBE8B_03FF,
+                0x8000_0000, // s_mov_b32 s11, 0x8000_0000
+                0x7E04_02FF,
+                0x3E80_0000, // v_mov_b32 v2, 0.25 (comparison reference)
+                0x7E06_02F0, // v_mov_b32 v3, 0.5 (u)
+                0x7E08_02F0, // v_mov_b32 v4, 0.5 (v)
+                0x7E0E_0280, // v_mov_b32 v7, 0
+                0x7E10_0284, // v_mov_b32 v8, 4
+                0xBF8C_C07F, // s_waitcnt lgkmcnt(0)
+                first_sample[0],
+                first_sample[1],
+                second_sample[0],
+                second_sample[1],
+                0xBF8C_3F70, // s_waitcnt vmcnt(0)
+                0xE070_1000,
+                0x8005_0507, // buffer_store_dword v5, v7, s[20:23], 0 offen
+                0xE070_1000,
+                0x8005_0608, // buffer_store_dword v6, v8, s[20:23], 0 offen
+                0xBF81_0000, // s_endpgm
+            ]
+            .into_iter()
+            .collect();
+            let native = super::NativeProgram {
+                stage: super::HwStage::Cs,
+                wave64: false,
+                vgprs: 16,
+                layout: vec![crate::native::RootParam {
+                    root: crate::native::RootType::Table,
+                    table_offset_dwords: 0,
+                    sgprs: 1,
+                    base_register: 0,
+                    user_data: 0,
+                    slot: 0,
+                }],
+                used: vec![
+                    crate::native::UsedResource {
+                        kind: crate::native::ResourceType::Srv,
+                        root: crate::native::RootType::Table,
+                        table_offset_dwords: 0,
+                        lower_bound: 0,
+                        stride: 0,
+                        dwords: 8,
+                        user_data: 0,
+                        slot: 0,
+                    },
+                    crate::native::UsedResource {
+                        kind: crate::native::ResourceType::Uav,
+                        root: crate::native::RootType::Table,
+                        table_offset_dwords: 8,
+                        lower_bound: 0,
+                        stride: 0,
+                        dwords: 4,
+                        user_data: 0,
+                        slot: 0,
+                    },
+                ],
+                io: crate::native::StageIo::Cs(crate::native::ComputeIo {
+                    rsrc2: 0,
+                    threads: [1, 1, 1],
+                }),
+                code: words.iter().flat_map(|w| w.to_le_bytes()).collect(),
+            };
+            let p = crate::ir::build(&native.patched_code(), native.wave64, native.vgprs).unwrap();
+            let st = crate::structure::structure(&p).unwrap();
+            let res = crate::resource::track(&p, &native.layout, native.stage, Some(&st)).unwrap();
+            let io = crate::io::raise(&p, &native).unwrap();
+            let lowered = lower::lower(&lower::Parts {
+                native: &native,
+                p: &p,
+                st: &st,
+                io: &io,
+                res: &res,
+                inputs: Vec::new(),
+                outputs: Vec::new(),
+                prims: Vec::new(),
+                mesh_stride: 0,
+            })
+            .expect("lower");
+            assert_eq!(lowered.samplers, vec![[0x3088, 0x0054_0100, 0x1400_0080, 0x8000_0000]; 2]);
+            assert_eq!(lowered.cmp_samplers, if cmp_first { 0b01 } else { 0b10 });
+            let mut host = super::HostShader {
+                stage: native.stage,
+                dxil: lowered.dxil,
+                user_data: lowered.user_data,
+                static_samplers: lowered
+                    .samplers
+                    .iter()
+                    .enumerate()
+                    .map(|(n, &w)| {
+                        let mut s = super::StaticSampler::from_words(w);
+                        if lowered.cmp_samplers >> n & 1 != 0 {
+                            s.filter |= 0x80;
+                        }
+                        s
+                    })
+                    .collect(),
+                samplers: lowered.samplers,
+                root_cbvs: lowered.root_cbvs,
+                root_srvs: lowered.root_srvs,
+                root_uavs: lowered.root_uavs,
+                memory: lowered.memory,
+                memory_writes: lowered.memory_writes,
+                view_addresses: lowered.view_addresses,
+                heap: lowered.heap,
+                heap_writes: lowered.heap_writes,
+            };
+            assert_eq!(host.static_samplers[0].filter & 0x80 != 0, cmp_first);
+            assert_eq!(host.static_samplers[1].filter & 0x80 != 0, !cmp_first);
+            if let Ok(mut v) = super::validator::Validator::load(
+                super::validator::Validator::default_path().as_deref(),
+            ) {
+                v.validate(&mut host.dxil)
+                    .expect("DXIL validation failed");
+            } else {
+                eprintln!("no dxil.dll; validation skipped");
+            }
+            let _one = super::valu_tests::ONE_AT_A_TIME
+                .lock()
+                .unwrap_or_else(|e| e.into_inner());
+            // R32_FLOAT: comparison sampling is not defined on RGBA32F
+            // (drivers return the raw texel or zeros there).
+            let texel = [0.5f32];
+            let views = [
+                super::host::View::RedTexture(1, 1, &texel),
+                super::host::View::RawUav(2),
+            ];
+            for (label, warp) in [("hardware", false), ("warp", true)] {
+                let Ok(device) = super::host::Host::new(warp) else {
+                    continue;
+                };
+                let (root, pso) = device
+                    .compute_pipeline(&host)
+                    .unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}"));
+                let out = device
+                    .dispatch(
+                        &root,
+                        &pso,
+                        &super::host::Dispatch {
+                            roots: vec![(0, super::host::Root::Constants(vec![0]))],
+                            views: &views,
+                            samplers: &[],
+                            groups: [1, 1, 1],
+                        },
+                    )
+                    .unwrap_or_else(|e| panic!("{label}: dispatch failed: {e}"));
+                assert_eq!(f32::from_bits(out[0][0]), 0.5, "{label} plain sample (cmp_first={cmp_first})");
+                assert_eq!(f32::from_bits(out[0][1]), 1.0, "{label} cmp sample (cmp_first={cmp_first})");
+                tested_orders += 1;
+            }
+        }
+        let _ = tested_orders;
+    }
 }
--- a/crates/victory-shader/src/emit/host.rs
+++ b/crates/victory-shader/src/emit/host.rs
@@ -1168,6 +1168,10 @@
 pub enum View<'a> {
     /// An RGBA32F texture SRV (width, height, texels).
     Texture(u32, u32, &'a [[f32; 4]]),
+    /// An R32_FLOAT texture SRV (width, height, texels): a format that
+    /// supports comparison sampling and comparison gathers, which RGBA32F
+    /// does not.
+    RedTexture(u32, u32, &'a [f32]),
     /// An RGBA32F texture SRV with mips (width, height, levels, texels of
     /// each level in turn).
     Mipped(u32, u32, u32, &'a [[f32; 4]]),
@@ -1488,6 +1492,56 @@
                         list.ResourceBarrier(&[transition(
                             &tex,
                             D3D12_RESOURCE_STATE_COPY_DEST,
+                            D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,
+                        )]);
+                        dev.CreateShaderResourceView(&tex, None, at);
+                        keep.push(tex);
+                    }
+                    View::RedTexture(w, h, texels) => {
+                        let desc = texture_as(w, h, D3D12_RESOURCE_FLAG_NONE, DXGI_FORMAT_R32_FLOAT);
+                        let tex = make(
+                            D3D12_HEAP_TYPE_DEFAULT,
+                            &desc,
+                            D3D12_RESOURCE_STATE_COPY_DEST,
+                        )?;
+                        let pitch = (w as usize * 4).next_multiple_of(256);
+                        let upload = make(
+                            D3D12_HEAP_TYPE_UPLOAD,
+                            &buffer((pitch * h as usize) as u64, D3D12_RESOURCE_FLAG_NONE),
+                            D3D12_RESOURCE_STATE_GENERIC_READ,
+                        )?;
+                        let mut p = std::ptr::null_mut();
+                        upload.Map(0, None, Some(&mut p)).map_err(err)?;
+                        for y in 0..h as usize {
+                            let row = &texels[y * w as usize..(y + 1) * w as usize];
+                            std::ptr::copy_nonoverlapping(
+                                row.as_ptr().cast::<u8>(),
+                                p.cast::<u8>().add(y * pitch),
+                                row.len() * 4,
+                            );
+                        }
+                        upload.Unmap(0, None);
+                        let from = D3D12_TEXTURE_COPY_LOCATION {
+                            pResource: std::mem::transmute_copy(&upload),
+                            Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT,
+                            Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
+                                PlacedFootprint: D3D12_PLACED_SUBRESOURCE_FOOTPRINT {
+                                    Offset: 0,
+                                    Footprint: D3D12_SUBRESOURCE_FOOTPRINT {
+                                        Format: DXGI_FORMAT_R32_FLOAT,
+                                        Width: w,
+                                        Height: h,
+                                        Depth: 1,
+                                        RowPitch: pitch as u32,
+                                    },
+                                },
+                            },
+                        };
+                        list.CopyTextureRegion(&subresource(&tex), 0, 0, 0, &from, None);
+                        keep.push(upload);
+                        list.ResourceBarrier(&[transition(
+                            &tex,
+                            D3D12_RESOURCE_STATE_COPY_DEST,
                             D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,
                         )]);
                         dev.CreateShaderResourceView(&tex, None, at);

Unit tests only, no game files. AI-assisted (Claude ported it; I ran it on my machine).

**@⁠wwwwwwww3333333** on GitHub · 2026-11-24 23:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7147431523) This PR doesn't compile against the new main (70564ae0), so I ported it and ran it on AMD. The fix itself, `lower.rs` and `shader.rs` at cc0f47a, merges as is. The test needed two changes: 1. main's `HostShader` gained `root_uavs`, `memory`, `memory_writes`, `view_addresses`, `heap` and `heap_writes`, so the test's initializer now fills them from `lowered`. 2. The test samples an RGBA32F texture with a comparison sampler. That format doesn't support comparison sampling, so drivers return the raw texel or zeros: the 0.5 @⁠sinan-cmyk saw on NVIDIA, and 0.0 on this AMD card before. I added a `View::RedTexture` (an R32_FLOAT SRV) to the test harness and switched the test to it, with the same texel 0.5. Result on 70564ae0 + this, RX 6750 XT (RDNA2), Windows 11, Rust 1.98.1 MSVC: - `immediate_sampler_used_with_and_without_comparison_validates_and_runs` passes on the hardware adapter and WARP, with DXIL validation. Plain sample 0.5, comparison 1.0, both orders. - victory-shader: 210 passed, 0 failed (main alone: 209). - `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean. This removes main's `shortcut: one sampler used with and without comparison would need two static samplers; it becomes a comparison one`, which matters for shadow-map sampling. <details><summary>Patch against 70564ae0 (the PR's lowering + the ported test + the R32_FLOAT view)</summary> ```diff --- a/crates/victory-shader/src/emit/lower.rs +++ b/crates/victory-shader/src/emit/lower.rs @@ -4684,18 +4684,25 @@ .get(..4) .and_then(|w| w.try_into().ok()) .ok_or("a sampler constant")?; - let n = match self.samplers.iter().position(|w| *w == words) { + // Plain and comparison samples require distinct DXIL/D3D12 + // sampler bindings even when they share console sampler words. + let cmp = props.0 & 0x8000 != 0; + let n = match self.samplers.iter().enumerate().position(|(i, w)| { + *w == words && (i < 64 && self.s.cmp_samplers >> i & 1 != 0) == cmp + }) { Some(n) => n, None => { + let n = self.samplers.len(); + if cmp { + if n >= 64 { + return Err("too many immediate samplers"); + } + self.s.cmp_samplers |= 1 << n; + } self.samplers.push(words); - self.samplers.len() - 1 + n } }; - if props.0 & 0x8000 != 0 { - // shortcut: one sampler used with and without comparison - // would need two static samplers; it becomes a comparison one. - self.s.cmp_samplers |= 1 << n; - } Ok(self.s.sampler_handle(self.cur, n as u32)) } Source::Constant(_) => Err("a constant resource descriptor"), --- a/crates/victory-shader/src/emit/shader.rs +++ b/crates/victory-shader/src/emit/shader.rs @@ -417,7 +417,7 @@ 217, &[bind, i, f], ); - let cmp = if self.cmp_samplers >> n & 1 != 0 { + let cmp = if n < 64 && self.cmp_samplers >> n & 1 != 0 { 0x8000 } else { 0 @@ -626,7 +626,7 @@ let u = self.m.undef(p); let mut list = Vec::new(); for n in 0..self.samplers { - let kind = (self.cmp_samplers >> n & 1) as u32; + let kind = u32::from(n < 64 && self.cmp_samplers >> n & 1 != 0); let ops = vec![ Some(i32c(&mut self, n)), Some(self.m.md_value(u)), --- a/crates/victory-shader/src/emit/mod.rs +++ b/crates/victory-shader/src/emit/mod.rs @@ -454,7 +454,7 @@ .enumerate() .map(|(n, &w)| { let mut s = StaticSampler::from_words(w); - if l.cmp_samplers >> n & 1 != 0 { + if n < 64 && l.cmp_samplers >> n & 1 != 0 { s.filter |= 0x80; } s @@ -1157,4 +1157,182 @@ // Translated or refused with a reason; it must not panic. let _ = super::emit(&c, &native, &p, &st, &io, &res); } + + #[cfg(windows)] + #[test] + fn immediate_sampler_used_with_and_without_comparison_validates_and_runs() { + let mut tested_orders = 0; + for cmp_first in [false, true] { + let plain = [0xF09C_0108, 0x0043_0503]; // image_sample_lz v5, v[3:4], s[12:19], s[8:11] + let cmp = [0xF0BC_0108, 0x0043_0602]; // image_sample_c_lz v6, v[2:4], s[12:19], s[8:11] + let (first_sample, second_sample) = if cmp_first { + (cmp, plain) + } else { + (plain, cmp) + }; + let words: Vec<u32> = [ + 0xBE84_0300, // s_mov_b32 s4, s0 + 0xBE85_0380, // s_mov_b32 s5, 0 + 0xF40C_0302, + 0xFA00_0000, // s_load_dwordx8 s[12:19], s[4:5], 0x0 + 0xF408_0502, + 0xFA00_0020, // s_load_dwordx4 s[20:23], s[4:5], 0x20 + 0xBE88_03FF, + 0x0000_3088, // s_mov_b32 s8, 0x3088 + 0xBE89_03FF, + 0x0054_0100, // s_mov_b32 s9, 0x0054_0100 + 0xBE8A_03FF, + 0x1400_0080, // s_mov_b32 s10, 0x1400_0080 + 0xBE8B_03FF, + 0x8000_0000, // s_mov_b32 s11, 0x8000_0000 + 0x7E04_02FF, + 0x3E80_0000, // v_mov_b32 v2, 0.25 (comparison reference) + 0x7E06_02F0, // v_mov_b32 v3, 0.5 (u) + 0x7E08_02F0, // v_mov_b32 v4, 0.5 (v) + 0x7E0E_0280, // v_mov_b32 v7, 0 + 0x7E10_0284, // v_mov_b32 v8, 4 + 0xBF8C_C07F, // s_waitcnt lgkmcnt(0) + first_sample[0], + first_sample[1], + second_sample[0], + second_sample[1], + 0xBF8C_3F70, // s_waitcnt vmcnt(0) + 0xE070_1000, + 0x8005_0507, // buffer_store_dword v5, v7, s[20:23], 0 offen + 0xE070_1000, + 0x8005_0608, // buffer_store_dword v6, v8, s[20:23], 0 offen + 0xBF81_0000, // s_endpgm + ] + .into_iter() + .collect(); + let native = super::NativeProgram { + stage: super::HwStage::Cs, + wave64: false, + vgprs: 16, + layout: vec![crate::native::RootParam { + root: crate::native::RootType::Table, + table_offset_dwords: 0, + sgprs: 1, + base_register: 0, + user_data: 0, + slot: 0, + }], + used: vec![ + crate::native::UsedResource { + kind: crate::native::ResourceType::Srv, + root: crate::native::RootType::Table, + table_offset_dwords: 0, + lower_bound: 0, + stride: 0, + dwords: 8, + user_data: 0, + slot: 0, + }, + crate::native::UsedResource { + kind: crate::native::ResourceType::Uav, + root: crate::native::RootType::Table, + table_offset_dwords: 8, + lower_bound: 0, + stride: 0, + dwords: 4, + user_data: 0, + slot: 0, + }, + ], + io: crate::native::StageIo::Cs(crate::native::ComputeIo { + rsrc2: 0, + threads: [1, 1, 1], + }), + code: words.iter().flat_map(|w| w.to_le_bytes()).collect(), + }; + let p = crate::ir::build(&native.patched_code(), native.wave64, native.vgprs).unwrap(); + let st = crate::structure::structure(&p).unwrap(); + let res = crate::resource::track(&p, &native.layout, native.stage, Some(&st)).unwrap(); + let io = crate::io::raise(&p, &native).unwrap(); + let lowered = lower::lower(&lower::Parts { + native: &native, + p: &p, + st: &st, + io: &io, + res: &res, + inputs: Vec::new(), + outputs: Vec::new(), + prims: Vec::new(), + mesh_stride: 0, + }) + .expect("lower"); + assert_eq!(lowered.samplers, vec![[0x3088, 0x0054_0100, 0x1400_0080, 0x8000_0000]; 2]); + assert_eq!(lowered.cmp_samplers, if cmp_first { 0b01 } else { 0b10 }); + let mut host = super::HostShader { + stage: native.stage, + dxil: lowered.dxil, + user_data: lowered.user_data, + static_samplers: lowered + .samplers + .iter() + .enumerate() + .map(|(n, &w)| { + let mut s = super::StaticSampler::from_words(w); + if lowered.cmp_samplers >> n & 1 != 0 { + s.filter |= 0x80; + } + s + }) + .collect(), + samplers: lowered.samplers, + root_cbvs: lowered.root_cbvs, + root_srvs: lowered.root_srvs, + root_uavs: lowered.root_uavs, + memory: lowered.memory, + memory_writes: lowered.memory_writes, + view_addresses: lowered.view_addresses, + heap: lowered.heap, + heap_writes: lowered.heap_writes, + }; + assert_eq!(host.static_samplers[0].filter & 0x80 != 0, cmp_first); + assert_eq!(host.static_samplers[1].filter & 0x80 != 0, !cmp_first); + if let Ok(mut v) = super::validator::Validator::load( + super::validator::Validator::default_path().as_deref(), + ) { + v.validate(&mut host.dxil) + .expect("DXIL validation failed"); + } else { + eprintln!("no dxil.dll; validation skipped"); + } + let _one = super::valu_tests::ONE_AT_A_TIME + .lock() + .unwrap_or_else(|e| e.into_inner()); + // R32_FLOAT: comparison sampling is not defined on RGBA32F + // (drivers return the raw texel or zeros there). + let texel = [0.5f32]; + let views = [ + super::host::View::RedTexture(1, 1, &texel), + super::host::View::RawUav(2), + ]; + for (label, warp) in [("hardware", false), ("warp", true)] { + let Ok(device) = super::host::Host::new(warp) else { + continue; + }; + let (root, pso) = device + .compute_pipeline(&host) + .unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}")); + let out = device + .dispatch( + &root, + &pso, + &super::host::Dispatch { + roots: vec![(0, super::host::Root::Constants(vec![0]))], + views: &views, + samplers: &[], + groups: [1, 1, 1], + }, + ) + .unwrap_or_else(|e| panic!("{label}: dispatch failed: {e}")); + assert_eq!(f32::from_bits(out[0][0]), 0.5, "{label} plain sample (cmp_first={cmp_first})"); + assert_eq!(f32::from_bits(out[0][1]), 1.0, "{label} cmp sample (cmp_first={cmp_first})"); + tested_orders += 1; + } + } + let _ = tested_orders; + } } --- a/crates/victory-shader/src/emit/host.rs +++ b/crates/victory-shader/src/emit/host.rs @@ -1168,6 +1168,10 @@ pub enum View<'a> { /// An RGBA32F texture SRV (width, height, texels). Texture(u32, u32, &'a [[f32; 4]]), + /// An R32_FLOAT texture SRV (width, height, texels): a format that + /// supports comparison sampling and comparison gathers, which RGBA32F + /// does not. + RedTexture(u32, u32, &'a [f32]), /// An RGBA32F texture SRV with mips (width, height, levels, texels of /// each level in turn). Mipped(u32, u32, u32, &'a [[f32; 4]]), @@ -1488,6 +1492,56 @@ list.ResourceBarrier(&[transition( &tex, D3D12_RESOURCE_STATE_COPY_DEST, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, + )]); + dev.CreateShaderResourceView(&tex, None, at); + keep.push(tex); + } + View::RedTexture(w, h, texels) => { + let desc = texture_as(w, h, D3D12_RESOURCE_FLAG_NONE, DXGI_FORMAT_R32_FLOAT); + let tex = make( + D3D12_HEAP_TYPE_DEFAULT, + &desc, + D3D12_RESOURCE_STATE_COPY_DEST, + )?; + let pitch = (w as usize * 4).next_multiple_of(256); + let upload = make( + D3D12_HEAP_TYPE_UPLOAD, + &buffer((pitch * h as usize) as u64, D3D12_RESOURCE_FLAG_NONE), + D3D12_RESOURCE_STATE_GENERIC_READ, + )?; + let mut p = std::ptr::null_mut(); + upload.Map(0, None, Some(&mut p)).map_err(err)?; + for y in 0..h as usize { + let row = &texels[y * w as usize..(y + 1) * w as usize]; + std::ptr::copy_nonoverlapping( + row.as_ptr().cast::<u8>(), + p.cast::<u8>().add(y * pitch), + row.len() * 4, + ); + } + upload.Unmap(0, None); + let from = D3D12_TEXTURE_COPY_LOCATION { + pResource: std::mem::transmute_copy(&upload), + Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, + Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { + PlacedFootprint: D3D12_PLACED_SUBRESOURCE_FOOTPRINT { + Offset: 0, + Footprint: D3D12_SUBRESOURCE_FOOTPRINT { + Format: DXGI_FORMAT_R32_FLOAT, + Width: w, + Height: h, + Depth: 1, + RowPitch: pitch as u32, + }, + }, + }, + }; + list.CopyTextureRegion(&subresource(&tex), 0, 0, 0, &from, None); + keep.push(upload); + list.ResourceBarrier(&[transition( + &tex, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, )]); dev.CreateShaderResourceView(&tex, None, at); ``` </details> Unit tests only, no game files. AI-assisted (Claude ported it; I ran it on my machine).
Author
Owner

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

Thanks for diagnosing the RGBA32F comparison-sampling requirement and porting the test against 70564ae, @⁠wwwwwwww3333333 (and thanks again for catching it on Ada, @⁠sinan-cmyk)!

Rebased #1493 onto main (70564ae), kept the SamplerComparisonState change in crates/victory-shader/src/emit/shader.rs, updated immediate_sampler_used_with_and_without_comparison_validates_and_runs for range::build and the new HostShader fields, and added View::RedTexture (DXGI_FORMAT_R32_FLOAT) in crates/victory-shader/src/emit/host.rs for the test. Re-verified immediate_sampler_used_with_and_without_comparison_validates_and_runs (DXIL validation + RTX 4060 + WARP), workspace clippy (--all-targets and --all-features), and xtask policy checks.

**@⁠piyonchu** on GitHub · 2026-11-25 00:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7148040603) Thanks for diagnosing the `RGBA32F` comparison-sampling requirement and porting the test against `70564ae`, @⁠wwwwwwww3333333 (and thanks again for catching it on Ada, @⁠sinan-cmyk)! Rebased `#1493` onto `main` (`70564ae`), kept the `SamplerComparisonState` change in `crates/victory-shader/src/emit/shader.rs`, updated `immediate_sampler_used_with_and_without_comparison_validates_and_runs` for `range::build` and the new `HostShader` fields, and added `View::RedTexture` (`DXGI_FORMAT_R32_FLOAT`) in `crates/victory-shader/src/emit/host.rs` for the test. Re-verified `immediate_sampler_used_with_and_without_comparison_validates_and_runs` (DXIL validation + RTX 4060 + WARP), workspace `clippy` (`--all-targets` and `--all-features`), and `xtask` policy checks.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:28 UTC · original · edited 2026-11-25 20:19 UTC

Automated triage for the maintainers.

The rebased head merges cleanly. In crates/victory-shader/src/emit/shader.rs, the dx.resources sampler list now gives comparison samplers a %struct.SamplerComparisonState* undef and plain samplers a %struct.SamplerState* undef. That matches what dxc emits and agrees with the kind field (1) that main already writes. emit/mod.rs adds a GPU test that runs one immediate sampler with and without comparison, in both orders, on hardware and WARP, using a new View::RedTexture (R32_FLOAT) in emit/host.rs. This gives the comparison keying that main gained with #1477 real execution coverage. Two notes, neither blocking. The NVIDIA 0.5 result traced back to the RGBA32F test texture, so the test probably passes on main without the metadata change and does not pin it on its own. tested_orders is counted and then discarded. CI passes.

Reply to the author: thanks for the rebase. I reviewed the current head 7b68a8b. The RedTexture/TypedUav conflict is resolved without changing TypedUav.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7151953752) · edited 2026-11-25 20:19 UTC <!-- victory-triage v1 head=7b68a8bf501956bac671861e35c18939cc444d64 verdict=merge-candidate at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. The rebased head merges cleanly. In `crates/victory-shader/src/emit/shader.rs`, the `dx.resources` sampler list now gives comparison samplers a `%struct.SamplerComparisonState*` undef and plain samplers a `%struct.SamplerState*` undef. That matches what dxc emits and agrees with the kind field (1) that `main` already writes. `emit/mod.rs` adds a GPU test that runs one immediate sampler with and without comparison, in both orders, on hardware and WARP, using a new `View::RedTexture` (R32_FLOAT) in `emit/host.rs`. This gives the comparison keying that `main` gained with #1477 real execution coverage. Two notes, neither blocking. The NVIDIA 0.5 result traced back to the RGBA32F test texture, so the test probably passes on `main` without the metadata change and does not pin it on its own. `tested_orders` is counted and then discarded. CI passes. Reply to the author: thanks for the rebase. I reviewed the current head `7b68a8b`. The `RedTexture`/`TypedUav` conflict is resolved without changing `TypedUav`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠piyonchu on GitHub · 2026-11-25 03:58 UTC · original

Updated #1493 (4f32381):

  • Dropped all three redundant n < 64 guards in crates/victory-shader/src/emit/shader.rs and crates/victory-shader/src/emit/mod.rs.
  • Rebased onto main (940d32f) to pick up view_marks and the headless GPU test skip fixes (ccfb029/42363ab) so CI check runs cleanly.
  • Re-verified locally (cargo clippy, cargo test -p victory-shader --lib immediate_sampler_ 2/2 passed, cargo test -p xtask 6/6 passed).
**@⁠piyonchu** on GitHub · 2026-11-25 03:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7152418404) Updated `#1493` (`4f32381`): - Dropped all three redundant `n < 64` guards in `crates/victory-shader/src/emit/shader.rs` and `crates/victory-shader/src/emit/mod.rs`. - Rebased onto `main` (`940d32f`) to pick up `view_marks` and the headless GPU test skip fixes (`ccfb029`/`42363ab`) so CI `check` runs cleanly. - Re-verified locally (`cargo clippy`, `cargo test -p victory-shader --lib immediate_sampler_` 2/2 passed, `cargo test -p xtask` 6/6 passed).
Author
Owner

@⁠piyonchu on GitHub · 2026-11-25 19:46 UTC · original

Rebased onto main (13f91ca, commit 7b68a8b) resolving the View::RedTexture / View::TypedUav conflict in crates/victory-shader/src/emit/host.rs, and re-verified (cargo clippy, cargo test -p victory-shader --lib immediate_sampler_ 2/2 passed, cargo test -p xtask 6/6 passed).

**@⁠piyonchu** on GitHub · 2026-11-25 19:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7172743899) Rebased onto `main` (`13f91ca`, commit `7b68a8b`) resolving the `View::RedTexture` / `View::TypedUav` conflict in `crates/victory-shader/src/emit/host.rs`, and re-verified (`cargo clippy`, `cargo test -p victory-shader --lib immediate_sampler_` 2/2 passed, `cargo test -p xtask` 6/6 passed).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 18:42 UTC · original · requested changes

This breaks cargo test -p victory-shader on macOS/Linux — verified locally on the PR head merged into main (ffe310e):

error[E0433]: cannot find `validator` in `super`   (emit/mod.rs:876)
error[E0433]: cannot find `validator` in `super`   (emit/mod.rs:877)
error[E0433]: cannot find `valu_tests` in `super`  (emit/mod.rs:884)
error[E0433]: cannot find `host` in `super`        (emit/mod.rs:889, 890, 893, ...)

The new test in emit/mod.rs::tests references super::validator (#[cfg(windows)]), super::host (#[cfg(all(windows, any(test, feature = "host")))]) and super::valu_tests (#[cfg(all(test, windows))]), but the test itself is only #[cfg(test)] via the module. Gate the test with #[cfg(all(test, windows))] (or move it next to the other host-execution tests) and macOS goes green again.

Also note: #1477 fixes the same immediate-sampler comparison-mode problem and is mergeable as-is (with an in-tree test); whichever lands second will need to rebase.

**@⁠catminou4** on GitHub · 2026-11-24 18:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#pullrequestreview-6045235519) · **requested changes** This breaks `cargo test -p victory-shader` on macOS/Linux — verified locally on the PR head merged into main (`ffe310e`): ``` error[E0433]: cannot find `validator` in `super` (emit/mod.rs:876) error[E0433]: cannot find `validator` in `super` (emit/mod.rs:877) error[E0433]: cannot find `valu_tests` in `super` (emit/mod.rs:884) error[E0433]: cannot find `host` in `super` (emit/mod.rs:889, 890, 893, ...) ``` The new test in `emit/mod.rs::tests` references `super::validator` (`#[cfg(windows)]`), `super::host` (`#[cfg(all(windows, any(test, feature = "host")))]`) and `super::valu_tests` (`#[cfg(all(test, windows))]`), but the test itself is only `#[cfg(test)]` via the module. Gate the test with `#[cfg(all(test, windows))]` (or move it next to the other host-execution tests) and macOS goes green again. Also note: #1477 fixes the same immediate-sampler comparison-mode problem and is mergeable as-is (with an in-tree test); whichever lands second will need to rebase.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 17:23 UTC · original · approved these changes

Verified head 7b68a8bf501956bac671861e35c18939cc444d64 merged onto main (63bcca43) on Windows 11 (RTX 5090 + WARP, Rust 1.98.1 MSVC, SDK dxil.dll, dxc.exe, and D3D12 Debug Layer).

  • Clean merge onto main (and clean co-merge with #1734 in emit/host.rs).
  • cargo xtask policy (191 files ok), cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features), and immediate_sampler_ tests (2/2) all pass.
  • Checked emitted DXIL with dxc -dumpbin across plain-only, comparison-only, plain-first, and comparison-first shaders: emit/shader.rs:753-777 lazily emits only %struct.SamplerState (kind 0) or %struct.SamplerComparisonState (kind 1) as needed, matching annotateHandle properties and passing dxil.dll validation.
  • Ran an additional probe using a 2x2 View::RedTexture (DXGI_FORMAT_R32_FLOAT, verifying non-1x1 row-pitch upload) with both passing (ref = 0.25 < 0.5 -> 1.0) and failing (ref = 0.75 < 0.5 -> 0.0) comparison outcomes alongside plain sampling (0.5): both RTX 5090 and WARP passed with zero new D3D12 Debug Layer warnings/errors (ID3D12InfoQueue showed only main's pre-existing ID=1328 warning from View::RawUav).

Minor non-blocking nit: tested_orders at emit/mod.rs:1795, 1967, 1970 is incremented and then discarded with let _ = tested_orders; — it could either be asserted (> 0) or dropped.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 17:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#pullrequestreview-6078299834) · **approved these changes** Verified head `7b68a8bf501956bac671861e35c18939cc444d64` merged onto `main` (`63bcca43`) on Windows 11 (RTX 5090 + WARP, Rust 1.98.1 MSVC, SDK `dxil.dll`, `dxc.exe`, and D3D12 Debug Layer). - Clean merge onto `main` (and clean co-merge with `#1734` in `emit/host.rs`). - `cargo xtask policy` (`191 files ok`), `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`), and `immediate_sampler_` tests (2/2) all pass. - Checked emitted DXIL with `dxc -dumpbin` across plain-only, comparison-only, plain-first, and comparison-first shaders: `emit/shader.rs:753-777` lazily emits only `%struct.SamplerState` (kind `0`) or `%struct.SamplerComparisonState` (kind `1`) as needed, matching `annotateHandle` properties and passing `dxil.dll` validation. - Ran an additional probe using a `2x2` `View::RedTexture` (`DXGI_FORMAT_R32_FLOAT`, verifying non-1x1 row-pitch upload) with both passing (`ref = 0.25 < 0.5 -> 1.0`) and failing (`ref = 0.75 < 0.5 -> 0.0`) comparison outcomes alongside plain sampling (`0.5`): both RTX 5090 and WARP passed with zero new D3D12 Debug Layer warnings/errors (`ID3D12InfoQueue` showed only `main`'s pre-existing `ID=1328` warning from `View::RawUav`). Minor non-blocking nit: `tested_orders` at `emit/mod.rs:1795, 1967, 1970` is incremented and then discarded with `let _ = tested_orders;` — it could either be asserted (`> 0`) or dropped.
Author
Owner

@⁠upipibi on GitHub · 2026-11-26 20:59 UTC · original

RTX 3070 8 GB (Ampere, wave32), driver 616.56, Windows 11, rustc 1.98.1. PR head 7b68a8b vs main 63bcca4, each in its own tree and target dir, --locked, --test-threads=1.

Test (-p victory-shader --lib) main PR
immediate_sampler_used_with_and_without_comparison_validates_and_runs, 3 runs not on main (new in the PR) 3/3 pass (0.4-0.6 s each)
immediate_sampler_ filter 1 passed (a different, existing test) the new test plus that one, passing
Full lib suite (skipping the crashing test) 298 pass, 3 fail, 3 ignored 267 pass, 3 fail, 3 ignored (older tree base, fewer tests)

The earlier 0.5 vs 1.0 failure on the RTX 4070 does not reproduce here on this head. Failures also on main, not caused by the PR: heap_direct_texture_reads_mark_their_heap_index kills the test process (STATUS_ACCESS_VIOLATION), see #2571. a_heap_buffer_read_by_element_takes_the_views_stride and a_heap_buffer_read_where_no_buffer_view_is_reads_zeros fail on NVIDIA's structured-buffer reads, see #1835. gathers_at_a_level_match_the_hardware, see #2323. No nvlddmkm resets.

AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).

**@⁠upipibi** on GitHub · 2026-11-26 20:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1493#issuecomment-7203277663) RTX 3070 8 GB (Ampere, wave32), driver 616.56, Windows 11, rustc 1.98.1. PR head 7b68a8b vs main 63bcca4, each in its own tree and target dir, `--locked`, `--test-threads=1`. | Test (`-p victory-shader --lib`) | main | PR | | --- | --- | --- | | `immediate_sampler_used_with_and_without_comparison_validates_and_runs`, 3 runs | not on main (new in the PR) | 3/3 pass (0.4-0.6 s each) | | `immediate_sampler_` filter | 1 passed (a different, existing test) | the new test plus that one, passing | | Full lib suite (skipping the crashing test) | 298 pass, 3 fail, 3 ignored | 267 pass, 3 fail, 3 ignored (older tree base, fewer tests) | The earlier 0.5 vs 1.0 failure on the RTX 4070 does not reproduce here on this head. Failures also on main, not caused by the PR: `heap_direct_texture_reads_mark_their_heap_index` kills the test process (STATUS_ACCESS_VIOLATION), see #2571. `a_heap_buffer_read_by_element_takes_the_views_stride` and `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` fail on NVIDIA's structured-buffer reads, see #1835. `gathers_at_a_level_match_the_hardware`, see #2323. No nvlddmkm resets. AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1493/head:github-bot/gh-1493'
git switch 'github-bot/gh-1493'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1493'
git switch 'github-bot/gh-1493'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1493'
git switch 'github-bot/gh-1493'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1493'
git switch 'main'
git merge --squash 'github-bot/gh-1493'
git switch 'main'
git merge --ff-only 'github-bot/gh-1493'
git switch 'main'
git merge 'github-bot/gh-1493'
git push origin 'main'
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!1493
No description provided.