fix(recompiler): hold 64 images in a sampled image heap #2347
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2347"
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 Pipodi on 2026-10-09T16:06:28Z.
What
A typed sampled-image heap holds
SampledHeapCapacity= 16 images. A compute program of PPSA26344 (Ghost of Yōtei) binds 29 sampled 3D images of one class, and the shader fails with:SampledHeapCapacitygoes to 64. A shader reported in review binds 40 sampled images of one class, so 32 would still be short. Heap arrays are declared with their compact length (binding.count), and the capacity enters neitherShaderDatanor the runtime ABI structs, so every shader that fitted before gets the same layout and SPIR-V.Versionis unchanged.ResourceMaterializer::BindlessSlots()returned the same constant. It sizes the bindless image tables, and each table takesslots - 1extra image entries againstShaderInfo::MaxImages, so tying it to the heap would double their cost. It now returnsBindlessTableSlots= 16, the previous value.Related open PRs: #2141 raises the sampler heap to 32, and #2282 raises the storage heap to 16 (splitting out
StorageMipSlots). Neither touches the sampled heap, and none of the three conflict beyond adjacent lines inRuntimeAbi.hpp.Tested
Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090 (driver 617.42).
agc_shader_device_profile:SampledHeapCapacity, and bindless tables keep 16 slots.SampledHeapCapacity= 32 the new check fails with "shader image heap capacity exceeded".Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T17:08:39Z.
I reviewed the complete three-file diff. The sampled-heap cap and bindless-table slot count have distinct roles here, and the Windows full-suite report covers the reported failure. The upstream PR checks currently show Conventions only; the Linux and Windows Build jobs did not run. Could an authorized collaborator dispatch the full Build matrix on this PR head before merge? The overlap with #2282 is limited to
RuntimeAbi.hpp; #2282 changes the separate storage-image capacity, so the objectives are distinct and both updates need to be preserved. AI-assisted review.Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:32:49Z.
Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Release,
-DBUILD_TESTING=ON, #2347 (edf4855f) tested on currentmain(0fdda7be).tests/agc_shader_device_profile_tests: passes cleanly (shader runtime ABI and device profile tests passed).tools/check_conventions.py: passes cleanly.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T19:08:36Z.
Review: COMMENTED
Verified on Linux (gcc 16.2.1), base
f8c2f072, this PR's headedf4855f. The change does what it says, the test bites, and the layout claim holds — the compiler enforces it.Arm A — the PR:
Arm B — only the implementation reverted (
RuntimeAbi.hppandResourceMaterializer.cppatupstream/main), test kept, rebuilt — the binary exits 1 with:(ctest wraps that as a Failed test, exit 8.) So the new
Require(… FindBinding(allocate(image, 32u) …).resources.size() == 32u …)genuinely bites: withSampledHeapCapacityback at 16 the 32-image heap is rejected and the test reports it.The "no layout change" claim is verified by the compiler, not just by reading.
ShaderDatasizes its image array byImageCapacity(256), notSampledHeapCapacity(RuntimeAbi.hpp:58), and the same header carriesstatic_assert(sizeof(ShaderData) == 13760u)plus the field-offset asserts (lines 78–81). If raising the capacity to 32 moved the struct or a table, the build would fail — it does not.Versionstays 10.The wall this lifts is real, and I hit it independently. A PPSA26344 run (
exp/yotei-757+ the decode-deferral) logged, for shader0x8000332100:That message is
BindingAllocator.cpp:146—imageGroups[i].size() > RuntimeAbi::HeapCapacity(…)— so the title is named and the log line matches a run I made before reading this PR.BindlessSlots()→BindlessTableSlots(16) is the right half of the fix. Leaving it tied to the heap would have doubled the bindless tables'slots - 1extra image entries, exactly as the body says.Regression sweep over the affected area (
ctest -R 'agc|shader|device_profile|bindless|sampl', 260 tests): 259 passed, 1 failed —agc_driver_dcc_keys_first_write,an unchanged pending image was uploaded again. That failure is pre-existing and unrelated: it fails identically on a pristinef8c2f072build with this PR absent.Two test-hygiene notes (not blocking):
32utwice, while the adjacentRejecton line 142 usesRuntimeAbi::SampledHeapCapacity. Expressing the expectation through the constant would let the test follow a future capacity change instead of silently pinning 32.16urather thanRuntimeAbi::BindlessTableSlots, so it asserts the value but not the decoupling that is the point of the change. Comparing against the constant (and asserting the two differ) would fail if they were ever re-tied.Not verified here: the "29 sampled 3D images of one class" count (that is from your run — I confirmed the title reaches the wall, not the count), and Windows.
One note for the maintainer: #2141 edits the same
RuntimeAbi.hppconstant block (sampler heap → 32), so the two conflict on rebase; the body already flags it as related.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T20:24:06Z.
Verified on Linux (gcc 16.2.1), base
f8c2f072, this PR's headedf4855f. The change does what it says, the test bites, and the layout claim holds — the compiler enforces it.Arm A — the PR:
Arm B — only the implementation reverted (
RuntimeAbi.hppandResourceMaterializer.cppatupstream/main), test kept, rebuilt — the binary exits 1 with:(ctest wraps that as a Failed test, exit 8.) So the new
Require(… FindBinding(allocate(image, 32u) …).resources.size() == 32u …)genuinely bites: withSampledHeapCapacityback at 16 the 32-image heap is rejected and the test reports it.The "no layout change" claim is verified by the compiler, not just by reading.
ShaderDatasizes its image array byImageCapacity(256), notSampledHeapCapacity(RuntimeAbi.hpp:58), and the same header carriesstatic_assert(sizeof(ShaderData) == 13760u)plus the field-offset asserts (lines 78–81). If raising the capacity to 32 moved the struct or a table, the build would fail — it does not.Versionstays 10.The wall this lifts is real, and I hit it independently. A PPSA26344 run (
exp/yotei-757+ the decode-deferral) logged, for shader0x8000332100:That message is
BindingAllocator.cpp:146—imageGroups[i].size() > RuntimeAbi::HeapCapacity(…)— so the title is named and the log line matches a run I made before reading this PR.BindlessSlots()→BindlessTableSlots(16) is the right half of the fix. Leaving it tied to the heap would have doubled the bindless tables'slots - 1extra image entries, exactly as the body says.Regression sweep over the affected area (
ctest -R 'agc|shader|device_profile|bindless|sampl', 260 tests): 259 passed, 1 failed —agc_driver_dcc_keys_first_write,an unchanged pending image was uploaded again. That failure is pre-existing and unrelated to this PR: it reproduces identically on a pristinef8c2f072build. For completeness it is also device-specific rather than universal — it fails on this machine's NVIDIA driver and passes on lavapipe, which is the device CI installs. So it should not be read as a regression, nor as something a reviewer needs to chase.Two test-hygiene notes (not blocking):
32utwice, while the adjacentRejecton line 142 usesRuntimeAbi::SampledHeapCapacity. Expressing the expectation through the constant would let the test follow a future capacity change instead of silently pinning 32.16urather thanRuntimeAbi::BindlessTableSlots, so it asserts the value but not the decoupling that is the point of the change. Comparing against the constant (and asserting the two differ) would fail if they were ever re-tied.Not verified here: the "29 sampled 3D images of one class" count (that is from your run — I confirmed the title reaches the wall, not the count), and Windows.
One note for the maintainer: #2141 edits the same
RuntimeAbi.hppconstant block (sampler heap → 32), so the two conflict on rebase; the body already flags it as related.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T22:34:38Z.
One shader I tested binds 40 sampled images of one class, so 32 is still short for it (
shader image heap capacity exceeded). Could the sampled cap go to 64? It's a cap, not part of the ShaderData layout, so no version bump. A case with 40 images in the test would cover it.Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-10T06:44:40Z.
@oneandonlydean done in
c9aa70fe:SampledHeapCapacityis 64. The test now allocates 40 images of one class, and a full class through the constant (which also covers @Dextroid17's note about the hard-coded 32). With the cap back at 32, it fails with "shader image heap capacity exceeded". No layout orVersionchange, as you said. Full ctest 507/507 on Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090. The title and description are updated.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T08:06:28Z.
Could you rebase?
RuntimeAbi.hppconflicts with main now (the storage and sampler heap lines next toSampledHeapCapacitychanged). The 64 cap and the 40-image case cover what I asked.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-10T08:12:35Z.
Astro Bot (PPSA21567), the title in #1789, gets past the heap wall with this.
Linux (CachyOS, GCC, Release), RX 9070 XT, RADV / Mesa 26.2.4, headless gamescope, scripted input.
maina29bae31: stops about 72 s in onShaderRecompiler::Recompile: shader image heap capacity exceeded. WithAPS5_HOST_IMPORT_MIB=64, two more runs stop the same way at about 60 s.maina29bae31+ this PR (c9aa70fe): no heap error. The run goes on to about 76 s and stops onsceAgcDcbResetQueue: unsupported op bit 0x40, which is unrelated (details on #1581).For your rebase: I resolved the
RuntimeAbi.hppconflict locally by keepingmain'sStorageMipSlots = 4,StorageHeapCapacity = 16andSamplerHeapCapacity = 32, and this PR'sSampledHeapCapacity = 64andBindlessTableSlots = 16. Full ctest then passes, apart fromimport_audit, which fails in my git-worktree build tree.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:18:40Z.
Rebased onto current
mainas @oneandonlydean asked; the only conflict wasRuntimeAbi.hpp(kept main'sStorageMipSlots,StorageHeapCapacity = 16andSamplerHeapCapacity = 32next toSampledHeapCapacity = 64andBindlessTableSlots = 16). No logic change.Checked on Linux: libSceAgc/libSceAgcDriver build + ctest 333/333, and
agc_shader_device_profilefails with theRuntimeAbi.hpp/ResourceMaterializer.cppchange reverted. Merging once CI is green.