Recompiler: map out-of-range typed buffer format codes (>77) to INVALID instead of 77 #1564
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1574"
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 b3IKK on 2026-11-24T17:50:48Z.
Addresses
XCL-BT-010from #1488.BufKind::FormatLoadandBufKind::FormatStoreincrates/xcl/src/gpu/recomp/emit.rsemittedFMT_INFO[min(fmt, 77u)]. Because entry77is valid32_32_32_32_FLOAT(16 bytes) while entry0isINVALID, any out-of-range 7-bit format code in78..=127was clamped to format77and treated as a valid 16-byte float4 read or write instead ofINVALID.This emits
uint t_fmt = fmt; uint t_info = (t_fmt <= 77u) ? FMT_INFO[t_fmt] : 0u;so out-of-range format codes evaluate to0(INVALID), returning0on loads and skipping stores.Note on premise: mapping reserved codes
78..=127toINVALID(0) is derived from the GFX10IMG_FORMATtable layout (0..=77valid,0 = INVALID), not measured on RDNA2 hardware (no RDNA2 GPU is available on this test machine to probe reserved format codes directly; the previousmin(fmt, 77u)was an array-bounds clamp that accidentally aliased78..=127to32_32_32_32_FLOAT).What is in it
crates/xcl/src/gpu/recomp/emit.rs: mapfmt > 77uto0u(INVALID) instead of clamping to77uinBufKind::FormatLoadandBufKind::FormatStore.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_typed_buffer_out_of_range_format_codes_are_invalid(verified failing before the fix with0xDEADBEEFreturned on format78).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware; 1no heap windows—heap_window_out_of_memory_falls_back_to_the_switch_form)cargo test -p xcl --lib gpu_typed_buffer_out_of_range_format_codes_are_invalid: 1 passed, 0 failed (failed on RTX 5080 before the fix)Regression run
main:
PR:
Not tested
78..=127(derived from the GFX10 format table, not hardware-probed)AI use
XCL-BT-010from #1488, wrote the fix and GPU regression test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T18:13:29Z.
One question on the premise: is "78–127 is INVALID (loads give 0, stores are dropped)" measured on RDNA2 hardware, or taken from the table's layout? The GPU test checks what this PR emits, not what the console does. #1414's measurements (77 formats on a gfx1036 by Lyrnc) stop at the valid codes. A reserved code could also behave like another format, or like 0 with the descriptor ignored. If nobody has a hardware answer, "derived, not measured" in the description would make that clear.
AI use: Claude Code (Claude Opus 5.5) read the change and wrote this.
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T18:29:08Z.
Good point @upipibi — mapping reserved codes 78..=127 to INVALID (0) is derived from the GFX10 format table definition (0..=77 valid, 0 = INVALID) rather than probed on RDNA2 silicon (no AMD GPU on this machine). I updated the PR description and Not tested section to state that explicitly.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:54:21Z.
Full-suite run, since this PR has no test report yet. Tested exact head
6ac16dd(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 776 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_typed_buffer_out_of_range_format_codes_are_invalid.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:51:36Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by Belox17 on 2026-11-24T20:02:53Z.
Test report for
6ac16ddfon NVIDIA (RTX 3060 Ti): passes, and the GPU test fails without the fixTested
6ac16ddfas is (base9e3831e), clean tree.gpu_typed_buffer_out_of_range_format_codes_are_invalid) withcargo test -p xcl --lib <name>: 1 passed (the GPU part ran on this adapter, noSKIPPED).cargo test --workspace -- --test-threads=4on the head: 777 passed, 0 failed, 41 ignored; its base9e3831eon the same machine: 776 passed, 0 failed, 41 ignored. SKIPPED on both:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).mainc160d86e(clean merge): 859 passed, 0 failed, 42 ignored;mainalone: 858 passed, 0 failed, 42 ignored, the same three SKIPPED as above.emit.rsreverted (test kept), the GPU test fails on this adapter:lane 0: format 78 load must yield 0 (INVALID), left[3735928559, 3735928559, 3735928559, 3735928559](0xDEADBEEF), right[0, 0, 0, 0].Not tested
AI use: Claude Code (Claude Opus 5.5) ran the commands on this machine and wrote this report from those runs.
upstream-sync referenced this pull request2026-11-25 06:04:27 +00:00
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:05:02Z.
Review: COMMENTED
This duplicates #2336 and has the same P1: it fixes only HLSL emit.rs, while Direct-DXIL lower_mem.rs still aliases typed-buffer format codes 78-127 to 77 under XCL_DIRECT_DXIL=1. Consolidate into one PR that fixes both backends and adds Direct-DXIL coverage. No Windows Build/test check is visible.
Imported from ivall/xcl. Originally posted by frenziedcoder on 2026-11-26T07:44:20Z.
Measured on NVIDIA, for @bmjask's review point: merged onto current
main, this PR's own test passes on the default backend and fails withXCL_DIRECT_DXIL=1. So the test is already the Direct-DXIL coverage the review asks for, once it runs on amainwhose test runner honours the switch.RTX 5080 16 GB (driver 621.40), Windows 11 Pro 26200, rustc 1.100.0 MSVC, debug, DXC 1.8.2502.11.
cargo test -p xcl --lib gpu_typed_buffer_out_of_range_format_codes_are_invalid -- --test-threads=1, each backend in its own process (XCL_DIRECT_DXILremoved for the default run,=1for the other), Cargo's exit code kept and the named test required to have run:XCL_DIRECT_DXIL=1main08db8020+ this PR (clean merge)lane 0: format 78 load must yield 0 (INVALID)6ac16dd(base9e3831e)9e3831erunner::run_codealways compiles the HLSL and nothing undergpu/readsXCL_DIRECT_DXIL9e3831e+ only this PR's test (no fix)That second row is why the green reports above (all on
9e3831e) could not show it. Onmainb49be183fmt_infoincrates/xcl/src/gpu/dxil/lower_mem.rsstill doesk.min(77)/umin(fmt, 77); no commit since08db8020touches it.AI use: Claude Code (Claude Opus 5.5) ran the checks on my machine and wrote this comment.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:24Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:09:50Z.
Triage (#1607) – head
6ac16dd#2336 made the same emit.rs change (FMT_INFO lookup guarded by
<= 77u) and was closed as a duplicate of this one. #1241 touches the same FormatLoad block but still clamps withmin(fmt, 77u), so it does not overlap. main still clamps to 77 at both sites.The GPU test fails without the fix (format 78 load would read the 32_32_32_32_FLOAT memory, format 127 store would write). The direct DXIL path (dxil/lower_mem.rs fmt_info,
FMT_INFO[min(fmt, 77)]) still maps codes > 77 to 77, so only the HLSL backend is fixed.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.