fix(shader): support long Windows cache file paths #7462
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7462"
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 AlexanderCalli on 2026-10-18T08:30:01Z.
What
Fix Windows shader and pipeline cache file I/O under long host paths. The shared atomic writer could fail for a 235-character destination once its temporary suffix crossed MAX_PATH; longer ordinary paths also failed on reads. Passing an already-extended path through the previous
std::filesystem::absolutecall was mishandled by the supported MinGW toolchain.Resolve ordinary Windows paths with GetFullPathNameW, then use the extended namespace consistently for directory creation, the temporary stream, atomic replacement and reads. Preserve already-extended/device paths and map UNC paths to the extended UNC form. Keep the existing FILE_RENAME_INFO replacement and delete-sharing flags.
Contract: Microsoft long-path documentation and FILE_RENAME_INFO. This does not depend on a host executable's longPathAware manifest. No shader semantics or cache format changes.
Fixes #7452.
Tested
Windows x86-64, supported WinLibs GCC 15.2.0 r7, Release relinker-only build.
shader_cache_file_read_tests; its existing allocation-failure/read cases and new Windows filesystem cases pass. Three consecutive cold-process CTest runs pass in 0.50 seconds total; a final run also passes.cannot write cache path, after passing the original five read cases..., missing-file reads, replacement while an old reader retains the original bytes, and absence of leftover temporary files.tools/check_conventions.py --base origin/mainandgit diff --checkpass.tools/pr_overlap.py --branch fix/windows-cache-long-paths --repo boykopovar/AnyPS5reports no overlap with open pull requests.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 oneandonlydean on 2026-10-18T09:22:58Z.
Thanks. Windows CI fails
shader_cache_file_readwith the default "Cache file read failed" (run 39112227465), after the five ordinary cases. Most likely it's the relative-path case:rootcomes fromtemp_directory_path(), which is on C: on GitHub's runner, while the test's current directory is the build tree on D:, solexically_relativereturns an empty path andRequire(!relative.empty())fails. Could you build the relative case from a directory on the same drive (for example set the current path torootfor that case, or derive the path relative toroot.root_path()), and give everyRequireinVerifyCachePathsits own message so a future failure names its check? The long-path cases themselves look fine. None of their explicit messages printed.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-18T09:36:55Z.
Thanks for picking up #7452. I independently validated
3df970aeb7on maincb1d6e5bd6with a test-only overlay; the cache production files are byte-identical to your head.shader_cache_file_readand the existingagc_shader_disk_cachepass three fresh runs each. Nine additional host-only runs also pass, including a deterministic 259-character destination whose temporary suffix exceeds MAX_PATH, ordinary/extended/relative/dot paths, deep parents, Unicode, and retained-reader bytes.a long-path cache entry was not persisted and mapped. It uses a 225-character cache root and a derived entry path over 260. It first verifies that the published bytes exactly equalEncodeEntry, so the shared writer has succeeded before the mapping failure.MapFilestill passes the ordinary long path toCreateFileW. Normalizing that call with yourNativeCachePath_nid_no_patchgets persistence/mapped-SPIR-V round trips through, then exposes a second 3/3 failure:a long-path cache pack was rejected: cannot open. The pack constructor has the same remaining raw open.I pushed the test-only reproduction and the two-call-site correction on top of your exact work, preserving attribution. Focused comparison: four files, including the regression/registration; no replacement of your shared helper. You can take the correction/regression here, or it can follow your PR.
Validation of focused head
0a3621bbbfis now complete: full Windows and Linux builds pass with SPIRV-Tools ON. The selected repeated matrix has 51 passes and one explicit Linux skip: NVIDIA 9, AMD 9, Windows CPU 15, Linux 18; the Linux pipeline-file fixture reports that lavapipe does not retain pipelines in a pipeline cache. All executed tests finish within 2.07 s. The GPU fixtures select RTX 5080 (10de:2c02, driver 610.62 / 32.0.16.1062) and Radeon(TM) Graphics (1002:13c0, driver 32.0.21036.18), Windows11 Enterprise26200; Vulkan validation is loaded with no validation warnings/errors in those selected runs. Linux uses Ubuntu24.04, GCC13.3 and lavapipe/Mesa25.2.8. Cppcheck then clang-tidy cover the two changed production translation units and the cache fixture: no clang-tidy diagnostics, one Cppcheck portability advisory on an unchanged serializer line also present in the parent; no parser/configuration errors. This is a selected matrix, not the full CTest suite. The original parent also needs the independently reproduced cross-drive fixture correction below; local same-drive success does not address that CI failure. This deeper-directory mapping case is additional coverage: the original Sonic replay had 254-character shader entries and 269-character pipeline files. It is not established as the cause of that replay's startup time. No performance claim.Ordinary title validation is now complete: integration
e4c6c8f970combines main9caecfd, your exact head, our mapped follow-up and the cross-drive fixture correction. A bounded180s Sonic/PPSA99902 replay at the original long host path reaches Continue/opening cinematic and records 60 shader writes,60 resource-plan writes, zero load/write failures;124 cache files (26,452,618 bytes) are archived, including the269-character pipeline-cache file. A second90s replay with that archived application cache records 56 shader hits, zero misses/writes/load failures, and loads5461.2KiB from the pipeline-cache file. Both runs have zero logged VUIDs, validation warnings/errors or guest fence failures in these intervals. All127 runtime-library hashes and145 restored prior files (including3 prior cache files), plus protected originals and launch/config hashes, independently verify for each run. Original executable/guest module/config/assets unchanged; copied archived save, no field edits. This validates persistence/readback in the composed title runtime; it is not an isolated performance comparison or a new gameplay-completion claim. Full source pins and limits.AI-assisted: yes, Codex.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-18T09:52:57Z.
Confirmed the cross-drive diagnosis in https://github.com/boykopovar/AnyPS5/pull/7462#issuecomment-6248195445: with a C: temporary directory and a Z: working-directory alias, unchanged
3df970aeb7fails3/3 after5 cache file read cases passed, printing the defaultCache file read failed.Focused fixture correction
de74182891sets the current directory to the temporary root for the relative case, restores it through an RAII guard, and gives everyRequireinVerifyCachePathsa descriptive message. No production changes. It passes3/3 same-drive and3/3 split-drive runs (all under0.14s), with the original Windows path/replacement checks intact. Z: was a temporary localsubstalias, removed afterward; no second physical volume or SMB claim.This is separate from the mapped-cache follow-up above and can be taken directly into this PR. WinLibs GCC15.2.0 r7, optimized static Windows executable. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T10:22:00Z.
Amoenus's report checks out: on
3df970aeb7MapFile(ShaderDiskCache.cpp:198) andCachePack(ShaderCachePack.cpp:43) still open the raw path, so a long-path entry is written but never mapped. Could you take their0a3621bbbf(two call sites throughNativeCachePath_nid_no_patch) and the83ad998790regression, together with the relative-path test fix, in one push?PipelineJournal.cpp:348andPipelineCache::readHeaderopen plain paths too, so either convert them or note them in the debt file.Imported from boykopovar/AnyPS5. Originally posted by LuisBiceps on 2026-10-18T11:59:22Z.
Besides the four sites above, these still take the plain path on
3df970aeb7:exists(:467, :650),file_size(:764, :781),resize_file(:768), the append stream (:794) andvalidTail's read (:834). With only the lock at :348 converted, every append still fails withcannot open the journal for writing.existsinPipelineCache::readFile(PipelineCache.cpp:96), so an unreadable long-path file is reported missing.last-usedstamp (ShaderDiskCache.cpp:1597-1599), its removal of stale.tmp.files (:1616, :1619), and the prebuilt status checks (:1431-1432, :1444).A caution for the directory listings (:1435, :1601 with its
remove_allat :1609, :1613). On Windows 10 with WinLibs GCC 15.2.0 r7,std::filesystem::directory_iteratoron an ordinary 270-character directory path fails withENOENT. On the same directory in\\?\form, it returned the entries of the process's working directory as children of the long path, andremove_allon it did not return. At 200 and 250 characters both forms list correctly. So these are safer left on the plain path, where a directory that long is skipped; that limit could go in the debt file note. Onmainthey already receive anANYPS5_SHADER_CACHE_DIRgiven in\\?\form unchanged (:51).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T12:21:58Z.
Thanks @LuisBiceps, that matches what I see on
3df970aeb7. Adding to the earlier ask:File operations under the cache root: please convert, or scope them in the debt note. These still take the plain path:
exists(PipelineJournal.cpp:467, :650),file_size(:764, :781),resize_file(:768), the append stream (:794) andvalidTail's read (:834). With only the lock at :348 converted, a journal under a long root is never written ("cannot open the journal for writing"). That is the same class of failure as the mapped reads, so I'd convert these withNativeCachePath_nid_no_patchlike the rest.PipelineCache::readFile'sexists(PipelineCache.cpp:96): a long-path file is reported missing.last-usedstamp (ShaderDiskCache.cpp:1597-1599), the.tmp.remove(:1616, :1619) and the prebuilt status checks (:1431-1432, :1444). These are safe to convert because they act on one known file each.Directory listings: please keep them on the plain path, and guard the
\\?\case. LuisBiceps measured on WinLibs GCC 15.2 thatdirectory_iteratorover a\\?\directory of about 270 characters lists the process's working directory as its children, and thatremove_allon it didn't return. Housekeeping iterates the cache root (:1601) and callsremove_all(:1609) on old 16-hex-digit subdirectories, so a\\?\root could make it act on entries that aren't in the cache, or hang at startup. So:remove_all) on plain paths, where a directory that long simply fails withENOENTand is skipped;ANYPS5_SHADER_CACHE_DIRgiven in\\?\form already reaches them unchanged onmain(ShaderDiskCache.cpp:51), strip a leading\\?\(and\\?\UNC\) from the root before housekeeping, or skip housekeeping for a prefixed root;A test for item 2 would be cheap: housekeeping with a
\\?\root that contains one stale 16-hex-digit directory must not touch anything outside the root and must return.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-18T12:52:21Z.
@AlexanderCalli @oneandonlydean Confirmed the
PipelineCache::readHeaderpoint with a focused regression and correction: 8d4b4914f0, based on main0d078f75d3plus your exact3df970aeb7. It reuses your native-path helper for this reader and adds the required shader-cache reviewed-name entry (host file I/O, no shader-output input).an unchanged long-path pipeline cache was reloaded for an idle save. Reverting just the reader on the final fixture reproduces the same failure on each GPU. The diagnostic AMD control counted cache creations rising1→4 across three idle saves.The focused commit is available to take into this PR alongside the already-requested follow-ups. This establishes redundant reloads, not a measured game speedup. Cppcheck and clang-tidy completed; clang-tidy has no selected diagnostics, while Cppcheck reports45 diagnostics outside the added ranges in the existing recorder fixture. No clean-analysis claim. The running Sonic composition does not yet include this reader correction. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-18T21:53:14Z.
Windows data:
shader_cache_file_readfails onmainand passes with this PR, on Windows 11 Pro 26300 with WinLibs GCC 15.2.0 r7, Release.shader_cache_file_read, ×33df970aebmerged intomainf3059421fCacheFileReadTests.cpponmainf3059421f, with none of its other changes5 cache file read cases passed, thencannot write cache pathFull CTest (
--parallel 4, 1513 tests) with this head merged, on an Intel UHD 770 (driver 32.0.101.7088) and an AMD RX 9070 XT (driver 32.0.31041.1004), fails the same tests asmainalone on this machine, none of them in the shader cache. I also ran full CTest with this PR and the 14 other open AGC PRs I tested in the same batch merged together (#7647, #7641, #7630, #7627, #7603, #7600, #7591, #7579, #7535, #7533, #7474, #7050, #7048, #7650). Neither GPU showed a failure beyondmain's own, except #7650's new test.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T09:52:19Z.
Thank you for this. #7933 has now merged (
d14a186f46) and carries this change, with your commits cherry-picked so the credit stays yours, together with the MapFile/CachePack long-path fix. So I'm closing this one as covered by #7933.Pull request closed