Skip to content

Revert "Recompiler: eliminate local array and branches in pixel-shader PRELUDE::rla()" (#2247) - #2929

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:revert-2247-rla-branchless
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:revert-2247-rla-branchless

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

Clean revert of #2247 (5081dc8b6e22fc74f6fe7d31de333182e8f7ec92, merged in 2898511), restoring the exact pre-#2247 PRELUDE::rla() implementation in crates/xcl/src/gpu/recomp/emit.rs.

Reverts #2247
Related to #1452

In #1452#issuecomment-7205972665, @SergeAx bisected 140 first-parent merges on main (568e7db..b49be18) on an RTX 5080 (NVIDIA driver 621.14, Windows 10 22H2) and isolated #2247 (2898511) as the first commit introducing 0x887a0005 (DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT) during retail world load (f9f6d49 / #2257: 0/4 removals; 2898511 / #2247: removed). Confirmation on b49be18 + #1435 hit 6/7 device removals with 5081dc8b present versus 0/5 removals with only 5081dc8b reverted.

Note on branch ancestry: 5081dc8b is also an ancestor of origin/nvidia-dev (ecc0bb57) and origin/amd-dev (bf7c82ee), so maintainers may want to cherry-pick or merge this revert into those branches once landed on main.

What is in it

  • Clean git revert 5081dc8b6e22fc74f6fe7d31de333182e8f7ec92 (crates/xcl/src/gpu/recomp/emit.rs, +6/-127 lines):
    • Restores xcl_lv[min(h >> 5, 3u)], scalar ?: for q/r, and the if (nib != 0u && ...) / if ((l >> 2) == ...) guards in pixel-shader PRELUDE::rla().
    • Removes the 3 #2247-specific branchless-rla() unit tests added by 5081dc8b, leaving all other emit::tests:: and gpu::recomp:: tests intact.

Tested

  • Hardware & toolchain: Windows 11 Home (build 26200), Intel Core i5-11400F (6C/12T), 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (32-lane waves, driver 621.14), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (WARP) and release (RTX 4060).
  • cargo clippy --all-targets -- -A clippy::approx_constant: exit 0, 0 new warnings and 0 errors in crates/xcl/src/gpu/recomp/emit.rs.
  • Debug WARP (XCL_WARP=1):
    • 3x cargo test -p xcl --lib -- gpu::recomp::emit::tests:: --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored (0 skipped).
    • cargo test -p xcl --lib -- gpu::recomp:: --test-threads=4: 398 passed, 0 failed, 20 ignored (23 expected SKIPPED notices: 20 wave64, 3 per-lane refusals).
  • Release RTX 4060:
    • 3x cargo test --release -p xcl --lib -- gpu::recomp::emit::tests:: --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored (0 skipped).
    • cargo test --release -p xcl --lib -- gpu::recomp:: --test-threads=4: 398 passed, 0 failed, 20 ignored (23 expected SKIPPED notices: 20 wave64, 3 per-lane refusals).
    • cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1439 passed, 0 failed, 47 ignored across 37 top-level test targets (29 expected SKIPPED notices: 21 wave64, 3 per-lane refusals, 3 D3D12 debug layer, 1 heap-window fallback, 1 Windows driver-cache toggle).
  • Mergeability: git merge-tree --write-tree origin/main HEAD exits 0 against live origin/main (8b957bec).

Regression run
Paired quiet 60 s release runs (scripts/smoke.ps1 -Seconds 60, XCL_NETWORK=0, default flags, RTX 4060 8 GB, driver 621.14) on exact parent on main (e120925e, ancestor of 8b957bec) and revert head (a87d3c2a):

Exact parent on main (e120925e, ancestor of 8b957bec):

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

PR (a87d3c2a):

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

Not tested

AI use

  • Google Antigravity (Gemini 4 Neon) verified 5081dc8b branch ancestry (main, nvidia-dev, amd-dev), prepared the clean git revert commit off e120925e, ran clippy, Debug WARP + Release RTX 4060 unit/recompiler/workspace suites and paired 60 s retail smokes on the hardware above, and drafted this PR description.

…r PRELUDE::rla()" (xcl-dev#2247)

This reverts commit 5081dc8 (merged in
2898511 / PR xcl-dev#2247), restoring the exact pre-xcl-dev#2247 `PRELUDE::rla()`
implementation in `crates/xcl/src/gpu/recomp/emit.rs`.

In xcl-dev#1452#issuecomment-7205972665, @SergeAx bisected 140 merges on
`main` (`568e7db..b49be18`) on an RTX 5080 (driver 621.14, Windows 10)
and isolated xcl-dev#2247 (`2898511`) as the first commit introducing
`0x887a0005` (`DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT`) during retail
world load (`f9f6d49` / xcl-dev#2257: 0/4 removals; `2898511` / xcl-dev#2247: bad).
Confirmation on `b49be18` + xcl-dev#1435 hit 6/7 device removals with
`5081dc8b` present versus 0/5 removals with only `5081dc8b` reverted.

Note: `5081dc8b` is also an ancestor of `nvidia-dev` (`ecc0bb57`) and
`amd-dev` (`bf7c82ee`).

Reverts xcl-dev#2247
Related to xcl-dev#1452

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

Copy link
Copy Markdown

Tested

Clean PR head a87d3c2ac52bac1e7d2df4e6050171fb2dee0887 and parent e120925e3abc9956a8b9bae631969d32e8ccd43c on Intel Arc A770 driver 32.0.101.9175, Windows 11 build 26200, Ryzen 7 3800X, Rust 1.100.0 MSVC and DXC/DXIL 1.9.2602.17. Built with cargo test -j 2 --locked -p xcl --lib --test console_shaders --no-run --message-format=json using separate target directories, CARGO_PROFILE_TEST_DEBUG=0 and CARGO_INCREMENTAL=0.

With XCL_ADAPTER=A770, ran the libtest executable with --exact --nocapture --test-threads=1 for each of the following checked-in synthetic tests under the shared Arc mutex.

  • gpu::recomp::tests::gpu_ps_masks_hold_helper_lanes_on_triangle_edges
  • gpu::recomp::tests::gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends
  • gpu::recomp::tests::gpu_ps_mask_loop_on_a_primitive_edge_ends
  • gpu::recomp::tests::gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k

All four passed on both revisions, with zero failures, ignores or skips. The derivative and loop cases reported no pixel mismatches. The ballot/quad test matched the expected layout across 1,024 pixels and ballot values in the tested helper neighbors. The parent-only gpu::recomp::emit::tests::gpu_rla_pixel_shader_matches_reference_including_helper_lanes also passed all 1,024 pixel assertions.

Not tested

Retail crash, performance, native wave64 hardware, full workspace suite and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol for the worker run) built and ran the fixtures. Codex in the coordinator session reran the four shared GPU tests and the parent-only control and drafted this report.

@DarkPanda69

Copy link
Copy Markdown

AMD and RTX 3060 run, moved here since #2930 closed as a duplicate. Its diff is byte-identical to this one (a87d3c2), so the results apply here.

Tested: pass, the diff applied on main 8b957be, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17, XCL_DIRECT_DXIL unset (the HLSL path), card picked with XCL_ADAPTER.
cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture, main and the revert one after the other on each card:

On both cards the only differences are the three #2247 tests the revert removes. The SKIPPED sets are the same. This doesn't touch the Blackwell world-load removal; I have no RTX 50 card.

Not tested: a title run, an RTX 50 card, Windows 10, release, Intel.

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

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Testing this now on nvidia-dev (ecc0bb5 + #684 + #2794, RTX 4080 16 GB, driver 621.40): the revert applies cleanly there, shaders are being re-translated for it, then two world runs against two runs of the same build without it. On this head our device losses (0x887a0005, no DRED breadcrumbs) came 147 s and 588 s after the first frame; details in #2688 (comment). I will post the four results here and on #1452. AI use: Claude Code (Claude Fable 5.2).

@SergeAx

SergeAx commented Nov 27, 2026 •

Copy link
Copy Markdown

Test report: a87d3c2a on the RTX 5080 from #1452: no device removal in 5 of 5 runs. All of them passed the world-load step at 99–128 s and ran to 240 s without a crash.

Tested

run world-load step (first 7-argument XG copy) device removed end
1 113.6 s no 240 s, 2186 frames shown
2 127.7 s no 240 s, 2507 frames shown
3 115.0 s no 240 s, 2131 frames shown
4 99.6 s no 240 s, 1851 frames shown
5 99.5 s no 240 s, 1697 frames shown

Not tested

Also on nvidia-dev, which still contains #2247: ecc0bb57 + this PR's commit + #1435's 14c8a2d (9ff0bc8a), same machine, release.

  • 5 unattended runs with XCL_PREPARE=0 XCL_DRED=1 XCL_NETWORK=0 and the same presses: 1800, 600, 1800, 240 and 240 s, the two short ones with XCL_PAGE_MAPPINGS=0 or XCL_DISPATCH_LOOP_BUDGET=0.
  • All passed the world-load step at 99–121 s and ran to their end: no device removal, no crash, about 69 minutes past the step in all.
  • After the step these runs mostly waited for graphics pipelines being built and drew few frames, so the GPU had less to do than in the main runs above, and less than in @throny's runs here, which kept drawing with XCL_GFX_PSO_WAIT_MS=200 and still lost the device with the revert. These runs do not contradict that.
  • An open-ended run with XCL_GFX_PSO_WAIT_MS=200 is going now; I will add how it ends.
  • Not tested: nvidia-dev without this commit on this card.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the title unattended, read the logs and wrote this report.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Result on nvidia-dev (ecc0bb5 + #684 + #2794), RTX 4080 16 GB, driver 621.40, Windows 11 26300, 64 GB RAM without a page file - same save, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_GFX_PSO_WAIT_MS=200 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200, up to 700 s from the first game frame, shaders re-translated for the revert (12,101 pixel shader records in 26 min, 0 errors):

build run device removed (0x887a0005) how the run ended
without this PR 94 147 s after the first frame device removed
without this PR (+ #2831 #2927 #2931) 95 156 s device removed
with this PR 97 352 s device removed
with this PR 98 not in 265 s our memory guard ended it (process commit 51.7 GB, under 3 GB free on this machine)

So with the revert the title lived more than twice as long in both runs, but one of the two still lost the device (again without DRED breadcrumbs, see #2920, and without an Aftermath dump). Two runs a side is thin: it agrees with the bisect in #1452 in direction, and it shows that on this card the revert alone is not the whole story. In the longer runs the next limit is commit: 45.6 GB at 352 s and 51.7 GB at 265 s, against about 40 GB at 150 s in the runs without it.

I can add runs if a larger sample helps the decision here; say how many. Numbers are from the logs of these runs. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

More runs, same setup as the table above: without the revert a third run lost the device at 146 s (so 147, 156, 146 s). With the revert, two further runs on a5e2d851 that also carried a ported XCL_CHAIN_WHOLE=1 prototype lost it at 212 s and 202 s (so 352 s, not within 265 s, 212 s, 202 s). The revert still roughly doubles the time to the loss here and does not remove it; the last two differ from the first two by the extra switch and the newer base, so they are not a clean repeat. AI use: Claude Code (Claude Fable 5.2).

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