tombox-xshader: translate s_buffer_store_dword* into UAV writes #258

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

@⁠azerioxfr on GitHub · 2026-11-23 08:01 UTC · original
azerioxfr:xshader-smem-stores → main · +118 −0 · 3 files · 1 commits · closed without merging

Library / area: tombox-xshader, SMEM stores (hlsl.rs scalar descriptor resolution and SMEM emission)

Exports changed (exports.txt rows): none

Source of the behaviour: opcodes from tests/isa_table/gfx1013.txt (SMEM 0x10..0x12, 0x18..0x1a). s_buffer_store_* addresses the descriptor exactly like s_buffer_load_* (SBASE + SOFFSET / imm).

One topic, +118: 2 lines in rdna2/mnem.rs, about 62 in hlsl.rs, 54 lines of test.

What was missing

tests/isa_table.rs lists s_buffer_store_dword{,x2,x4} and s_store_dword{,x2,x4} under "smem: gfx1013 opcodes not named by the decoder".

The change

opcode change
s_buffer_store_dword / _x2 / _x4 the descriptor resolves through the existing desc_candidates / kind_at used by the scalar loads. A writable buffer is written as one dword per SDATA register at (SOFFSET & ~3) + imm, into the same (structured) UAV the MUBUF store path uses. A base that is not a descriptor, could name more than one descriptor, or names a non-writable one is refused explicitly.
s_store_dword / _x2 / _x4 decoder names plus an explicit refusal. These write through the 64-bit address in the SBASE pair, and the translator has no GPU-VA-to-resource map for scalar stores.

Tests

run (WARP, --release, DXC 1.9.2609) result
new scalar_buffer_stores (3 widths, imm 0 / 4 / 8 / 0x40, SOFFSET 12 + imm 4, untouched neighbour checked) 3 mnemonics verified, 0 failing, 15 cases (static and runtime inputs)
new scalar_smem_store_refusals (three s_store_dword refusals; non-descriptor and non-writable s_buffer_store) passes
mutation: x2 / x4 store every dword to the first word 1 verified, 2 failing
regression scalar_smem_loads 10 mnemonics verified, 0 failing, 47 cases
--test isa_table / opcodes / synthetic 3 / 26 / 24 passed

Run on x86_64-pc-windows-gnu (no MSVC linker here). Integer only.

  • tests pass
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note
**@⁠azerioxfr** on GitHub · 2026-11-23 08:01 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/258) `azerioxfr:xshader-smem-stores` → `main` · +118 −0 · 3 files · 1 commits · closed without merging **Library / area:** tombox-xshader, SMEM stores (`hlsl.rs` scalar descriptor resolution and SMEM emission) **Exports changed (exports.txt rows):** none **Source of the behaviour:** opcodes from `tests/isa_table/gfx1013.txt` (SMEM 0x10..0x12, 0x18..0x1a). `s_buffer_store_*` addresses the descriptor exactly like `s_buffer_load_*` (SBASE + SOFFSET / imm). One topic, +118: 2 lines in `rdna2/mnem.rs`, about 62 in `hlsl.rs`, 54 lines of test. ### What was missing `tests/isa_table.rs` lists `s_buffer_store_dword{,x2,x4}` and `s_store_dword{,x2,x4}` under "smem: gfx1013 opcodes not named by the decoder". ### The change | opcode | change | |---|---| | `s_buffer_store_dword` / `_x2` / `_x4` | the descriptor resolves through the existing `desc_candidates` / `kind_at` used by the scalar loads. A writable buffer is written as one dword per SDATA register at `(SOFFSET & ~3) + imm`, into the same (structured) UAV the MUBUF store path uses. A base that is not a descriptor, could name more than one descriptor, or names a non-writable one is refused explicitly. | | `s_store_dword` / `_x2` / `_x4` | decoder names plus an explicit refusal. These write through the 64-bit address in the SBASE pair, and the translator has no GPU-VA-to-resource map for scalar stores. | ### Tests | run (WARP, `--release`, DXC 1.9.2609) | result | |---|---| | new `scalar_buffer_stores` (3 widths, imm 0 / 4 / 8 / 0x40, SOFFSET 12 + imm 4, untouched neighbour checked) | **3 mnemonics verified, 0 failing, 15 cases** (static and runtime inputs) | | new `scalar_smem_store_refusals` (three `s_store_dword` refusals; non-descriptor and non-writable `s_buffer_store`) | passes | | mutation: x2 / x4 store every dword to the first word | 1 verified, 2 failing | | regression `scalar_smem_loads` | 10 mnemonics verified, 0 failing, 47 cases | | `--test isa_table` / `opcodes` / `synthetic` | 3 / 26 / 24 passed | Run on `x86_64-pc-windows-gnu` (no MSVC linker here). Integer only. - [x] tests pass - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
`--test isa_table -- --nocapture` lists SMEM 0x18-0x1a (s_buffer_store_
dword/_x2/_x4) and 0x10-0x12 (s_store_dword/_x2/_x4) among the gfx1013
opcodes the decoder does not name, so a shader that stores through a
descriptor failed to decode.

s_buffer_store_* addresses the same descriptor that s_buffer_load_* reads
(SBASE + SOFFSET/imm byte offset). The scalar loads already resolve that
descriptor through desc_candidates/kind_at; a store resolves it the same
way, and when the descriptor names a writable buffer the store is emitted
into the same (structured) UAV the MUBUF store path uses: one dword per
SDATA register at (SOFFSET & ~3) + imm, indexed flat over the declared
element. A store whose base is not a descriptor, names more than one
candidate descriptor, or resolves to a descriptor that is not writable is
refused explicitly; nothing is guessed.

s_store_dword* writes through the 64-bit address in the SBASE register
pair, not through a buffer descriptor, and the translator has no
GPU-VA-to-resource map for scalar stores, so the decoder names them and
translation returns an explicit error naming the instruction and offset
instead of falling through to an unrelated constant-buffer failure.

Tests: scalar_buffer_stores covers all three store widths at immediate
offsets 0, 4, 8 and 0x40, plus SOFFSET 12 with imm 4, checking the written
words and the untouched neighbour (3 mnemonics, 15 cases, both static and
runtime-input preludes). scalar_smem_store_refusals pins the three
s_store_dword refusals and the non-descriptor / non-writable descriptor
refusals for s_buffer_store_dword. Mutation: storing every dword of the
x2/x4 forms to the first word reports "1 mnemonics verified, 2 failing";
renaming the refusal text reports a failing refusal assertion.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:16:12 +00:00
github-bot closed this pull request 2026-11-26 06:16:12 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 14:08 UTC · original

Applied locally on main with your authorship kept (cherry-picked, ecc06dd); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.

**@⁠omonkeyz** on GitHub · 2026-11-23 14:08 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/258#issuecomment-7103542962) Applied locally on main with your authorship kept (cherry-picked, ecc06dd); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.
Author
Owner

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

Applied on main in ecc06dd (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:08 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/258#issuecomment-7163358596) Applied on main in ecc06dd (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.
Author
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-24 14:34 UTC · original · reviewed

A note in case someone plans a silicon check of this PR: s_buffer_store_dword* can't be verified on RDNA2.x parts. LLVM 18 assembles the scalar stores for gfx1013 but rejects them for gfx1036 ("instruction not supported on this GPU"). An unsupported opcode I tried on the same gfx1036 today hung the GPU, so I didn't run them. A check needs a gfx101x GPU (RX 5000 series).

(Measured with an AI assistant, Claude.)

**@⁠SchmashinPrunes** on GitHub · 2026-11-24 14:34 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/258#pullrequestreview-6041181784) · **reviewed** A note in case someone plans a silicon check of this PR: `s_buffer_store_dword*` can't be verified on RDNA2.x parts. LLVM 18 assembles the scalar stores for gfx1013 but rejects them for gfx1036 ("instruction not supported on this GPU"). An unsupported opcode I tried on the same gfx1036 today hung the GPU, so I didn't run them. A check needs a gfx101x GPU (RX 5000 series). (Measured with an AI assistant, Claude.)

Pull request closed

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