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

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

@⁠Decodere on GitHub · 2026-11-25 20:52 UTC · original
Decodere:fix-dxil-ps-live-lanes-675 → main · +175 −5 · 2 files · 1 commits · open

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.
**@⁠Decodere** on GitHub · 2026-11-25 20:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2501) `Decodere:fix-dxil-ps-live-lanes-675` → `main` · +175 −5 · 2 files · 1 commits · open 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 #675
Part of #1401
Part of #1833

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:15 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 21:03 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 21:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/2501#issuecomment-7174551292) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 21:08 UTC · original

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.

**@⁠SlopTart** on GitHub · 2026-11-25 21:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/2501#issuecomment-7174661996) `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.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 21:07 UTC · original · edited 2026-11-25 22:02 UTC

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:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010; XCL_SPLIT_WAVE64 unset): gpu_direct_ps_readfirstlane_and_mask_live_on_triangle_edges, direct_ps_readfirstlane_filters_exec_by_live_lanes and direct_ps_mask_and_scc_counts_live_lanes_only ok. 701 passed, 2 failed; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on main. Same skip count as main (6).
  • RTX 3060 (driver 32.0.16.1088): the same 3 tests ok; 703 passed, 0 failed.

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.

**@⁠DarkPanda69** on GitHub · 2026-11-25 21:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2501#issuecomment-7174644623) · edited 2026-11-25 22:02 UTC **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`: - **RX 9070 XT** (RDNA4, driver 32.0.32029.2010; `XCL_SPLIT_WAVE64` unset): `gpu_direct_ps_readfirstlane_and_mask_live_on_triangle_edges`, `direct_ps_readfirstlane_filters_exec_by_live_lanes` and `direct_ps_mask_and_scc_counts_live_lanes_only` ok. 701 passed, 2 failed; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on `main`. Same skip count as `main` (6). - **RTX 3060** (driver 32.0.16.1088): the same 3 tests ok; 703 passed, 0 failed. 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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 04:16 UTC · original · edited 2026-11-26 04:20 UTC

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.

**@⁠luckyteagirl** on GitHub · 2026-11-26 04:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/2501#issuecomment-7182451874) · edited 2026-11-26 04:20 UTC 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.
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/2501/head:github-bot/gh-2501'
git switch 'github-bot/gh-2501'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2501'
git switch 'github-bot/gh-2501'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2501'
git switch 'github-bot/gh-2501'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2501'
git switch 'main'
git merge --squash 'github-bot/gh-2501'
git switch 'main'
git merge --ff-only 'github-bot/gh-2501'
git switch 'main'
git merge 'github-bot/gh-2501'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.