Skip to content

Recompiler: Wave32 pixel mask writes kill one SGPR, not a pair - #2781

Merged
throny merged 1 commit into
xcl-dev:mainfrom
itsSio:recomp/wave32-pixel-mask-carry
Nov 29, 2026
Merged

throny merged 1 commit into
xcl-dev:mainfrom
itsSio:recomp/wave32-pixel-mask-carry

Conversation

@itsSio

@itsSio itsSio commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

In a Wave32 pixel shader, VALU mask writes (carry or compare SDST) and scalar SAVEEXEC / WREXEC write a single 32-bit SGPR, whereas x64_masks liveness used the wave64 pair kill sets from the ISA tables. A subsequent Wave32 carry into s20 therefore killed a live mask in s21, causing the earlier s21 carry to be lowered with ballot_px_local and lose WQM helper-lane bits at triangle edges (Fixes #2584).

Carried onto main (b49be183) from akimfomin/xcl@d3e7725 with his narrow liveness fix and regression tests preserved, adding the gpu_ready() guard on the new GPU test so WARP CI skips cleanly, and omitting the unrelated README line.

What is in it

  • Recompiler: Wave32 pixel mask writes kill one SGPR, not a pair (e1e5bbf0):
    • crates/xcl/src/gpu/recomp/x64_masks.rs: add liveness_uses (masking Wave32 V_*, SAVEEXEC, and WREXEC kill sets to one dword) and full_mask_destinations (preserving the existing pair rule while forcing full ballots when a Wave32 pixel mask's single output word can still be read whole), plus unit test wave32_carry_into_s20_preserves_a_whole_read_of_s21.
    • crates/xcl/src/gpu/recomp/emit.rs & crates/xcl/src/gpu/recomp/mod.rs: switch Em from mask_whole_live (live & (3 << n) == 0) to full_mask_destinations (live & (1 << n) == 0), passing opt.wave64 for pixel shaders and true for split wave64 compute/mesh/kernel shaders.
    • crates/xcl/src/gpu/recomp/tests.rs: add GPU regression test gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges (with gpu_ready() guard for WARP CI).

Tested
Commit e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3 (based on main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7), clean checkouts on both PCs, debug builds for workspace tests and release build for the retail smoke run.

  • Pre-fix repro on PC 1 (RTX 5080, b49be183 + new GPU test only, DXC 1.9.2609.5, XCL_ADAPTER=NVIDIA): gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges FAILED as expected (mask popcount at 0: left 12.0, right 16.0).
  • WARP check on PC 1 (XCL_ADAPTER=warp): gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges skips cleanly (SKIPPED: no wave64, 0.03 s); fork Windows CI green (2m43s).
  • PC 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, rustc 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA).
    • cargo build --workspace: exit 0.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1437 passed, 0 failed, 47 ignored (both new tests pass).
    • SKIPPED: 26 (no wave64, 3 refused wave32 per-lane f16/cvt forms #1426, no heap windows, driver cache requiring Developer Mode).
  • PC 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, rustc 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA).
    • cargo build --workspace: exit 0.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1437 passed, 0 failed, 47 ignored (both new tests pass).
    • SKIPPED: 29 (same 26 as PC 1 plus 3 requiring d3d12SDKLayers.dll).

Regression run

main (b49be183, RTX 5080, release):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5080
title: c12269de
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 10006 MB

PR (e1e5bbf0, RTX 5080, release):

xcl-smoke v1
commit: e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3
gpu: NVIDIA GeForce RTX 5080
title: c12269de
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 11310 MB

Not tested

  • AMD / Intel GPUs on this exact rebased commit (upstream testers verified the underlying d3e7725 patch on RX 9070 XT, RX 6800M, and RTX 3060 in #2584).
  • Retail scripts/smoke.ps1 on the RTX 2080 SUPER, Linux / Wine / vkd3d-proton, and past-world-load gameplay scenes (the 60 s smoke stays in loading and checks for regressions).

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Claude Opus 5.5 (High)): audited #2584, carried akimfomin's fix onto main (preserving Co-authored-by), reviewed the diff, and ran the pre-fix repro.
  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): diagnosed the WARP CI failure, added the gpu_ready() guard in e1e5bbf0, ran the dual-PC workspace suites and paired RTX 5080 b49be183/e1e5bbf0 smokes.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated verification, ran scripts/pr_check.py --local, and prepared this description.
  • Upstream fix and tests originally authored by akimfomin (assisted by OpenAI Codex (GPT-6) per #2584).

In a Wave32 pixel shader a VALU mask write (a carry or compare SDST) and
a scalar SAVEEXEC / WREXEC write one dword: write_mask calls write32
when the program is not wave64. The liveness that decides whether a
mask needs the helper lanes' quad reads (x64_masks) took its kill sets
from the ISA tables, which describe the wave64 pair. So
`v_add_co_u32 v3, s20, ...` was taken to overwrite s21 as well; an
earlier carry into s21 that `v_bcnt_u32_b32 v4, s21, 0` reads later was
taken for a lane-local mask and built with ballot_px_local, and with
WQM on its helper lanes' bits were missing at triangle edges (xcl-dev#2584).

For Wave32 pixel shaders those writes now kill one dword, and a mask
write takes the full ballot when either this liveness or the existing
pair rule says its destination can be read whole, so no mask that took
the full ballot before loses it. Split wave64 and wave64 pixel shaders
keep the pair rule; the direct DXIL path (by_pc) is unchanged.

Tests: x64_masks::tests::wave32_carry_into_s20_preserves_a_whole_read_of_s21
and gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges,
which draws the issue's program on two triangles.

Fix and tests by akimfomin (akimfomin/xcl@d3e7725), carried onto main
without its README line.

Refs xcl-dev#2584

Co-authored-by: akimfomin <akim.fomin@mail.ru>
Assisted-by: Google Antigravity CLI (Claude Opus 5.5 (High))
@SzczepanGrela

Copy link
Copy Markdown

Confirmed the new pixel regression and its passing result on RX 9070 under Wine at exact head e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3.

Tested

  • Main control: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 with only the new GPU test appended to recomp/tests.rs. Main's translator and mask analysis were unchanged. The head had no local source changes.
  • AMD Radeon RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, Mesa 26.3.1-arch3.5, GE-Proton11-12 Wine 11.0 Staging, vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, release x86_64-pc-windows-gnu.
  • XCL_ADAPTER="AMD Radeon RX 9070", XCL_REQUIRE_GPU=wave64, XCL_DIRECT_DXIL=0, XCL_NETWORK=0. Fresh process and XCL DXIL cache directory for each run; vkd3d shader cache disabled.

Invoked the libtest binaries directly through GE-Proton Wine:

--exact gpu::recomp::tests::gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges --nocapture --test-threads=1
  • Main control: failed 3/3 times at mask popcount at 32, with left: 10.0, right: 16.0. Each run: 0 passed, 1 failed, 0 ignored, 0 skip markers.
  • Exact head: passed 3/3 fresh-process runs. Each run: 1 passed, 0 failed, 0 ignored, 0 skip markers. The fixture checks coverage and matching mask counts over all 1,024 pixels.
  • Related GPU checks: basic VS/PS drawing, the existing helper-lane edge and pixel-mask loop tests, and all three split-wave64 local/whole/partial-write/diverging-mask tests: 6 passed, 0 failed, 0 ignored, 0 skip markers per revision, each test in its own serial process.
  • Filter gpu::recomp::x64_masks::tests::, at both --test-threads=1 and 4: main control 19 passed / 0 failed / 1 ignored; head 20 passed / 0 failed / 1 ignored. The ignored test is the existing manual bench_whole_live_out benchmark. No skip markers.

All 22 raw summaries, the three repeated failure messages, source inventories and executable hashes were checked after testing.

Not tested

Native Windows, other GPUs, the Direct-DXIL graphics path, retail workloads, smoke runs, full workspace suite, or performance. The ignored benchmark was not run.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, ran and checked the paired synthetic tests, and drafted this report. Publication authorized by the account owner.

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Ran the Wave32 pixel mask tests at e1e5bbf0:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib wave32_carry_into_s20 -- --nocapture
1 passed; 0 failed; 0 ignored; 1337 filtered out      (exit 0)

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges -- --nocapture
1 passed; 0 failed; 0 ignored; 1337 filtered out      (exit 0)

Both new tests pass here. The GPU regression test runs on the real adapter, so the adjacent mask survives the Wave32 carry at triangle edges on this Blackwell part too.

What this adds: the author tested an RTX 5080 and an RTX 2080 SUPER. This is a third NVIDIA host, with a different driver and DXC version, and the thread has no report from another machine.

Not tested: the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, WARP, Wine, release profile, title data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@DarkPanda69

Copy link
Copy Markdown

AMD and NVIDIA run on this exact rebased commit (listed as untested): the regression test passes on an RX 9070 XT and an RTX 3060, and nothing else changes in the GPU suite.

Head e1e5bbf applied on main b49be18, debug, Windows 11 Pro 26200, card chosen with XCL_ADAPTER:

Not tested: Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@tiagonleal

Copy link
Copy Markdown
Contributor

Suite on RTX 5070 Ti (Windows 11) at e1e5bbf0: 1433 passed, 4 failed (the fuzz out-of-memory ones, same on main); both new tests pass

Tested

  • Head e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3 (parent main b49be183), clean detached worktree, built as is, debug. PR open and head unchanged when I started.
  • RTX 5070 Ti 16 GB (driver 32.0.16.1742), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, rustc 1.100.0 (0ef1bc386 2026-11-09). NVIDIA profile for xcl.exe: shader heap 1024 MB. DXC in use: Windows SDK 1.8.2502.11.
  • cargo build --workspace: ok. cargo test --workspace --no-fail-fast -- --test-threads=4: 1433 passed, 4 failed, 47 ignored.
  • 25 lines contain SKIPPED: 21 "no wave64", 3 wave32 per-lane forms refused (f16 arithmetic, f16 packed, f32 conversions), 1 heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, each CreateComputePipelineState: Not enough memory resources are available to complete this operation. (0x8007000E). They fail the same way on main b49be183 (cargo test -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu: 0 passed, 4 failed).
  • New tests plus their module: cargo test -p xcl --lib -- gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges wave32_carry_into_s20_preserves_a_whole_read_of_s21 x64_masks:: --nocapture --test-threads=1: 21 passed, 0 failed, 1 ignored (bench_whole_live_out, a manual benchmark). Both new tests are among the 21; the GPU one ran and was not skipped.

Not tested

  • The retail title, AMD or Intel, a release-profile suite, Wine or Linux. One machine, one suite run.
  • The GPU test on main, to see it fail on this card. The PR and other reports show it does.

AI use

  • Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Sonnet 5.5) ran the builds and tests and wrote this; I checked it.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2781 at head e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3 (1 commit; exact parent & merge-base: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (e1e5bbf0)

Command Result
cargo test --release -p xcl --lib wave32_carry_into_s20_preserves_a_whole_read_of_s21 -- --nocapture 1 passed; 0 failed; 0 ignored; 1337 filtered out (0.00s)
cargo test --release -p xcl --lib gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges -- --nocapture (3 consecutive runs, on-GPU RTX 4060) 1 passed; 0 failed; 0 ignored; 1337 filtered out × 3 (0.30s, 0.23s, 0.23s)
cargo test --release -p xcl --lib gpu::recomp:: 403 passed; 0 failed; 20 ignored; 915 filtered out (5.06s; Wave64-only and #1426-refused subcases self-skipped as expected on Wave32-only RTX 4060)
cargo build --release -p xcl --bin xcl Clean build (1m 11s, exit 0)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):

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

PR #2781 (e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3):

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

Runtime log observations (xcl.log)

  • 9223 log lines, 0 [ERROR] / device-removal / panic lines.
  • Final draw/memory telemetry in log: 19648 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 13991 MB committed by the process; video memory 6115 MB local, 4650 MB non-local.

Limits of coverage

  • Single-SGPR Wave32 pixel mask liveness (wave32_carry_into_s20_preserves_a_whole_read_of_s21) and WQM helper-lane preservation at triangle edges (gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges, 3/3 on-GPU RTX 4060 runs) passed directly alongside the full gpu::recomp:: suite (403/0/20).
  • Wave64-only GPU subcases in gpu::recomp:: self-skipped on the Wave32-only RTX 4060, and the 60 s retail smoke on title: 29640639 ran against the warm shader cache as an end-to-end non-regression check (no visual triangle-edge screenshot diff was captured in live gameplay). Frame-count delta vs. the cached parent smoke (1629 vs. 1518) reflects normal single-run startup variance and is not attributed to this PR.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…xcl-dev#2818 (loop budget, wave32 mask kill, SDWA SDST, u32x2 routing)
@JJAutoCompare

Copy link
Copy Markdown

Tested

Clean e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3 on Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC and DXC/DXIL 1.9.2602.17. Built using cargo test -j 2 -p xcl --lib --no-run in a dedicated target. Used checked-in synthetic inputs only.

  • CPU: gpu::recomp::x64_masks::tests::, plus exact libtest filters gpu::recomp::tests::ps_masks_in_loops_quad_read_the_operands_not_the_compare and gpu::recomp::tests::wave32_src_vccz_execz_and_saveexec_b32_hlsl, all with --nocapture --test-threads=1. 22 passed, 0 failed, 1 ignored (manual benchmark), 0 skips.
  • Arc: with XCL_ADAPTER=A770 XCL_DIRECT_DXIL=0, ran $exe --exact --nocapture --test-threads=1 <filter> separately under the shared Arc mutex for gpu::recomp::tests::gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges, gpu::recomp::tests::gpu_ps_masks_hold_helper_lanes_on_triangle_edges, and gpu::recomp::tests::gpu_ps_mask_loop_on_a_primitive_edge_ends. 3 passed, 0 failed, 0 ignored, 0 skips. The carry readback matched all 1,024 pixels. The helper-lane test reported zero mismatches in 1,024 pixels for each input width. The Wave32-input loop reported zero mismatches in 1,024 pixels and 16 hardware lanes.

Not tested

Parent, direct DXIL, other adapters, performance, full workspace suite, and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol for the worker run) built and ran the fixtures and drafted the report. Codex in the coordinator session independently reran the same filters.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: e1e5bbf

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 6089122
head: e1e5bbf
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: none. The renamed field has all its uses on main updated; the wave64 path is equivalent to the old check; the wave32 rule only adds liveness, so it is conservative. A tester in the thread reports the GPU test fails without the fix (not run on main here).
performance: it changes a translator source: every tester re-translates all shaders once. One extra liveness pass per wave32 pixel program (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@thehollowedone

thehollowedone commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 2c717a0 (main)
head: e1e5bbf
merge: clean, uncommitted trial merge
build: cargo build --workspace --locked -> ok
tests: cargo test --workspace --locked --no-fail-fast -- --test-threads=4 -> 1,467 passed, 1 failed, 47 ignored; 25 GPU SKIPPED notices. Both new Wave32 tests passed, including the RTX 3080 Ti pixel readback. The only failure, console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, is the same failure on clean main 2c717a04 with the same command and machine (1,465 passed, 1 failed, 47 ignored, 25 skips; paired baseline report). As a negative control, I added only this PR's 39-line GPU regression to clean main: cargo test -p xcl --lib gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges --locked -- --nocapture -> 0 passed, 1 failed, 0 ignored, 0 skips (mask popcount at 0: 12.0 versus 16.0). The unchanged test passed in the merged full suite.
review: No blocker in the four-file diff. Wave32 mask writes now kill only their actual SGPR word during liveness, so a later write to s20 does not erase the whole read of s21; Wave64 retains the previous pair-wide decision. The emitter consumes the new per-destination result, and the GPU test compares the carry result against a separately computed WQM EXEC count. A separate open Direct-DXIL optimization, #2571, still uses width-blind pair kills in ps_masks.rs; it needs its own Wave32 follow-up, but does not change this PR's HLSL fix.
performance: Wave32 pixel translation runs two liveness analyses rather than one. Affected mask writes now retain helper-lane quad reads where correctness requires them. I did not measure cold compile time or frame-time cost; unaffected shaders keep their prior path.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300; RTX 3080 Ti 12 GB, NVIDIA 621.35; Ryzen 7 9800X3D; Rust 1.99.1 MSVC; DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the merge, build, full GPU suite and negative control, reviewed the diff and wrote this report; Codex (GPT-6.2 Astra) independently traced the mask-liveness paths. I did not run a retail smoke on this head.

@throny
throny merged commit 2dc63f1 into xcl-dev:main Nov 29, 2026
2 checks passed
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.

HLSL pixel masks: adjacent Wave32 carry destinations lose s21 on WQM triangle edges

9 participants