perf(agc): draw cache keys on the user words each stage reads #493

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/493 into main 2026-10-08 07:09:08 +00:00
MichonGoddijn231849 commented 2026-10-04 09:10:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-04T09:10:47Z.


What

Split out of #291, as discussed there. The draw cache key mixed all 32 user data words of every stage, so draws that differed only in words their programs never read got separate entries and decoded and compiled again. The key now mixes only the user words each stage's RSRC2 counts (USER_SGPR, including the high bit). The RSRC2 registers themselves stay in the key, so a different count is a different key. APS5_DRAW_KEY_ALL_USER_WORDS=1 mixes all 32 again.

The other part of #291 is #494 (data-only hits, on top of this). #291's time-based failure memo is dropped.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • ctest: everything that passes on main here passes. There's no unit test for the key itself: Driver::drawRegisterKey is internal to the driver DLL, and no test target links the Execution code.
  • In-game, this change was tested as part of #291 (GTA V PPSA04264 Story Mode, Dreaming Sarah PPSA02929's title menu with its text). This split version hasn't been re-run in a game.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4733189281 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/493). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-04T09:10:47Z. --- ### What Split out of #291, as discussed there. The draw cache key mixed all 32 user data words of every stage, so draws that differed only in words their programs never read got separate entries and decoded and compiled again. The key now mixes only the user words each stage's RSRC2 counts (USER_SGPR, including the high bit). The RSRC2 registers themselves stay in the key, so a different count is a different key. `APS5_DRAW_KEY_ALL_USER_WORDS=1` mixes all 32 again. The other part of #291 is #494 (data-only hits, on top of this). #291's time-based failure memo is dropped. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - `ctest`: everything that passes on `main` here passes. There's no unit test for the key itself: `Driver::drawRegisterKey` is internal to the driver DLL, and no test target links the Execution code. - In-game, this change was tested as part of #291 (GTA V PPSA04264 Story Mode, Dreaming Sarah PPSA02929's title menu with its text). This split version hasn't been re-run in a game. ### 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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-04 09:52:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T09:52:50Z.


Thanks for splitting it. I checked the key against the decoder: decodeDraw reads exactly the first USER_SGPR words (bits 1 to 5 plus USER_SGPR_MSB at bit 27, which matches SPI_SHADER_PGM_RSRC2_PS/GS/HS in Mesa's gfx10.json) from 0x0c, 0x8c and 0x10c. The RSRC2 registers stay in the key, and nothing else in the draw path reads the words past that count, so a shared entry can't give a different decode or compile. A unit test isn't really possible without a draw harness, so that's fine with me. Merged with current main it builds and passes the full ctest here. Since it changes which draws share a cache entry, I'll run it through PPSA21564 on my integration branch first; after that it's ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5978698982 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/493#issuecomment-5978698982). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T09:52:50Z. --- Thanks for splitting it. I checked the key against the decoder: `decodeDraw` reads exactly the first USER_SGPR words (bits 1 to 5 plus USER_SGPR_MSB at bit 27, which matches SPI_SHADER_PGM_RSRC2_PS/GS/HS in Mesa's gfx10.json) from 0x0c, 0x8c and 0x10c. The RSRC2 registers stay in the key, and nothing else in the draw path reads the words past that count, so a shared entry can't give a different decode or compile. A unit test isn't really possible without a draw harness, so that's fine with me. Merged with current main it builds and passes the full ctest here. Since it changes which draws share a cache entry, I'll run it through PPSA21564 on my integration branch first; after that it's ready to merge from my side.
MichonGoddijn231849 commented 2026-10-07 17:31:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-07T17:31:14Z.


Rebased onto current main (now 131adc17), no conflicts. Build and ctest pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6043249423 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/493#issuecomment-6043249423). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-07T17:31:14Z. --- Rebased onto current `main` (now 131adc17), no conflicts. Build and ctest pass.
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!493
No description provided.