Recompiler: typed buffer loads read the channels a format lacks as RDNA2 does (#1414) #1413
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1423"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:48:28Z.
Typed buffer loads read the channels a format lacks the way @Lyrnc measured on gfx1036 (RDNA2) over all buffer formats in #1414:
tbuffer_load_format_*reads 0 in every missing channel, the 4th too.fmt_compgave 1 / 1.0 for a missing 4th channel.buffer_load_format_*with an X..W selector on a missing channel reads channelsel mod nof the format:(x, x, x, x),(x, y, x, y)and(x, y, z, x)for 1, 2 and 3 channels. XCL gave 0 / 1. ZERO / ONE selectors were already right.Fixes points 1 and 3 of #1414. Point 2 (MTBUF ignoring the V#'s
DST_SEL) is #875, which this leaves alone.What is in it
crates/xcl/src/gpu/recomp/emit.rs:fmt_compreturns 0 for a missing channel.mubuf_selmaps an X..W selector to4 + (sel - 4) % n.BufKind::FormatLoadpasses the V#'s selectors through it forENC_MUBUF(d16 forms included).crates/xcl/src/gpu/recomp/tests.rs,gpu_typed_buffer_loads_and_stores:16_16_FLOAT, identity) now expects(1, -2, 1, -2), as #1414 predicts for 2-channel formats.buffer_load_format_xyzwof32_FLOATreads(x, x, x, x).buffer_load_format_xyzwof32_32_32_FLOATreads(x, y, z, x).tbuffer_load_format_xyzwof32_32_32_FLOATreads a 4th channel of 0.(x, 0, 0, 1),(x, y, z, 1)andw = 1.0onmain.Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc, no errors (C code stubbed, nothing linked).mainand on this branch. That was by reading it, not by running it.7c6a1b9(report):cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored, with SKIPPED (no wave64)gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware.gpu_typed_buffer_loads_and_storespasses in all 64 lanes. Copied onto930e8b4, it fails at case B, and lane 0 reads the old results: B(1, -2, 0, 1), G(2.5, 0, 0, 1), H(4, 2, 3, 1), I(4, 2, 3, 1).b7aa9f3: 751 passed, 0 failed, 41 ignored, no GPU skips. That includesgpu_typed_buffer_loads_and_storesand the native-wave64 tests. (report)cargo test --workspace --release, 751 passed, 0 failed, 41 ignored. (report)Regression run
By @LocranKing:
scripts/smoke.ps1, 60 s, RTX 3060 Ti, unedited, from the report.main:
PR:
Not tested
sel mod nrule is the issue's reading of 1, 2 and 3 channels with the identity and X↔Y selectors.Overlaps
#875 and #1310 change the same lines of
BufKind::FormatLoad; whichever merges later rebases. #1310'sfmt_selis a different helper frommubuf_sel.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-24T15:59:13Z.
Native Windows GPU test report for
7c6a1b9gpu_typed_buffer_loads_and_storespassed on an RTX 5090. I also ran the PR’s test on its base with a lane-0 readback before the assertions. The base failed at case B, and its readback showed the old results in all four cases.930e8b4, lane 07c6a1b9, verified across all 64 lanes16_16_FLOAT(1, -2, 0, 1)(1, -2, 1, -2)32_FLOAT(2.5, 0, 0, 1)(2.5, 2.5, 2.5, 2.5)32_32_32_FLOAT(4, 2, 3, 1)(4, 2, 3, 4)32_32_32_FLOAT(4, 2, 3, 1)(4, 2, 3, 0)Tested
cargo test --locked -p xcl --lib gpu_typed_buffer_loads_and_stores -- --nocapture --test-threads=1passed on clean head7c6a1b9e5b7ef22e9c5076ea5c8de8007b590c8e. For the baseline, I copied only the updated test function to930e8b49c1c2ec683d22c724a398b39111cd0e56and added the lane-0 readback above.cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputpassed on the PR head. Cargo reported 751 passed, 0 failed, 41 ignored, including the synthetic end-to-end title. The pass count includes two GPU skips for lack of native wave64:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware.Not tested
AI use
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:59:57Z.
Thank you, @nnonno91! The base-vs-head table across B / G / H / I is exactly the evidence this needed. It's in Tested, and the PR is marked ready for review.
Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T16:34:23Z.
Hardware test report — commit
7c6a1b9Verified clean merge with
main(b7aa9f3) on7c6a1b9e5b7ef22e9c5076ea5c8de8007b590c8e: pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace --no-fail-fast -- --test-threads=4:751 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none), includinggpu::recomp::tests::gpu_typed_buffer_loads_and_storesand the native-wave64 tests (gpu_wave32_program_in_wave64_hardware,console_wave64_compute_through_the_pso_hook_dispatch_and_read_back)Regression run
main(b7aa9f3; merge-base930e8b4also measured1667frames /14861 MBon this machine):PR (
7c6a1b9):Not tested
XCL_D3D12_DEBUG=1; gameplay past the menusAI use
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-24T16:55:19Z.
Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32), including a 60 s retail regression smoke run on clean head
7c6a1b9e5b7ef22e9c5076ea5c8de8007b590c8e.Tested
7c6a1b9e5b7ef22e9c5076ea5c8de8007b590c8e(clean tree, merge-base930e8b4)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo build --release --workspace: ok (exit 0)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored, exit0SKIPPED(no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardwareRegression run
mainbaseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):PR head (
7c6a1b9e5b7ef22e9c5076ea5c8de8007b590c8e):Not tested: debug build,
XCL_SAMPLE_*tests on this branch, AMD / native wave64 hardware, interactive past-menu gameplay beyond 60 s.AI use: Antigravity (
Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:21:25Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T19:22:02Z.
Thank you, @eizispark and @LocranKing! Both suites are in Tested, and LocranKing's
xcl-smokepair is under Regression run exactly as posted. Itstitlenames no game, so it can go in. @eizispark, yours names the game through the folder, so it's linked rather than pasted.Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Lyrnc on 2026-11-26T17:10:06Z.
Test report for
7c6a1b9on gfx1036 and an RTX 5080, with and without #875Setup
maine120925e, main + #1423, main + #875 (077de0d9), and main + both. main is now8b957bec, but none of those 5 commits touchcrates/xcl/src/gpu.XCL_ADAPTER=radeon|nvidia XCL_REQUIRE_GPU=wave64 cargo test -p xcl --lib -- --exact gpu::recomp::tests::<test> --nocapture --test-threads=1, andcargo test -p xcl --lib recomp -- --test-threads=4on each tree.prog+runner::run_code, compared with the gfx1036 results.Merging onto current main. #1423 conflicts with
9f65f957(from #1524) in both files:emit.rs: main'sdst_selnow indexes withpick4(c, (sel - 4u) & 3u). I kept main's line and addedmubuf_selafter it.tests.rs: main added a32_32_32_32selector case togpu_typed_buffer_loads_and_stores. It uses v35..v38, SRSRC 11 and 13, and data at0x140..0x160, which are the registers and memory G / H / I use. Git merges the instruction list without a conflict, so both sets of loads end up in it, sharing those V#s. I moved G / H / I to v39..v50, SRSRC 14 / 15 and data at0x160/0x170, and left main's case as it is.Results. The Radeon and the 5080 gave the same pass / fail in every cell.
gpu_typed_buffer_loads_and_stores(each tree's own version)emit.rsgpu_tbuffer_load_identity_dst_sel(#875)tbuffer_load_ignores_vsharp_dst_sel(#875)cargo test -p xcl --lib recomp, passed / failed / ignoredOn main's
emit.rs, lane 0 reads B(1, -2, 0, 1), G(2.5, 0, 0, 1), H(4, 2, 3, 1)and I(4, 2, 3, 1)on both GPUs. Therecompruns had the same SKIPPED lines in every tree: 6 on the Radeon and 23 on the 5080 (#1426 refusals, no native wave64).Jobs that differ from gfx1036 by more than 1 ULP (the same counts on both GPUs):
tbuffer_load_format_xyzw, 77 formats, identity V#buffer_load_format_xyzw, 8 formats × 4 V# selectorstbuffer_load_format_xyzw, 8 formats × 4 V# selectorsWith #1423 alone, the 18 jobs left are all point 2 (#875): W = ONE and X↔Y on all 8 formats, and W = ZERO on the two 4-channel ones. With both PRs, the only differences left are 1-ULP UNORM / SNORM results (the rounding #1414 lists separately) and NaN payloads.
Conflict with #875. I merged #875 on top. In the
emit.rsconflict, tbuffer takes{t}_c.x..was in #875, and buffer_load_format goes throughmubuf_sel. Two of #875's tests then fail on both GPUs:tests.rs:1631at077de0d9:assert_eq!(v[18..22], [f(1.0), f(-2.0), 0, f(1.0)], "lane {l} tbuffer 16_16_FLOAT: V# SEL_0 ignored, z = 0, w = 1");The run gives
left: [1065353216, 3221225472, 0, 0]. A 4th channel of 0 on a 2-channel format is what gfx1036 returns in #1414 (point 1).The next line,
assert_eq!(v[22..24], [0xC000_3C00, 0x3C00_0000], "lane {l} tbuffer d16 xyzw");, expects 1.0 in the d16 form as well, and a lane-0 readback givesv23 = 0. I didn't measure d16 on hardware.tests.rs:1590:assert!(t.hlsl.contains("v10 = select(t1_ok, dst_sel(t1_c, (s15 >> 0u) & 7u, t1_int), 0u);"), "{}", t.hlsl);The HLSL is now
v10 = select(t1_ok, dst_sel(t1_c, mubuf_sel((s15 >> 0u) & 7u, t1_info), t1_int), 0u);. With only that string changed, the rest of the test passes.Whichever PR lands second needs those lines changed.
Not covered by either PR. With
XCL_DIRECT_DXIL=1, the direct DXIL backend (crates/xcl/src/gpu/dxil/lower_mem.rs, which has its ownfmt_comp/dst_sel) still behaves as main does. On main + both, the 141 jobs give the same output as main byte for byte, andgpu_typed_buffer_loads_and_storesfails at B.Not tested: a title smoke run, the full workspace suite, and d16 loads against hardware.
AI use: Claude Code (Claude Opus 5.5) ran the tests and the comparison on the GPUs above and drafted this comment; the numbers come from those runs.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:42:23Z.
Triage (#1607) – head
7c6a1b9No open or merged PR makes this change. #1840 (also mentions #1414) changes how normalized formats round, not what missing channels read, so the two do not overlap.
Since this branch was cut, main has a direct-DXIL lowering of format loads:
gpu/dxil/lower_mem.rsfmt_compstill returns 1 / 1.0 for a missing 4th channel, and it has nomubuf_sel. After the rebase that path will still read the old values unless the same change is made there.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.