Skip to content

Recompiler: mask bridged V_CMP_* results with EXEC in per-lane lowering - #2503

Open
ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:recomp/per-lane-bridged-vcmp-exec
Open

ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:recomp/per-lane-bridged-vcmp-exec

Conversation

@ChalanaGimhanaX

Copy link
Copy Markdown
Contributor

Mask bridged non-CMPX V_CMP_* results with EXEC in per-lane direct DXIL lowering (Lower::bridge), matching RDNA2 hardware, native Lower::valu_op, and the HLSL path.

lane_masks::is_vector excludes all V_CMP* instructions so their PCs are never in self.guarded, and Lower::valu_op only lowers plain U32/I32 compares natively. Every float (F32/F16/F64), 64-bit, 16-bit, V_CMP_CLASS_*, and VOP3-modified/SDWA compare falls through to Lower::bridge, which previously only captured old_exec for V_CMPX* and passed guard = true to Ir::foreign. Inactive lanes outside EXEC therefore left 1 in VCC/SDST instead of 0, corrupting subsequent mask ops and S_CBRANCH_VCCZ/VCCNZ branches.

Part of #2458, #1269, and #1833. (Issue #2458 item 2 — NULL / SDST = 125 writes — is already covered by open PR #2117 and intentionally left out to stay single-purpose and avoid conflicts.)

What is in it

  • crates/xcl/src/gpu/recomp/lower.rs: in Lower::bridge, capture old_exec for all V_CMP* instructions (when !in_guarded_run), not only V_CMPX*, so inactive lanes are ANDed out before write_bit.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: added a_bridged_v_cmp_clears_inactive_lanes_outside_exec covering bridged VOPC (VCC) and VOP3 (s4) V_CMP_LT_F32 under narrowed EXEC (exact register checks + HLSL GPU parity) and compute S_CBRANCH_VCCZ under both wave32 and split wave64 (with DXIL validation on CPU).

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.8.2502.11, release build.
  • Failing-first check before the lower.rs fix: cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests::a_bridged_v_cmp_clears_inactive_lanes_outside_exec -- --exact --nocapture failed with assertion left == right failed: vcc must clear inactive lanes 16..31 (left: 4294901760 [0xFFFF_0000], right: 0).
  • Targeted after fix (1051482):
    • RTX 3060: cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests:: -- --test-threads=4 --nocapture: 22 passed, 0 failed.
    • WARP (XCL_ADAPTER=warp): a_bridged_v_cmp_clears_inactive_lanes_outside_exec passed (all 3 DXIL containers compiled and validated on CPU; GPU execution skipped cleanly with no GPU with 32-lane waves).
  • Full workspace release suite (1051482): cargo build --release --workspace + cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1424 passed, 0 failed, 46 ignored across 37 test binaries.
  • SKIPPED GPU/adapter tests (26): 21 no wave64, 3 refused per-lane f16/f32 forms (#1426), 1 no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required for driver cache disable).
  • cargo test --release -p xcl --test e2e -- --test-threads=1 (1051482): 4 passed, 0 failed.

Regression run

main (6d051da):

xcl-smoke v1
commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1473 (PresentX 1473)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14348 MB

this PR (1051482):

xcl-smoke v1
commit: 10514822001f2302cd102b9431a9d8613e45cf3a
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1474 (PresentX 1474)
presents per 2 s (last 3): 42 60 60
device removals: 0
crashes: 0
peak commit: 10168 MB

Not tested

  • Native wave64 hardware (split = false GPU execution path), AMD / Intel GPUs, Linux / Wine, and retail gameplay beyond the 60-second smoke run.

AI use

  • Antigravity (Gemini 4 Neon) implemented the Lower::bridge EXEC-masking fix and GPU/DXIL-validation regression test, ran the test suite and regression smoke run, and drafted this description.

@DarkPanda69

Copy link
Copy Markdown

Ran on an AMD RX 9070 XT (RDNA4) and an RTX 3060: the new test passes on both cards, and nothing else changes.

Diff applied on main 6d12f58, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4 on main and with the PR, card chosen with XCL_ADAPTER, run twice: once with XCL_PER_LANE=1 alone, once with XCL_PER_LANE=1 XCL_DIRECT_DXIL=1. Both gave the same results:

No other test changes result on either card.

On the "native wave64" gap: the test's wave64 case goes through compute_split, so on the RX 9070 XT it runs the split form too. This run doesn't cover the native (split = false) path either.

Not tested: retail shaders, Intel, Linux / Wine.
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): 164 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 a_bridged_v_cmp_clears_inactive_lanes_outside_exec: passed.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 10514822001f2302cd102b9431a9d8613e45cf3a (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1422 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's GPU test passed (no skips): gpu::recomp::lower_dxil::tests::a_bridged_v_cmp_clears_inactive_lanes_outside_exec.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 10514822001f2302cd102b9431a9d8613e45cf3a
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14236 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@xpatfussy69x

Copy link
Copy Markdown

Test run on exact head 1051482 (10514822001f2302cd102b9431a9d8613e45cf3a, on base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too; Recompiler: the per-lane form takes f16 converts and products from #1426 #2182 removes them)
  • cargo test -p xcl --lib a_bridged_v_cmp: 2 passed (a_bridged_v_cmp_clears_inactive_lanes_outside_exec and the existing a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out), not skipped
  • I hit the same bug independently (closed duplicate Recompiler: a bridged v_cmp writes 0 for the lanes outside EXEC (#2458) #2507): on main, a program with EXEC = lanes 0–15, a bridged v_cmp_le_f32 true in every lane, EXEC restored and v_cndmask on VCC gives 7 in lane 16 instead of 0; this PR's change gives 0

Regression run (60 s, default settings)

main:

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1130 (PresentX 1130)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14808 MB

this PR:

xcl-smoke v1
commit: 10514822001f2302cd102b9431a9d8613e45cf3a
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1150 (PresentX 1150)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14782 MB

No crash or device removal; frames 102 % of main's, peak commit 100 %.

Not tested

  • AMD / native wave64
  • Whether the title reaches a bridged v_cmp under a narrowed EXEC (not run with XCL_PER_LANE=1): a regression check only

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

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)
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
… upstream xcl-dev#2503)

Shared per-lane lowering soundness (recomp/lower.rs): a bridged
(non-CMPX) V_CMP_* clears its destination bit in lanes outside EXEC,
matching RDNA2 hardware; previously only cmpx read back old EXEC.
The per-lane test vector lands verbatim in lower_dxil.rs (CPU
translate asserts + GPU/dxc-gated checks, windows-gated on Linux
like its neighbours).
@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2503 at head 10514822001f2302cd102b9431a9d8613e45cf3a (1 commit; exact parent & merge-base: 6d12f58a229bc73889878a448c64dc3af25eeba0, 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 (10514822)

Command Result
cargo test --release -p xcl --lib a_bridged_v_cmp_clears_inactive_lanes_outside_exec -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 1324 filtered out × 3 (0.25s, 0.21s, 0.21s, 0 skipped — live execution on RTX 4060)
cargo test --release -p xcl --lib gpu::recomp:: -- --test-threads=4 (3 consecutive runs) 393 passed; 0 failed; 19 ignored; 913 filtered out × 3 (5.83s, 5.93s, 6.00s; 370 executed on RTX 4060 + 23 expected Wave32-only/env skips)
cargo build --release -p xcl Clean build (1m 09s, exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

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

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

PR #2503 (10514822001f2302cd102b9431a9d8613e45cf3a):

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

Runtime log observations (xcl.log)

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

Limits of coverage

  • Masking bridged V_CMP_* results with EXEC in per-lane lowering was directly executed on desktop Wave32-only RTX 4060 via a_bridged_v_cmp_clears_inactive_lanes_outside_exec (3/3, 0 skipped) and gpu::recomp:: (370 executed + 23 expected Wave32-only/env skips × 3).
  • Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on title: 29640639 confirms zero runtime regression rather than recompiling a cold shader set (frame-count delta vs. cached parent reflects single-run startup variance, not this PR).

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

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.

7 participants