feat(shader): support 24-bit high products and fix image sample variants #148

Merged
SamG-Coder merged 5 commits from upstream-pr/148 into main 2026-10-01 10:45:19 +00:00
SamG-Coder commented 2026-09-29 12:37:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SamG-Coder on 2026-09-29T12:37:25Z.


Adds signed and unsigned 24-bit high-multiply instructions and fixes image sampling offsets and comparison-texture bindings.

  • Implement V_MUL_HI_I32_I24 and V_MUL_HI_U32_U24 using 24-bit operand extraction and signed/unsigned high products, including e32, e64 and SDWA encodings.
  • Emit constant texel offsets while preserving upstream LOD-clamp behavior and SPIR-V operand order. Nonconstant offsets fail explicitly.
  • Add native D32/D16 snapshots for R32 float / R16 unorm comparison textures, with distinct cache keys from ordinary sampled views. Preserve upstream depth surfaces, moved metadata, DCC clear handling, minimum-LOD chaining and first-layer views.
  • Count ten tested shared-handler instruction variants. This PR implements two new opcodes, not twelve.

Rebased directly onto upstream c7fb2575 in five focused commits. No unmerged dependency stack or separate patched test relinker is required.

Current validation

Windows / RTX 5080:

  • Full build and library packaging passed; 88/88 CTest tests passed on final commit dfdbeae9.
  • 23/23 original PS5-targeted C/assembly demos passed again on final commit dfdbeae9 after building PS5 ELF executables and converting them with the freshly built relinker.
  • Both captured frames per demo matched the independent 224-sample-per-frame oracle within 1/255 per channel. Incorrect-reference controls were rejected.
  • Ten additional consecutive runs of the previously intermittent S_CMPK_LE_U32 demo passed, including both frames and incorrect-reference controls.
  • All 23 freshly regenerated SPIR-V modules passed external spirv-val for Vulkan 1.1. The external validator harness was updated for upstream's SPI_PS_INPUT_ADDR layout.
  • GPU coverage includes e32/e64/SDWA high products, carry/borrow, immediate comparisons, store/wait/load, positive/negative offsets, explicit LOD, bias, R16/R32 depth comparisons, linear comparison filtering, and mixed ordinary/comparison views.

The first rebased Linux CI run caught the expanded descriptor's stale size guard. Investigation also found that the disk-cache encoder omitted the new comparison-image flags. The existing round-trip test was extended and failed before the fix, then passed after adding encoding/decoding and advancing the cache format to version 3. Old entries are rejected and rebuilt.

Limits and previous failure

On the previous upstream base a67b644f, the initial suite passed 22/23 and the S_CMPK_LE_U32 demo produced blank foreground captures. Three isolated reruns then passed. That failure is retained here: it was not reproduced in the current full suite or ten additional runs, but its root cause has not been established. The current evidence supports review; it does not prove the intermittent failure can never recur.

Offsets require constants. Snapshot comparison bindings support R32 float and R16 unorm, excluding 3D depth textures. Combined offset/LOD-clamp behavior was reconciled in code but has not received a dedicated GPU regression case. S_CODE_END is tested only as trailing padding. Demos are stopped after capture; no clean-exit, performance, physical-console, or complete-application compatibility claim is made.

The earlier local instruction audit covered 2,331 representative streams. The two newly implemented multiply instructions were not found in their reached instruction streams; synthetic success is not proof of original-program rendering. That audit was not repeated for this rebase.

Demos, captures and detailed reports remain outside Git. No original application shader bytes or assets are included.

References: AMD RDNA ISA, SPIR-V specification.

Checklist

  • Based on current upstream main; merged dependencies removed
  • General shader translation and sampling behavior; unsupported paths fail explicitly
  • No investigation documents, images or original application assets in Git
  • Build, CTest and converted GPU demos validated
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4677254898 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/148). Originally posted by [SamG-Coder](https://github.com/SamG-Coder) on 2026-09-29T12:37:25Z. --- Adds signed and unsigned 24-bit high-multiply instructions and fixes image sampling offsets and comparison-texture bindings. - Implement V_MUL_HI_I32_I24 and V_MUL_HI_U32_U24 using 24-bit operand extraction and signed/unsigned high products, including e32, e64 and SDWA encodings. - Emit constant texel offsets while preserving upstream LOD-clamp behavior and SPIR-V operand order. Nonconstant offsets fail explicitly. - Add native D32/D16 snapshots for R32 float / R16 unorm comparison textures, with distinct cache keys from ordinary sampled views. Preserve upstream depth surfaces, moved metadata, DCC clear handling, minimum-LOD chaining and first-layer views. - Count ten tested shared-handler instruction variants. This PR implements two new opcodes, not twelve. Rebased directly onto upstream c7fb2575 in five focused commits. No unmerged dependency stack or separate patched test relinker is required. ### Current validation Windows / RTX 5080: - Full build and library packaging passed; 88/88 CTest tests passed on final commit dfdbeae9. - 23/23 original PS5-targeted C/assembly demos passed again on final commit dfdbeae9 after building PS5 ELF executables and converting them with the freshly built relinker. - Both captured frames per demo matched the independent 224-sample-per-frame oracle within 1/255 per channel. Incorrect-reference controls were rejected. - Ten additional consecutive runs of the previously intermittent S_CMPK_LE_U32 demo passed, including both frames and incorrect-reference controls. - All 23 freshly regenerated SPIR-V modules passed external spirv-val for Vulkan 1.1. The external validator harness was updated for upstream's SPI_PS_INPUT_ADDR layout. - GPU coverage includes e32/e64/SDWA high products, carry/borrow, immediate comparisons, store/wait/load, positive/negative offsets, explicit LOD, bias, R16/R32 depth comparisons, linear comparison filtering, and mixed ordinary/comparison views. The first rebased Linux CI run caught the expanded descriptor's stale size guard. Investigation also found that the disk-cache encoder omitted the new comparison-image flags. The existing round-trip test was extended and failed before the fix, then passed after adding encoding/decoding and advancing the cache format to version 3. Old entries are rejected and rebuilt. ### Limits and previous failure On the previous upstream base a67b644f, the initial suite passed 22/23 and the S_CMPK_LE_U32 demo produced blank foreground captures. Three isolated reruns then passed. That failure is retained here: it was not reproduced in the current full suite or ten additional runs, but its root cause has not been established. The current evidence supports review; it does not prove the intermittent failure can never recur. Offsets require constants. Snapshot comparison bindings support R32 float and R16 unorm, excluding 3D depth textures. Combined offset/LOD-clamp behavior was reconciled in code but has not received a dedicated GPU regression case. S_CODE_END is tested only as trailing padding. Demos are stopped after capture; no clean-exit, performance, physical-console, or complete-application compatibility claim is made. The earlier local instruction audit covered 2,331 representative streams. The two newly implemented multiply instructions were not found in their reached instruction streams; synthetic success is not proof of original-program rendering. That audit was not repeated for this rebase. Demos, captures and detailed reports remain outside Git. No original application shader bytes or assets are included. References: [AMD RDNA ISA](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna-shader-instruction-set-architecture.pdf), [SPIR-V specification](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html). ### Checklist - [x] Based on current upstream main; merged dependencies removed - [x] General shader translation and sampling behavior; unsupported paths fail explicitly - [x] No investigation documents, images or original application assets in Git - [x] Build, CTest and converted GPU demos validated - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-09-29 12:37:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-29T12:37:51Z.


Progress report (c7fb257 → dfdbeae)

📈 GPU shader instructions: 52.23% (+0.17%, +2 implemented instructions)

✅ 2 implemented
Encoding Name
VOP2 V_MUL_HI_I32_I24
VOP2 V_MUL_HI_U32_U24
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5890459608 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/148#issuecomment-5890459608). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-29T12:37:51Z. --- <!-- progress-report --> ### Progress report (c7fb257 → dfdbeae) 📈 **GPU shader instructions**: 52.23% (+0.17%, +2 implemented instructions) <details> <summary>✅ 2 implemented</summary> | Encoding | Name | | - | - | | VOP2 | `V_MUL_HI_I32_I24` | | VOP2 | `V_MUL_HI_U32_U24` | </details>
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!148
No description provided.