tombox-xshader: decode and translate ds_read_b96, ds_read_b128, ds_wr… #240

Closed
azerioxfr wants to merge 1 commit from upstream-pr/240 into main
azerioxfr commented 2026-11-23 06:44:05 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by azerioxfr on 2026-11-23T06:44:05Z.


Library / area: tombox-xshader, wide LDS accesses (hlsl/ds_ext.rs split_wide_lds)

Exports changed (exports.txt rows): none

Source of the behaviour: opcodes from tests/isa_table/gfx1013.txt (DS 0xde, 0xdf, 0xfe, 0xff). Semantics from the RDNA2 ISA: consecutive dwords at addr + offset, like ds_read_b64 / ds_write_b64.

One topic, +25 / -2: 1 line in rdna2/mnem.rs, 9 in hlsl/ds_ext.rs, 15 lines of test.

What was missing

tests/isa_table.rs lists these four under "ds: gfx1013 opcodes not named by the decoder", so a compute or geometry shader that moves 3 or 4 dwords through LDS in one instruction failed translation.

The change

opcode split into
ds_write_b96 (0xde) / ds_write_b128 (0xdf) ds_write_b32 of data0..data0+2 / +3 at offset, +4, +8 (+12)
ds_read_b96 (0xfe) / ds_read_b128 (0xff) ds_read_b32 into vdst..vdst+2 / +3 at the same offsets; a part whose vdst is the address register is read last (the existing rule)

Unaligned b96 / b128 addresses depend on the LDS alignment mode, so they are not claimed. The tests use 16-byte aligned addresses.

Tests

ds_lds_b64_compute gains, for both widths, a write then a read through the neighbouring lane at offsets 0, 0x10 and 0x400, with vdst 10 and with vdst 15 (the read's own address register):

run (WARP, --release, DXC 1.9.2609) result
exec_mem::ds::ds_lds_b64_compute 10 mnemonics verified, 0 failing, 45 cases
mutation: b128 split reuses +8 for the 4th dword 8 verified, 2 failing
--test isa_table / --test opcodes 3 / 26 passed

Run on x86_64-pc-windows-gnu (no MSVC linker here). These are data moves only, with no floating point.

  • cargo test -p tombox-xshader --test exec -- --exact exec_mem::ds::ds_lds_b64_compute passes
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6553867194 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/240). Originally posted by [azerioxfr](https://github.com/azerioxfr) on 2026-11-23T06:44:05Z. --- **Library / area:** tombox-xshader, wide LDS accesses (`hlsl/ds_ext.rs` `split_wide_lds`) **Exports changed (exports.txt rows):** none **Source of the behaviour:** opcodes from `tests/isa_table/gfx1013.txt` (DS 0xde, 0xdf, 0xfe, 0xff). Semantics from the RDNA2 ISA: consecutive dwords at `addr + offset`, like `ds_read_b64` / `ds_write_b64`. One topic, +25 / -2: 1 line in `rdna2/mnem.rs`, 9 in `hlsl/ds_ext.rs`, 15 lines of test. ### What was missing `tests/isa_table.rs` lists these four under "ds: gfx1013 opcodes not named by the decoder", so a compute or geometry shader that moves 3 or 4 dwords through LDS in one instruction failed translation. ### The change | opcode | split into | |---|---| | `ds_write_b96` (0xde) / `ds_write_b128` (0xdf) | `ds_write_b32` of data0..data0+2 / +3 at offset, +4, +8 (+12) | | `ds_read_b96` (0xfe) / `ds_read_b128` (0xff) | `ds_read_b32` into vdst..vdst+2 / +3 at the same offsets; a part whose vdst is the address register is read last (the existing rule) | Unaligned b96 / b128 addresses depend on the LDS alignment mode, so they are not claimed. The tests use 16-byte aligned addresses. ### Tests `ds_lds_b64_compute` gains, for both widths, a write then a read through the neighbouring lane at offsets 0, 0x10 and 0x400, with vdst 10 and with vdst 15 (the read's own address register): | run (WARP, `--release`, DXC 1.9.2609) | result | |---|---| | `exec_mem::ds::ds_lds_b64_compute` | **10 mnemonics verified, 0 failing, 45 cases** | | mutation: b128 split reuses `+8` for the 4th dword | 8 verified, 2 failing | | `--test isa_table` / `--test opcodes` | 3 / 26 passed | Run on `x86_64-pc-windows-gnu` (no MSVC linker here). These are data moves only, with no floating point. - [x] `cargo test -p tombox-xshader --test exec -- --exact exec_mem::ds::ds_lds_b64_compute` passes - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
omonkeyz commented 2026-11-23 14:08:34 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-23T14:08:34Z.


Applied locally on main with your authorship kept (cherry-picked, 00052ef); 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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7103543566 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/240#issuecomment-7103543566). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-23T14:08:34Z. --- Applied locally on main with your authorship kept (cherry-picked, 00052ef); 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 commented 2026-11-25 13:08:56 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:08:56Z.


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

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7163359552 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/240#issuecomment-7163359552). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:08:56Z. --- Applied on main in 00052ef (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator!240
No description provided.