fix(agc): create tessellation pipelines without the pipeline cache on MoltenVK #10046

Merged
jotitadev merged 2 commits from upstream-pr/10046 into main 2026-10-25 11:38:17 +00:00
jotitadev commented 2026-10-23 06:08:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T06:08:45Z.


What

On MoltenVK, agc_driver_tessellation's merged hull cases draw nothing (#10045). MoltenVK pads the domain stage's input struct to the per-vertex outputs of the hull it is linked with. The shader cache inside a VkPipelineCache matches a cached conversion when the new configuration has the inputs that conversion used, so the domain shader converted next to a 16-byte hull is reused next to the merged hull. The merged hull's ControlShared record adds a second per-vertex output, so the domain stage reads its control points at 16 bytes over a 48-byte buffer.

This PR creates tessellation pipelines without the pipeline cache when the driver is MoltenVK. Each tessellation pipeline then gets a conversion for its own interface. Tessellation pipelines also skip the graphics pipeline library path while the cache is off (libraryKeys in Pipeline.cpp), so the parts, the link and the optimized relink in PipelineLibrary.cpp never see context.pipelineCache for them. MoltenVK does not expose VK_EXT_graphics_pipeline_library (not listed by vulkaninfo with MoltenVK 1.4.2 or MoltenVK main), so the guard does not change what runs on Apple today; it keeps the rule if that changes. TessellationPipelineCacheUsable(VkDriverId) follows FragmentShaderBarycentricUsable and SubgroupControlBarrierUsable, with a unit test for its driver table. agc_driver_graphics checks with the mock device that a tessellation pipeline is prebuilt from graphics pipeline libraries when the cache is shared and is not when it is off. Other drivers and other pipelines keep the cache.

Tested

Apple M2 Max (32 GB), macOS 27.2, x86_64 build under Rosetta, Release. main does not build on macOS yet, so I applied this diff to #8658 (feat/macos-port) @ 46673ede9e, which has main 0db47b263d merged. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ctest -j1 --timeout 30.

  • agc_driver_tessellation, with every case run: both merged hull cases fail before and pass after. The only case left failing is RequireInstancedRelativePatches, which fails before and after (see #10045).
  • With the cache kept but the merged hull cases run first, they pass too (measured on #8658 @ 4e0468722f). That confirms the order dependence.
  • ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64", 898 tests before and 899 after: the same 22 failures with MoltenVK 1.4.2 and the same 21 with MoltenVK main + SPIRV-Cross #2704, before and after. agc_driver_tessellation is in both lists: before it stops at the merged hull, after at RequireInstancedRelativePatches. The other failures are unrelated to tessellation and fail the same way on the base.
  • agc_tessellation_pipeline_cache and agc_driver_graphics pass.
  • agc_driver_graphics (mock device, tessellationPipelineLibraryCacheTests): fails without the libraryKeys change with "tessellation pipelines without the pipeline cache were built from graphics pipeline libraries" and passes with it. The shared-cache case passes in both, so the test reaches the library path.
  • tools/check_conventions.py --base origin/main passes.

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 (tested on top of #8658, since main does not build on macOS)
  • Fixes: #10045
  • Unblocks: none
  • GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704, macOS 27.2
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4978625489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10046). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-23T06:08:45Z. --- ### What On MoltenVK, `agc_driver_tessellation`'s merged hull cases draw nothing (#10045). MoltenVK pads the domain stage's input struct to the per-vertex outputs of the hull it is linked with. The shader cache inside a `VkPipelineCache` matches a cached conversion when the new configuration has the inputs that conversion used, so the domain shader converted next to a 16-byte hull is reused next to the merged hull. The merged hull's `ControlShared` record adds a second per-vertex output, so the domain stage reads its control points at 16 bytes over a 48-byte buffer. This PR creates tessellation pipelines without the pipeline cache when the driver is MoltenVK. Each tessellation pipeline then gets a conversion for its own interface. Tessellation pipelines also skip the graphics pipeline library path while the cache is off (`libraryKeys` in `Pipeline.cpp`), so the parts, the link and the optimized relink in `PipelineLibrary.cpp` never see `context.pipelineCache` for them. MoltenVK does not expose `VK_EXT_graphics_pipeline_library` (not listed by `vulkaninfo` with MoltenVK 1.4.2 or MoltenVK main), so the guard does not change what runs on Apple today; it keeps the rule if that changes. `TessellationPipelineCacheUsable(VkDriverId)` follows `FragmentShaderBarycentricUsable` and `SubgroupControlBarrierUsable`, with a unit test for its driver table. `agc_driver_graphics` checks with the mock device that a tessellation pipeline is prebuilt from graphics pipeline libraries when the cache is shared and is not when it is off. Other drivers and other pipelines keep the cache. ### Tested Apple M2 Max (32 GB), macOS 27.2, x86_64 build under Rosetta, Release. `main` does not build on macOS yet, so I applied this diff to #8658 (`feat/macos-port`) @ `46673ede9e`, which has `main` 0db47b263d merged. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`, `ctest -j1 --timeout 30`. - `agc_driver_tessellation`, with every case run: both merged hull cases fail before and pass after. The only case left failing is `RequireInstancedRelativePatches`, which fails before and after (see #10045). - With the cache kept but the merged hull cases run first, they pass too (measured on #8658 @ `4e0468722f`). That confirms the order dependence. - `ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64"`, 898 tests before and 899 after: the same 22 failures with MoltenVK 1.4.2 and the same 21 with MoltenVK main + SPIRV-Cross #2704, before and after. `agc_driver_tessellation` is in both lists: before it stops at the merged hull, after at `RequireInstancedRelativePatches`. The other failures are unrelated to tessellation and fail the same way on the base. - `agc_tessellation_pipeline_cache` and `agc_driver_graphics` pass. - `agc_driver_graphics` (mock device, `tessellationPipelineLibraryCacheTests`): fails without the `libraryKeys` change with "tessellation pipelines without the pipeline cache were built from graphics pipeline libraries" and passes with it. The shared-cache case passes in both, so the test reaches the library path. - `tools/check_conventions.py --base origin/main` passes. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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 (tested on top of #8658, since `main` does not build on macOS) - [x] Fixes: #10045 - [x] Unblocks: none - [x] GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704, macOS 27.2 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-23 06:11:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:11:21Z.

Review: CHANGES_REQUESTED


Reviewed exact head 8404eb5f14134d0184f810fe3ddbf36fb90421a2. Blocking gap: the new pipelineCache local is used only in Pipeline.cpp’s non-library creation calls. When libraries is true, this code calls LinkPipelineFromLibraries, whose pre-rasterization library creation and final link in Graphics/src/PipelineLibrary.cpp still pass context.pipelineCache directly (around lines 234 and 281); optimized relinking also captures that cache (around line 290). Thus any device using the graphics pipeline library path still has tessellation shader conversions in the same VkPipelineCache, despite tessellationPipelineCache == false. Please thread the per-pipeline cache choice through the library parts/link/relink paths, or disable the affected GPL path for MoltenVK, and add coverage for the path that reproduces #10045. The standalone driver-table test, diff check, and conventions pass locally; check_main_sync.py reports a clean merge but notes CMakeLists.txt also changed in #6946. Hosted product builds are skipped by path policy. This request is for a code path that bypasses the stated fix, not repository intake.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624596150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10046#pullrequestreview-5624596150). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T06:11:21Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `8404eb5f14134d0184f810fe3ddbf36fb90421a2`. Blocking gap: the new `pipelineCache` local is used only in `Pipeline.cpp`’s non-library creation calls. When `libraries` is true, this code calls `LinkPipelineFromLibraries`, whose pre-rasterization library creation and final link in `Graphics/src/PipelineLibrary.cpp` still pass `context.pipelineCache` directly (around lines 234 and 281); optimized relinking also captures that cache (around line 290). Thus any device using the graphics pipeline library path still has tessellation shader conversions in the same VkPipelineCache, despite `tessellationPipelineCache == false`. Please thread the per-pipeline cache choice through the library parts/link/relink paths, or disable the affected GPL path for MoltenVK, and add coverage for the path that reproduces #10045. The standalone driver-table test, diff check, and conventions pass locally; `check_main_sync.py` reports a clean merge but notes `CMakeLists.txt` also changed in #6946. Hosted product builds are skipped by path policy. This request is for a code path that bypasses the stated fix, not repository intake.
adriadam10 commented 2026-10-23 06:13:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T06:13:22Z.

Review: CHANGES_REQUESTED


Thanks, the diagnosis in #10045 is clear. One gap, the same one MarcZX10 raised:

  • Pipeline.cpp:215 (libraryKeys) does not exclude tessellation, so when context.graphicsPipelineLibrary is on, LinkPipelineFromLibraries is used and its pre-rasterization library creation (PipelineLibrary.cpp:234), final link (:281) and optimized relink (:291) still pass context.pipelineCache. The new toggle only reaches the non-library calls. Please make tessellation pipelines skip the library path when !context.tessellationPipelineCache (or pass the null cache through those three places), so the rule holds whatever extensions the device exposes. If MoltenVK can never expose graphics pipeline libraries, say so in the PR and keep the guard anyway.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624610125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10046#pullrequestreview-5624610125). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-23T06:13:22Z. **Review:** CHANGES_REQUESTED --- Thanks, the diagnosis in #10045 is clear. One gap, the same one MarcZX10 raised: - `Pipeline.cpp:215` (`libraryKeys`) does not exclude tessellation, so when `context.graphicsPipelineLibrary` is on, `LinkPipelineFromLibraries` is used and its pre-rasterization library creation (`PipelineLibrary.cpp:234`), final link (`:281`) and optimized relink (`:291`) still pass `context.pipelineCache`. The new toggle only reaches the non-library calls. Please make tessellation pipelines skip the library path when `!context.tessellationPipelineCache` (or pass the null cache through those three places), so the rule holds whatever extensions the device exposes. If MoltenVK can never expose graphics pipeline libraries, say so in the PR and keep the guard anyway.
MarcZX10 commented 2026-10-23 11:51:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:51:03Z.

Review: APPROVED


Reviewed the updated head 0e38bdc3d02f0d72f0c39451fc3f74af4d8d7289. The fix now covers both pipeline creation paths: tessellation pipelines for drivers that cannot safely share the cache bypass graphics pipeline libraries, and direct creation uses VK_NULL_HANDLE for their cache. The new mock test exercises the shared-cache and no-cache library-selection cases, including the failure mode when the guard is absent. The author reports the merged-hull regression passing on MoltenVK before/after, with unrelated failures unchanged; hosted conventions, eligibility, labels and report checks pass. Product/relinker checks are skipped by path policy, so I am relying on the reported focused Apple/MoltenVK runs for the driver-specific behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5627813371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10046#pullrequestreview-5627813371). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T11:51:03Z. **Review:** APPROVED --- Reviewed the updated head `0e38bdc3d02f0d72f0c39451fc3f74af4d8d7289`. The fix now covers both pipeline creation paths: tessellation pipelines for drivers that cannot safely share the cache bypass graphics pipeline libraries, and direct creation uses `VK_NULL_HANDLE` for their cache. The new mock test exercises the shared-cache and no-cache library-selection cases, including the failure mode when the guard is absent. The author reports the merged-hull regression passing on MoltenVK before/after, with unrelated failures unchanged; hosted conventions, eligibility, labels and report checks pass. Product/relinker checks are skipped by path policy, so I am relying on the reported focused Apple/MoltenVK runs for the driver-specific behavior.
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!10046
No description provided.