test(shader): cover the s_cmpk compares and count them as tested variants #363

Merged
DotDebian merged 2 commits from upstream-pr/363 into main 2026-10-04 01:05:05 +00:00
DotDebian commented 2026-10-02 15:07:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DotDebian on 2026-10-02T15:07:23Z.


What

The twelve SOPK compares (S_CMPK_{EQ,LG,GT,GE,LT,LE}_{I32,U32}, opcodes 0x03-0x0e) already decode onto the SOPC compare opcodes with the 16-bit immediate as second source, but tools/progress.py counts shared-handler variants only once they are tested (#148), and only S_CMPK_LT_I32 and S_CMPK_LE_U32 were counted.

  • Add the execution test agc_driver_scalar_sopk_compare: a compute program runs the twelve compares on ten values taken from user data registers against six immediates (720 compares), reads SCC back through s_cselect_b32 and stores one mask per value/immediate pair. The expected results follow the RDNA ISA: the I32 compares sign-extend SIMM16, the U32 compares zero-extend it. The values and immediates sit on both sides of 0x7fff/0x8000 and of the 32-bit sign bit, so the two extensions give different answers.
  • Count the ten remaining variants in OPCODE_VARIANTS. progress.py --compare reports SOPK +10 (shaders 695 -> 705 of 1166).

No change to the recompiler: the test found no defect.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA RTX 5080.

  • ctest: 109/109 passed, including the new agc_driver_scalar_sopk_compare.
  • The test fails when the decoder is broken on purpose, then passes again once restored: sign-extending the U32 immediates (s_cmpk_eq_u32 0x00008000, 0x00008000 is 0, expected 1), and mapping opcode 0x0c to SCmpGtU32 (s_cmpk_ge_u32 0x00000000, 0x00000000 is 0, expected 1).

Not run on Linux/lavapipe locally. The program uses no subgroup operation.

Checklist

  • Based on current main; no other open PR implements the same functions (#333 covers s_cmovk_i32, s_version and s_setreg_imm32_b32, not the compares)
  • 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:4718043813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/363). Originally posted by [DotDebian](https://github.com/DotDebian) on 2026-10-02T15:07:23Z. --- ### What The twelve SOPK compares (`S_CMPK_{EQ,LG,GT,GE,LT,LE}_{I32,U32}`, opcodes 0x03-0x0e) already decode onto the SOPC compare opcodes with the 16-bit immediate as second source, but `tools/progress.py` counts shared-handler variants only once they are tested (#148), and only `S_CMPK_LT_I32` and `S_CMPK_LE_U32` were counted. - Add the execution test `agc_driver_scalar_sopk_compare`: a compute program runs the twelve compares on ten values taken from user data registers against six immediates (720 compares), reads SCC back through `s_cselect_b32` and stores one mask per value/immediate pair. The expected results follow the RDNA ISA: the I32 compares sign-extend SIMM16, the U32 compares zero-extend it. The values and immediates sit on both sides of 0x7fff/0x8000 and of the 32-bit sign bit, so the two extensions give different answers. - Count the ten remaining variants in `OPCODE_VARIANTS`. `progress.py --compare` reports SOPK +10 (shaders 695 -> 705 of 1166). No change to the recompiler: the test found no defect. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA RTX 5080. - `ctest`: 109/109 passed, including the new `agc_driver_scalar_sopk_compare`. - The test fails when the decoder is broken on purpose, then passes again once restored: sign-extending the U32 immediates (`s_cmpk_eq_u32 0x00008000, 0x00008000 is 0, expected 1`), and mapping opcode 0x0c to `SCmpGtU32` (`s_cmpk_ge_u32 0x00000000, 0x00000000 is 0, expected 1`). Not run on Linux/lavapipe locally. The program uses no subgroup operation. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#333 covers `s_cmovk_i32`, `s_version` and `s_setreg_imm32_b32`, not the compares) - [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)
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!363
No description provided.