perf(agc): reuse frontend within shader registration pairs #2526

Merged
Celegans12 merged 1 commit from upstream-pr/2526 into main 2026-10-10 06:20:53 +00:00
Celegans12 commented 2026-10-10 01:40:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-10T01:40:11Z.


What

Preparing normal and partial-thread compute variants repeats decoding and control-flow construction for the same program. Keep one immutable frontend until that registration pair finishes.

Reuse requires identical owned code words, stage, fetch-call allowance and user-data register range. Each variant still translates, plans resources and emits from separate mutable IR with its current inputs. Failed construction preserves the previous frontend.

APS5_NO_PERF_FRONTEND_PAIR=1 disables reuse for same-build comparisons without changing disk-cache keys. Persisted layouts and shader interfaces are unchanged.

This complements #2327's removal of the earlier registration precheck and #2363's publication-lock change; neither shares the frontend between variants.

One same-build integration replay, reuse on then off, reduced pair preparation from 198.414 s to 113.562 s (42.8%); both SPIR-V variants were byte-identical. It used exact captured code with reconstructed historical context and no header. This is one offline preparation comparison, not standalone timing, an exact captured request or FPS.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, -DBUILD_TESTING=ON: full build, libs and registration passed on main 0c0dc1e9 plus feature (tree 07a69b63). Windows: 558 passes/3 skips. Linux/lavapipe: 541 passes/29 skips, 570 total; executed tests passed three times. agc_shader_frontend_pair and _off ran; no full-suite failures.

Skip gates and control

Windows upstream skip checker passed; strict local NVIDIA gate failed for two offscreen VideoOut skips. Both exact built modes passed native SDL; the third skip is the intentional missing-Vulkan negative case.

Linux's 29 skip names match #2521's run. Individual skip output was not captured; the current JUnit skip gate was not run.

Removing only the three cached-hit return lines, with API/tests unchanged, makes ON fail the required reuse assertion (exit 8) and OFF pass (exit 0), no skips. This controls the cache-hit mechanism, not bare main or end-to-end registration counts.

Not tested: standalone title or console behavior.

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 (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4807747589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2526). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-10T01:40:11Z. --- ### What Preparing normal and partial-thread compute variants repeats decoding and control-flow construction for the same program. Keep one immutable frontend until that registration pair finishes. Reuse requires identical owned code words, stage, fetch-call allowance and user-data register range. Each variant still translates, plans resources and emits from separate mutable IR with its current inputs. Failed construction preserves the previous frontend. `APS5_NO_PERF_FRONTEND_PAIR=1` disables reuse for same-build comparisons without changing disk-cache keys. Persisted layouts and shader interfaces are unchanged. This complements #2327's removal of the earlier registration precheck and #2363's publication-lock change; neither shares the frontend between variants. One same-build integration replay, reuse on then off, reduced pair preparation from 198.414 s to 113.562 s (42.8%); both SPIR-V variants were byte-identical. It used exact captured code with reconstructed historical context and no header. This is one offline preparation comparison, not standalone timing, an exact captured request or FPS. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, `-DBUILD_TESTING=ON`: full build, libs and registration passed on main `0c0dc1e9` plus feature (tree `07a69b63`). Windows: **558 passes/3 skips**. Linux/lavapipe: **541 passes/29 skips**, 570 total; executed tests passed three times. `agc_shader_frontend_pair` and `_off` ran; no full-suite failures. <details><summary>Skip gates and control</summary> Windows upstream skip checker passed; strict local NVIDIA gate failed for two offscreen VideoOut skips. Both exact built modes passed native SDL; the third skip is the intentional missing-Vulkan negative case. Linux's 29 skip names match #2521's run. Individual skip output was not captured; the current JUnit skip gate was not run. Removing only the three cached-hit return lines, with API/tests unchanged, makes ON fail the required reuse assertion (exit 8) and OFF pass (exit 0), no skips. This controls the cache-hit mechanism, not bare main or end-to-end registration counts. Not tested: standalone title or console behavior. </details> ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [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
adriadam10 commented 2026-10-10 06:20:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:20:49Z.


Checked on Linux (merged onto current main): scoped build + ctest 299/299, agc_shader_frontend_pair and _off pass. Negative control: disabling the cached-hit return makes the ON test fail and OFF pass. Reuse is keyed on identical owned code words, stage, fetch-call allowance and user-data range, and each variant still translates on its own IR (verifyFrontendProgram). The new ShaderPreparationContext type isn't in the shader-cache reviewed-names check and doesn't need to be; PrepareShader already is. Not reproduced here: the 198 s → 114 s replay figure and the Windows run. Note that this conflicts textually with #2072 in tests/ShaderMemory.cpp; whichever lands second needs a rebase. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094598280 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2526#issuecomment-6094598280). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:20:49Z. --- Checked on Linux (merged onto current main): scoped build + ctest 299/299, `agc_shader_frontend_pair` and `_off` pass. Negative control: disabling the cached-hit return makes the ON test fail and OFF pass. Reuse is keyed on identical owned code words, stage, fetch-call allowance and user-data range, and each variant still translates on its own IR (`verifyFrontendProgram`). The new `ShaderPreparationContext` type isn't in the shader-cache reviewed-names check and doesn't need to be; `PrepareShader` already is. Not reproduced here: the 198 s → 114 s replay figure and the Windows run. Note that this conflicts textually with #2072 in `tests/ShaderMemory.cpp`; whichever lands second needs a rebase. Merging.
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!2526
No description provided.