Skip to content

Per-lane: track the SCC of mixed mask and number operations - #1866

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
Kalmarv:per-lane-mixed-mask
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
Kalmarv:per-lane-mixed-mask

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Pipodi's point 2 on #1745: a scalar bitwise operation or compare that reads a mask (VCC, EXEC, a compare result) together with an SGPR the analysis can't track. The per-lane lowering takes that operation as a mask and extracts each lane's bit, while the analysis dropped the mask and classified SCC as uniform. So a branch or select on that SCC went per lane where the console tests the whole word once for the wave. The fix gives the untracked operand a lane atom, so the existing whole-wave checks see these operations and refuse them where the condition differs across lanes. @gefydev handed this point to us on #1269 (#1269 (comment)).

What is in it

  • crates/xcl/src/gpu/recomp/lane_masks.rs: a mask operation with one untracked operand keeps a lane atom for that operand instead of losing the mask.
  • crates/xcl/src/gpu/recomp/lower.rs: the whole-wave guard reads the same mask-valued SCC.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: GPU and CPU tests. A wave32 compute program sets the low 16 bits of VCC, ANDs VCC with an all-ones input SGPR and branches on SCC; further cases cover a scalar select and a mixed compare.

Tested

  • Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, Rust 1.99.0 (MSVC x64), release, DXC 1.9.2609.5.
  • cargo test --release --workspace -- --test-threads=4 on 33b1b33: 960 passed, 0 failed, 43 ignored. Twelve tests printed 22 SKIPPED messages (no native wave64, heap windows, the existing f16 exclusions). The mixed-mask GPU test ran without a skip.
  • The GPU test on unchanged main c4d37be: lane 16 reads 0 in the per-lane form where HLSL gives 1 (lanes 16 to 31 differ). On 33b1b33: HLSL gives 1 in all 32 lanes, and the per-lane translator refuses the branch.
  • The compute pack, with the same native wave settings and four switch-selected memory windows: main takes 316 of 2,689 programs per lane, and so does this change, with the same programs and the same DXIL sizes. The whole-wave check is the first refusal for 1,771 programs before and 1,769 after, because two programs now stop at a later check.
  • The case was first found by a Z3 check of per-lane DXIL against the HLSL form, then confirmed on the GPU.

Regression run

scripts/smoke.ps1, the same retail title for 60 s each, one after the other on the machine under Tested, release builds from clean trees.

main 689f2db (this PR's base):

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1235 (PresentX 1235)
presents per 2 s (last 3): 9 12 35
device removals: 0
crashes: 0
peak commit: 26475 MB

this PR, 438d420:

xcl-smoke v1
commit: 438d4203ea60d1a19c64dcd8af4f9248c0334aa6
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1280 (PresentX 1280)
presents per 2 s (last 3): 7 32 42
device removals: 0
crashes: 0
peak commit: 26990 MB

PR vs main: 1280 / 1235 frames (104 %), peak commit 26990 / 26475 MB (102 %); device removals 0 and crashes 0 on the PR run, 0 and 0 on main.

The tests under Tested ran on 33b1b33, this change before its rebase onto main 689f2db; the rebase applied without conflicts.

Not tested

  • Linux, on our side. AMD with native wave64 (@DarkPanda69) and an RTX 3070 (@upipibi) were tested by others; their results are in the comments.
  • A second launch-ABI difference seen on main in the same test harness, not fixed here: a wave32 kernel launched with EXEC = fffffffe gives s0 = 0 per lane where HLSL gives 5. We have not seen it in a retail program.
  • World loading: a 60 s run ends before it.

AI use

OpenAI Codex (GPT-6.2) wrote the patch and the tests and ran the suite, the GPU tests and the pack count. A separate Codex session built the Z3 check that found the case. Claude Code (Claude Opus 5.5) ran the regression pair and wrote this description; no person reviewed the code before posting.

🤖 Generated with Claude Code

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Same on Ampere: RTX 3070 8 GB (32-lane waves), driver 616.56, Windows 11, debug, 33b1b33 merged onto main 689f2db.

  • a_branch_on_a_mixed_mask_matches_the_hlsl_path_on_the_gpu: passes, 2 of 2 runs.
  • gpu::recomp::l* (lower, lower_dxil, lane_masks): 57 passed, 0 failed.

AI-assisted (Claude Code). Synthetic tests only.

@DarkPanda69

DarkPanda69 commented Nov 24, 2026 •

Copy link
Copy Markdown

AMD run with native 64-lane waves, which this PR lists as not tested (the other report here is Ampere). Updated for head 438d420 (first run was on 33b1b33, same result).

Tested: pass, head 438d420 applied on main 20cf130, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, waves 32..64: 262 passed, 0 failed, 18 ignored. a_branch_on_a_mixed_mask_matches_the_hlsl_path_on_the_gpu ok, not skipped. The 6 SKIPPED lines (per-lane form refused for some f16/f32 programs) are the same on main.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 262 passed, 0 failed, 18 ignored. Same test ok; the SKIPPED lines are the same as on main.

Not tested: Linux; the whole workspace suite.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

The per-lane lowering extracts a bit from a numeric operand when a bitwise operation or compare also reads a mask. Give the unknown operand a lane atom in the mask analysis so its branch and select guards see the same mask-valued SCC.
@Kalmarv
Kalmarv force-pushed the per-lane-mixed-mask branch from 33b1b33 to 438d420 Compare November 24, 2026 23:03
@thehollowedone

Copy link
Copy Markdown

Independent split-wave64 check of 438d420 on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11.

In a synthetic compute shader, only lane 63 set VCC. A 64-bit AND with a user SGPR pair supplied the SCC branch condition. With the parent analysis, the shader entered the per-lane path and 63 of 64 lanes wrote the wrong branch result when the SGPR pair kept bit 63. With XCL_DIRECT_DXIL=1 XCL_PER_LANE=1 on this PR, the runtime selected per-instruction DXIL. All 64 writes matched HLSL both when the mask kept bit 63 (1) and when it discarded it (0). The 32 untouched words matched in both dispatches.

cargo test --offline --locked -p xcl --lib mixed -- --nocapture --test-threads=1: 2 passed, zero skips, including the stock wave32 test and the split-wave64 extension.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the GPU test and drafted this report.

@raylitebull
raylitebull merged commit 62265d3 into xcl-dev:main Nov 24, 2026
2 of 3 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
, xcl-dev#1876, xcl-dev#1866)

Brings main to full parity with upstream/main (62265d3):
- xcl-dev#1005: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx
- xcl-dev#1053: opt-in fast-boot env vars (Bink intro skip, frame interval override, device type, TTS mute)
- xcl-dev#1876: float v_cmpx through xcl-dev#1426 lowering keeps lanes outside EXEC out
- xcl-dev#1866: track SCC of mixed mask and number operations

Conflict in crates/xcl/src/hle/xgameruntime/api.rs resolved by keeping both the
in-process Wine XAsync path and upstream's XCL_MUTE_TTS XAccessibility path.

Assisted-by: Antigravity (Gemini 4)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
Pulls in xcl-dev#1836 (graphics and two-pass PSO disk cache + lazy MS/GS + shader build coalescing), xcl-dev#1930 (DXIL CSE across discard), xcl-dev#1900, xcl-dev#1005, xcl-dev#1053, xcl-dev#1864, xcl-dev#1866, xcl-dev#1869, xcl-dev#1876, and xcl-dev#1898 while keeping our RDNA4 MSAA clamp (xcl-dev#1908), wave64 graphics Direct DXIL guard (xcl-dev#1913), atomic writable-range tracking, static-sampler cache keys, and 4M-group indirect dispatch clamp.
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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.

6 participants