fix(shader): find the shader cache directory on macOS #4019
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4019"
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 ahir061 on 2026-10-11T21:29:33Z.
What
ShaderRecompiler::ShaderCacheDirectory()finds the executable folder on every non-Windows host throughstd::filesystem::read_symlink("/proc/self/exe", error). macOS has no/proc, so it returns an empty path there. An empty path disables both the shader disk cache (DiskStorenever sets its directory, soEnabled()is false) and the Vulkan pipeline cache inPipelineCache.cpp(no load, no saver thread), silently, unlessANYPS5_SHADER_CACHE_DIRis set.On macOS the executable path now comes from
_NSGetExecutablePath(size queried first), resolved withstd::filesystem::canonicalusing theerror_codeoverload, so the default is<real executable folder>/shader_cache, as on Linux. The function keeps its failure behaviour: it returns an empty path and never throws.ANYPS5_NO_SHADER_CACHEandANYPS5_SHADER_CACHE_DIRare handled first, as before. Linux and Windows are unchanged.Same
/proc/self/exeproblem as #4014 (libSceFont and libSceNpEntitlementAccess); this is the shader cache part, independent of it.Tested
read_symlinkfails with No such file or directory).<real folder>/shader_cachewhen the program is run by full path, through a symlink in another folder and through a relative symlink path.ANYPS5_SHADER_CACHE_DIR=/some/dirreturns/some/dir, andANYPS5_NO_SHADER_CACHE=1returns an empty path.verifyDefaultDirectoryinlibSceAgcDriver/tests/ShaderDiskCache.cpp, run against both versions: they fail before ("not named shader_cache") and pass after.ShaderDiskCache.cppcompiles for x86_64 macOS with-fsyntax-only -Wall -Wextraand no warnings (withShaderCacheVersion.hppgenerated by the project'sShaderCacheVersion.cmake).tools/check_conventions.py --base upstream/mainpasses.agc_drivertests, since the full build does not complete on macOS yet; Linux and Windows builds (their code path is unchanged).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T00:29:48Z.
What I could check from here — Linux, static reading; I have no macOS host, so the platform claim itself is not exercised:
ShaderCacheDirectory()) and consumed by both the shader disk cache and the Vulkan pipeline cache (PipelineCache.cpp:34), so one change covers both. That an empty path silently disabled both is what makes this worth merging rather than a cosmetic porting change.#ifdef __APPLE__inside the existing non-Windows branch — and a failing resolve still returns an empty path rather than throwing.canonicalwith theerror_codeoverload is the right choice:_NSGetExecutablePathcan hand back a path that is still a symlink, andcanonicalgives the real folder, which is whatread_symlink("/proc/self/exe")already yields on Linux.mach-o/dyld.hdocuments: Apple's dyld does fill*bufsizewhen the buffer is null, so the first call works, but the reliance is worth a line in the commit message. If you would rather stay on documented behaviour, the grow-and-retry loop the Windows arm already uses is the pattern./proc/self/exeis absolute; and this is not the whole/proc/self/exestory —libc/src/GuestAllocations.cpp:79,libkernel/Module/src/ModuleInfo.cpp:114andtests/GuestImageAnonymous.cpp:17still assume it, and #4014 covers onlylibSceFontandlibSceNpEntitlementAccess.Coverage: on this PR
linuxandwindowsare skipped andrelinkerskips too, while the macOS jobs that do run build the standalonecore/libs/testssubprojects. No job that ran compiled this file on any platform, which is why the extraction you ran by hand is the only evidence — a small device-free target forShaderCacheDirectory()that builds on all three runners would giveverifyDefaultDirectorysomething to run under__APPLE__.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T23:05:06Z.
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.
main)core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56core/shader/recompiler/ShaderDiskCache.cppL55-56