feat(shader): implement the D16 byte/short loads and high-half stores #319

Merged
adriadam10 merged 1 commit from upstream-pr/319 into main 2026-10-04 09:53:21 +00:00
adriadam10 commented 2026-10-02 05:02:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T05:02:09Z.


What

These threw "MUBUF/FLAT/DS opcode is not supported":

  • buffer_load_{ubyte,sbyte,short}_d16, buffer_load_{ubyte,sbyte,short}_d16_hi, buffer_store_{byte,short}_d16_hi
  • the same eight for FLAT, which progress.py also counts for their global_* and scratch_* forms
  • ds_read_{u8,i8}_d16, ds_read_{u8,i8}_d16_hi, ds_write_b8_d16_hi

They reuse what ds_read_u16_d16(_hi) / ds_write_b16_d16_hi already do. A D16 load writes the low (_d16) or high (_d16_hi) half of the VGPR through the 16-bit destination select, keeping the other half; byte forms are zero- or sign-extended to 16 bits first. A _d16_hi store reads its byte/short from the high half. The ad-hoc select assignments in the DS decoder are folded into one d16Half helper, which the MUBUF and FLAT decoders use too. No new IR.

Not included: the *_format_d16_hi_x and tbuffer_*_format_d16_* forms, which need format conversion to f16 (separate PR).

Test agc_driver_d16_memory: one wave32 shader (words from llvm-mc -mcpu=gfx1013). On VGPRs preset to 0xabcdabcd it runs every load pair (lo then hi) for buffer, global (address from the buffer descriptor) and LDS. It also runs ds_write_b8_d16_hi and the two buffer _d16_hi stores, at odd/unaligned byte offsets with sign-carrying bytes. Each lane is checked against a C++ model. Global stores are not covered: the driver refuses writable FLAT/GLOBAL addresses without GPU ownership tracking, which the test harness has no way to set up.

Tested

Linux, full ctest (99) passes.

  • RADV (Radeon 660M) and lavapipe: the test passes.
  • Without the change it fails with "MUBUF opcode is not supported".

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #251 (test harness); review only the last commit
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4712875854 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/319). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-02T05:02:09Z. --- ### What These threw "MUBUF/FLAT/DS opcode is not supported": - `buffer_load_{ubyte,sbyte,short}_d16`, `buffer_load_{ubyte,sbyte,short}_d16_hi`, `buffer_store_{byte,short}_d16_hi` - the same eight for FLAT, which `progress.py` also counts for their `global_*` and `scratch_*` forms - `ds_read_{u8,i8}_d16`, `ds_read_{u8,i8}_d16_hi`, `ds_write_b8_d16_hi` They reuse what `ds_read_u16_d16(_hi)` / `ds_write_b16_d16_hi` already do. A D16 load writes the low (`_d16`) or high (`_d16_hi`) half of the VGPR through the 16-bit destination select, keeping the other half; byte forms are zero- or sign-extended to 16 bits first. A `_d16_hi` store reads its byte/short from the high half. The ad-hoc select assignments in the DS decoder are folded into one `d16Half` helper, which the MUBUF and FLAT decoders use too. No new IR. Not included: the `*_format_d16_hi_x` and `tbuffer_*_format_d16_*` forms, which need format conversion to f16 (separate PR). Test `agc_driver_d16_memory`: one wave32 shader (words from `llvm-mc -mcpu=gfx1013`). On VGPRs preset to `0xabcdabcd` it runs every load pair (lo then hi) for buffer, global (address from the buffer descriptor) and LDS. It also runs `ds_write_b8_d16_hi` and the two buffer `_d16_hi` stores, at odd/unaligned byte offsets with sign-carrying bytes. Each lane is checked against a C++ model. Global stores are not covered: the driver refuses writable FLAT/GLOBAL addresses without GPU ownership tracking, which the test harness has no way to set up. ### Tested Linux, full ctest (99) passes. - RADV (Radeon 660M) and lavapipe: the test passes. - Without the change it fails with "MUBUF opcode is not supported". ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #251 (test harness); review only the last commit - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-02 05:02:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T05:02:30Z.


Progress report (d3ec1f1 → 504a2fd)

📈 GPU shader instructions: 74.19% (+3.18%, +37 implemented instructions)

✅ 37 implemented
Encoding Name
DS DS_READ_I8_D16
DS DS_READ_I8_D16_HI
DS DS_READ_U8_D16
DS DS_READ_U8_D16_HI
DS DS_WRITE_B8_D16_HI
FLAT FLAT_LOAD_SBYTE_D16
FLAT FLAT_LOAD_SBYTE_D16_HI
FLAT FLAT_LOAD_SHORT_D16
FLAT FLAT_LOAD_SHORT_D16_HI
FLAT FLAT_LOAD_UBYTE_D16
FLAT FLAT_LOAD_UBYTE_D16_HI
FLAT FLAT_STORE_BYTE_D16_HI
FLAT FLAT_STORE_SHORT_D16_HI
GLOBAL GLOBAL_LOAD_SBYTE_D16
GLOBAL GLOBAL_LOAD_SBYTE_D16_HI
GLOBAL GLOBAL_LOAD_SHORT_D16
GLOBAL GLOBAL_LOAD_SHORT_D16_HI
GLOBAL GLOBAL_LOAD_UBYTE_D16
GLOBAL GLOBAL_LOAD_UBYTE_D16_HI
GLOBAL GLOBAL_STORE_BYTE_D16_HI
GLOBAL GLOBAL_STORE_SHORT_D16_HI
MUBUF BUFFER_LOAD_SBYTE_D16
MUBUF BUFFER_LOAD_SBYTE_D16_HI
MUBUF BUFFER_LOAD_SHORT_D16
MUBUF BUFFER_LOAD_SHORT_D16_HI
MUBUF BUFFER_LOAD_UBYTE_D16
MUBUF BUFFER_LOAD_UBYTE_D16_HI
MUBUF BUFFER_STORE_BYTE_D16_HI
MUBUF BUFFER_STORE_SHORT_D16_HI
SCRATCH SCRATCH_LOAD_SBYTE_D16
SCRATCH SCRATCH_LOAD_SBYTE_D16_HI
SCRATCH SCRATCH_LOAD_SHORT_D16
SCRATCH SCRATCH_LOAD_SHORT_D16_HI
SCRATCH SCRATCH_LOAD_UBYTE_D16
SCRATCH SCRATCH_LOAD_UBYTE_D16_HI
SCRATCH SCRATCH_STORE_BYTE_D16_HI
SCRATCH SCRATCH_STORE_SHORT_D16_HI
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5945906992 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/319#issuecomment-5945906992). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-02T05:02:30Z. --- <!-- progress-report --> ### Progress report (d3ec1f1 → 504a2fd) 📈 **GPU shader instructions**: 74.19% (+3.18%, +37 implemented instructions) <details> <summary>✅ 37 implemented</summary> | Encoding | Name | | - | - | | DS | `DS_READ_I8_D16` | | DS | `DS_READ_I8_D16_HI` | | DS | `DS_READ_U8_D16` | | DS | `DS_READ_U8_D16_HI` | | DS | `DS_WRITE_B8_D16_HI` | | FLAT | `FLAT_LOAD_SBYTE_D16` | | FLAT | `FLAT_LOAD_SBYTE_D16_HI` | | FLAT | `FLAT_LOAD_SHORT_D16` | | FLAT | `FLAT_LOAD_SHORT_D16_HI` | | FLAT | `FLAT_LOAD_UBYTE_D16` | | FLAT | `FLAT_LOAD_UBYTE_D16_HI` | | FLAT | `FLAT_STORE_BYTE_D16_HI` | | FLAT | `FLAT_STORE_SHORT_D16_HI` | | GLOBAL | `GLOBAL_LOAD_SBYTE_D16` | | GLOBAL | `GLOBAL_LOAD_SBYTE_D16_HI` | | GLOBAL | `GLOBAL_LOAD_SHORT_D16` | | GLOBAL | `GLOBAL_LOAD_SHORT_D16_HI` | | GLOBAL | `GLOBAL_LOAD_UBYTE_D16` | | GLOBAL | `GLOBAL_LOAD_UBYTE_D16_HI` | | GLOBAL | `GLOBAL_STORE_BYTE_D16_HI` | | GLOBAL | `GLOBAL_STORE_SHORT_D16_HI` | | MUBUF | `BUFFER_LOAD_SBYTE_D16` | | MUBUF | `BUFFER_LOAD_SBYTE_D16_HI` | | MUBUF | `BUFFER_LOAD_SHORT_D16` | | MUBUF | `BUFFER_LOAD_SHORT_D16_HI` | | MUBUF | `BUFFER_LOAD_UBYTE_D16` | | MUBUF | `BUFFER_LOAD_UBYTE_D16_HI` | | MUBUF | `BUFFER_STORE_BYTE_D16_HI` | | MUBUF | `BUFFER_STORE_SHORT_D16_HI` | | SCRATCH | `SCRATCH_LOAD_SBYTE_D16` | | SCRATCH | `SCRATCH_LOAD_SBYTE_D16_HI` | | SCRATCH | `SCRATCH_LOAD_SHORT_D16` | | SCRATCH | `SCRATCH_LOAD_SHORT_D16_HI` | | SCRATCH | `SCRATCH_LOAD_UBYTE_D16` | | SCRATCH | `SCRATCH_LOAD_UBYTE_D16_HI` | | SCRATCH | `SCRATCH_STORE_BYTE_D16_HI` | | SCRATCH | `SCRATCH_STORE_SHORT_D16_HI` | </details>
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
boykopovar/AnyPS5!319
No description provided.