perf(agc): build the color target swizzle tables once per element size #404

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/404 into main 2026-10-04 09:56:15 +00:00
MichonGoddijn231849 commented 2026-10-02 19:27:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-02T19:27:47Z.


What

ColorTargetLayout's constructor built the SW_64KB_R_X swizzle tables (xOffsets, yOffsets) every time: two vectors filled through a 16-bit parity loop per element. Every draw builds a layout for each color target, while decoding the state and again while setting the target up.

  • The tables depend only on the element size, not on the surface's extent. They are now built once per element size, under std::call_once, and the layout points into them.
  • In GTA V's Prologue, sampling the submission thread put 3.2% of its time in this constructor, most of it in the table loops.

If #377 merges first, its SW_4KB_S tables can be cached the same way, with a second table set per element size.

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.

  • GTA V (PPSA04264), with #401, #403 and the rendering fixes still in progress, at the same spot of the Prologue without profiling: 10.1 fps before, 10.5 after. The frame renders as before.
  • Dreaming Sarah (PPSA02929): the title menu and its text render as on main.
  • ctest: all tests pass, including the color target layout tests.

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:4720561727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/404). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-02T19:27:47Z. --- ### What `ColorTargetLayout`'s constructor built the SW_64KB_R_X swizzle tables (`xOffsets`, `yOffsets`) every time: two vectors filled through a 16-bit parity loop per element. Every draw builds a layout for each color target, while decoding the state and again while setting the target up. - The tables depend only on the element size, not on the surface's extent. They are now built once per element size, under `std::call_once`, and the layout points into them. - In GTA V's Prologue, sampling the submission thread put 3.2% of its time in this constructor, most of it in the table loops. If #377 merges first, its SW_4KB_S tables can be cached the same way, with a second table set per element size. ### 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. - GTA V (PPSA04264), with #401, #403 and the rendering fixes still in progress, at the same spot of the Prologue without profiling: 10.1 fps before, 10.5 after. The frame renders as before. - Dreaming Sarah (PPSA02929): the title menu and its text render as on `main`. - `ctest`: all tests pass, including the color target layout tests. ### 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-03 06:28:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-03T06:28:28Z.


+1. My integration branch has carried an equivalent change. In PPSA21564 the ColorTargetLayout constructor rebuilt the SW_64KB_R_X tables twice per draw, which took 2 to 3.7% of the GPU worker thread's time.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5966362098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/404#issuecomment-5966362098). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-03T06:28:28Z. --- +1. My integration branch has carried an equivalent change. In PPSA21564 the ColorTargetLayout constructor rebuilt the SW_64KB_R_X tables twice per draw, which took 2 to 3.7% of the GPU worker thread's time.
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!404
No description provided.