perf(shader): hash only the recompiler's inputs into the shader cache version #457

Merged
oneandonlydean merged 1 commit from upstream-pr/457 into main 2026-10-04 02:45:13 +00:00
oneandonlydean commented 2026-10-03 13:52:04 +00:00 (Migrated from github.com)

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


What

The shader disk cache version (SourceVersion) hashes every libSceAgcDriver source as well as the recompiler, so any driver-only change makes every cached shader stale and the next run recompiles all of them. Of the last 200 merges on main, 88 changed that version; with the inputs below, 51 would have.

The version now covers what can change a recompile result:

  • core/shader/recompiler/** (sources, headers, CMake files), as before;
  • prx/libc/include/HostThreadLocal.hpp, the one header the recompiler includes from outside its directory (checked against the ninja dependency files);
  • the checked-out commits of SPIRV-Headers and glslang, plus SPIRV-Tools when ANYPS5_ENABLE_SPIRV_TOOLS is on. The submodules' git HEAD files are dependencies of the version step, so moving a submodule regenerates the version;
  • the compiler, build type, architecture and C++ flags.

Everything else the driver hands to the recompiler arrives in the RecompileRequest, which the per-entry key already covers. Two build-time checks keep it that way and fail the version step with a message naming the file and what to do:

  • a recompiler source that includes a project header outside the hashed set;
  • a driver source that calls or using-declares a ShaderRecompiler name that is not on the reviewed list (the 16 names the driver uses today), brings the whole namespace in, or sets an environment variable (which could flip a recompiler APS5_* switch behind the key).

APS5_* switches are collected from every hashed source, as before. The version script now starts with cmake_minimum_required: without it, CMake 3.x runs it with CMP0054 OLD and reads the quoted section names in its if() tests as variables, so the version silently missed the recompiler sources.

Tested

  • Linux (CachyOS, x86-64): full build with BUILD_TESTING=ON and ctest pass (145/145), including agc_shader_disk_cache.
  • The checks fire: a call to an unreviewed ShaderRecompiler::SomethingNew(...) in Draw.cpp, and an include of Graphics/include/Draw.hpp from Recompiler.cpp, each fail the build with their message.
  • No open PR trips the checks: none adds an unreviewed ShaderRecompiler call, a setenv in the driver or a recompiler include from outside its tree. With #316 (adriadam10, subgroup size) merged in, the version step passes: its device-dependent subgroup size reaches the recompiler through RecompileRequest::target, which the key covers.
  • PPSA21564: on my integration branch since 2026-10-03; driver-only rebuilds there keep the shader cache warm.

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:4727049363 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/457). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-03T13:52:04Z. --- ### What The shader disk cache version (`SourceVersion`) hashes every `libSceAgcDriver` source as well as the recompiler, so any driver-only change makes every cached shader stale and the next run recompiles all of them. Of the last 200 merges on `main`, 88 changed that version; with the inputs below, 51 would have. The version now covers what can change a recompile result: - `core/shader/recompiler/**` (sources, headers, CMake files), as before; - `prx/libc/include/HostThreadLocal.hpp`, the one header the recompiler includes from outside its directory (checked against the ninja dependency files); - the checked-out commits of SPIRV-Headers and glslang, plus SPIRV-Tools when `ANYPS5_ENABLE_SPIRV_TOOLS` is on. The submodules' git HEAD files are dependencies of the version step, so moving a submodule regenerates the version; - the compiler, build type, architecture and C++ flags. Everything else the driver hands to the recompiler arrives in the `RecompileRequest`, which the per-entry key already covers. Two build-time checks keep it that way and fail the version step with a message naming the file and what to do: - a recompiler source that includes a project header outside the hashed set; - a driver source that calls or using-declares a `ShaderRecompiler` name that is not on the reviewed list (the 16 names the driver uses today), brings the whole namespace in, or sets an environment variable (which could flip a recompiler `APS5_*` switch behind the key). `APS5_*` switches are collected from every hashed source, as before. The version script now starts with `cmake_minimum_required`: without it, CMake 3.x runs it with CMP0054 OLD and reads the quoted section names in its `if()` tests as variables, so the version silently missed the recompiler sources. ### Tested - Linux (CachyOS, x86-64): full build with `BUILD_TESTING=ON` and `ctest` pass (145/145), including `agc_shader_disk_cache`. - The checks fire: a call to an unreviewed `ShaderRecompiler::SomethingNew(...)` in `Draw.cpp`, and an include of `Graphics/include/Draw.hpp` from `Recompiler.cpp`, each fail the build with their message. - No open PR trips the checks: none adds an unreviewed `ShaderRecompiler` call, a `setenv` in the driver or a recompiler include from outside its tree. With #316 (adriadam10, subgroup size) merged in, the version step passes: its device-dependent subgroup size reaches the recompiler through `RecompileRequest::target`, which the key covers. - PPSA21564: on my integration branch since 2026-10-03; driver-only rebuilds there keep the shader cache warm. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
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!457
No description provided.