Direct DXIL: route pixel-shader v_cmp_class_f16 through quad-read ballot #3429
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3429"
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 ivall/xcl. Originally posted by Kalmarv on 2026-11-29T15:38:38Z.
What is in it
Routes Direct DXIL pixel-shader
V_CMP_CLASS_F16andV_CMPX_CLASS_F16through the shared VOPC quad-read operand ballot path instead of returning early viavopc_write(crates/xcl/src/gpu/dxil/lower_valu.rs):ty == "f16"withopn == "class", extracts the selected half and appliesABS/NEGtoua, then selects"f16_class"instead of callingvopc_writeearly.Variant::Plain, noguard_override),V_CMP_CLASS_F16/V_CMPX_CLASS_F16now quad-read VGPR operands withdx.op.quadReadLaneAt.i32(neverdx.op.quadOp, matching#134) and short-circuitDst::Nullwith zero quad reads."f16_class"insidevopc_condusingfclass16(ua)shifted/masked againstub, keeping the non-PS path identical.V_CMP_CLASS_F16,V_CMPX_CLASS_F16, andVDST=125null destination) and a real-GPU triangle-edge pixel-shader test (V_CMPX_CLASS_F16+V_CMP_CLASS_F16withNEG=1+ DPP quad derivatives) incrates/xcl/src/gpu/dxil/lanes.rs, guarded onrunner::wave32_supported()anddxc::location().Tested
direct_ps_cmp_class_f16_uses_quad_read_lane_at_not_quad_opfailed onorigin/mainbecauseV_CMP_CLASS_F16/V_CMPX_CLASS_F16emitteddx.op.quadOp.i32instead ofdx.op.quadReadLaneAt.i32.cargo test -p xcl --lib -- ps_ballot_tests:: cmp_class fclass): 15 passed, 0 failed (including both newV_CMP_CLASS_F16/V_CMPX_CLASS_F16unit and GPU triangle-edge tests).cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::with DXC 1.9.2609.5): 41 test binaries, 2717 passed, 0 failed, 49 ignored, 9 filtered; 27SKIPPED(22no wave64on RTX 5070 Ti, 3 per-lane#1426refused, 2no heap windows).Regression run
Baseline (
mainancestorf0e8fdd5c3942ddd399d5ee11384c8595c5aacff):This PR (
06c0be7d4610113b51f969bc189976b3209bc6e1):Not tested
dx.op.quadOpand presence ofdx.op.quadReadLaneAt.i32).test_title_runs_and_game_folder_is_untouchedanduma_driver::tests::(skipped during the workspace run).AI use
Used an AI coding assistant to locate the early
vopc_writereturn inlower_valu.rs, write the fix and synthetic unit/GPU tests, and verify the workspace tests and smoke run.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:44:39Z.
merge-check
base:
d0832e614fhead:
06c0be7d46merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 1 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: gpu::dxil::lanes::ps_ballot_tests::direct_ps_cmp_class_f16_uses_quad_read_lane_at_not_quad_op (the PR's own new test; lanes.rs:1254, "wave64 false V_CMP_CLASS_F16: PS VOPC must quad-read VGPR operands via quadReadLaneAt"). It can't fail on main, where the test doesn't exist; it fails because main's ps_masks now gives this compare a form without quad reads (finding 1).
review: read the whole diff (lower_valu.rs, lanes.rs tests). It changes the default path: every pixel shader with a plain
v_cmp_class_f16/v_cmpx_class_f16compiles differently. The claim about main is right: today that instruction leaves early throughvopc_write->write_mask->ballot_ps, which emitsquadOp(the AMD compiler crash of #134). Findings: (1) the PR is based 201 commits behind main, and main has since gainedps_masks(f4ee8ac5), which gives a compare read only byv_cndmaska form with no quad reads. The PR now routes class_f16 through that too, so the new test's assertion thatdx.op.quadReadLaneAt.i32appears (theV_CMP(X)_CLASS_F16+v_cndmask+expcases) contradicts main's sibling test of the same shape withV_CMP_LT_F32, which asserts no quad reads. The test result above confirms it. A test whose mask is really read (e.g. by DPP under EXEC) would cover the quad-read path. (2)gpu_direct_ps_cmp_class_f16_preserves_helper_lanes…should also pass on main (main'squadOpballot includes helper lanes too) and doesn't reproduce the AMD crash, so it adds coverage but isn't a regression test. (3) Not in the description: class_f16 now also gets the cheaperps_masksforms (correct by the same reasoning as the other compares). (4) AI use names no tool or model; the subject usesdxil:, not a repo area. (5) #1980 edits the same class_f16 lines (OP_SEL[1] for the mask), so whichever merges second conflicts. Fine: abs/neg are applied before the quad reads (pure per-lane functions),vopc_condignores the modifiers forf16_classso they aren't applied twice, non-pixel shaders and SDWA/DPP variants get the same IR as before, and the HLSL path already sends class_f16 throughQuadReadLaneAt.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (2256ccd9): 1516 -> 1677 frames shown (111 %; 60 presents per 2 s in both), peak commit 18133 -> 17057 MB, no device removal, no crash.verdict: not yet: the PR's new test fails on the merge with current main (rebase onto main and test a compare whose mask is really read)
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.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T05:44:25Z.
Review: COMMENTED
Review of
06c0be7d: 1 finding(s). These are on lines outside the diff:crates/xcl/src/gpu/dxil/lower_valu.rs:1263: The fix only routes Plain, non-guarded f16 class compares onto the quadReadLaneAt path. Any PS VOPC that misses the gate (SDWA/DPP forms like v_cmp_class_f16_sdwa, or a setguard_override) still goesvopc_write->write_mask->ballot_psand emits dx.op.quadOp. A pixel shader running such a compare on a value derived from v_readfirstlane still hits the #134 amdxc64 crash pattern on RDNA2/3/4. Changingballot_ps(orwrite_maskin PS) to read across the quad with quadReadLaneAt would cover every VOPC at once instead of adding one opcode/type at a time.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.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:13:56Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:39:59Z.
Closing: predates
main'sps_masks(f4ee8ac5), fails merged withmain, and has 0 safe checks; will re-open cleanly againstps_masksonly if a title hits it.Pull request closed