shader: support DS_WRITE_B8_D16_HI #794

Manually merged
github merged 1 commit from gh-pr/794/head into gh-pr/794/base 2026-11-26 09:32:38 +00:00
Owner

@⁠DenizSAHIN570 on GitHub · 2026-09-23 20:23 UTC · original
DenizSAHIN570:feat/ds-write-b8-d16-hi → main · +60 −1 · 6 files · 1 commits · merged 2026-09-23 20:44 UTC

Summary

  • decode the GFX10 DS opcode 0xa0 as DS_WRITE_B8_D16_HI
  • lower it through the existing 8-bit shared-memory write
  • the stored byte is bits 23:16 of the data VGPR, selected with SDWA BYTE_2 on src1 (the byte counterpart of the existing DS_WRITE_B16_D16_HI handling)
  • add captured-instruction decode coverage and a runtime regression

Rationale

A GTA V (PPSA04264) compute shader contains this instruction and was rejected by the CFG builder:

shader CFG build failed: unsupported decoded instruction in CFG at pc 0x00001598: unsupported family=DS opcode=0xa0 raw=[0xda800200 0x00001413] reason=DS opcode is not implemented

The encoding comes from LLVM's AMDGPU backend (DS_Real_gfx10<0x0a0>, next to DS_WRITE_B16_D16_HI at 0xa1 and the D16 reads at 0xa6/0xa7 already handled here). The semantics come from LLVM's selection pattern for it, DSWritePat<DS_WRITE_B8_D16_HI, i32, truncstorei8_hi16_local>, where truncstorei8_hi16 is truncstorei8(srl(value, 16)), i.e. bits 23:16. I did not check AMD's ISA document itself.

Validation

  • Linux release build (clang), full kyty_tests build against current main (569ec04)
  • shader_cfg_tests: passed, including a decode check of the captured words above (address v19, data v20, offset 0x200, 8-bit data, sdwa_sel 2)
  • New runtime test DsWriteB8D16HiWritesByteTwo: pre-fills LDS with 0xdeadbeef, writes bits 23:16 of 0x11a22233 (0xa2) to byte address 1, reads the dword back and expects 0xdeada2ef. All four source bytes differ, so any other byte selection fails. It also checks that an unrelated VGPR is untouched.
  • The test really checks the bit range: temporarily selecting byte 0 instead makes it fail with expected 0xdeada2ef, actual 0xdead33ef.
  • shader_recompiler_compute_tests: the full run does not complete on my machine (Radeon RX 9070 XT, Mesa RADV), and it aborts identically on unmodified main at 569ec04:
    • GpuTilerCpuParity failed at detile bytes family=4 bpe=1 (addressed in a separate PR)
    • image format does not support required usage: format=129, because this GPU does not support D24_UNORM_S8_UINT
      So I ran the DS cases through a local name filter that is not part of this PR: 31 DS cases pass on unmodified main; with this change 32 pass, the only difference being the new case. The opcode coverage check passes as well.
  • Not built or run on Windows. The change is additive decode/translate code in shared files.
  • Formatting: the added row in DS_OPCODE_LIST follows the one-entry-per-line style of its neighbours. The pinned clang-format would re-pack that whole table even on unmodified main, so I did not reflow it. The other source edits are clean under the pinned formatter.

Scope

This PR only adds DS_WRITE_B8_D16_HI.

AI assistance

An AI coding assistant was used for this change: to help analyse the failure, to draft the implementation and the tests, and to draft this description. I reproduced the original failure by running the game on my own machine and I reviewed the complete diff. The builds and test runs above were done in my environment and I checked their output. All communication on this PR comes from me.

**@⁠DenizSAHIN570** on GitHub · 2026-09-23 20:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/794) `DenizSAHIN570:feat/ds-write-b8-d16-hi` → `main` · +60 −1 · 6 files · 1 commits · merged 2026-09-23 20:44 UTC ## Summary - decode the GFX10 DS opcode 0xa0 as DS_WRITE_B8_D16_HI - lower it through the existing 8-bit shared-memory write - the stored byte is bits 23:16 of the data VGPR, selected with SDWA BYTE_2 on src1 (the byte counterpart of the existing DS_WRITE_B16_D16_HI handling) - add captured-instruction decode coverage and a runtime regression ## Rationale A GTA V (PPSA04264) compute shader contains this instruction and was rejected by the CFG builder: ``` shader CFG build failed: unsupported decoded instruction in CFG at pc 0x00001598: unsupported family=DS opcode=0xa0 raw=[0xda800200 0x00001413] reason=DS opcode is not implemented ``` The encoding comes from LLVM's AMDGPU backend (`DS_Real_gfx10<0x0a0>`, next to DS_WRITE_B16_D16_HI at 0xa1 and the D16 reads at 0xa6/0xa7 already handled here). The semantics come from LLVM's selection pattern for it, `DSWritePat<DS_WRITE_B8_D16_HI, i32, truncstorei8_hi16_local>`, where `truncstorei8_hi16` is `truncstorei8(srl(value, 16))`, i.e. bits 23:16. I did not check AMD's ISA document itself. ## Validation - Linux release build (clang), full `kyty_tests` build against current main (569ec04) - `shader_cfg_tests`: passed, including a decode check of the captured words above (address v19, data v20, offset 0x200, 8-bit data, sdwa_sel 2) - New runtime test `DsWriteB8D16HiWritesByteTwo`: pre-fills LDS with 0xdeadbeef, writes bits 23:16 of 0x11a22233 (0xa2) to byte address 1, reads the dword back and expects 0xdeada2ef. All four source bytes differ, so any other byte selection fails. It also checks that an unrelated VGPR is untouched. - The test really checks the bit range: temporarily selecting byte 0 instead makes it fail with `expected 0xdeada2ef, actual 0xdead33ef`. - `shader_recompiler_compute_tests`: the full run does not complete on my machine (Radeon RX 9070 XT, Mesa RADV), and it aborts identically on unmodified main at 569ec04: - `GpuTilerCpuParity failed at detile bytes family=4 bpe=1` (addressed in a separate PR) - `image format does not support required usage: format=129`, because this GPU does not support D24_UNORM_S8_UINT So I ran the DS cases through a local name filter that is not part of this PR: 31 DS cases pass on unmodified main; with this change 32 pass, the only difference being the new case. The opcode coverage check passes as well. - Not built or run on Windows. The change is additive decode/translate code in shared files. - Formatting: the added row in `DS_OPCODE_LIST` follows the one-entry-per-line style of its neighbours. The pinned clang-format would re-pack that whole table even on unmodified main, so I did not reflow it. The other source edits are clean under the pinned formatter. ## Scope This PR only adds DS_WRITE_B8_D16_HI. ## AI assistance An AI coding assistant was used for this change: to help analyse the failure, to draft the implementation and the tests, and to draft this description. I reproduced the original failure by running the game on my own machine and I reviewed the complete diff. The builds and test runs above were done in my environment and I checked their output. All communication on this PR comes from me.
Decode GFX10 DS opcode 0xa0 as DS_WRITE_B8_D16_HI (next to
DS_WRITE_B16_D16_HI at 0xa1) and lower it through the existing 8-bit
shared-memory write. The stored byte is bits 23:16 of the data VGPR,
selected with SDWA BYTE_2 on src1.

Add captured-instruction decode coverage (from GTA V, PPSA04264) and a
runtime regression that writes one byte of a distinctive source value
into a pre-filled LDS dword.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:32:35 +00:00
github manually merged commit 7611bcd8f3 into gh-pr/794/base 2026-11-26 09:32:38 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-23 20:30 UTC · original

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 05b44081-e839-48c8-bac2-c186c364f251

📥 Commits

Reviewing files that changed from the base of the PR and between 569ec04d1a and 7611bcd8f3.

📒 Files selected for processing (6)
  • src/graphics/shader/recompiler/frontend/decode/MemoryOps.cpp
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h
  • src/graphics/shader/recompiler/frontend/translate/Memory.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds the DS_WRITE_B8_D16_HI opcode to the shader decoder and translator. The decoder maps opcode 0xa0 to an 8-bit write and selects source byte 2. The translator includes the opcode in operand selection and dispatch. Tests check decoded instruction fields, the written 32-bit value, and the decoded opcode count.

Suggested reviewers: nmzik

Merge Risk: ⚪ Minimal · up to 7611b

The new byte-write path has no identified merge-blocking issue after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: support for the DS_WRITE_B8_D16_HI shader opcode.
Description check ✅ Passed The description directly explains the opcode decoding, translation, byte selection semantics, regression coverage, validation results, and scope.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (2 skipped: 2 too large.)


Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-23 20:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/794#issuecomment-5802431399) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/794"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `05b44081-e839-48c8-bac2-c186c364f251` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 569ec04d1a77127c601eed522ad5bba187173f9d and 7611bcd8f3e126cddba84093c19f4815d4fd8bd3. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `src/graphics/shader/recompiler/frontend/decode/MemoryOps.cpp` * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp` * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h` * `src/graphics/shader/recompiler/frontend/translate/Memory.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 9 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The change adds the `DS_WRITE_B8_D16_HI` opcode to the shader decoder and translator. The decoder maps opcode `0xa0` to an 8-bit write and selects source byte 2. The translator includes the opcode in operand selection and dispatch. Tests check decoded instruction fields, the written 32-bit value, and the decoded opcode count. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `7611b` <!-- final_review_risk_coverage:{"sourceCommitId":"7611bcd8f3e126cddba84093c19f4815d4fd8bd3","coveredCommitId":"7611bcd8f3e126cddba84093c19f4815d4fd8bd3","kind":"reviewed"} --> The new byte-write path has no identified merge-blocking issue after normal checks. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (2 skipped: 2 … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------ | | Title check | ✅ Passed | The title clearly and concisely identifies the main change: support for the DS_WRITE_B8_D16_HI shader opcode. | | Description check | ✅ Passed | The description directly explains the opcode decoding, translation, byte selection semantics, regression coverage, validation results, and scope. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (2 skipped: 2 too large.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.