feat(shader): support scalar 64-bit reverse and arithmetic shift #96

Merged
SamG-Coder merged 1 commit from upstream-pr/96 into main 2026-09-28 22:55:08 +00:00
SamG-Coder commented 2026-09-28 18:10:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SamG-Coder on 2026-09-28T18:10:46Z.


Shaders using S_BREV_B64 or S_ASHR_I64 currently fail decoding with unsupported SOP1 opcode 12 or SOP2 opcode 35. Decode both as two-dword scalar destinations and translate them through existing integer IR and SPIR-V operations.

S_BREV_B64 reverses and exchanges the two 32-bit halves while preserving SCC. S_ASHR_I64 uses the existing signed 64-bit shift, six-bit count masking, and nonzero-result SCC update. The change is 17 added lines across four files.

Validation

External demos assemble gfx1030/wave64 shaders, build PS5 ELF executables with the public homebrew toolchain, convert them with AnyPS5, and run the resulting Windows executables. Runtime buffer inputs are checked against independently calculated Python references; shaders check both output words and SCC before rendering a pixel-checkable result.

  • 55/55 graphics cases passed: 440 arithmetic/flag rows, 110 captures, 24,640 sampled pixels, maximum channel error 1/255.
  • Bit reversal: all 64 single-bit positions, zero/all-one/asymmetric values, in-place destinations, and SCC preservation.
  • Arithmetic shift: counts 0-63 on positive/negative inputs, immediate and dynamic boundary counts including 64 and 0xffffffff, destination/source and destination/count overlap, and SCC updates.
  • Five deliberately incorrect shaders completed rendering and were rejected by the pixel oracle: reverse replaced with copy, and signed shift replaced with logical shift. Maximum error 109/255.
  • Release build, explicit libs NID-patching target, and all 54 registered CTests passed.
  • A decoder built from exact upstream 8ccfbb9 sources rejects both instructions; the patched decoder accepts both and verifies destination width.

Screenshots and the detailed evidence report are attached in the PR conversation. Demos and results remain outside Git.

Validation limits

Converted Windows execution on an RTX 5080; no physical PS5, full-game, or performance claim. SPIR-V Tools was disabled. The harness terminates each demo after its capture-complete marker, so normal teardown is not covered. Final graphics results use explicitly rebuilt NID-patched libraries; the exact-upstream baseline proof is the separate decoder test.

Rebase validation (2026-09-29)

Rebased onto upstream dee7ecb; head 86401fe. The exact rebased shader branch builds and all 54 CTests pass. The 55-case graphics sweep passed 54 cases initially; ashr_alias_sign1_3 had a pixel mismatch alongside "guest memory changed while GPU results were pending" warnings. An isolated rerun of the same case passed both captures with maximum error 1/255. The original failure and rerun are preserved in the external evidence folder. This is an intermittent validation failure, not a clean 55/55 sweep; no root-cause claim is made.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4667537398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/96). Originally posted by [SamG-Coder](https://github.com/SamG-Coder) on 2026-09-28T18:10:46Z. --- Shaders using S_BREV_B64 or S_ASHR_I64 currently fail decoding with unsupported SOP1 opcode 12 or SOP2 opcode 35. Decode both as two-dword scalar destinations and translate them through existing integer IR and SPIR-V operations. S_BREV_B64 reverses and exchanges the two 32-bit halves while preserving SCC. S_ASHR_I64 uses the existing signed 64-bit shift, six-bit count masking, and nonzero-result SCC update. The change is 17 added lines across four files. ### Validation External demos assemble gfx1030/wave64 shaders, build PS5 ELF executables with the public homebrew toolchain, convert them with AnyPS5, and run the resulting Windows executables. Runtime buffer inputs are checked against independently calculated Python references; shaders check both output words and SCC before rendering a pixel-checkable result. - 55/55 graphics cases passed: 440 arithmetic/flag rows, 110 captures, 24,640 sampled pixels, maximum channel error 1/255. - Bit reversal: all 64 single-bit positions, zero/all-one/asymmetric values, in-place destinations, and SCC preservation. - Arithmetic shift: counts 0-63 on positive/negative inputs, immediate and dynamic boundary counts including 64 and 0xffffffff, destination/source and destination/count overlap, and SCC updates. - Five deliberately incorrect shaders completed rendering and were rejected by the pixel oracle: reverse replaced with copy, and signed shift replaced with logical shift. Maximum error 109/255. - Release build, explicit `libs` NID-patching target, and all 54 registered CTests passed. - A decoder built from exact upstream 8ccfbb9 sources rejects both instructions; the patched decoder accepts both and verifies destination width. Screenshots and the detailed evidence report are attached in the PR conversation. Demos and results remain outside Git. ### Validation limits Converted Windows execution on an RTX 5080; no physical PS5, full-game, or performance claim. SPIR-V Tools was disabled. The harness terminates each demo after its capture-complete marker, so normal teardown is not covered. Final graphics results use explicitly rebuilt NID-patched libraries; the exact-upstream baseline proof is the separate decoder test. ### Rebase validation (2026-09-29) Rebased onto upstream `dee7ecb`; head `86401fe`. The exact rebased shader branch builds and all 54 CTests pass. The 55-case graphics sweep passed 54 cases initially; `ashr_alias_sign1_3` had a pixel mismatch alongside "guest memory changed while GPU results were pending" warnings. An isolated rerun of the same case passed both captures with maximum error 1/255. The original failure and rerun are preserved in the external evidence folder. This is an intermittent validation failure, not a clean 55/55 sweep; no root-cause claim is made.
github-actions[bot] commented 2026-09-28 18:11:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-28T18:11:09Z.


Progress report (dee7ecb → 86401fe)

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

✅ 2 implemented
Encoding Name
SOP1 S_BREV_B64
SOP2 S_ASHR_I64
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5875810478 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/96#issuecomment-5875810478). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-28T18:11:09Z. --- <!-- progress-report --> ### Progress report (dee7ecb → 86401fe) 📈 **GPU shader instructions**: 50.0% (+0.17%, +2 implemented instructions) <details> <summary>✅ 2 implemented</summary> | Encoding | Name | | - | - | | SOP1 | `S_BREV_B64` | | SOP2 | `S_ASHR_I64` | </details>
SamG-Coder commented 2026-09-28 18:11:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SamG-Coder on 2026-09-28T18:11:44Z.


Screenshots and reproducible evidence

Validated commit: a12ea6b. The full matrix passed 55/55 cases, covering 110 captures and 24,640 pixel samples, with maximum channel error 1/255. All 54 CTests passed.

Passing shader — signed 64-bit shift, runtime boundary counts. Each triangle uses the brighter 0.75-scaled gradient only when all eight rows match the independently calculated low word, high word, and SCC.

Passing arithmetic-shift shader capture

Deliberately incorrect control — signed shift replaced with logical shift. The darker 0.25-scaled output indicates failed arithmetic checks. The pixel oracle rejected it with maximum error 109/255. This is a negative control, not the unpatched upstream output. All five wrong-shader controls were rejected.

Rejected logical-shift negative control

Download report, test sources, generated assembly, input rows, results, hashes, and logs

The archive includes reproduction instructions and baseline provenance in REPORT.md. Host validation was Windows Release on an RTX 5080. Physical PS5 execution, performance, independent SPIR-V validation, and normal teardown are not claimed. Screenshots and demo files remain outside the Git changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5875819395 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/96#issuecomment-5875819395). Originally posted by [SamG-Coder](https://github.com/SamG-Coder) on 2026-09-28T18:11:44Z. --- ### Screenshots and reproducible evidence Validated commit: `a12ea6b`. The full matrix passed **55/55 cases**, covering **110 captures and 24,640 pixel samples**, with maximum channel error **1/255**. All **54 CTests passed**. **Passing shader — signed 64-bit shift, runtime boundary counts.** Each triangle uses the brighter 0.75-scaled gradient only when all eight rows match the independently calculated low word, high word, and SCC. ![Passing arithmetic-shift shader capture](https://github.com/user-attachments/assets/3521697c-3239-48be-87aa-654a4c840b1a) **Deliberately incorrect control — signed shift replaced with logical shift.** The darker 0.25-scaled output indicates failed arithmetic checks. The pixel oracle rejected it with maximum error **109/255**. This is a negative control, not the unpatched upstream output. All five wrong-shader controls were rejected. ![Rejected logical-shift negative control](https://github.com/user-attachments/assets/76eb3d2b-3485-488b-912f-978692997215) [Download report, test sources, generated assembly, input rows, results, hashes, and logs](https://github.com/user-attachments/files/32761966/scalar64-evidence.zip) The archive includes reproduction instructions and baseline provenance in `REPORT.md`. Host validation was Windows Release on an RTX 5080. Physical PS5 execution, performance, independent SPIR-V validation, and normal teardown are not claimed. Screenshots and demo files remain outside the Git changes.
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!96
No description provided.