Recompiler: direct DXIL s_buffer_load offsets wrap within their window #2062

Open
github-bot wants to merge 1 commit from github-bot/gh-2062 into main AGit
Owner

@⁠LucasHoepfner on GitHub · 2026-11-25 02:25 UTC · original
LucasHoepfner:dxil-raw-buffer-bounds → main · +44 −1 · 2 files · 1 commits · open

With two or more memory windows, the direct DXIL translator read an s_buffer_load whose 32-bit offset (OFFSET + soff) wraps from the next window, 4 GiB above the buffer. It used the wrapped sum for the range check and the address, but took the window from the two parts added in 64 bits. The HLSL path uses the 32-bit sum for all three. Part of #1893: #1933 has the MUBUF and atomic cases, and with it this is every case measured there where the two translators differ (#1893), so the issue can be closed once both are in.

What is in it

  • Recompiler: direct DXIL s_buffer_load offsets wrap within their window: the window comes from the 32-bit offset (crates/xcl/src/gpu/dxil/lower_mem.rs, one line), with the GPU test gpu_scalar_buffer_load_offset_wraps_within_its_window (crates/xcl/src/gpu/recomp/tests.rs): s_buffer_load_dword and dwordx4 with OFFSET 0x20 and soff 0xFFFF_FFF0 on a two-window arena, through both translators and both window forms.

Tested

  • NVIDIA GeForce RTX 3060 Ti 8 GB (32-lane waves), driver 621.01; Intel Core i7-14700KF, 32 GB; Windows 11 Pro 26200; rustc 1.99.1 stable-x86_64-pc-windows-msvc; DXC 1.8.2502.11. This head (a984c01, on main 08db802): the commit was rebased to resolve a conflict in tests.rs, where another test had been added at the same place. The change is the same. Tests in the debug profile, smoke in release.
  • cargo test -p xcl --lib gpu_scalar_buffer_load_offset_wraps_within_its_window: without the lower_mem.rs line, 1 failed at direct true, heap windows false: dword (left 0xB000_0000, window 1's marker; right 0xA000_0000); with it, 1 passed.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1430 passed, 0 failed, 47 ignored. SKIPPED: 21 × no wave64, heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (Developer Mode is off), uploads_start_from_each_subresources_state (no D3D12 debug layer), 2 × the title under the debug layer (no d3d12SDKLayers.dll), 3 per-lane programs with f16 instructions (refused (unsupported …)).

Regression run

  • scripts/smoke.ps1 -Game <folder> -Seconds 60 on a retail title, no input, on the machine above. Each block is the second run of its build (one unreported run of the same length came first, so that neither is a first run with cold caches); the PR's was run before main's. Unedited.

main 08db802:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3060 Ti
title: 30a45910
seconds: 60
exit: 0x0
frames shown: 1664 (PresentX 1664)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14101 MB

This head a984c01:

xcl-smoke v1
commit: a984c017553519dd708f58617c6e5c231aaceeb4
gpu: NVIDIA GeForce RTX 3060 Ti
title: 30a45910
seconds: 60
exit: 0x0
frames shown: 1663 (PresentX 1663)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14074 MB
  • An earlier pair, for the head before the rebase (7e2c923), is in Parakeet-Wheat's comment (RTX 3070): #2062

Not tested

  • Past the first 60 seconds of the title with no input: the smoke run does not show the title reaching an s_buffer_load that wraps, or whether it used the direct translator. AMD / Intel GPUs; native wave64; a release build of the tests.
  • Whether a title ever has such an offset: the case is synthetic.
  • The issue's two other remarks (soff is not part of the MUBUF range check; num_records * stride can wrap) are the same on the HLSL path and are not changed here.

AI use

  • Claude Code (Claude Fable 5.2) found the case, wrote the change, the test and this description, did the rebase, and ran the tests and the smoke runs.
**@⁠LucasHoepfner** on GitHub · 2026-11-25 02:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/2062) `LucasHoepfner:dxil-raw-buffer-bounds` → `main` · +44 −1 · 2 files · 1 commits · open With two or more memory windows, the direct DXIL translator read an `s_buffer_load` whose 32-bit offset (`OFFSET + soff`) wraps from the next window, 4 GiB above the buffer. It used the wrapped sum for the range check and the address, but took the window from the two parts added in 64 bits. The HLSL path uses the 32-bit sum for all three. Part of #1893: #1933 has the MUBUF and atomic cases, and with it this is every case measured there where the two translators differ (https://git.gtahub.st/github/xcl-dev--xcl/issues/1893), so the issue can be closed once both are in. **What is in it** - `Recompiler: direct DXIL s_buffer_load offsets wrap within their window`: the window comes from the 32-bit offset (`crates/xcl/src/gpu/dxil/lower_mem.rs`, one line), with the GPU test `gpu_scalar_buffer_load_offset_wraps_within_its_window` (`crates/xcl/src/gpu/recomp/tests.rs`): `s_buffer_load_dword` and `dwordx4` with `OFFSET` 0x20 and `soff` 0xFFFF_FFF0 on a two-window arena, through both translators and both window forms. **Tested** - NVIDIA GeForce RTX 3060 Ti 8 GB (32-lane waves), driver 621.01; Intel Core i7-14700KF, 32 GB; Windows 11 Pro 26200; rustc 1.99.1 `stable-x86_64-pc-windows-msvc`; DXC 1.8.2502.11. This head (`a984c01`, on `main` `08db802`): the commit was rebased to resolve a conflict in `tests.rs`, where another test had been added at the same place. The change is the same. Tests in the debug profile, smoke in release. - `cargo test -p xcl --lib gpu_scalar_buffer_load_offset_wraps_within_its_window`: without the `lower_mem.rs` line, 1 failed at `direct true, heap windows false: dword` (left 0xB000_0000, window 1's marker; right 0xA000_0000); with it, 1 passed. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 1430 passed, 0 failed, 47 ignored. SKIPPED: 21 × `no wave64`, `heap_window_out_of_memory_falls_back_to_the_switch_form` (`no heap windows`), `pso_measurement_compiles_an_exact_synthetic_record` (Developer Mode is off), `uploads_start_from_each_subresources_state` (`no D3D12 debug layer`), 2 × `the title under the debug layer` (`no d3d12SDKLayers.dll`), 3 per-lane programs with f16 instructions (`refused (unsupported …)`). **Regression run** - `scripts/smoke.ps1 -Game <folder> -Seconds 60` on a retail title, no input, on the machine above. Each block is the second run of its build (one unreported run of the same length came first, so that neither is a first run with cold caches); the PR's was run before `main`'s. Unedited. `main` `08db802`: ``` xcl-smoke v1 commit: 08db8020d323bf478964fcc586152cce54959cfc gpu: NVIDIA GeForce RTX 3060 Ti title: 30a45910 seconds: 60 exit: 0x0 frames shown: 1664 (PresentX 1664) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14101 MB ``` This head `a984c01`: ``` xcl-smoke v1 commit: a984c017553519dd708f58617c6e5c231aaceeb4 gpu: NVIDIA GeForce RTX 3060 Ti title: 30a45910 seconds: 60 exit: 0x0 frames shown: 1663 (PresentX 1663) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14074 MB ``` - An earlier pair, for the head before the rebase (`7e2c923`), is in Parakeet-Wheat's comment (RTX 3070): https://git.gtahub.st/github/xcl-dev--xcl/pulls/2062 **Not tested** - Past the first 60 seconds of the title with no input: the smoke run does not show the title reaching an `s_buffer_load` that wraps, or whether it used the direct translator. AMD / Intel GPUs; native wave64; a release build of the tests. - Whether a title ever has such an offset: the case is synthetic. - The issue's two other remarks (`soff` is not part of the MUBUF range check; `num_records * stride` can wrap) are the same on the HLSL path and are not changed here. **AI use** - Claude Code (Claude Fable 5.2) found the case, wrote the change, the test and this description, did the rebase, and ran the tests and the smoke runs.
A scalar buffer load's offset is OFFSET + soff in 32 bits. The direct
translator used that sum for the range check and the address, but took
the memory window from the two parts added in 64 bits. Where the sum
wraps, the check passed on the wrapped offset and the load read the
right low address in the next window, 4 GiB above the buffer. The HLSL
path uses the 32-bit sum for all three.

The window now comes from the 32-bit offset too.

Test: s_buffer_load_dword and dwordx4 with OFFSET 0x20 and soff
0xFFFF_FFF0 on a two-window arena, through both translators and both
window forms. Without the change the direct path returns window 1's
marker (0xB000_0000 where 0xA000_0000 is expected); the HLSL path
passes before and after.

Part of #1893; #1933 has the MUBUF and atomic cases.

Assisted-by: Claude Code (Claude Fable 5.2)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:06 +00:00
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-25 03:14 UTC · original

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's new test passes.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 7e2c923 as it is (merge base with main aaa0936), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • gpu_scalar_buffer_load_offset_wraps_within_its_window: ok, not skipped

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
**@⁠JoaoPauluu** on GitHub · 2026-11-25 03:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2062#issuecomment-7151726921) A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's new test passes. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `7e2c923` as it is (merge base with `main` `aaa0936`), no uncommitted changes. The lib test binary runs under Wine, one test per process. - `gpu_scalar_buffer_load_offset_wraps_within_its_window`: ok, not skipped **Not tested** - the whole suite on this head, a retail title, native Windows, AMD. **AI use** - Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
Author
Owner

@⁠Parakeet-Wheat on GitHub · 2026-11-25 03:19 UTC · original

NVIDIA RTX 3070 on native Windows, head 7e2c923 on its base aaa0936: the new test fails without the lower_mem.rs line and passes with it, the whole suite passes, and the smoke pair is within the limits.

Tested

  • NVIDIA GeForce RTX 3070 8 GB (driver 610.88, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head 7e2c923 (one commit on main aaa0936), checked out clean. Tests in the debug profile, smoke in release.
  • cargo test -p xcl --lib gpu_scalar_buffer_load_offset_wraps_within_its_window -- --nocapture --test-threads=1:
    • on aaa0936 with only the PR's tests.rs copied in: 1 failed, direct true, heap windows false: dword, left 2952790016 (0xB000_0000, window 1's marker), right 2684354560 (0xA000_0000);
    • on 7e2c923: 1 passed, 0 failed, not skipped.
  • .\scripts\test.ps1 (cargo build --workspace, then cargo test --workspace -- --test-threads=4) on 7e2c923: 1152 passed, 0 failed, 46 ignored across 20 test binaries, exit 0. SKIPPED, 25: 20 × no wave64, 3 × per-lane form refused (V_CVT_F16_F32, V_PK_MUL_F16, V_MUL_F16: "its #1426 semantics differ from the console's"), 1 × no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).

Regression run (scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited). main aaa0936:

xcl-smoke v1
commit: aaa093657bd96a146c05c0c1a9b61149fe761453
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1410 (PresentX 1410)
presents per 2 s (last 3): 59 61 60
device removals: 0
crashes: 0
peak commit: 15274 MB

PR head 7e2c923:

xcl-smoke v1
commit: 7e2c9235dfc6ab91dee9f85eaca03d50174506b6
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1560 (PresentX 1560)
presents per 2 s (last 3): 61 60 51
device removals: 0
crashes: 0
peak commit: 15097 MB

That is 111 % of main's frames and 99 % of its peak commit.

Not tested

  • AMD, native wave64 (the 20 no wave64 skips above), a world run (the smoke stays in the menus, so it does not show whether the title reaches an s_buffer_load that wraps), the tests on game data (XCL_SAMPLE_* not set).

AI use

  • Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.
**@⁠Parakeet-Wheat** on GitHub · 2026-11-25 03:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2062#issuecomment-7151813399) NVIDIA RTX 3070 on native Windows, head `7e2c923` on its base `aaa0936`: the new test fails without the `lower_mem.rs` line and passes with it, the whole suite passes, and the smoke pair is within the limits. **Tested** - NVIDIA GeForce RTX 3070 8 GB (driver `610.88`, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 `stable-x86_64-pc-windows-msvc`, DXC 1.8.2502.11, retail 1.0.2.1. Head `7e2c923` (one commit on `main` `aaa0936`), checked out clean. Tests in the debug profile, smoke in release. - `cargo test -p xcl --lib gpu_scalar_buffer_load_offset_wraps_within_its_window -- --nocapture --test-threads=1`: - on `aaa0936` with only the PR's `tests.rs` copied in: **1 failed**, `direct true, heap windows false: dword`, left `2952790016` (`0xB000_0000`, window 1's marker), right `2684354560` (`0xA000_0000`); - on `7e2c923`: **1 passed**, 0 failed, not skipped. - `.\scripts\test.ps1` (`cargo build --workspace`, then `cargo test --workspace -- --test-threads=4`) on `7e2c923`: **1152 passed, 0 failed, 46 ignored** across 20 test binaries, exit 0. SKIPPED, 25: 20 × `no wave64`, 3 × per-lane form refused (`V_CVT_F16_F32`, `V_PK_MUL_F16`, `V_MUL_F16`: "its #1426 semantics differ from the console's"), 1 × `no heap windows`, 1 × cannot disable the driver cache (Windows Developer Mode required). **Regression run** (`scripts/smoke.ps1 -Game <folder> -Seconds 60`, the same title, back to back, menus, no input; unedited). `main` `aaa0936`: ``` xcl-smoke v1 commit: aaa093657bd96a146c05c0c1a9b61149fe761453 gpu: NVIDIA GeForce RTX 3070 title: 3d7db37d seconds: 60 exit: 0x0 frames shown: 1410 (PresentX 1410) presents per 2 s (last 3): 59 61 60 device removals: 0 crashes: 0 peak commit: 15274 MB ``` PR head `7e2c923`: ``` xcl-smoke v1 commit: 7e2c9235dfc6ab91dee9f85eaca03d50174506b6 gpu: NVIDIA GeForce RTX 3070 title: 3d7db37d seconds: 60 exit: 0x0 frames shown: 1560 (PresentX 1560) presents per 2 s (last 3): 61 60 51 device removals: 0 crashes: 0 peak commit: 15097 MB ``` That is 111 % of `main`'s frames and 99 % of its peak commit. **Not tested** - AMD, native wave64 (the 20 `no wave64` skips above), a world run (the smoke stays in the menus, so it does not show whether the title reaches an `s_buffer_load` that wraps), the tests on game data (`XCL_SAMPLE_*` not set). **AI use** - Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 04:55 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 04:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2062#issuecomment-7153283254) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 07:13 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 07:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/2062#issuecomment-7185236014) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2062/head:github-bot/gh-2062'
git switch 'github-bot/gh-2062'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2062'
git switch 'github-bot/gh-2062'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2062'
git switch 'github-bot/gh-2062'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2062'
git switch 'main'
git merge --squash 'github-bot/gh-2062'
git switch 'main'
git merge --ff-only 'github-bot/gh-2062'
git switch 'main'
git merge 'github-bot/gh-2062'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.