Skip to content

perf(shader): keep specialized modules in the shader disk cache - #6954

Closed
alfalfa-star wants to merge 1 commit into
boykopovar:mainfrom
alfalfa-star:perf/shader-module-disk-cache
Closed

alfalfa-star wants to merge 1 commit into
boykopovar:mainfrom
alfalfa-star:perf/shader-module-disk-cache

Conversation

@alfalfa-star

@alfalfa-star alfalfa-star commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What

The shader disk cache keeps compiled shaders and resource plans, but not the specialized modules built from them (the SPIR-V for one set of specialization classes and constants). Every run rebuilds all of them, even when every shader comes from the cache. In Kena: Bridge of Spirits (PPSA01802) this rebuild work repeats on every start and whenever a new area loads.

Specialized modules are stored in the cache's versioned entry directory under modules/, keyed by a hash of the artifact's SPIR-V, stencil references, specialization classes, constants and target (Vulkan/SPIR-V version, image-offset support), and loaded from there on later runs. Writes go through a temporary file and a rename, so a crashed run leaves no partial entry. Because the entry directory is per source version, a recompiler change never reuses old modules. APS5_NO_MODULE_CACHE=1 turns it off.

Tested

AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9), Kena: Bridge of Spirits (PPSA01802).

  • ctest: no new failures (agc_driver_tessellation segfaults on main without this change; guest_kernel_fcntl is flaky under parallel load and passes on rerun).
  • Kena: used in our local test build for several days of runs with a persistent cache, without rendering differences.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: none (performance of PPSA01802)
  • GPUs tested: AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9)
  • AI-assisted: yes

🤖 Generated with Claude Code

A specialized module (the SPIR-V a compiled shader becomes for one set of
specialization classes and constants) was rebuilt on every run, even when
the shader itself came from the disk cache. Specialized modules are now
stored in the cache's versioned entry directory under modules/, keyed by a
hash of the artifact's SPIR-V, stencil references, classes, constants and
target, and loaded from there on later runs. APS5_NO_MODULE_CACHE=1 turns
it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alfalfa-star

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #6924 by @moong15, opened two hours before this one. Both store the modules specializeModule builds in the shader disk cache and load them on a warm start. #6924 also keeps the binding plans, stores both inside the disk cache format with key and damage checks, and has tests, so this PR adds nothing it lacks. Its checklist line "no other open PR implements the same functions" was wrong; I missed #6924 when opening it.

AI-assisted: yes (Claude Code)

@github-actions

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6924 core/shader/recompiler/Recompiler.cpp L833-834, L853-854

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4048 core/shader/recompiler/Recompiler.cpp
PR 4072 core/shader/recompiler/Recompiler.cpp
PR 4339 core/shader/recompiler/Recompiler.cpp
PR 4650 core/shader/recompiler/Recompiler.cpp
PR 5021 core/shader/recompiler/Recompiler.cpp
PR 5500 core/shader/recompiler/Recompiler.cpp
PR 5609 core/shader/recompiler/Recompiler.cpp
PR 6177 core/shader/recompiler/Recompiler.cpp
PR 6222 core/shader/recompiler/Recompiler.cpp
PR 6412 core/shader/recompiler/Recompiler.cpp
PR 6503 core/shader/recompiler/Recompiler.cpp
PR 6539 core/shader/recompiler/Recompiler.cpp
PR 6612 core/shader/recompiler/Recompiler.cpp
PR 6762 core/shader/recompiler/Recompiler.cpp
PR 6879 core/shader/recompiler/Recompiler.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant