test(shader): cover the SOPK s_waitcnt counters and count them as decoded #383

Merged
DotDebian merged 1 commit from upstream-pr/383 into main 2026-10-04 22:42:41 +00:00
DotDebian commented 2026-10-02 16:56:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DotDebian on 2026-10-02T16:56:47Z.


What

The decoder already maps the four SOPK wait instructions (s_waitcnt_vscnt, s_waitcnt_vmcnt, s_waitcnt_expcnt, s_waitcnt_lgkmcnt, opcodes 0x17 to 0x1a) to SWaitcnt, but no test encodes any of them and tools/progress.py only counts S_WAITCNT_VSCNT.

  • tests/execution/ScalarSopkWaitcnt.cpp runs each of the four opcodes with the register field set to null and to a live SGPR, and with levels 0, 0x3f and 0xffff. It checks that the wait leaves SCC as it was (once set, once clear) and leaves the register named in its field unchanged: LLVM's SOPK_WAITCNT takes that field as a source, not a destination.
  • tools/progress.py lists the three other counters as variants of SWaitcnt (+3 SOPK instructions, 695 to 698).

No change to the recompiler. Opcode numbers are the GFX10 ones from LLVM's SOPInstructions.td (SOPK_Real32_gfx10<0x017> to <0x01a>).

The OPCODE_VARIANTS line edited here sits between the lines added by #363 and #380: it conflicts textually with both (one line, no functional dependency). I will rebase once they are merged.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, ctest: 109/109 pass, including the new agc_driver_scalar_sopk_waitcnt (ran on a real Vulkan device, not skipped). Since the recompiler is unchanged, the test was checked against deliberately broken decoders instead, one opcode at a time: 0x17 rejected, 0x18 decoded as s_movk_i32, 0x19 as s_cmpk_eq_i32, 0x1a as s_cmpk_lg_i32. It fails on each and passes on the unmodified decoder. No title was run.

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: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4719127338 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/383). Originally posted by [DotDebian](https://github.com/DotDebian) on 2026-10-02T16:56:47Z. --- ### What The decoder already maps the four SOPK wait instructions (`s_waitcnt_vscnt`, `s_waitcnt_vmcnt`, `s_waitcnt_expcnt`, `s_waitcnt_lgkmcnt`, opcodes 0x17 to 0x1a) to `SWaitcnt`, but no test encodes any of them and `tools/progress.py` only counts `S_WAITCNT_VSCNT`. - `tests/execution/ScalarSopkWaitcnt.cpp` runs each of the four opcodes with the register field set to `null` and to a live SGPR, and with levels 0, 0x3f and 0xffff. It checks that the wait leaves SCC as it was (once set, once clear) and leaves the register named in its field unchanged: LLVM's `SOPK_WAITCNT` takes that field as a source, not a destination. - `tools/progress.py` lists the three other counters as variants of `SWaitcnt` (+3 SOPK instructions, 695 to 698). No change to the recompiler. Opcode numbers are the GFX10 ones from LLVM's `SOPInstructions.td` (`SOPK_Real32_gfx10<0x017>` to `<0x01a>`). The `OPCODE_VARIANTS` line edited here sits between the lines added by #363 and #380: it conflicts textually with both (one line, no functional dependency). I will rebase once they are merged. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, `ctest`: 109/109 pass, including the new `agc_driver_scalar_sopk_waitcnt` (ran on a real Vulkan device, not skipped). Since the recompiler is unchanged, the test was checked against deliberately broken decoders instead, one opcode at a time: 0x17 rejected, 0x18 decoded as `s_movk_i32`, 0x19 as `s_cmpk_eq_i32`, 0x1a as `s_cmpk_lg_i32`. It fails on each and passes on the unmodified decoder. No title was run. ### 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: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-04 05:43:34 +00:00 (Migrated from github.com)

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


This looks good to me. #363 and #380 just merged and touch the same OPCODE_VARIANTS table in tools/progress.py, so this needs the one-line rebase you offered. After that it looks ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5977025836 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/383#issuecomment-5977025836). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T05:43:34Z. --- This looks good to me. #363 and #380 just merged and touch the same `OPCODE_VARIANTS` table in tools/progress.py, so this needs the one-line rebase you offered. After that it looks ready to merge from my side.
oneandonlydean commented 2026-10-04 22:37:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:37:59Z.


Thanks for the rebase; the only change is the OPCODE_VARIANTS context after #363 and #380, and CI is green. agc_driver_scalar_sopk_waitcnt passes here on current main. Ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985219026 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/383#issuecomment-5985219026). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T22:37:59Z. --- Thanks for the rebase; the only change is the `OPCODE_VARIANTS` context after #363 and #380, and CI is green. `agc_driver_scalar_sopk_waitcnt` passes here on current main. Ready to merge from my side.
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!383
No description provided.