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).

@ClosetPie107

Copy link
Copy Markdown

Tested on AMD / Linux: a87d3c2a (RX 9070 16 GB, RDNA4, Mesa 26.3.1 RADV; Ryzen 5 9600X, 32 GB; CachyOS; Proton Experimental experimental-11.0-20261112 with vkd3d-proton master ec207194 plus a local patch dropping the lpVtbl checks of command allocators and lists; DXC 1.9.2609.5; Rust 1.96.0, x86_64-pc-windows-gnu debug build, tests run under Wine)

The head as it is (base e120925e), with main f9a0cb80 the same session as the baseline.

Tests (XCL_REQUIRE_GPU=wave64)

  • cargo test -p xcl --lib -- gpu::recomp::emit::tests:: --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib -- gpu::recomp:: --test-threads=1: 395 passed, 3 failed, 20 ignored; the 3 (f32_programs_on_the_gpu, f64_programs_on_the_gpu, gpu_nonfused_mad_and_mac_prevent_fma_contraction) fail on main here too.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 with --skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole (here the first loses the RADV device, the other two run out of memory under Wine): lib 1303 passed, 8 failed, 27 ignored; main f9a0cb80 lib (--test-threads=1, same skips): 1323 passed, 9 failed, 27 ignored. All failures are among main's. The other binaries fail the same 3 tests as on main (e2e, pls_quota, predication_e2e).
  • d3d12_resource_and_sync: its fence and queue test ended the process here, as it does on main and most other trees in this setup.

Not tested

  • Native Windows, NVIDIA / Intel
  • A retail title: the device removal this reverts for was seen on NVIDIA, which I don't have

AI use

  • Claude Code (Claude Opus 5.5) wrote the test scripts, ran the builds and tests on my machine and wrote this report.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Update to my test above, relevant to whether this revert is needed: on my card the removal was the shader-heap limit (#2403), not #2247. After the NVIDIA profile for xcl.exe went from a 1 GiB to a 2 GiB shader heap, builds without this revert stopped losing the device here:

build (RTX 4080 16 GB, driver 621.40) shader heap profile device removed
nvidia-dev without the revert, 5 runs (the ones above) 1 GiB 145-156 s after the first frame
with the revert, 4 runs (above) 1 GiB 202-352 s, or not within 265 s
nvidia-dev 3f39671d / d1be8103 without the revert, 9 runs of 420-600 s 2 GiB none
with the revert, 3 runs of 900 s 2 GiB none

With DRED working (#2967) every one of the 1 GiB removals read the same: device state 0, no page fault, no list in flight, and the amount of pipeline code built at the removal was the same whether it came after 145 s or 588 s (details on #2688 and #2403). So my earlier "the revert doubles the time to the loss" is better explained by the revert changing how fast pipeline code accumulates than by #2247 causing a fault. I have no evidence on this machine that #2247 is wrong.

Two things for whoever decides on the merge: the revert undoes #2247's removal of a local array and branches in the pixel shaders that call rla() (its message says 7,634 of 12,056 in this title), with no measurement here of what that costs; and it changes a translator source, so every tester re-translates all shaders afterwards. @SergeAx's bisect on the RTX 5080 was on driver 621.14 and, as far as I can see, without a raised shader heap: a rerun of the bad commit with a 2 GiB profile (xcl nvprofile install --mb 2048 from #2590) would show whether it is the same limit there.

Numbers are from the logs of these runs. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this; a Claude Sonnet 5.5 sub-agent compared the revert with the original commit (it is exact).

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Merge status (I have been asked to prepare merges of PRs with several independent tests; the bar is: no open critical finding or performance regression, a fresh check of the merge result against today's main, and green required checks. Each merge is still confirmed by a person.)

Not proposing this one for merging at the moment, for the reasons in my comment above: on the machine where I measured it, the removal turned out to be the shader-heap limit and is gone without the revert, and the revert undoes an optimisation in most pixel shaders without a measurement of the cost. The revert itself is exact (compared line by line with 5081dc8b). What would change my reading: a rerun of the bisect's bad commit with the 2 GiB profile that still loses the device, or frame-time numbers showing the revert costs nothing.

AI use: Claude Code (Claude Fable 5.2).

@Decodere

Copy link
Copy Markdown
Contributor Author

Thanks @throny for running #2967 DRED and isolating the 1 GiB -> 2 GiB #2403 shader-heap ceiling.

Agreed — holding #2929 (do not merge) pending @SergeAx's RTX 5080 retest with xcl nvprofile install --mb 2048. If raising the shader-heap cap to 2 GiB resolves the issue there cleanly without regressing #2247 or shader caches, we will happily close #2929.


AI-assisted response (Decodere): engineering decision/comment reviewed by maintainer-directed testing context.

@SergeAx

SergeAx commented Nov 27, 2026

Copy link
Copy Markdown

Retest on the RTX 5080 with a 2 GiB shader heap: no device removal in 7 of 7 runs of the bisect's bad tree without this revert. So here, too, the removal was the #2403 limit, not #2247. As @throny suggested above.

Setup: the same machine, title and runs as in the bisect.

tree shader heap runs device removed
b49be18 + #1435 (bisect) 512 MB 7 6, 1–37 s after the step
same with this revert (bisect) 512 MB 5 0
b49be18 + #1435 2 GiB 7 0
  • All 7 runs passed the step and ran to 240 s with no removal and no crash.
    • 6 runs reached the step at 101–117 s, leaving 123–139 s after it.
    • One run reached it only at 209 s, leaving 31 s. Its loading screen kept drawing, at 11–30 fps; the log doesn't show why it took longer.
  • So the bisect probably measured Recompiler: eliminate local array and branches in pixel-shader PRELUDE::rla() #2247 filling the 512 MB heap sooner on this card, as @throny read it on the RTX 4080. The revert's 0 of 5 fits that.

A correction to my nvidia-dev addendum above: a later run of nvidia-dev + this revert + #1435 did lose the device.

  • It ran with warm caches, XCL_PREPARE=0 and the default heap.
  • The device was lost at 281 s, 130 s after the step. DRED showed device state 0, a page fault at VA 0x0 and no list in flight.
  • So on nvidia-dev the revert didn't prevent it here either.

Not tested:

  • The 1 GiB setting.
  • nvidia-dev with the 2 GiB heap.
  • Runs longer than 240 s with the 2 GiB heap.
  • The frame-time cost of the revert.
  • AMD.

AI use: Claude Code (Claude Opus 5.5) built the trees, read #2590's NVAPI code against NVIDIA's headers, ran the runs (unattended; I ran the elevated install), read the logs and wrote this.

@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the recompiler suite at a87d3c2a on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 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 -- gpu::recomp:: --test-threads=1
398 passed; 0 failed; 20 ignored; 0 measured; 921 filtered out      (exit 0)

All 398 tests pass with 20 ignored. There were 23 SKIPPED notices: 20 no wave64, two for per-lane f16/f32 forms refused, and one for a const-mask wave64 form; these are expected on a 32-lane-only card and are not counted as coverage. The thread has runs on RTX 5080, RTX 4080, RTX 3060 and AMD, but no 5070 Ti; this adds a second Blackwell datapoint with driver 32.0.16.2124.

Not tested: a retail world-load run, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game 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.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head a87d3c2

main still has the #2247 select() form of pixel-shader PRELUDE::rla() (emit.rs). This is a clean revert of 5081dc8, and the bisect cited in #1452 supports it.
#2930 tried the same revert and is closed. No other open PR reverts it.
No problems found in the diff. It restores the pre-#2247 body exactly and drops only #2247's three tests.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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.

8 participants