Skip to content

dxil: prefer live lanes in PS v_readfirstlane and lane-mask SCC tests - #2501

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-dxil-ps-live-lanes-675
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-dxil-ps-live-lanes-675

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

Bring the direct DXIL pixel-shader lowering into parity with the HLSL recompiler's live-lane handling for helper lanes under s_wqm (v_readfirstlane and VCC/EXEC lane-mask SCC checks). Part of #675. Part of #1401. Part of #1833.

What is in it

  • crates/xcl/src/gpu/dxil/lanes.rs:
    • Added Lw::is_pixel (reused in ballot and rla) and Lw::live_lanes, which emits WaveActiveBallot(true) and selects the active half in wave32-in-64 mode (matching HLSL ballot(true)).
    • Updated Lw::first_lane so pixel shaders intersect (lo, hi) with live_lanes() before firstbitlow when any live lane bit is set, falling back to raw (lo, hi) when only helper lanes are set (parity with HLSL first_lane_live; non-pixel stages unchanged).
  • crates/xcl/src/gpu/dxil/lower.rs:
    • Added Lw::ps_mask_live_scc matching pixel-shader ENC_SOP2 s_and_b32, s_andn2_b32, s_and_b64, and s_andn2_b64 instructions with VCC (106) or EXEC (126) as SSRC0, SSRC1, or SDST.
    • Updated Lw::salu and Lw::salu64 to mask only the SCC zero-check by live_lanes() when ps_mask_live_scc holds, leaving the destination register write (write32 / write64) unmasked (parity with HLSL mask_live, extended to 64-bit masks).
  • crates/xcl/src/gpu/dxil/lanes.rs (ps_ballot_tests):
    • direct_ps_readfirstlane_filters_exec_by_live_lanes: pure-CPU DXC 1.9 validation and disassembly check for wave32/wave64 PS plus compute negative control.
    • direct_ps_mask_and_scc_counts_live_lanes_only: pure-CPU DXC 1.9 validation and disassembly check for wave32/wave64 PS s_and/s_andn2 touching VCC/EXEC (including SDST=NULL) plus non-mask PS and compute negative controls.
    • gpu_direct_ps_readfirstlane_and_mask_live_on_triangle_edges: draws two triangles sharing a diagonal (32x32) on wave32 (and wave64 when supported) verifying v_readfirstlane selects a live lane (2.0), helper-only s_andn2 sets SCC == 0 while preserving helper bits in the destination and live-lane s_and sets SCC == 1, and a 6-pass march loop exits at 6.0 on all 1024/1024 pixels (cleanly skipped on WARP/CI without wave32).

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14, 32-lane waves), Intel Core i5-11400F, Windows 11 Home build 26200, Rust 1.100.0, DXC / dxil.dll 1.9.2609.5, release build.
  • Failing-first before the lanes.rs / lower.rs fix (on origin/main e0d93c8): both new pure-CPU/DXC tests failed (0 passed, 2 failed).
  • Targeted cargo test --release -p xcl --lib -- gpu::dxil::lanes::ps_ballot_tests:: --nocapture:
    • RTX 4060: 7 passed, 0 failed, 0 ignored (0.43 s, 0 skipped; 1024/1024 pixels passed for both wave64 = false and wave64 = true).
    • XCL_ADAPTER=warp: 7 passed, 0 failed, 0 ignored (0.05 s; all 5 pure-CPU/DXC tests passed with 0 skips; the 2 GPU edge-draw tests cleanly skipped with no wave32 / no wave64).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture (RTX 4060): 1424 passed, 0 failed, 46 ignored across 37 test binaries (184/184 gpu::dxil::* passed; 29 pre-existing SKIPPED GPU/environment checks: 21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in ps_ballot_tests).

Regression run
main:

xcl-smoke v1
commit: e0d93c84ad8253f6e17738d14741c1bab7061127
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1579 (PresentX 1579)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 13985 MB

PR:

xcl-smoke v1
commit: de915b5adb519c9aa342107fb05fbe56540541ff
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1542 (PresentX 1542)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13984 MB

Not tested

  • Native 64-lane pixel-shader execution on AMD RDNA2/3/4 hardware (where driver helper-lane register zeroing occurs in loops) and D3D12 debug-layer tests requiring d3d12SDKLayers.dll.

AI use

  • Google Antigravity (Gemini 4 Neon) implemented is_pixel/live_lanes/first_lane in lanes.rs and ps_mask_live_scc in lower.rs, wrote the DXC-validated and GPU edge tests, ran the test and smoke suites, and drafted this PR description.

Bring the direct DXIL pixel-shader lowering into parity with the HLSL
recompiler's live-lane handling for helper lanes under s_wqm:

- lanes.rs: add Lw::is_pixel (reused in ballot and rla) and
  Lw::live_lanes (WaveActiveBallot(true), selecting the active half in
  wave32-in-64 mode). Update Lw::first_lane so pixel shaders intersect
  EXEC with live lanes before firstbitlow when any live lane is set,
  falling back to the raw mask otherwise (parity with first_lane_live).
- lower.rs: add Lw::ps_mask_live_scc and mask only the SCC zero-check
  (leaving the destination register unmasked) for pixel-shader ENC_SOP2
  s_and_b32 / s_andn2_b32 / s_and_b64 / s_andn2_b64 instructions that
  reference VCC (106) or EXEC (126) (parity with mask_live, extended to
  64-bit masks).
- lanes.rs (ps_ballot_tests): add DXC-validated disassembly tests with
  non-mask and compute negative controls plus a two-triangle edge GPU
  test covering v_readfirstlane, helper-only s_andn2 SCC, unmasked
  destination preservation, and the 6-pass march loop shape.

Part of xcl-dev#675
Part of xcl-dev#1401
Part of xcl-dev#1833

Assisted-by: Google Antigravity (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@DarkPanda69

DarkPanda69 commented Nov 25, 2026 •

Copy link
Copy Markdown

Correction: the PR test translates its wave64 pass in the native form (wave64: true, split: false), and that pass ran and passed on the RX 9070 XT. Which wave size the driver gives a pixel shader is the driver's choice, though, and the test does not check it, so this report does not show that the pass ran in 64-lane waves.

AMD RDNA4 run of the native (split: false) wave64 pixel-shader form, plus an RTX 3060: all 3 new tests pass on both cards, and nothing else changes.

Diff applied on main 6d12f58, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, run on main and with the PR, card chosen with XCL_ADAPTER:

No other test changes result on either card.

Not tested: the D3D12 debug-layer tests (d3d12SDKLayers.dll), RDNA2/3, retail pixel shaders.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@SlopTart

Copy link
Copy Markdown

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of the new mask/readfirstlane tests (direct_ps_mask_and_scc_counts_live_lanes_only, direct_ps_readfirstlane_filters_exec_by_live_lanes, gpu_direct_ps_readfirstlane_and_mask_live_on_triangle_edges, helper): 4 passed.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 26, 2026
…ev#2446, xcl-dev#2503

Integrates direct DXIL graphics shader flags (xcl-dev#2451), PS live-lane
v_readfirstlane/SCC (xcl-dev#2501), MSG_GS_DONE emit/cut (xcl-dev#2485), VS/PS scalar
reload CSE (xcl-dev#2446), and per-lane V_CMP EXEC masking (xcl-dev#2503).

Assisted-by: Antigravity (Gemini 4 Neon)
@luckyteagirl

luckyteagirl commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

RX 6800M focused validation on exact PR head de915b5adb519c9aa342107fb05fbe56540541ff:

  • Windows 11 Home build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC 1.9.2609.5.
  • XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, pinned XCL_DXC_DIR; cargo test --locked -p xcl --lib gpu::dxil::lanes::ps_ballot_tests::gpu_direct_ps_readfirstlane_and_mask_live_on_triangle_edges -- --exact --test-threads=1 --show-output.
  • Result: 1 passed, 0 failed, 0 ignored, 0 explicit SKIPPED (1324 filtered out). The test's rendered-pixel assertions passed. Isolated guarded run exited 0 without a memory-guard stop.

The fixture does not print its selected adapter or report the driver's physical pixel-shader wave width. The XCL_ADAPTER selector and required-GPU mode were set, but this result should not be read as proof that the driver executed 64-lane pixel waves. This was one focused debug test, not a full suite or retail-title run.

AI use: Codex (exact model name not exposed to me) with a Luna subagent prepared and ran the test and drafted this report; I checked the exact head and log before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants