fix(shader): make s_getpc_b64 return the shader's absolute address #111

Merged
oneandonlydean merged 1 commit from upstream-pr/111 into main 2026-09-29 10:11:56 +00:00
oneandonlydean commented 2026-09-28 23:57:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-28T23:57:18Z.


What

s_getpc_b64 returned the next instruction's offset from the start of the shader, not its address. A shader that addresses data stored after its own code builds a V# with s_getpc_b64; s_add_u32; s_addc_u32, so the V# pointed at a tiny address near zero.

The result is now GetShaderBase + offset. GetShaderBase is already evaluated per request from the code address by the resource walk. So the V# names the real data, and the same code loaded at another address still shares its compiled variant.

Found on Astro Bot's NV12→RGB video pass. It draws its quad with an NGG shader that fetches the four vertices from behind its own code (+0x98). The buffer resolved to 0xf0, every vertex read as zero, and the video stayed black.

Tested

  • Linux (CachyOS, RTX 4090): Astro Bot's PlayStation Studios intro video now renders.
  • New case in agc_shader_memory_tests: a vertex shader loads a dword stored behind its code through a PC-relative V#. It checks that the V# names that data at the shader's address, and that a copy at a second address binds its own data. It fails on main with "the V# does not name the data at the shader's address".
  • ctest: 57/57 pass.

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4670723496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/111). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-28T23:57:18Z. --- ### What `s_getpc_b64` returned the next instruction's offset from the start of the shader, not its address. A shader that addresses data stored after its own code builds a V# with `s_getpc_b64; s_add_u32; s_addc_u32`, so the V# pointed at a tiny address near zero. The result is now `GetShaderBase + offset`. `GetShaderBase` is already evaluated per request from the code address by the resource walk. So the V# names the real data, and the same code loaded at another address still shares its compiled variant. Found on Astro Bot's NV12→RGB video pass. It draws its quad with an NGG shader that fetches the four vertices from behind its own code (`+0x98`). The buffer resolved to `0xf0`, every vertex read as zero, and the video stayed black. ### Tested - Linux (CachyOS, RTX 4090): Astro Bot's PlayStation Studios intro video now renders. - New case in `agc_shader_memory_tests`: a vertex shader loads a dword stored behind its code through a PC-relative V#. It checks that the V# names that data at the shader's address, and that a copy at a second address binds its own data. It fails on `main` with "the V# does not name the data at the shader's address". - `ctest`: 57/57 pass. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
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!111
No description provided.