Recompiler: write all bytes of unaligned multi-dword formatted buffer stores #312

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

@⁠Michael-Glaser on GitHub · 2026-11-23 23:07 UTC · original
Michael-Glaser:fix/recomp-st-bytes-unaligned → main · +60 −3 · 2 files · 1 commits · open

st_bytes in PRELUDE_MEM only wrote r.x on its unaligned / non-multiple-of-4 fallback path, dropping bytes 4..15 of 8-, 12-, and 16-byte formatted buffer stores.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: loop over all 4 dwords of r in st_bytes's fallback path.
  • crates/xcl/src/gpu/recomp/tests.rs: HLSL emission test + GPU test for 8-, 12-, and 16-byte unaligned formatted stores.

Tested

  • Cross-checked on macOS (aarch64-apple-darwin, Rust 1.100.0): cargo check --offline --target x86_64-pc-windows-msvc --workspace --tests (0 errors, 0 new warnings).

Not tested

  • Not built or executed on Windows; DXC, cargo test, GPU tests (AMD/NVIDIA), and scripts/smoke.ps1 not run yet.

AI use

  • Antigravity with Gemini 4 Neon (audit, fix, tests, description).
**@⁠Michael-Glaser** on GitHub · 2026-11-23 23:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/312) `Michael-Glaser:fix/recomp-st-bytes-unaligned` → `main` · +60 −3 · 2 files · 1 commits · open `st_bytes` in `PRELUDE_MEM` only wrote `r.x` on its unaligned / non-multiple-of-4 fallback path, dropping bytes 4..15 of 8-, 12-, and 16-byte formatted buffer stores. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: loop over all 4 dwords of `r` in `st_bytes`'s fallback path. - `crates/xcl/src/gpu/recomp/tests.rs`: HLSL emission test + GPU test for 8-, 12-, and 16-byte unaligned formatted stores. **Tested** - Cross-checked on macOS (`aarch64-apple-darwin`, Rust 1.100.0): `cargo check --offline --target x86_64-pc-windows-msvc --workspace --tests` (0 errors, 0 new warnings). **Not tested** - Not built or executed on Windows; DXC, `cargo test`, GPU tests (AMD/NVIDIA), and `scripts/smoke.ps1` not run yet. **AI use** - Antigravity with Gemini 4 Neon (audit, fix, tests, description).
st_bytes in PRELUDE_MEM iterated over r[0..4] only on the aligned multiple-of-4-bytes fast path. On the unaligned or non-multiple-of-4 fallback path it clamped the byte mask to 4 bytes and wrote only r.x, silently dropping bytes 4..15 of 8-, 12-, and 16-byte formatted buffer stores (e.g. 32_32_*, 32_32_32_*, 32_32_32_32_* at a % 4 != 0).

Loop over all four dwords of r in the fallback path, computing the remaining byte count and mask per dword and splitting across the 4-byte boundary when needed. Add an HLSL emission test and a GPU test covering 8-, 12-, and 16-byte unaligned formatted stores.

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:45 +00:00
Author
Owner

@⁠regiumlepidi on GitHub · 2026-11-23 23:45 UTC · original

A Windows run for this draft, since the description has none yet: d9d6fe0 merged onto current main db1ddb2 (clean merge): builds and passes on NVIDIA and AMD, and the new tests catch the bug.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (32-lane waves), driver 617.42 (32.0.16.1742), and AMD Radeon(TM) Graphics (Ryzen 7 9800X3D iGPU, RDNA2, 64-lane waves), driver 32.0.21030.2001, selected with XCL_ADAPTER=radeon
  • Ryzen 7 9800X3D, 48 GB, Windows 11 Pro 25H2, rustc 1.100.0 MSVC, DXC from Windows SDK 10.0.26100, debug
  • .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4), no XCL_SAMPLE_* set
Build RTX 5070 Ti RDNA2 iGPU
main db1ddb2 666 passed, 0 failed, 41 ignored 666 passed, 0 failed, 41 ignored
d9d6fe0 on db1ddb2 668 passed, 0 failed, 41 ignored 668 passed, 0 failed, 41 ignored

GPU tests skipped: the usual 2 (no wave64) on NVIDIA, none on the iGPU.

The two new tests with this PR's tests.rs but main's emit.rs: both fail on both adapters, e.g. gpu_unaligned_multi_dword_format_stores: store of 8 bytes at 0x100+1, left: [170, 68, 51, 34, 17, 170, 170, …], right: [170, 68, 51, 34, 17, 136, 119, 102, 85, 170, …] (the second dword never written). With this PR's emit.rs both pass on both adapters.

Not tested

  • scripts/smoke.ps1 on a real title (I have none).
  • RDNA3 / RDNA4, Intel.

AI use: Claude Code with Claude Opus 5.5 ran the build and tests and wrote this comment; the numbers come from those runs.

**@⁠regiumlepidi** on GitHub · 2026-11-23 23:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/312#issuecomment-7117335236) A Windows run for this draft, since the description has none yet: `d9d6fe0` merged onto current `main` `db1ddb2` (clean merge): **builds and passes on NVIDIA and AMD**, and the new tests catch the bug. **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (32-lane waves), driver 617.42 (32.0.16.1742), and AMD Radeon(TM) Graphics (Ryzen 7 9800X3D iGPU, RDNA2, 64-lane waves), driver 32.0.21030.2001, selected with `XCL_ADAPTER=radeon` - Ryzen 7 9800X3D, 48 GB, Windows 11 Pro 25H2, rustc 1.100.0 MSVC, DXC from Windows SDK 10.0.26100, debug - `.\scripts\test.ps1` (`cargo test --workspace -- --test-threads=4`), no `XCL_SAMPLE_*` set | Build | RTX 5070 Ti | RDNA2 iGPU | |---|---|---| | `main` `db1ddb2` | 666 passed, 0 failed, 41 ignored | 666 passed, 0 failed, 41 ignored | | `d9d6fe0` on `db1ddb2` | 668 passed, 0 failed, 41 ignored | 668 passed, 0 failed, 41 ignored | GPU tests skipped: the usual 2 (`no wave64`) on NVIDIA, none on the iGPU. The two new tests with this PR's `tests.rs` but `main`'s `emit.rs`: both fail on both adapters, e.g. `gpu_unaligned_multi_dword_format_stores`: `store of 8 bytes at 0x100+1`, `left: [170, 68, 51, 34, 17, 170, 170, …]`, `right: [170, 68, 51, 34, 17, 136, 119, 102, 85, 170, …]` (the second dword never written). With this PR's `emit.rs` both pass on both adapters. **Not tested** - `scripts/smoke.ps1` on a real title (I have none). - RDNA3 / RDNA4, Intel. AI use: Claude Code with Claude Opus 5.5 ran the build and tests and wrote this comment; the numbers come from those runs.
Author
Owner

@⁠ghost on GitHub · 2026-11-23 23:48 UTC · original

Tested d9d6fe0 merged onto main db1ddb2 (clean merge) on AMD RDNA4: pass, and both new tests fail without the emit.rs change. This covers the Windows build and GPU run listed under "Not tested".

Tested

  • AMD Radeon RX 9060 XT (RDNA4), driver 32.0.32029.2010; Ryzen 7 5800X3D; Windows 11 Pro 26200; Rust 1.100.0; DXC 1.9.2602.17 (SDK 10.0.26100); debug build.
  • .\scripts\test.ps1: 668 passed, 0 failed, 41 ignored; no SKIPPED GPU tests on this adapter.
  • XCL_REQUIRE_GPU=wave64,mesh cargo test -p xcl --lib unaligned: st_bytes_writes_every_dword_of_unaligned_stores and gpu_unaligned_multi_dword_format_stores pass.
  • Negative control: the merged tree with only emit.rs put back to main. Both tests fail. The GPU one fails at its first case, store of 8 bytes at 0x100+1: bytes 1..4 hold r.x and bytes 5..8 stay 0xAA (expected 88 77 66 55). (The PR's own tests.rs, from its base 4017f8f, doesn't compile on current main, so the control uses the merged tree.)

Not tested

  • No XCL_SAMPLE_* set and no retail title, so no smoke.ps1 regression run; NVIDIA.

AI use

  • Claude Code (Claude Opus 5.5) ran the commands and wrote this report from the logs; I checked it before posting.
**@⁠ghost** on GitHub · 2026-11-23 23:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/312#issuecomment-7117388278) Tested `d9d6fe0` merged onto `main` `db1ddb2` (clean merge) on AMD RDNA4: **pass**, and both new tests fail without the `emit.rs` change. This covers the Windows build and GPU run listed under "Not tested". **Tested** - AMD Radeon RX 9060 XT (RDNA4), driver 32.0.32029.2010; Ryzen 7 5800X3D; Windows 11 Pro 26200; Rust 1.100.0; DXC 1.9.2602.17 (SDK 10.0.26100); debug build. - `.\scripts\test.ps1`: 668 passed, 0 failed, 41 ignored; no `SKIPPED` GPU tests on this adapter. - `XCL_REQUIRE_GPU=wave64,mesh cargo test -p xcl --lib unaligned`: `st_bytes_writes_every_dword_of_unaligned_stores` and `gpu_unaligned_multi_dword_format_stores` pass. - Negative control: the merged tree with only `emit.rs` put back to `main`. Both tests fail. The GPU one fails at its first case, `store of 8 bytes at 0x100+1`: bytes 1..4 hold `r.x` and bytes 5..8 stay `0xAA` (expected `88 77 66 55`). (The PR's own `tests.rs`, from its base `4017f8f`, doesn't compile on current `main`, so the control uses the merged tree.) **Not tested** - No `XCL_SAMPLE_*` set and no retail title, so no `smoke.ps1` regression run; NVIDIA. **AI use** - Claude Code (Claude Opus 5.5) ran the commands and wrote this report from the logs; I checked it before posting.
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-24 21:02 UTC · original

Regression run on a retail title for b8424b2: pass (no device removal, no crash, frames and peak commit within the check's limits).

Tested

  • RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build.
  • scripts\smoke.ps1 -Game <folder> -Seconds 60, no input, on this PR's head as it is and on main 47efa2e, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The main block is shared with my reports on other PRs of the same base.

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1446 (PresentX 1446)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19285 MB

this PR:

xcl-smoke v1
commit: b8424b2cf36680f1b83579da9fbcdc96aa17befa
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1482 (PresentX 1482)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19370 MB

Not tested

  • Whether the 60 s reach the code this PR changes, the world load, the test suite, current main merged in, AMD and Intel GPUs.

AI use

  • Claude Code (Claude Opus 5.5) made the runs with me present and wrote this from the script's output.
**@⁠CuteBooty** on GitHub · 2026-11-24 21:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/312#issuecomment-7144393006) Regression run on a retail title for `b8424b2`: **pass** (no device removal, no crash, frames and peak commit within the check's limits). **Tested** - RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build. - `scripts\smoke.ps1 -Game <folder> -Seconds 60`, no input, on this PR's head as it is and on `main` `47efa2e`, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The `main` block is shared with my reports on other PRs of the same base. main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 3070 title: game seconds: 60 exit: 0x0 frames shown: 1446 (PresentX 1446) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19285 MB ``` this PR: ``` xcl-smoke v1 commit: b8424b2cf36680f1b83579da9fbcdc96aa17befa gpu: NVIDIA GeForce RTX 3070 title: game seconds: 60 exit: 0x0 frames shown: 1482 (PresentX 1482) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19370 MB ``` **Not tested** - Whether the 60 s reach the code this PR changes, the world load, the test suite, current `main` merged in, AMD and Intel GPUs. **AI use** - Claude Code (Claude Opus 5.5) made the runs with me present and wrote this from the script's output.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 14:43 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 14:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/312#issuecomment-7165718856) 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!
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/312/head:github-bot/gh-312'
git switch 'github-bot/gh-312'

Merge

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