feat(recompiler): add an uncached compile entry point and entry key helpers for offline tools #6296
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6296"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by SaloQT on 2026-10-15T09:51:53Z.
What
Two small recompiler additions that offline shader tooling needs, split out of #6032 as requested there:
CompileShaderUncached: compiles a request to aCompiledVariantwithout reading or writing the disk cache, with optional frontend/backend timings. Runtime behaviour is untouched; nothing in the emulator calls it yet.EntryHeaderBytes(48, static-asserted against the on-disk header),EntryKey(extract and hash-check the key stored in an encoded entry), andIsCurrentEntryHeader(cheap current-format check for a header plus file size). These let tools build and inspect cache entries in the exact on-disk format without duplicating the layout.The offline shader archive tool that consumes these will follow as its own PR once this lands and its real-run hit rate is measured.
Tested
Windows 11:
agc_shader_disk_cacheandshader_cache_file_readpass, including new cases: entry-key round trip, truncated/damaged headers rejected, uncached compile deterministic across two calls and leaving the disk-cache totals (hits, misses, writes, bytes) unchanged.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:03:24Z.
Review: CHANGES_REQUESTED
Thanks for splitting it out. Small and well tested (determinism and untouched disk-cache totals are the right checks). Two things to fix, then a reply to what you wrote on Discord, so it's all in one place.
Changes
unwrapEntry's validation.EntryKeyandIsCurrentEntryHeaderrepeat the header checks ofunwrapEntry(ShaderDiskCache.cpp), andEntryKeyskips one of them: the zero-padding check between key and payload. SoEntryKeycan return a key for an entry thatDecodeEntrythen rejects, which is exactly what a tool must not believe. Please move the header/size/padding validation out ofunwrapEntryinto one helper and have all three use it, so there is a single definition of "a valid current entry".EntryKeyis declared inShaderCachePack.hppandIsCurrentEntryHeaderinShaderDiskCache.hpp, both defined inShaderDiskCache.cpp. Neither is about packs; please declare both inShaderDiskCache.hpp.Before merging we'll run the full Build (the PR's
linux/windowsjobs are skipping) andagc_shader_disk_cache/shader_cache_file_readon Linux here, since it was only tested on Windows.About your message on Discord
Not anymore: since #5792 merged you have one merged PR, so the limit is 20 open PRs, not 1 (the bot's text: "at least 1 merged can have 20"). You didn't need to close #6032. Reopen the tool as its own PR whenever you want, marked "Depends on: #6296", and send the other prerequisites in parallel too, each one small and with its own tests.
That's the goal, and we want it too. The reason we keep asking for numbers is that what happens on your local copy isn't what this series does upstream:
CompiledVariants doesn't skip the driver compile, and nothing loadspipeline-cache.binupstream. So even with 100 % hits, "no compilation at all" doesn't follow from this series as it stands.[shader-prebuilt]hits/misses from a real run, with a pack built bybuild --paksonly, plus load time with and without it.Suggested order on your side: fix 1–2 here (we'll merge after the full Build), then reopen the tool on top with the hit-rate numbers, and the key/pipeline write-up in parallel.
Imported from boykopovar/AnyPS5. Originally posted by SaloQT on 2026-10-15T11:29:33Z.
Both fixed, squashed into the commits that own them:
parseEntryHeader(magic/format/source version, nonzero key, payload size arithmetic) andvalidatedEntry(header plus zero-padding, key hash and payload hash) now sit under all three:unwrapEntryadds only the key-equality check,EntryKeyreturns the key only for a fully validated entry, andIsCurrentEntryHeaderis the header-only form. One behaviour note: a stored zero-length key now reads asRejectedinstead ofKeyMismatch, since the shared header check requires a nonzero key;wrapEntrynever writes one. The test now also damages a padding byte and requires bothEntryKeyandDecodeEntryto refuse it.EntryKeymoved fromShaderCachePack.hpptoShaderDiskCache.hpp, next toIsCurrentEntryHeader.Rebased onto current main;
agc_shader_disk_cacheandshader_cache_file_readpass locally, conventions clean. The tool PR reopens alongside this one, marked Depends on: #6296 — thanks for the limit correction.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:18:16Z.
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.
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceProgram.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceProgram.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceProgram.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceProgram.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppPull request closed