feat(shader): implement waitcnt counter variants #387

Closed
asimplestray wants to merge 1 commit from upstream-pr/387 into main
asimplestray commented 2026-10-02 17:03:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by asimplestray on 2026-10-02T17:03:53Z.


What

Implements 3 SOPK opcodes (0x18-0x1A, verified against LLVM's GFX10 disassembler tests):

  • S_WAITCNT_VMCNT/EXPCNT/LGKMCNT decode to their own opcodes (previously folded into generic SWaitcnt) and reuse the wait translation, including the immediate-operand decode and the wait-opcode classifications.

The S_FLBIT_I32/S_QUADMASK_B32 parts of the original revision have since landed in main via other work; the test still covers all five encodings.

Tested

Linux (GCC, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF): full build, ctest 126/126 pass, including the new scalar_misc_ops test.

Checklist

  • Based on current main; no other open PR implements the same opcodes (checked open shader PRs)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (decoding unknown opcodes still throws)
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4719194063 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/387). Originally posted by [asimplestray](https://github.com/asimplestray) on 2026-10-02T17:03:53Z. --- ### What Implements 3 SOPK opcodes (`0x18`-`0x1A`, verified against LLVM's GFX10 disassembler tests): - `S_WAITCNT_VMCNT/EXPCNT/LGKMCNT` decode to their own opcodes (previously folded into generic `SWaitcnt`) and reuse the wait translation, including the immediate-operand decode and the wait-opcode classifications. The `S_FLBIT_I32`/`S_QUADMASK_B32` parts of the original revision have since landed in `main` via other work; the test still covers all five encodings. ### Tested Linux (GCC, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`): full build, `ctest` 126/126 pass, including the new `scalar_misc_ops` test. ### Checklist - [x] Based on current `main`; no other open PR implements the same opcodes (checked open shader PRs) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (decoding unknown opcodes still throws) - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-02 17:04:20 +00:00 (Migrated from github.com)

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


Progress report (7d40a57 → b92a852)

📈 GPU shader instructions: 64.58% (+0.26%, +3 implemented instructions)

✅ 3 implemented
Encoding Name
SOPK S_WAITCNT_EXPCNT
SOPK S_WAITCNT_LGKMCNT
SOPK S_WAITCNT_VMCNT
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5957353832 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/387#issuecomment-5957353832). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-02T17:04:20Z. --- <!-- progress-report --> ### Progress report (7d40a57 → b92a852) 📈 **GPU shader instructions**: 64.58% (+0.26%, +3 implemented instructions) <details> <summary>✅ 3 implemented</summary> | Encoding | Name | | - | - | | SOPK | `S_WAITCNT_EXPCNT` | | SOPK | `S_WAITCNT_LGKMCNT` | | SOPK | `S_WAITCNT_VMCNT` | </details>
oneandonlydean commented 2026-10-06 05:34:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:34:29Z.


Thanks for this. On main, SOPK 0x18 to 0x1a already decode to SWaitcnt and translate as a wait (decodeSopkOpcode in RdnaScalarOpDecoder.cpp). This PR gives them their own enum values but doesn't change what any shader does. #383 has landed and counts the three for the progress report, with an execution test, so I think this one can be closed. If there's a behavioural difference I missed, let me know.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6010067552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/387#issuecomment-6010067552). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T05:34:29Z. --- Thanks for this. On main, SOPK 0x18 to 0x1a already decode to `SWaitcnt` and translate as a wait (`decodeSopkOpcode` in `RdnaScalarOpDecoder.cpp`). This PR gives them their own enum values but doesn't change what any shader does. #383 has landed and counts the three for the progress report, with an execution test, so I think this one can be closed. If there's a behavioural difference I missed, let me know.
adriadam10 commented 2026-10-06 20:53:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T20:53:01Z.


Closing, as Dean noted above: on main, SOPK 0x18-0x1a already decode to SWaitcnt (RdnaScalarOpDecoder.cpp) and translate as a wait, so the new enum values don't change what any shader does, and #383 already counts the three in the progress report with an execution test. Thanks for the work; feel free to reopen if there's a behavioural difference we missed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6025241628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/387#issuecomment-6025241628). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-06T20:53:01Z. --- Closing, as Dean noted above: on `main`, SOPK `0x18`-`0x1a` already decode to `SWaitcnt` (`RdnaScalarOpDecoder.cpp`) and translate as a wait, so the new enum values don't change what any shader does, and #383 already counts the three in the progress report with an execution test. Thanks for the work; feel free to reopen if there's a behavioural difference we missed.

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
boykopovar/AnyPS5!387
No description provided.