fix(shader): accept the VOP3P clamp bit on packed 16-bit min, max and shifts #19190

Merged
angrysandhill merged 3 commits from upstream-pr/19190 into main 2026-11-21 16:50:03 +00:00
angrysandhill commented 2026-11-12 23:23:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by angrysandhill on 2026-11-12T23:23:15Z.


What

The decoder refused the VOP3P clamp bit on seven packed 16-bit opcodes with VOP3P integer clamp is not implemented:

  • v_pk_max_i16 (0x07), v_pk_min_i16 (0x08), v_pk_max_u16 (0x0c) and v_pk_min_u16 (0x0d);
  • v_pk_lshlrev_b16 (0x04), v_pk_lshrrev_b16 (0x05) and v_pk_ashrrev_i16 (0x06).

Measured on RDNA2 (gfx1031, RX 6750 XT; the PS5's gfx1013 is not measured), clamp changes nothing on any of them: every result with it equals the one without. #502 found the same for v_pk_mul_lo_u16 on gfx1035, and accepted the bit there without effect. These seven now join it in that exception. Their translation never reads clamp, so the change is decoder-only.

The integer dot opcodes (v_dot2/dot4/dot8_*) keep refusing clamp, as the debt list records.

Tested

Setup: Windows 10 Home 22H2 (10.0.19045), AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, on main a221a742da.

RDNA2 measurement (hardware oracle, HIP runtime).

  • Rows: 289 operand pairs. The halves are drawn from 0, 1, 2, 15, 16, 17, 31, 32, 0x7ffe, 0x7fff, 0x8000, 0x8001, 0xfffe, 0xffff, 0x00ff, 0x1234 and 0xedcc, so shift counts cover 0, 1, 15, 16, 17, 31 and 32, and min/max cover both signed and unsigned limits.
  • Forms: each opcode with and without clamp, in three operand selects: the default, op_sel:[1,1] op_sel_hi:[0,0] and op_sel:[0,1] op_sel_hi:[1,0]. The assembled words carry the clamp bit (for example 0xcc07c00a against 0xcc07400a).
  • Settings: IEEE 0 with DX10_CLAMP 1, and IEEE 1 with DX10_CLAMP 0. Both give the same values.
main this PR
Hardware, clamp against no clamp 0 of 6,069 results differ in each setting —
Recompiler against the hardware (HW_ORACLE_RUNTIME=vulkan), with and without clamp refused (VOP3P integer clamp is not implemented) 0 of 12,138 values differ in each setting

Tests:

  • New agc_driver_packed_min_max_shift_clamp: 32 of the 289 pairs through the 21 clamp forms. The expected values are RDNA2's.
    • On main with only this test file added it fails: ShaderRecompiler::Recompile: VOP3P integer clamp is not implemented.
    • With this change it passes.
  • Full ^(agc_|shader), 4 at a time: 1,660 tests; 1,658 pass. The two failures also fail on main a221a742da on this card, with the same messages:
    • agc_driver_sample_order_grid_reference: the odd-row failure #18229 reports; #9503 addresses it.
    • agc_import_settle_initial_dcc: "the resident target missed the CPU store to its FMASK". #19138, merged after that base, reverts #18288, which it names as the change that broke this test on Windows.
  • Validation layer (1.4.367): VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, one at a time.
    • Run: the 38 tests matching -R "^(agc_driver_packed_min_max_shift_clamp|agc_driver_packed_.*|agc_driver_integer_dot|agc_driver_.*vop3p.*|agc_vop.*|shader_.*vop3p.*|agc_driver_.*int16.*)$". They include the new test, agc_driver_packed_integer_clamp, agc_driver_integer_dot and the four decoder tests.
    • Result: all pass.
    • Layer check: the layer is inserted in the 34 that open a device, with no VUID- line. The four decoder tests open none.
  • Outside that suite: the seven vector_* tests and decoder_length also pass.

Overlap: tools/pr_overlap.py --branch finds no conflict. #9889 already conflicts with main, and gains no conflict hunk from this branch.

Not measured: the PS5's gfx1013, and hosts other than this one.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (32.0.21045.16010), Windows 10 22H2
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5286953876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19190). Originally posted by [angrysandhill](https://github.com/angrysandhill) on 2026-11-12T23:23:15Z. --- ### What The decoder refused the VOP3P `clamp` bit on seven packed 16-bit opcodes with `VOP3P integer clamp is not implemented`: - `v_pk_max_i16` (`0x07`), `v_pk_min_i16` (`0x08`), `v_pk_max_u16` (`0x0c`) and `v_pk_min_u16` (`0x0d`); - `v_pk_lshlrev_b16` (`0x04`), `v_pk_lshrrev_b16` (`0x05`) and `v_pk_ashrrev_i16` (`0x06`). Measured on RDNA2 (gfx1031, RX 6750 XT; the PS5's gfx1013 is not measured), `clamp` changes nothing on any of them: every result with it equals the one without. #502 found the same for `v_pk_mul_lo_u16` on gfx1035, and accepted the bit there without effect. These seven now join it in that exception. Their translation never reads `clamp`, so the change is decoder-only. The integer dot opcodes (`v_dot2/dot4/dot8_*`) keep refusing `clamp`, as the debt list records. ### Tested **Setup:** Windows 10 Home 22H2 (10.0.19045), AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), WinLibs GCC 15.2.0 r7 UCRT, Release, `BUILD_TESTING=ON`, on `main` `a221a742da`. **RDNA2 measurement** ([hardware oracle](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/HW_ORACLE.md), HIP runtime). - **Rows:** 289 operand pairs. The halves are drawn from 0, 1, 2, 15, 16, 17, 31, 32, `0x7ffe`, `0x7fff`, `0x8000`, `0x8001`, `0xfffe`, `0xffff`, `0x00ff`, `0x1234` and `0xedcc`, so shift counts cover 0, 1, 15, 16, 17, 31 and 32, and min/max cover both signed and unsigned limits. - **Forms:** each opcode with and without `clamp`, in three operand selects: the default, `op_sel:[1,1] op_sel_hi:[0,0]` and `op_sel:[0,1] op_sel_hi:[1,0]`. The assembled words carry the clamp bit (for example `0xcc07c00a` against `0xcc07400a`). - **Settings:** IEEE 0 with DX10_CLAMP 1, and IEEE 1 with DX10_CLAMP 0. Both give the same values. | | `main` | this PR | |---|---|---| | Hardware, `clamp` against no `clamp` | 0 of 6,069 results differ in each setting | — | | Recompiler against the hardware (`HW_ORACLE_RUNTIME=vulkan`), with and without `clamp` | refused (`VOP3P integer clamp is not implemented`) | 0 of 12,138 values differ in each setting | **Tests:** - **New `agc_driver_packed_min_max_shift_clamp`:** 32 of the 289 pairs through the 21 `clamp` forms. The expected values are RDNA2's. - **On `main` with only this test file added** it fails: `ShaderRecompiler::Recompile: VOP3P integer clamp is not implemented`. - **With this change** it passes. - **Full `^(agc_|shader)`, 4 at a time:** 1,660 tests; 1,658 pass. The two failures also fail on `main` `a221a742da` on this card, with the same messages: - `agc_driver_sample_order_grid_reference`: the odd-row failure #18229 reports; #9503 addresses it. - `agc_import_settle_initial_dcc`: "the resident target missed the CPU store to its FMASK". #19138, merged after that base, reverts #18288, which it names as the change that broke this test on Windows. - **Validation layer** (1.4.367): `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`, one at a time. - **Run:** the 38 tests matching `-R "^(agc_driver_packed_min_max_shift_clamp|agc_driver_packed_.*|agc_driver_integer_dot|agc_driver_.*vop3p.*|agc_vop.*|shader_.*vop3p.*|agc_driver_.*int16.*)$"`. They include the new test, `agc_driver_packed_integer_clamp`, `agc_driver_integer_dot` and the four decoder tests. - **Result:** all pass. - **Layer check:** the layer is inserted in the 34 that open a device, with no `VUID-` line. The four decoder tests open none. - **Outside that suite:** the seven `vector_*` tests and `decoder_length` also pass. **Overlap:** `tools/pr_overlap.py --branch` finds no conflict. #9889 already conflicts with `main`, and gains no conflict hunk from this branch. **Not measured:** the PS5's gfx1013, and hosts other than this one. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6750 XT (gfx1031), AMD Software Adrenalin 26.10.1 (32.0.21045.16010), Windows 10 22H2 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-13 00:22:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-13T00:22:14Z.

Review: COMMENTED


Reviewed the VOP3P clamp change — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head reviewed: 853710b5d50d8943101b914e654309bffa7533ac (base main).
  • No build and no test run: the review checks the code by reading it, and the author's hardware runs are not repeated here.
  • Commands (repository reader, repo_read.py):
repo_read.py search VPkMaxI16
repo_read.py search VPkLshlrevB16
repo_read.py search packedInteger16Shift
repo_read.py search GLOB core/libs/prx/libSceAgcDriver/tests
repo_read.py cat core/shader/recompiler/Translation/src/VectorInstructions.cpp 915 960
repo_read.py cat core/shader/recompiler/Translation/src/IntegerInstructions.cpp 155 170
repo_read.py cat core/shader/recompiler/Translation/src/IntegerInstructions.cpp 221 245

Results

Check Result Note
Diff matches the description passed Decoder and one new test only
Translation reads clamp for the seven opcodes passed Min/max and shift helpers do not read it
New test is compiled passed tests/execution/*.cpp is globbed
Build and test run not run Not part of this review
Test values against hardware not run Author-reported only

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceAgcDriver/tests/execution/PackedMinMaxShiftClamp.cpp:155 uses std::nullopt but does not include <optional>. It compiles only if an included header brings it in. Adding #include <optional> with the other standard headers would make it explicit. Not verified whether the header chain provides it.

Sources

Not verified

  • The author's hardware measurements on RDNA2 (gfx1031): 289 operand pairs, 6,069 and 12,138 comparisons, and the expected-value table. I checked lane 0 for forms 0 and 1 by hand and they agree. The rest was not checked.
  • The PS5 gfx1013 was not measured, as the description says.
  • The test results on main (the failing negative control) and with the change: author-reported, not run here.
  • The two pre-existing failures named in the description, and the references #502, #9503, #18229 and #19138: not checked.
  • packedInteger16Native (the native 16-bit path) was not read, so the claim that no clamp read happens there is not verified.
  • The test name agc_driver_packed_min_max_shift_clamp is not checked against the test naming scheme.
  • Changed files: the test file is new, so its diff is its full text. For the decoder file I read the changed hunks and the reader searches, not the full file from files/.

To get this to a good state

Nothing is required.

Optional: add #include <optional> to the test file (see the non-blocking point above).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5884187526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19190#pullrequestreview-5884187526). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-13T00:22:14Z. **Review:** COMMENTED --- # Reviewed the VOP3P clamp change — no blocking findings Nothing blocks this; the points below are optional. ## What I ran - Head reviewed: `853710b5d50d8943101b914e654309bffa7533ac` (base `main`). - No build and no test run: the review checks the code by reading it, and the author's hardware runs are not repeated here. - Commands (repository reader, `repo_read.py`): ``` repo_read.py search VPkMaxI16 repo_read.py search VPkLshlrevB16 repo_read.py search packedInteger16Shift repo_read.py search GLOB core/libs/prx/libSceAgcDriver/tests repo_read.py cat core/shader/recompiler/Translation/src/VectorInstructions.cpp 915 960 repo_read.py cat core/shader/recompiler/Translation/src/IntegerInstructions.cpp 155 170 repo_read.py cat core/shader/recompiler/Translation/src/IntegerInstructions.cpp 221 245 ``` ## Results | Check | Result | Note | |---|---|---| | Diff matches the description | passed | Decoder and one new test only | | Translation reads `clamp` for the seven opcodes | passed | Min/max and shift helpers do not read it | | New test is compiled | passed | `tests/execution/*.cpp` is globbed | | Build and test run | not run | Not part of this review | | Test values against hardware | not run | Author-reported only | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceAgcDriver/tests/execution/PackedMinMaxShiftClamp.cpp:155` uses `std::nullopt` but does not include `<optional>`. It compiles only if an included header brings it in. Adding `#include <optional>` with the other standard headers would make it explicit. Not verified whether the header chain provides it. ## Sources - Decoder change: [RdnaVectorOpDecoder.cpp lines 1802–1815](https://github.com/boykopovar/AnyPS5/blob/853710b5d50d8943101b914e654309bffa7533ac/core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp#L1802-L1815) and [line 2520](https://github.com/boykopovar/AnyPS5/blob/853710b5d50d8943101b914e654309bffa7533ac/core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp#L2520). - Min/max translation does not read `clamp`: [IntegerInstructions.cpp lines 221–236](https://github.com/boykopovar/AnyPS5/blob/853710b5d50d8943101b914e654309bffa7533ac/core/shader/recompiler/Translation/src/IntegerInstructions.cpp#L221-L236). - Shift translation does not read `clamp`: [IntegerInstructions.cpp lines 155–170](https://github.com/boykopovar/AnyPS5/blob/853710b5d50d8943101b914e654309bffa7533ac/core/shader/recompiler/Translation/src/IntegerInstructions.cpp#L155-L170). - Test sources are globbed: [CMakeLists.txt line 691](https://github.com/boykopovar/AnyPS5/blob/853710b5d50d8943101b914e654309bffa7533ac/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L691). ## Not verified - The author's hardware measurements on RDNA2 (gfx1031): 289 operand pairs, 6,069 and 12,138 comparisons, and the expected-value table. I checked lane 0 for forms 0 and 1 by hand and they agree. The rest was not checked. - The PS5 gfx1013 was not measured, as the description says. - The test results on `main` (the failing negative control) and with the change: author-reported, not run here. - The two pre-existing failures named in the description, and the references #502, #9503, #18229 and #19138: not checked. - `packedInteger16Native` (the native 16-bit path) was not read, so the claim that no clamp read happens there is not verified. - The test name `agc_driver_packed_min_max_shift_clamp` is not checked against the test naming scheme. - Changed files: the test file is new, so its diff is its full text. For the decoder file I read the changed hunks and the reader searches, not the full file from `files/`. ## To get this to a good state Nothing is required. Optional: add `#include <optional>` to the test file (see the non-blocking point above).
MarcZX10 commented 2026-11-13 22:32:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-13T22:32:55Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks merging based on the code reviewed; the hardware and CI results below are author-reported and were not independently run here.

What I ran

  • Reviewed head 6a7f4c133fbb90414d12452494134b777ec127e9 and the prepared diff; no repository tests or build commands were run.
  • Read description.md, commits.md, manifest.json, diff.patch, PackedMinMaxShiftClamp.cpp, RdnaVectorOpDecoder.cpp, PackedIntegerClamp.cpp, MulLoU16HighHalf.cpp, agc_driver_tests.cmake, agc_driver_packed_add_f16_rounding_tests.cmake, and CMakeLists.txt.
  • Confirmed the new execution test is picked up and registered by the existing source glob and default test registration.

Results

Check Result Note
Decoder scope passed Exception lists only the intended packed integer operations and existing multiply case.
Test registration passed Execution source glob registers the added test.
Build and runtime tests not run PR description reports author-run hardware and CI checks.

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • No build, test, or negative-control run was performed in this review environment.
  • Hardware measurements, validation-layer logs, and the reported CI outcomes were not independently confirmed; they are described by the author as measured on an RX 6750 XT (gfx1031), not a PS5 gfx1013.
  • files.json was not available in the review materials, so excluded files and the complete reviewed-file set could not be independently checked.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5898984744 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19190#pullrequestreview-5898984744). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-13T22:32:55Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks merging based on the code reviewed; the hardware and CI results below are author-reported and were not independently run here. ## What I ran - Reviewed head `6a7f4c133fbb90414d12452494134b777ec127e9` and the prepared diff; no repository tests or build commands were run. - Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `PackedMinMaxShiftClamp.cpp`, `RdnaVectorOpDecoder.cpp`, `PackedIntegerClamp.cpp`, `MulLoU16HighHalf.cpp`, `agc_driver_tests.cmake`, `agc_driver_packed_add_f16_rounding_tests.cmake`, and `CMakeLists.txt`. - Confirmed the new execution test is picked up and registered by the existing source glob and default test registration. ## Results | Check | Result | Note | |---|---|---| | Decoder scope | passed | Exception lists only the intended packed integer operations and existing multiply case. | | Test registration | passed | Execution source glob registers the added test. | | Build and runtime tests | not run | PR description reports author-run hardware and CI checks. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified - No build, test, or negative-control run was performed in this review environment. - Hardware measurements, validation-layer logs, and the reported CI outcomes were not independently confirmed; they are described by the author as measured on an RX 6750 XT (gfx1031), not a PS5 gfx1013. - `files.json` was not available in the review materials, so excluded files and the complete reviewed-file set could not be independently checked. ## To get this to a good state Nothing is required.
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!19190
No description provided.