tombox-xshader: decode and translate the MUBUF D16 byte/short loads and d16_hi stores #235

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

@⁠azerioxfr on GitHub · 2026-11-23 06:29 UTC · original
azerioxfr:xshader-mubuf-d16-subword → main · +45 −3 · 3 files · 1 commits · closed without merging

Library / area: tombox-xshader, MUBUF sub-dword accesses: buffer_load_{ubyte,sbyte,short}_d16{,_hi}, buffer_store_{byte,short}_d16_hi

Exports changed (exports.txt rows): none

Source of the behaviour: opcodes from tests/isa_table/gfx1013.txt (MUBUF 0x19, 0x1b, 0x20..0x25). Semantics from the RDNA2 ISA descriptions, lowered the same way as the LDS D16 forms in 28f54b2.

One topic, +45 / -3: 4 lines in rdna2/mnem.rs, 17 in hlsl.rs, 23 lines of test.

What was missing

These eight opcodes were not decoded. tests/isa_table.rs lists them under "mubuf: 37 gfx1013 opcodes not named by the decoder", so a shader that used one failed translation.

The change

opcode lowering
buffer_load_ubyte_d16 / buffer_load_sbyte_d16 (0x20 / 0x22) the byte, zero- or sign-extended to 16 bits, replaces vdst[15:0]; vdst[31:16] kept
buffer_load_ubyte_d16_hi / buffer_load_sbyte_d16_hi (0x21 / 0x23) the same into vdst[31:16]; vdst[15:0] kept
buffer_load_short_d16 / _hi (0x24 / 0x25) the halfword into vdst[15:0] / [31:16]
buffer_store_byte_d16_hi / buffer_store_short_d16_hi (0x19 / 0x1b) stores data[23:16] / data[31:16], with the same InterlockedAnd/InterlockedOr merge as buffer_store_byte / _short

The loads read vdst for the kept half, as the LDS D16 reads do.

Tests

buffer_mubuf gains the six loads (vdst preloaded with 0x5a5aa5a5, so the kept half is checked) and both stores, at the five existing address / offset pairs:

run (WARP, --release, DXC 1.9.2609) result
buffer_mubuf on this branch 26 mnemonics verified, 0 failing, 183 cases
kept half dropped in hlsl.rs (mutation) 20 verified, 6 failing (all six loads)
--test isa_table, --test opcodes 3 and 26 passed

Run on x86_64-pc-windows-gnu (no MSVC linker here); these are integer-only paths.

  • cargo test -p tombox-xshader --test exec -- --exact buffer_mubuf passes
  • 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 06:29 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/235) `azerioxfr:xshader-mubuf-d16-subword` → `main` · +45 −3 · 3 files · 1 commits · closed without merging **Library / area:** tombox-xshader, MUBUF sub-dword accesses: `buffer_load_{ubyte,sbyte,short}_d16{,_hi}`, `buffer_store_{byte,short}_d16_hi` **Exports changed (exports.txt rows):** none **Source of the behaviour:** opcodes from `tests/isa_table/gfx1013.txt` (MUBUF 0x19, 0x1b, 0x20..0x25). Semantics from the RDNA2 ISA descriptions, lowered the same way as the LDS D16 forms in 28f54b2. One topic, +45 / -3: 4 lines in `rdna2/mnem.rs`, 17 in `hlsl.rs`, 23 lines of test. ### What was missing These eight opcodes were not decoded. `tests/isa_table.rs` lists them under "mubuf: 37 gfx1013 opcodes not named by the decoder", so a shader that used one failed translation. ### The change | opcode | lowering | |---|---| | `buffer_load_ubyte_d16` / `buffer_load_sbyte_d16` (0x20 / 0x22) | the byte, zero- or sign-extended to 16 bits, replaces vdst[15:0]; vdst[31:16] kept | | `buffer_load_ubyte_d16_hi` / `buffer_load_sbyte_d16_hi` (0x21 / 0x23) | the same into vdst[31:16]; vdst[15:0] kept | | `buffer_load_short_d16` / `_hi` (0x24 / 0x25) | the halfword into vdst[15:0] / [31:16] | | `buffer_store_byte_d16_hi` / `buffer_store_short_d16_hi` (0x19 / 0x1b) | stores data[23:16] / data[31:16], with the same `InterlockedAnd`/`InterlockedOr` merge as `buffer_store_byte` / `_short` | The loads read vdst for the kept half, as the LDS D16 reads do. ### Tests `buffer_mubuf` gains the six loads (vdst preloaded with `0x5a5aa5a5`, so the kept half is checked) and both stores, at the five existing address / offset pairs: | run (WARP, `--release`, DXC 1.9.2609) | result | |---|---| | `buffer_mubuf` on this branch | **26 mnemonics verified, 0 failing, 183 cases** | | kept half dropped in `hlsl.rs` (mutation) | 20 verified, 6 failing (all six loads) | | `--test isa_table`, `--test opcodes` | 3 and 26 passed | Run on `x86_64-pc-windows-gnu` (no MSVC linker here); these are integer-only paths. - [x] `cargo test -p tombox-xshader --test exec -- --exact buffer_mubuf` passes - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
MUBUF opcodes 0x19, 0x1b and 0x20..0x25 were not decoded (the
isa_table test lists them under "gfx1013 opcodes not named by the
decoder"). They now decode and are lowered next to the other sub-dword
buffer accesses:
- buffer_load_ubyte_d16 / buffer_load_sbyte_d16 (0x20 / 0x22): the
  byte, zero- or sign-extended to 16 bits, replaces bits [15:0] of vdst;
- buffer_load_ubyte_d16_hi / buffer_load_sbyte_d16_hi (0x21 / 0x23):
  the same into bits [31:16];
- buffer_load_short_d16 / buffer_load_short_d16_hi (0x24 / 0x25): the
  halfword into bits [15:0] / [31:16];
- buffer_store_byte_d16_hi / buffer_store_short_d16_hi (0x19 / 0x1b):
  store bits [23:16] / [31:16] of the data register, with the same
  InterlockedAnd/InterlockedOr merge as buffer_store_byte/short.
The other half of vdst is kept, so the loads also read vdst. Semantics
follow the RDNA2 ISA descriptions, as for the LDS D16 forms (28f54b2).

Tests: buffer_mubuf gains the six loads (vdst preloaded with
0x5a5aa5a5 so the kept half is checked) and both stores, at the five
existing address/offset pairs: 26 mnemonics verified, 183 cases, on
WARP. Dropping the kept half fails the 6 loads.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:15:07 +00:00
github-bot closed this pull request 2026-11-26 06:15:07 +00:00
Author
Owner

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

Applied in 283ac34 (merged in d8d37e4) with your authorship kept, thanks. It shipped in r32h (e67e3d4), which passed its Trackmania control run; the TM shader corpus showed no output changes.

**@⁠omonkeyz** on GitHub · 2026-11-23 08:44 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/235#issuecomment-7095786607) Applied in 283ac34 (merged in d8d37e4) with your authorship kept, thanks. It shipped in r32h (e67e3d4), which passed its Trackmania control run; the TM shader corpus showed no output changes.

Pull request closed

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