Repository navigation
Conversation
|
Reviewed and tested at Looks solid — clean quad-operand-read lowering for 64-bit PS compares ( Tested locally
AI use
|
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
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.
| // 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") { |
There was a problem hiding this comment.
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.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
|
Closing: predates |
What changed
Lw::valu64):f64_pairandvopc64_condhelpers for 64-bit compares (u64,i64,f64, andclass_f64).self.is_pixel() && self.guard_override.is_none() && opn != "f"), lowered 64-bitv_cmp_*andv_cmpx_*by quad-reading VGPR operand dwords viadx.op.quadReadLaneAt, evaluating each quad member's predicate with itsEXECbit, and collecting the wave mask viaballot_ps_quad, matching 32-bit/16-bit compares inlower_valu::vopcand the HLSL path'squad_bits.Dst::Nullin pixel-shader 64-bit compares and avoided redundantquadReadLaneAtcalls on SGPR / constant operands or on the constant upper dword ofv_cmp_class_f64's 32-bit class mask.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-bitv_readfirstlane_b32+v_cmp_eq_u64waterfall loop,v_cmp_gt_i64,v_cmp_lt_f64,v_cmp_class_f64(both SGPR and VGPR class masks),Dst::Null, andv_cmpx_ne_u64, asserting zerodx.op.quadOpinstructions and presence ofdx.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_*foru64,i64,f64, andclass_f64) inlower_wide::valu64bypassed the pixel-shader quad-operand ballot path and calledwrite_mask->ballot_ps, which emitsdx.op.quadOp(QuadReadAcross*) on the compare predicate result. On AMD RDNA2/3/4 (amdxc64),quadOpon a value derived fromWaveReadLaneAt(such as a 64-bitv_readfirstlane_b32+v_cmp_eq_u64descriptor/address waterfall loop in a pixel shader) crashes the driver compiler at PSO creation (the exact pattern already avoided for 32-bit compares inlower_valu::vopc). Quad-reading only the VGPR operands withdx.op.quadReadLaneAtand building the ballot withballot_ps_quadeliminatesdx.op.quadOpon 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 --workspaceandcargo test --workspace -- --test-threads=4: all workspace unit, e2e (D3D12 debug layer + DRED), and tiling tests passed (exit 0).2c93bbff567a8ca8403f052e7866e2a747595993):mainbaseline (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):Not tested
dx.op.quadOpis verified by DXIL validation and disassembly for both wave32 and wave64).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.