fix(agc): read the pipeline cache header through the long-path form on Windows #8554

Merged
aarushkha merged 2 commits from upstream-pr/8554 into main 2026-10-21 04:20:35 +00:00
aarushkha commented 2026-10-20 16:25:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by aarushkha on 2026-10-20T16:25:49Z.


What

PipelineCache::readHeader opened the cache file with a plain std::ifstream(path). readFile (through ShaderRecompiler::ReadWholeFile) and the atomic writer already resolve the path with NativeCachePath_nid_no_patch. On Windows, past MAX_PATH, the header read fails while the full read and write succeed. save then compares a missing on-disk header with settledFile, treats the file as changed, and re-reads and merges it on every save. This is the remaining header reader confirmed in #7452.

On Windows the header is now read through the extended path, as PipelineJournal does for its directory. If the path cannot be resolved, it returns std::nullopt, matching a failed open. readFile had the same gap in its fallback: when the full read fails it calls std::filesystem::exists to tell a missing file from an unreadable one, and used the plain path. Past MAX_PATH an existing file was reported missing instead of unreadable, so save could write over it. It now checks the extended path too. This was listed in the review of #7462 and is not part of #7933 or open #7945. Linux and macOS are unchanged.

Tested

Windows 10 Pro (10.0.19045), WinLibs GCC 15.2.0 posix UCRT r7, Release, full build with -DBUILD_TESTING=ON, NVIDIA GeForce RTX 3060 (driver 617.42). Both commits applied to main 83751168dd (they cherry-pick cleanly; this branch's own base is older). PipelineCache.cpp compiles with no warnings.

ctest --test-dir build -R "^agc_pipeline_cache(_file)?$" with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1:

Tree agc_pipeline_cache agc_pipeline_cache_file
main 83751168dd passed passed
main + this PR passed 3 of 3 passed 3 of 3

These tests write the cache under a short temporary path, so they check that the change does not break the ordinary path. They do not exercise a path past MAX_PATH. I tried that by pointing TEMP at a 196-character directory, so the cache file lands past MAX_PATH. On main, agc_pipeline_cache_file then hangs rather than failing. That matches the housekeeping hang on long extended roots that #7945 addresses, so this PR's long-path behaviour could not be measured that way, and no long-path regression is added here.

Not run: the Khronos validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation), because no Vulkan SDK is installed on this machine; Linux; a title.

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
  • Fixes: none (the remaining PipelineCache::readHeader gap from #7452)
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060, driver 617.42, Windows 10 Pro 19045 (host file I/O only; without the validation layer)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4938922298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8554). Originally posted by [aarushkha](https://github.com/aarushkha) on 2026-10-20T16:25:49Z. --- ### What `PipelineCache::readHeader` opened the cache file with a plain `std::ifstream(path)`. `readFile` (through `ShaderRecompiler::ReadWholeFile`) and the atomic writer already resolve the path with `NativeCachePath_nid_no_patch`. On Windows, past MAX_PATH, the header read fails while the full read and write succeed. `save` then compares a missing on-disk header with `settledFile`, treats the file as changed, and re-reads and merges it on every save. This is the remaining header reader confirmed in #7452. On Windows the header is now read through the extended path, as `PipelineJournal` does for its directory. If the path cannot be resolved, it returns `std::nullopt`, matching a failed open. `readFile` had the same gap in its fallback: when the full read fails it calls `std::filesystem::exists` to tell a missing file from an unreadable one, and used the plain path. Past MAX_PATH an existing file was reported missing instead of unreadable, so `save` could write over it. It now checks the extended path too. This was listed in the review of #7462 and is not part of #7933 or open #7945. Linux and macOS are unchanged. ### Tested Windows 10 Pro (10.0.19045), WinLibs GCC 15.2.0 posix UCRT r7, Release, full build with `-DBUILD_TESTING=ON`, NVIDIA GeForce RTX 3060 (driver 617.42). Both commits applied to `main` `83751168dd` (they cherry-pick cleanly; this branch's own base is older). `PipelineCache.cpp` compiles with no warnings. `ctest --test-dir build -R "^agc_pipeline_cache(_file)?$"` with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`: | Tree | `agc_pipeline_cache` | `agc_pipeline_cache_file` | |---|---|---| | `main` `83751168dd` | passed | passed | | `main` + this PR | passed 3 of 3 | passed 3 of 3 | These tests write the cache under a short temporary path, so they check that the change does not break the ordinary path. They do not exercise a path past MAX_PATH. I tried that by pointing `TEMP` at a 196-character directory, so the cache file lands past MAX_PATH. On `main`, `agc_pipeline_cache_file` then hangs rather than failing. That matches the housekeeping hang on long extended roots that #7945 addresses, so this PR's long-path behaviour could not be measured that way, and no long-path regression is added here. Not run: the Khronos validation layer (`VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`), because no Vulkan SDK is installed on this machine; Linux; a title. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none (the remaining `PipelineCache::readHeader` gap from #7452) - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060, driver 617.42, Windows 10 Pro 19045 (host file I/O only; without the validation layer) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Amoenus commented 2026-10-20 21:17:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-20T21:17:11Z.


Current-main integration follow-up, 2026-10-21 UTC

#8554 is merged as 042504ea2820a97e6add8c89829ea65e4244e7a1. We have now adapted the previously offered header regression to the version-directory layout: fixture adjustment 2e844131db. It enumerates the current 16-digit source-version directory, keeps that listing below MAX_PATH, requires the actual cache filename beyond MAX_PATH, and retains persisted-byte equality plus the real cache-creation counter across three idle saves.

The old fixture first failed because it expected a cache file directly under the configured root; that failure is retained. After the fixture correction, agc_pipeline_cache_header passes 3/3 fresh serial processes on each physical GPU: RTX 5080 and AMD Radeon(TM) Graphics on Windows 11 Enterprise 26200. Required Vulkan and the loaded Khronos 1.4.363 layer; no skips, timeouts, VUIDs or validation warnings/errors. The two neighboring ordinary cache groups also pass 3/3 per GPU: 18 passing GPU processes total.

Scope: experimental integration 2e844131db on main 7d7b097407a0d5d1ddd243d98f0ddc5d9cbc5420, with other title-bring-up changes. Its PipelineCache.cpp is byte-identical to that main; this is not an isolated run of #8554's former head or a literal-main whole-build result. The integration's full Windows build and explicit libraries build pass. No new negative-control run, failed-read/existence fault injection, title-speed or console claim. No production change or competing PR here. The earlier control and authorship/proposal history remain below.

AI-assisted: yes (Codex); author responsible.

Original regression offer and historical controls

@aarushkha there is an existing focused regression for the header half that you can reuse: 8d4b4914f0, offered in #7462. Its agc_pipeline_cache_header mode keeps the directory at 220–249 characters and makes only the filename cross MAX_PATH, so it does not need an oversized TEMP. It checks exact persisted bytes and counts real cache creations: three idle saves must neither reload the unchanged cache nor alter the bytes.

The recorded test-only control failed 3/3 on RTX 5080 and 3/3 on Radeon Graphics; the corrected old composition passed on both with Khronos validation. Those results are pinned to main 0d078f75d3 + #7462 3df970aeb7 + the offered commit, not this PR's current head. Full details and limitations are in that earlier report. The fixture needs adaptation to current main and cannot substitute for a regression of your separate failed-read/existence check.

I will not open a competing header-reader PR. Please preserve original authorship if you take the fixture; your existence-check correction remains your separate contribution. AI-assisted: yes (Codex); author responsible.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301678167 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8554#issuecomment-6301678167). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-20T21:17:11Z. --- ### Current-main integration follow-up, 2026-10-21 UTC #8554 is merged as `042504ea2820a97e6add8c89829ea65e4244e7a1`. We have now adapted the previously offered header regression to the version-directory layout: [fixture adjustment `2e844131db`](https://github.com/Amoenus/AnyPS5/commit/2e844131db5603a86e1b967adb878625a0bc1638). It enumerates the current 16-digit source-version directory, keeps that listing below MAX_PATH, requires the actual cache filename beyond MAX_PATH, and retains persisted-byte equality plus the real cache-creation counter across three idle saves. The old fixture first failed because it expected a cache file directly under the configured root; that failure is retained. After the fixture correction, `agc_pipeline_cache_header` passes **3/3 fresh serial processes on each physical GPU**: RTX 5080 and AMD Radeon(TM) Graphics on Windows 11 Enterprise 26200. Required Vulkan and the loaded Khronos 1.4.363 layer; no skips, timeouts, VUIDs or validation warnings/errors. The two neighboring ordinary cache groups also pass 3/3 per GPU: **18 passing GPU processes total**. **Scope:** experimental integration `2e844131db` on main `7d7b097407a0d5d1ddd243d98f0ddc5d9cbc5420`, with other title-bring-up changes. Its `PipelineCache.cpp` is byte-identical to that main; this is not an isolated run of #8554's former head or a literal-main whole-build result. The integration's full Windows build and explicit libraries build pass. No new negative-control run, failed-read/existence fault injection, title-speed or console claim. No production change or competing PR here. The earlier control and authorship/proposal history remain below. AI-assisted: yes (Codex); author responsible. <details> <summary>Original regression offer and historical controls</summary> @aarushkha there is an existing focused regression for the header half that you can reuse: [`8d4b4914f0`](https://github.com/Amoenus/AnyPS5/commit/8d4b4914f082ddc04731ebec3f3e12f485d1b27c), offered in [#7462](https://github.com/boykopovar/AnyPS5/pull/7462#issuecomment-6250139911). Its `agc_pipeline_cache_header` mode keeps the directory at 220–249 characters and makes only the filename cross MAX_PATH, so it does not need an oversized `TEMP`. It checks exact persisted bytes and counts real cache creations: three idle saves must neither reload the unchanged cache nor alter the bytes. The recorded test-only control failed 3/3 on RTX 5080 and 3/3 on Radeon Graphics; the corrected old composition passed on both with Khronos validation. Those results are pinned to main `0d078f75d3` + #7462 `3df970aeb7` + the offered commit, **not this PR's current head**. Full details and limitations are in that earlier report. The fixture needs adaptation to current main and cannot substitute for a regression of your separate failed-read/existence check. I will not open a competing header-reader PR. Please preserve original authorship if you take the fixture; your existence-check correction remains your separate contribution. AI-assisted: yes (Codex); author responsible. </details>
Queuse commented 2026-10-21 23:36:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-21T23:36:34Z.


Follow-up regression coverage is in #9013, 8b01446efc, main a6dcea9279; original fixture authorship preserved. It checks long cache filenames while keeping the directory below MAX_PATH, idle saves without reload, and locked-file diagnostics/byte retention.

Current baseline passes both existing cache cases; candidate passes all 3 (Windows 11, RTX 3050 Laptop/617.42, GCC 15.2.0-r7), no skips, missing validation layer or VUIDs. Independent header/existence controls on 27c88a8d75 each fail their expected assertion; restoring passes 3/3. No Linux/title/full-suite claim. AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328970006 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8554#issuecomment-6328970006). Originally posted by [Queuse](https://github.com/Queuse) on 2026-10-21T23:36:34Z. --- Follow-up regression coverage is in [#9013](https://github.com/boykopovar/AnyPS5/pull/9013), `8b01446efc`, main `a6dcea9279`; original fixture authorship preserved. It checks long cache filenames while keeping the directory below MAX_PATH, idle saves without reload, and locked-file diagnostics/byte retention. Current baseline passes both existing cache cases; candidate passes all 3 (Windows 11, RTX 3050 Laptop/617.42, GCC 15.2.0-r7), no skips, missing validation layer or VUIDs. Independent header/existence controls on `27c88a8d75` each fail their expected assertion; restoring passes 3/3. No Linux/title/full-suite claim. 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!8554
No description provided.