tombox-xshader tests: bit-exact buffer_gl0_inv and buffer_gl1_inv #332

Closed
github-bot wants to merge 1 commit from gh-pr/332/head into gh-pr/332/base
Owner

@⁠GDAgent on GitHub · 2026-11-23 20:21 UTC · original
GDAgent:tests/xshader-exec-mubuf-cache-inv → main · +33 −0 · 2 files · 1 commits · closed without merging

Library / area: tombox-xshader, tests only (new tests/exec_mem/mubuf_inv.rs, one mod line in tests/exec_mem/mod.rs)

Exports changed (exports.txt rows): none

Source of the behaviour: RDNA2 ISA: MUBUF opcodes 0x71 BUFFER_GL0_INV and 0x72 BUFFER_GL1_INV invalidate the vector L0 and the GL1 caches; they take no resource and write no register. The translator already emits nothing for them. Run natively on Windows 11 on an AMD RDNA2 GPU (Radeon RX 6600 XT, gfx1032) and on WARP; not run under Proton.

What

buffer_gl0_inv and buffer_gl1_inv are translated, but no exec case ran them, so neither counts as verified. The new test executes each of them on the device through the existing CsCase harness (compute shader, buffer readback). Per mnemonic and per value (a plain dword and one with the sign bit set), the shader:

  1. stores a dword,
  2. runs the invalidate,
  3. loads the same dword back and stores the loaded value next to it,
  4. stores the original value again.

The test checks that the stored data is still visible after the invalidate, that a register written before the invalidate is intact, and that the neighbouring dword stays 0. The group is also rerun with runtime inputs, like the other groups.

Why

Both opcodes occur in the shaders of The Matrix Awakens (Xbox Series X build) as the RDNA2 form of the GCN buffer_wbinvl1; the ISA table test already maps that name to them. A mistranslation here (for example treating the instruction as a memory access that needs a resource) would refuse every shader that contains one, so a pinned case is cheap protection.

No translator bug turned up: all 4 cases passed on WARP and on the GPU at the first run.

This PR replaces the cache-invalidate group of an earlier broader MUBUF branch of ours; the other 11 mnemonics of that branch are covered by #297, so they are not repeated here. The new module is named mubuf_inv and sits away from the other mod lines so it does not conflict with #297 (checked with a trial merge against #297, #298, #286, #287, #242 and #302).

tools/progress/progress.json rdna2_verified is not touched, to keep this PR test-only.

Tests

  • cargo test -p tombox-xshader --test exec mubuf_cache_invalidates (WARP): 1 passed.
  • TOMBOX_EXEC_HW=1 cargo test -p tombox-xshader --test exec mubuf_cache_invalidates -- --nocapture (Radeon RX 6600 XT): 1 passed; output line mubuf_cache_invalidates: 2 mnemonics verified, 0 failing, 4 cases, 4 rerun with runtime inputs.
  • pr_gate.py --base origin/main: 0 problems.

Not verified

  • Not verified in a title: test-only change.
  • The full exec binary was not run with this commit. On main and this GPU, four existing tests fail with TOMBOX_EXEC_HW=1 on this AMD GPU (f16_omod_follows_mode, mtbuf_d16_store_formats, scalar_smem_loads, vop2_basic); they fail the same way on plain main and they share no code with this module. They pass on WARP.
  • Whether the invalidate has any visible effect on hardware is not tested: a single-wave shader cannot observe a stale cache line. The test checks that the instruction is accepted, runs, and does not disturb data or registers.
**@⁠GDAgent** on GitHub · 2026-11-23 20:21 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/332) `GDAgent:tests/xshader-exec-mubuf-cache-inv` → `main` · +33 −0 · 2 files · 1 commits · closed without merging **Library / area:** `tombox-xshader`, tests only (new `tests/exec_mem/mubuf_inv.rs`, one `mod` line in `tests/exec_mem/mod.rs`) **Exports changed (exports.txt rows):** none **Source of the behaviour:** RDNA2 ISA: MUBUF opcodes 0x71 `BUFFER_GL0_INV` and 0x72 `BUFFER_GL1_INV` invalidate the vector L0 and the GL1 caches; they take no resource and write no register. The translator already emits nothing for them. Run natively on Windows 11 on an AMD RDNA2 GPU (Radeon RX 6600 XT, gfx1032) and on WARP; not run under Proton. ## What `buffer_gl0_inv` and `buffer_gl1_inv` are translated, but no exec case ran them, so neither counts as verified. The new test executes each of them on the device through the existing `CsCase` harness (compute shader, buffer readback). Per mnemonic and per value (a plain dword and one with the sign bit set), the shader: 1. stores a dword, 2. runs the invalidate, 3. loads the same dword back and stores the loaded value next to it, 4. stores the original value again. The test checks that the stored data is still visible after the invalidate, that a register written before the invalidate is intact, and that the neighbouring dword stays 0. The group is also rerun with runtime inputs, like the other groups. ## Why Both opcodes occur in the shaders of The Matrix Awakens (Xbox Series X build) as the RDNA2 form of the GCN `buffer_wbinvl1`; the ISA table test already maps that name to them. A mistranslation here (for example treating the instruction as a memory access that needs a resource) would refuse every shader that contains one, so a pinned case is cheap protection. No translator bug turned up: all 4 cases passed on WARP and on the GPU at the first run. This PR replaces the cache-invalidate group of an earlier broader MUBUF branch of ours; the other 11 mnemonics of that branch are covered by #297, so they are not repeated here. The new module is named `mubuf_inv` and sits away from the other `mod` lines so it does not conflict with #297 (checked with a trial merge against #297, #298, #286, #287, #242 and #302). `tools/progress/progress.json` `rdna2_verified` is not touched, to keep this PR test-only. ## Tests - `cargo test -p tombox-xshader --test exec mubuf_cache_invalidates` (WARP): 1 passed. - `TOMBOX_EXEC_HW=1 cargo test -p tombox-xshader --test exec mubuf_cache_invalidates -- --nocapture` (Radeon RX 6600 XT): 1 passed; output line `mubuf_cache_invalidates: 2 mnemonics verified, 0 failing, 4 cases, 4 rerun with runtime inputs`. - `pr_gate.py --base origin/main`: 0 problems. ## Not verified - Not verified in a title: test-only change. - The full `exec` binary was not run with this commit. On `main` and this GPU, four existing tests fail with `TOMBOX_EXEC_HW=1` on this AMD GPU (`f16_omod_follows_mode`, `mtbuf_d16_store_formats`, `scalar_smem_loads`, `vop2_basic`); they fail the same way on plain `main` and they share no code with this module. They pass on WARP. - Whether the invalidate has any visible effect on hardware is not tested: a single-wave shader cannot observe a stale cache line. The test checks that the instruction is accepted, runs, and does not disturb data or registers.
MUBUF opcodes 0x71 and 0x72 invalidate the GPU data caches and translate
to nothing, but no exec case ran them. Each case stores a dword, runs the
invalidate, loads the dword back, stores the loaded value and the original
again, and checks that the stored data is still visible and that the
neighbouring dword is untouched. One case per mnemonic and per value
(a plain dword and one with the sign bit set).

Executed on WARP by default, on the GPU with TOMBOX_EXEC_HW=1.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:19:16 +00:00
github-bot closed this pull request 2026-11-26 06:19:16 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:51 UTC · original

Thanks. #305 covers buffer_gl0_inv and buffer_gl1_inv with the same and additional cases, so this is superseded.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:51 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/332#issuecomment-7164391903) Thanks. #305 covers buffer_gl0_inv and buffer_gl1_inv with the same and additional cases, so this is superseded.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.