Direct DXIL: quad-read VGPR operands for 64-bit pixel-shader compares #3405

Closed
Kalmarv wants to merge 1 commit from upstream-pr/3405 into main
Kalmarv commented 2026-11-29 13:53:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T13:53:41Z.


What changed

  • In crates/xcl/src/gpu/dxil/lower_wide.rs (Lw::valu64):
    • Added f64_pair and vopc64_cond helpers for 64-bit compares (u64, i64, f64, and class_f64).
    • In pixel shaders (self.is_pixel() && self.guard_override.is_none() && opn != "f"), lowered 64-bit v_cmp_* and v_cmpx_* by quad-reading VGPR operand dwords via dx.op.quadReadLaneAt, evaluating each quad member's predicate with its EXEC bit, and collecting the wave mask via ballot_ps_quad, matching 32-bit/16-bit compares in lower_valu::vopc and the HLSL path's quad_bits.
    • Short-circuited Dst::Null in pixel-shader 64-bit compares and avoided redundant quadReadLaneAt calls on SGPR / constant operands or on the constant upper dword of v_cmp_class_f64's 32-bit class mask.
  • Added CPU and GPU tests in crates/xcl/src/gpu/dxil/lower_wide.rs (mod cmp64_tests):
    • ps_cmp64_uses_quad_operand_reads_without_quad_op: translates and validates both wave32 and wave64 Direct DXIL pixel shaders containing a 64-bit v_readfirstlane_b32 + v_cmp_eq_u64 waterfall loop, v_cmp_gt_i64, v_cmp_lt_f64, v_cmp_class_f64 (both SGPR and VGPR class masks), Dst::Null, and v_cmpx_ne_u64, asserting zero dx.op.quadOp instructions and presence of dx.op.quadReadLaneAt.
    • gpu_ps_cmp64_waterfall_and_class_f64: capability-guarded real D3D12 GPU triangle draw verifying all 64 pixels (including diagonal edge quads with helper lanes) execute the Direct DXIL wave32 pixel shader and produce exact expected RGBA outputs.

Why

Previously, 64-bit pixel-shader compares (v_cmp_* / v_cmpx_* for u64, i64, f64, and class_f64) in lower_wide::valu64 bypassed the pixel-shader quad-operand ballot path and called write_mask -> ballot_ps, which emits dx.op.quadOp (QuadReadAcross*) on the compare predicate result. On AMD RDNA2/3/4 (amdxc64), quadOp on a value derived from WaveReadLaneAt (such as a 64-bit v_readfirstlane_b32 + v_cmp_eq_u64 descriptor/address waterfall loop in a pixel shader) crashes the driver compiler at PSO creation (the exact pattern already avoided for 32-bit compares in lower_valu::vopc). Quad-reading only the VGPR operands with dx.op.quadReadLaneAt and building the ballot with ballot_ps_quad eliminates dx.op.quadOp on the predicate while keeping helper lanes accurate across every 2x2 quad.

Tested

Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), rustc 1.99.0, DXC 1.9.2609.5 (XCL_DXC_DIR).

  • cargo check --workspace --all-targets: passed (0 errors, 0 new warnings).
  • cargo test -p xcl --lib -- gpu::dxil::lower_wide::cmp64_tests:: --test-threads=1: 4 passed, 0 failed, 0 ignored.
  • cargo build --workspace and cargo test --workspace -- --test-threads=4: all workspace unit, e2e (D3D12 debug layer + DRED), and tiling tests passed (exit 0).
  • 150 s real-title smoke at PR head (2c93bbff567a8ca8403f052e7866e2a747595993):
xcl-smoke v1
commit: 2c93bbff567a8ca8403f052e7866e2a747595993
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 34119 MB
  • Ancestor main baseline (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):
xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB

Not tested

  • AMD RDNA2/3/4 hardware directly (tested on NVIDIA RTX 5070 Ti; the absence of dx.op.quadOp is verified by DXIL validation and disassembly for both wave32 and wave64).
  • Wave64 pixel-shader GPU draw execution (RTX 5070 Ti is wave32-only; wave64 translation, DXIL validation, and disassembly are verified on CPU).

AI use

Written and verified with an AI coding assistant (Antigravity); all code, tests, workspace runs, and smoke results were directly reviewed and executed on local hardware.

<!-- greyfinch-sync:ivall/xcl:issue:5551383742 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T13:53:41Z. --- **What changed** - In [crates/xcl/src/gpu/dxil/lower_wide.rs](crates/xcl/src/gpu/dxil/lower_wide.rs) (`Lw::valu64`): - Added `f64_pair` and `vopc64_cond` helpers for 64-bit compares (`u64`, `i64`, `f64`, and `class_f64`). - In pixel shaders (`self.is_pixel() && self.guard_override.is_none() && opn != "f"`), lowered 64-bit `v_cmp_*` and `v_cmpx_*` by quad-reading VGPR operand dwords via `dx.op.quadReadLaneAt`, evaluating each quad member's predicate with its `EXEC` bit, and collecting the wave mask via `ballot_ps_quad`, matching 32-bit/16-bit compares in `lower_valu::vopc` and the HLSL path's `quad_bits`. - Short-circuited `Dst::Null` in pixel-shader 64-bit compares and avoided redundant `quadReadLaneAt` calls on SGPR / constant operands or on the constant upper dword of `v_cmp_class_f64`'s 32-bit class mask. - Added CPU and GPU tests in `crates/xcl/src/gpu/dxil/lower_wide.rs` (`mod cmp64_tests`): - `ps_cmp64_uses_quad_operand_reads_without_quad_op`: translates and validates both wave32 and wave64 Direct DXIL pixel shaders containing a 64-bit `v_readfirstlane_b32` + `v_cmp_eq_u64` waterfall loop, `v_cmp_gt_i64`, `v_cmp_lt_f64`, `v_cmp_class_f64` (both SGPR and VGPR class masks), `Dst::Null`, and `v_cmpx_ne_u64`, asserting zero `dx.op.quadOp` instructions and presence of `dx.op.quadReadLaneAt`. - `gpu_ps_cmp64_waterfall_and_class_f64`: capability-guarded real D3D12 GPU triangle draw verifying all 64 pixels (including diagonal edge quads with helper lanes) execute the Direct DXIL wave32 pixel shader and produce exact expected RGBA outputs. **Why** Previously, 64-bit pixel-shader compares (`v_cmp_*` / `v_cmpx_*` for `u64`, `i64`, `f64`, and `class_f64`) in `lower_wide::valu64` bypassed the pixel-shader quad-operand ballot path and called `write_mask` -> `ballot_ps`, which emits `dx.op.quadOp` (`QuadReadAcross*`) on the compare predicate result. On AMD RDNA2/3/4 (`amdxc64`), `quadOp` on a value derived from `WaveReadLaneAt` (such as a 64-bit `v_readfirstlane_b32` + `v_cmp_eq_u64` descriptor/address waterfall loop in a pixel shader) crashes the driver compiler at PSO creation (the exact pattern already avoided for 32-bit compares in `lower_valu::vopc`). Quad-reading only the VGPR operands with `dx.op.quadReadLaneAt` and building the ballot with `ballot_ps_quad` eliminates `dx.op.quadOp` on the predicate while keeping helper lanes accurate across every 2x2 quad. **Tested** Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), `rustc 1.99.0`, DXC 1.9.2609.5 (`XCL_DXC_DIR`). - `cargo check --workspace --all-targets`: passed (0 errors, 0 new warnings). - `cargo test -p xcl --lib -- gpu::dxil::lower_wide::cmp64_tests:: --test-threads=1`: 4 passed, 0 failed, 0 ignored. - `cargo build --workspace` and `cargo test --workspace -- --test-threads=4`: all workspace unit, e2e (D3D12 debug layer + DRED), and tiling tests passed (exit 0). - 150 s real-title smoke at PR head (`2c93bbff567a8ca8403f052e7866e2a747595993`): ``` xcl-smoke v1 commit: 2c93bbff567a8ca8403f052e7866e2a747595993 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1566 (PresentX 1566) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 34119 MB ``` - Ancestor `main` baseline (`f0e8fdd5c3942ddd399d5ee11384c8595c5aacff`): ``` xcl-smoke v1 commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1695 (PresentX 1695) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31546 MB ``` **Not tested** - AMD RDNA2/3/4 hardware directly (tested on NVIDIA RTX 5070 Ti; the absence of `dx.op.quadOp` is verified by DXIL validation and disassembly for both wave32 and wave64). - Wave64 pixel-shader GPU draw execution (RTX 5070 Ti is wave32-only; wave64 translation, DXIL validation, and disassembly are verified on CPU). **AI use** Written and verified with an AI coding assistant (Antigravity); all code, tests, workspace runs, and smoke results were directly reviewed and executed on local hardware.
saintwolf commented 2026-11-29 14:20:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-29T14:20:46Z.


Reviewed and tested at 2c93bbff.

Looks solid — clean quad-operand-read lowering for 64-bit PS compares (u64, i64, f64, class_f64) with good DXIL validation and GPU waterfall coverage. One tiny nit: when opn is "t" or "tru", both a_vgpr and b_vgpr are false, so the 4-iteration for p in 0..4 loop still evaluates vopc64_cond 4 times instead of short-circuiting to true.

Tested locally

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0, DXC 1.8.2502.11.
  • cargo test -p xcl --lib gpu::dxil::lower_wide::cmp64_tests:: -- --test-threads=1: 4 passed, 0 failed (including ps_cmp64_uses_quad_operand_reads_without_quad_op and gpu_ps_cmp64_waterfall_and_class_f64).

AI use

  • Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.
<!-- greyfinch-sync:ivall/xcl:comment:7257230964 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405#issuecomment-7257230964). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-29T14:20:46Z. --- Reviewed and tested at `2c93bbff`. Looks solid — clean quad-operand-read lowering for 64-bit PS compares (`u64`, `i64`, `f64`, `class_f64`) with good DXIL validation and GPU waterfall coverage. One tiny nit: when `opn` is `"t"` or `"tru"`, both `a_vgpr` and `b_vgpr` are `false`, so the 4-iteration `for p in 0..4` loop still evaluates `vopc64_cond` 4 times instead of short-circuiting to `true`. ### Tested locally - Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver `32.0.16.2140`), AMD Ryzen 7 7800X3D, `rustc 1.100.0`, DXC `1.8.2502.11`. - `cargo test -p xcl --lib gpu::dxil::lower_wide::cmp64_tests:: -- --test-threads=1`: **4 passed, 0 failed** (including `ps_cmp64_uses_quad_operand_reads_without_quad_op` and `gpu_ps_cmp64_waterfall_and_class_f64`). ### AI use - Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.
Foniass commented 2026-12-01 04:22:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:22:18Z.


merge-check
base: d0832e614f
head: 2c93bbff56
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (lower_wide.rs, +276/-28). Every 64-bit pixel-shader v_cmp/v_cmpx changes form on the default direct path. The PR is based 259 commits behind main (before ps_masks, f4ee8ac5) and merges cleanly, but the new path doesn't follow main's ps_masks rules. Findings: (1) helper-lane bits can be lost (from reading). The new quad loop (lower_wide.rs ~903-923 in the merged tree) takes each quad member's bit from this lane's own copy of EXEC (lanebit_at(el, eh, lp)) and writes ballot_ps_quad(q) directly. After an earlier compare in a ps_masks local form, live lanes' copies of EXEC lack the helper lanes' bits, so the 64-bit mask drops them. After a v_cmpx or saveexec, helper lanes then stop and derivatives go wrong. Main's 32-bit path ORs in the lane's own bit for exactly this case (ballot_ps_local(own_bit), lower_valu.rs ~1369-1374) and calls note_own_bit, and main's current ballot_ps route for 64-bit compares keeps those bits, so this is a regression once merged. (2) Cost on the default path: up to 16 quadReadLaneAt and 4 compare evaluations per 64-bit compare (four f64 compares for _f64) versus 3 quadOp + 1 ballot on main, with ps_masks' cheaper forms never consulted even when only v_cndmask reads the mask. (3) The GPU test passes on NVIDIA either way and checks no output that depends on helper lanes, so it shows neither the AMD crash nor the helper-lane behaviour. (4) AI use says only "Antigravity", no model. Fine: f64 abs/neg are applied after the quad reads, the class mask reads only its low dword, constants and SGPRs aren't quad-read, Dst::Null returns early, and the tests still pass on main's ps_masks (64-bit compares bypass it), unlike #3429's. The PR's red CI (8 title_textures tests) was already red on its base.
performance: 60 s smoke of a retail title, main d0832e61 vs this merge (719c25a9): 1516 -> 1680 frames shown (110 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 17148 MB, 0 device removals, 0 crashes. Not shown here: whether the title's pixel shaders use 64-bit compares under a local-form EXEC.
verdict: not yet: once merged with main's ps_masks the new 64-bit path drops helper lanes' bits (finding 1; main's 32-bit path ORs in the own bit for this), and it skips ps_masks' cheaper forms
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7300666002 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405#issuecomment-7300666002). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:22:18Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: 2c93bbff567a8ca8403f052e7866e2a747595993 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (lower_wide.rs, +276/-28). Every 64-bit pixel-shader `v_cmp`/`v_cmpx` changes form on the default direct path. The PR is based 259 commits behind main (before `ps_masks`, f4ee8ac5) and merges cleanly, but the new path doesn't follow main's ps_masks rules. Findings: (1) helper-lane bits can be lost (from reading). The new quad loop (lower_wide.rs ~903-923 in the merged tree) takes each quad member's bit from this lane's own copy of EXEC (`lanebit_at(el, eh, lp)`) and writes `ballot_ps_quad(q)` directly. After an earlier compare in a ps_masks local form, live lanes' copies of EXEC lack the helper lanes' bits, so the 64-bit mask drops them. After a `v_cmpx` or saveexec, helper lanes then stop and derivatives go wrong. Main's 32-bit path ORs in the lane's own bit for exactly this case (`ballot_ps_local(own_bit)`, lower_valu.rs ~1369-1374) and calls `note_own_bit`, and main's current `ballot_ps` route for 64-bit compares keeps those bits, so this is a regression once merged. (2) Cost on the default path: up to 16 `quadReadLaneAt` and 4 compare evaluations per 64-bit compare (four f64 compares for `_f64`) versus 3 `quadOp` + 1 ballot on main, with ps_masks' cheaper forms never consulted even when only `v_cndmask` reads the mask. (3) The GPU test passes on NVIDIA either way and checks no output that depends on helper lanes, so it shows neither the AMD crash nor the helper-lane behaviour. (4) AI use says only "Antigravity", no model. Fine: f64 abs/neg are applied after the quad reads, the class mask reads only its low dword, constants and SGPRs aren't quad-read, `Dst::Null` returns early, and the tests still pass on main's ps_masks (64-bit compares bypass it), unlike #3429's. The PR's red CI (8 title_textures tests) was already red on its base. performance: 60 s smoke of a retail title, main d0832e61 vs this merge (719c25a9): 1516 -> 1680 frames shown (110 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 17148 MB, 0 device removals, 0 crashes. Not shown here: whether the title's pixel shaders use 64-bit compares under a local-form EXEC. verdict: not yet: once merged with main's ps_masks the new 64-bit path drops helper lanes' bits (finding 1; main's 32-bit path ORs in the own bit for this), and it skips ps_masks' cheaper forms hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
bmjask commented 2026-12-02 04:19:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T04:19:50Z.

Review: COMMENTED


Review of 2c93bbff: 2 finding(s). 1 are inline. These are on lines outside the diff:

crates/xcl/src/gpu/dxil/lower_wide.rs:953: In the same valu64, v_mad_u64_u32 / v_mad_i64_i32 still write their carry through write_mask -> ballot_ps -> dx.op.quadOp, so 64-bit address math in a pixel shader can still put quadOp on a WaveReadLaneAt-derived predicate. In a PS waterfall (v_readfirstlane_b32 s0, v2 then v_mad_u64_u32 v[4:5], s[6:7], s0, v1, v[8:9]), the carry depends on s0 from WaveReadLaneAt, so ballot_ps emits QuadReadAcross* on it. That's the amdxc64 PSO-creation crash this PR describes, still reachable through the function it touches. The HLSL path applies quad_bits in its shared mask writer for every mask, which would be the equivalent fix here.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6144702820 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405#pullrequestreview-6144702820). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T04:19:50Z. **Review:** COMMENTED --- Review of `2c93bbff`: 2 finding(s). 1 are inline. These are on lines outside the diff: **`crates/xcl/src/gpu/dxil/lower_wide.rs:953`**: In the same `valu64`, `v_mad_u64_u32` / `v_mad_i64_i32` still write their carry through `write_mask` -> `ballot_ps` -> `dx.op.quadOp`, so 64-bit address math in a pixel shader can still put quadOp on a `WaveReadLaneAt`-derived predicate. In a PS waterfall (`v_readfirstlane_b32 s0, v2` then `v_mad_u64_u32 v[4:5], s[6:7], s0, v1, v[8:9]`), the carry depends on s0 from WaveReadLaneAt, so `ballot_ps` emits QuadReadAcross* on it. That's the amdxc64 PSO-creation crash this PR describes, still reachable through the function it touches. The HLSL path applies `quad_bits` in its shared mask writer for every mask, which would be the equivalent fix here. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 04:19:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T04:19:51Z.

Code review location: crates/xcl/src/gpu/dxil/lower_wide.rs; line 873

@@ -828,38 +858,71 @@ impl Lw {
             }
         }
         let u64v = |s: &mut Self, i: usize| s.pack64(lh[i].0, lh[i].1);
-        let f64v = |s: &mut Self, i: usize| {
-            let mut hi = lh[i].1;
-            if m.abs[i.min(2)] {
-                hi = s.andc(hi, 0x7FFF_FFFF);
-            }
-            if m.neg[i.min(2)] {
-                let k = s.c(0x8000_0000);
-                hi = s.xor(hi, k);
-            }
-            s.mkd(lh[i].0, hi)
-        };
+        let f64v = |s: &mut Self, i: usize| s.f64_pair(lh[i], &m, i);
         let dst = outs.first().map(|o| Self::dst_of(d, o)).unwrap_or(Dst::Null);
         if let Some(rest) = name.strip_prefix("v_cmpx_").or_else(|| name.strip_prefix("v_cmp_")) {
             let (opn, ty) = rest.rsplit_once('_').ok_or_else(|| format!("{}: VOPC", rdna2::format(d)))?;
+            if lh.len() < 2 {
+                return err(d, "VOPC 64");
+            }
             let dst = if name.starts_with("v_cmpx_") { Dst::S(126) } else { dst };
-            if opn == "class" && ty == "f64" {
-                let x = f64v(self, 0);
-                let cls = self.fclass64(x);
-                let s = self.bin(BinOp::LShr, lh[1].0, cls);
-                let s = self.andc(s, 1);
-                let cond = self.nz(s);
-                self.write_mask(&dst, cond);
+            // Pixel shaders (#134): quad-read the compare's VGPR operands rather than its
+            // predicate result (AMD RDNA2/3/4 amdxc64 crashes on quadOp of values derived
+            // from WaveReadLaneAt, e.g. 64-bit v_readfirstlane waterfall loops with v_cmp_eq_u64).
+            if self.is_pixel() && self.guard_override.is_none() && opn != "f" {
+                if matches!(dst, Dst::Null) && matches!(ty, "f64" | "i64" | "u64") {

Not certain about this one: the pixel-shader Dst::Null short-circuit returns Ok before the predicate is checked. So v_cmp_<op>_u64 null, ... with an <op> that cmp64 doesn't support lowers silently to nothing in a pixel shader, but returns a "VOPC 64" error in every other stage, which hides an unhandled opcode in PS only. Checking the predicate before the short-circuit keeps the behaviour the same across stages.

<!-- greyfinch-sync:ivall/xcl:review-comment:4764689095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405#discussion_r4764689095). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T04:19:51Z. **Code review location:** `crates/xcl/src/gpu/dxil/lower_wide.rs`; line 873 ~~~~diff @@ -828,38 +858,71 @@ impl Lw { } } let u64v = |s: &mut Self, i: usize| s.pack64(lh[i].0, lh[i].1); - let f64v = |s: &mut Self, i: usize| { - let mut hi = lh[i].1; - if m.abs[i.min(2)] { - hi = s.andc(hi, 0x7FFF_FFFF); - } - if m.neg[i.min(2)] { - let k = s.c(0x8000_0000); - hi = s.xor(hi, k); - } - s.mkd(lh[i].0, hi) - }; + let f64v = |s: &mut Self, i: usize| s.f64_pair(lh[i], &m, i); let dst = outs.first().map(|o| Self::dst_of(d, o)).unwrap_or(Dst::Null); if let Some(rest) = name.strip_prefix("v_cmpx_").or_else(|| name.strip_prefix("v_cmp_")) { let (opn, ty) = rest.rsplit_once('_').ok_or_else(|| format!("{}: VOPC", rdna2::format(d)))?; + if lh.len() < 2 { + return err(d, "VOPC 64"); + } let dst = if name.starts_with("v_cmpx_") { Dst::S(126) } else { dst }; - if opn == "class" && ty == "f64" { - let x = f64v(self, 0); - let cls = self.fclass64(x); - let s = self.bin(BinOp::LShr, lh[1].0, cls); - let s = self.andc(s, 1); - let cond = self.nz(s); - self.write_mask(&dst, cond); + // Pixel shaders (#134): quad-read the compare's VGPR operands rather than its + // predicate result (AMD RDNA2/3/4 amdxc64 crashes on quadOp of values derived + // from WaveReadLaneAt, e.g. 64-bit v_readfirstlane waterfall loops with v_cmp_eq_u64). + if self.is_pixel() && self.guard_override.is_none() && opn != "f" { + if matches!(dst, Dst::Null) && matches!(ty, "f64" | "i64" | "u64") { ~~~~ --- Not certain about this one: the pixel-shader `Dst::Null` short-circuit returns Ok before the predicate is checked. So `v_cmp_<op>_u64 null, ...` with an `<op>` that `cmp64` doesn't support lowers silently to nothing in a pixel shader, but returns a "VOPC 64" error in every other stage, which hides an unhandled opcode in PS only. Checking the predicate before the short-circuit keeps the behaviour the same across stages.
bmjask commented 2026-12-02 14:14:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:14:28Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7348217498 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405#issuecomment-7348217498). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:14:28Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Kalmarv commented 2026-12-02 19:39:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:39:48Z.


Closing: predates main's ps_masks (f4ee8ac5), drops helper-lane bits under ps_masks, and has 0 safe checks; will re-open cleanly against ps_masks only if a title hits it.

<!-- greyfinch-sync:ivall/xcl:comment:7356526880 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3405#issuecomment-7356526880). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T19:39:48Z. --- Closing: predates `main`'s `ps_masks` (`f4ee8ac5`), drops helper-lane bits under `ps_masks`, and has 0 safe checks; will re-open cleanly against `ps_masks` only if a title hits it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
xcl-dev/xcl!3405
No description provided.