Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
MathiasDevelopes:fix/recompiler-storage-heap-capacity
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
MathiasDevelopes:fix/recompiler-storage-heap-capacity

Conversation

@MathiasDevelopes

Copy link
Copy Markdown
Contributor

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)

Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 9, 2026
@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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
adriadam10 force-pushed the fix/recompiler-storage-heap-capacity branch from 85268f8 to 1a6c8e4 Compare October 10, 2026 06:16
…e dynamic image

A typed storage-image heap held four elements, and a dynamic-mip storage
image takes four of them for its mip slots. A shader with a dynamic-mip
storage image and any other storage image of the same class needed five
and failed with "shader image heap capacity exceeded". The mip slots
per dynamic image stay four (StorageMipSlots); a storage heap now holds
sixteen elements (StorageHeapCapacity). Heap arrays are declared with
their compact length, so shaders that fitted before are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 force-pushed the fix/recompiler-storage-heap-capacity branch from 1a6c8e4 to 83e0a01 Compare October 10, 2026 06:48
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

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

@adriadam10
adriadam10 merged commit d5c8e42 into boykopovar:main Oct 10, 2026
14 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…er-storage-heap-capacity

fix(recompiler): size a typed storage heap for several images, not one dynamic image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants