fix(recompiler): size a typed storage heap for several images, not one dynamic image #2282

Merged
MathiasDevelopes merged 1 commit from upstream-pr/2282 into main 2026-10-10 06:55:16 +00:00
MathiasDevelopes commented 2026-10-09 14:31:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-09T14:31:15Z.


What

A typed storage-image heap held StorageHeapCapacity = 4 elements, and a dynamic-mip storage image reserves that many for its mip slots ([BindingAllocator::place](https://github.com/boykopovar/AnyPS5/blob/main/core/shader/recompiler/Optimization/src/BindingAllocator.cpp)). A shader with one dynamic-mip storage image and any other storage image of the same class therefore needed 5 elements and failed:

what():  ShaderRecompiler::Recompile: shader image heap capacity exceeded

Planet Coaster (PPSA01736) hits this with a mip-chain compute shader: the allocator reported group 30 needing 5 of 4 for 6 images (from a temporary diagnostic in the failure message). The title aborts there.

The constant is split in two: StorageMipSlots = 4 stays the number of slots per dynamic-mip image, and StorageHeapCapacity becomes 16, the elements one storage heap can hold. Heap arrays are declared with their compact length (binding.count), so every shader that fitted before gets the same layout and SPIR-V. The ABI structs and Version are unchanged.

Related open PRs: #757 and #758 also use StorageHeapCapacity for the dynamic mip count in ResourceMaterializer.cpp; whichever lands second needs to pick up the rename to StorageMipSlots on that line. #2141 changes the sampler heap size only.

Tested

Windows 11, MinGW-w64 15.2.0.

  • agc_shader_device_profile: a storage heap now holds two dynamic-mip images (8 elements), fills to exactly StorageHeapCapacity, and still rejects one image more with heap capacity exceeded. The previous version of the test expected the second image to be rejected, so it fails with the old constant.
  • Full ctest suite: 507/507 passed. tools/check_conventions.py --base origin/main passes.
  • PPSA01736: with the change, the shader compiles and the title runs on. The title needs other fixes to reach this shader on main.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4801826294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-09T14:31:15Z. --- ### What A typed storage-image heap held `StorageHeapCapacity` = 4 elements, and a dynamic-mip storage image reserves that many for its mip slots ([`[BindingAllocator::place](https://github.com/boykopovar/AnyPS5/blob/main/core/shader/recompiler/Optimization/src/BindingAllocator.cpp)`](https://github.com/boykopovar/AnyPS5/blob/main/core/shader/recompiler/Optimization/src/BindingAllocator.cpp)). A shader with one dynamic-mip storage image and any other storage image of the same class therefore needed 5 elements and failed: ``` what(): ShaderRecompiler::Recompile: shader image heap capacity exceeded ``` Planet Coaster (PPSA01736) hits this with a mip-chain compute shader: the allocator reported group 30 needing 5 of 4 for 6 images (from a temporary diagnostic in the failure message). The title aborts there. The constant is split in two: `StorageMipSlots` = 4 stays the number of slots per dynamic-mip image, and `StorageHeapCapacity` becomes 16, the elements one storage heap can hold. Heap arrays are declared with their compact length (`binding.count`), so every shader that fitted before gets the same layout and SPIR-V. The ABI structs and `Version` are unchanged. Related open PRs: #757 and #758 also use `StorageHeapCapacity` for the dynamic mip count in `ResourceMaterializer.cpp`; whichever lands second needs to pick up the rename to `StorageMipSlots` on that line. #2141 changes the sampler heap size only. ### Tested Windows 11, MinGW-w64 15.2.0. - `agc_shader_device_profile`: a storage heap now holds two dynamic-mip images (8 elements), fills to exactly `StorageHeapCapacity`, and still rejects one image more with `heap capacity exceeded`. The previous version of the test expected the second image to be rejected, so it fails with the old constant. - Full ctest suite: 507/507 passed. `tools/check_conventions.py --base origin/main` passes. - PPSA01736: with the change, the shader compiles and the title runs on. The title needs other fixes to reach this shader on main. ### 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 in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [[Claude Code](https://claude.com/claude-code)](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-10-09 14:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-09T14:31:21Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5471442509 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#pullrequestreview-5471442509). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-09T14:31:21Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
MarcZX10 commented 2026-10-09 14:44:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T14:44:03Z.


I reviewed the full diff against current main; separating the per-image mip slot count from the aggregate storage-heap limit is internally consistent, and the PR’s Windows full-suite report plus all three relinker jobs are useful coverage. The upstream Build run skipped both full Linux and Windows jobs, though, and the contribution matrix asks for those jobs on the PR head. Could an authorized collaborator dispatch the full Build workflow before merge? I see #2141 changes the adjacent sampler-capacity/ABI version in RuntimeAbi.hpp; the changes are semantically separate, but the final merge order should preserve both updates and the sampler ABI version bump.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083205691 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#issuecomment-6083205691). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T14:44:03Z. --- I reviewed the full diff against current `main`; separating the per-image mip slot count from the aggregate storage-heap limit is internally consistent, and the PR’s Windows full-suite report plus all three relinker jobs are useful coverage. The upstream Build run skipped both full Linux and Windows jobs, though, and the contribution matrix asks for those jobs on the PR head. Could an authorized collaborator dispatch the full Build workflow before merge? I see #2141 changes the adjacent sampler-capacity/ABI version in `RuntimeAbi.hpp`; the changes are semantically separate, but the final merge order should preserve both updates and the sampler ABI version bump.
MarcZX10 commented 2026-10-09 17:09:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T17:09:03Z.


Follow-up to the overlap note: #2347 now also touches the adjacent RuntimeAbi.hpp capacity lines. It raises SampledHeapCapacity, while this PR raises StorageHeapCapacity and splits out StorageMipSlots; these are separate capacities with no dependency, and both changes need to survive the merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085608989 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#issuecomment-6085608989). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:09:03Z. --- Follow-up to the overlap note: #2347 now also touches the adjacent `RuntimeAbi.hpp` capacity lines. It raises `SampledHeapCapacity`, while this PR raises `StorageHeapCapacity` and splits out `StorageMipSlots`; these are separate capacities with no dependency, and both changes need to survive the merge.
Mouhand-Kaddo commented 2026-10-09 22:05:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-09T22:05:07Z.


Additional Arch Linux validation of head 85268f86742cfe4ca270ec3431c036cc3e8aae02, cherry-picked alone onto main 19a0daa7 (local validation commit c6839278).

Environment: Arch under WSL2, GCC 16.2.1, CMake 4.4.4, kernel 6.6.87.2-microsoft-standard-WSL2, Vulkan lavapipe/llvmpipe LLVM 23.1.1.

  • Full build and patched libs build completed.
  • Full CTest: 530 total, 502 passed, 27 skipped, 1 timeout, 45.58 s. The timeout is agc_driver_flat_store, also reproduced after rebuilding that target on unchanged main da122c90; there are no additional failure names. Skips reflect the software device's capabilities and platform-specific tests.
  • agc_shader_device_profile passes in 0.01 s, including two dynamic-mip storage images sharing a heap, filling its capacity, and rejecting overflow. The per-image mip slot count remains four.

This validation includes only this PR's changes on main, without the other adjacent heap-capacity PRs. Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090027450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#issuecomment-6090027450). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-09T22:05:07Z. --- Additional Arch Linux validation of head `85268f86742cfe4ca270ec3431c036cc3e8aae02`, cherry-picked alone onto main `19a0daa7` (local validation commit `c6839278`). Environment: Arch under WSL2, GCC 16.2.1, CMake 4.4.4, kernel 6.6.87.2-microsoft-standard-WSL2, Vulkan lavapipe/llvmpipe LLVM 23.1.1. - Full build and patched `libs` build completed. - Full CTest: **530 total, 502 passed, 27 skipped, 1 timeout**, 45.58 s. The timeout is `agc_driver_flat_store`, also reproduced after rebuilding that target on unchanged main `da122c90`; there are no additional failure names. Skips reflect the software device's capabilities and platform-specific tests. - `agc_shader_device_profile` passes in 0.01 s, including two dynamic-mip storage images sharing a heap, filling its capacity, and rejecting overflow. The per-image mip slot count remains four. This validation includes only this PR's changes on main, without the other adjacent heap-capacity PRs. Written with AI assistance.
adriadam10 commented 2026-10-10 06:16:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:16:15Z.


Checked the diff, built and ran the libSceAgc/libSceAgcDriver ctest (all green, agc_shader_device_profile included); without the change the new test doesn't build, and it covers two dynamic-mip images, a full heap and one image over. Heap arrays keep their compact binding.count, so layouts of shaders that already fitted are unchanged and no ABI bump is needed.
The PR conflicted with main in ResourceMaterializer.cpp (adjacent lines); I rebased it onto current main, no logic change. Merging once CI is green.
Thanks @MarcZX100 and @Mouhand-Kaddo for the extra runs.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094564022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#issuecomment-6094564022). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:16:15Z. --- Checked the diff, built and ran the libSceAgc/libSceAgcDriver ctest (all green, `agc_shader_device_profile` included); without the change the new test doesn't build, and it covers two dynamic-mip images, a full heap and one image over. Heap arrays keep their compact `binding.count`, so layouts of shaders that already fitted are unchanged and no ABI bump is needed. The PR conflicted with main in `ResourceMaterializer.cpp` (adjacent lines); I rebased it onto current main, no logic change. Merging once CI is green. Thanks @MarcZX100 and @Mouhand-Kaddo for the extra runs.
adriadam10 commented 2026-10-10 06:48:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:48:53Z.


Rebased onto current main again: the only conflict was in RuntimeAbi.hpp next to the sampler heap change from #2141 (merged). Kept StorageMipSlots = 4, StorageHeapCapacity = 16 and main's SamplerHeapCapacity = 32; no logic change. libSceAgc/libSceAgcDriver ctest is green, agc_shader_device_profile included. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094812124 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#issuecomment-6094812124). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:48:53Z. --- Rebased onto current main again: the only conflict was in `RuntimeAbi.hpp` next to the sampler heap change from #2141 (merged). Kept `StorageMipSlots = 4`, `StorageHeapCapacity = 16` and main's `SamplerHeapCapacity = 32`; no logic change. libSceAgc/libSceAgcDriver ctest is green, `agc_shader_device_profile` included. Merging once CI is green.
github-actions[bot] commented 2026-10-10 06:51:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:51:53Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2347 core/shader/recompiler/RuntimeAbi.hpp L37-38
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094835177 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2282#issuecomment-6094835177). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T06:51:53Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2347 | `core/shader/recompiler/RuntimeAbi.hpp` [L37-38](https://github.com/boykopovar/AnyPS5/blob/40a7711a3e9345f33c28ab6549f4caf91400daba/core/shader/recompiler/RuntimeAbi.hpp#L37-L38) | | |
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!2282
No description provided.