Recompiler: widen 1-window raw MUBUF bounds checks to 64-bit to prevent wrap #1137
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1146"
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-24T12:32:22Z.
In
mubuf,buffer_atomic, andmubuf_d16, the single-window (mem_windows == 1) path computedt_off = voff + OFFSETand checkedt_off + bytes <= d2in 32-bituint, unlike the multi-window path which already usesuint64_t. A large/negativevoff(e.g.0xFFFFFFFCwithbytes = 4, or0xFFFFFFF0withOFFSET = 16) wrapped past2^32to0 <= d2, reading or writing out of bounds instead of treating the access as out of bounds.This hoists
uint64_t t_offand uses the 64-bit raw bounds check in both single- and multi-window modes acrossmubuf,buffer_atomic, andmubuf_d16.What is in it
crates/xcl/src/gpu/recomp/emit.rs: computet_offand rawSTRIDE == 0bounds comparisons inuint64_tformubuf,buffer_atomic, andmubuf_d16regardless ofmem_windows.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_mubuf_raw_bounds_do_not_wrap_32bitcoveringBUFFER_LOAD_DWORD,BUFFER_STORE_DWORD,BUFFER_ATOMIC_ADD, andBUFFER_LOAD_SHORT_D16(verified failing before the fix); update the HLSL text check inatomic_fcmpswap_x2_is_a_bitwise_64_bit_casfor the widened comparison.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): 742 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)cargo test -p xcl --lib gpu_mubuf_raw_bounds_do_not_wrap_32bit: 1 passed, 0 failed (failed on the GPU before the fix, reading0xDEAD_BEEFfrombase - 4)Regression run
main:
PR:
Not tested
AI use
emit.rs, wrote the fix and GPU test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:44:29Z.
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.
cargo test -p xcl --lib mubuf: 1 passed, 0 failed —gpu_mubuf_raw_bounds_do_not_wrap_32bitexercises the widened 64-bit bounds check on real hardware.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Imported from ivall/xcl. Originally posted by bjarngard on 2026-11-24T13:05:13Z.
Test report for head
9e43be5(AMD, native wave64)Tested
XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, no SKIPPEDXCL_REQUIRE_GPU=wave64:gpu_mubuf_raw_bounds_do_not_wrap_32bitpassedNot tested: retail titles, RDNA3/RDNA4.
AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T13:57:02Z.
A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.
Tested
x86_64-pc-windows-gnu.9e43be5as it is (based on47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).gpu::recomp::tests::gpu_mubuf_raw_bounds_do_not_wrap_32bit: ok, no SKIPPED.Not tested
AI use
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T04:22:05Z.
RX 6800M focused GPU report for PR #1146 at
9e43be57c295938915ae2dd4e458e113d1d3e89cSetup: Windows 11 build 26200, AMD Radeon RX 6800M (driver
30.0.13002.13003), Ryzen 9 5980HX, Rust1.99.0MSVC, DXC/DXIL1.9.2609.5. Clean exact-head worktree;XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=1,XCL_DIRECT_DXIL=0.Tested
cargo test --locked -p xcl --lib -j 2 gpu_mubuf_raw_bounds_do_not_wrap_32bit -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, no printedSKIPPEDsubcases. This covers raw MUBUF bounds near 32-bit wrap, including load, store, atomic add, and D16 load on the AMD GPU.cargo build --locked --workspace -j 2: passed.Not tested: Full workspace suite, paired retail-title smoke, other GPUs, or the Direct DXIL path. This verifies the focused HLSL regression on the PR head; it does not establish a green full suite or world-load behavior. No game data was used.
AI assistance: OpenAI Codex (GPT-6) ran the commands, extracted the test counts from the log, and drafted this report.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:17:46Z.
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-01T04:55:40Z.
Triage (#1607) – head
9e43be5#1933 and the merged #3265 guard the same 32-bit wrap in the direct DXIL backend (
lower_mem.rs). This PR fixes the HLSL backend (emit.rs), where main's single-window path still computesuint _off = voff + OFFSETand_off + bytes <= num_recordsin 32 bits. So it is not a duplicate.The change matches what the multi-window path already does, and the updated
atomic_fcmpswap_x2assertion follows the new HLSL text. The scalar-offset grouped-load path (uint _off = imm + soff) is not covered. The PR conflicts with main.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.