fix(shader): keep a shader's selected image-table records within the image and pair limits #7527
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7527"
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 EagleBearerYS on 2026-10-18T12:14:55Z.
What
A regression from our #6243. On
main1c523bdb4, Death Stranding 2: On the Beach (PPSA02015) gets five pixel shaders refused atResolveShaderAbi, before the first frames of its pre-logo scene (TripyFox's A/B):0xc280a65500: "sampled image/sampler pair limit exceeded";0xc280a9e900,0xc282a85000,0xc282ab9f00and0xc282ad0b00: "image resource limit exceeded".TripyFox's build logs a refused shader instead of aborting; plain
mainaborts the guest thread there. With #6243's merge (0e94c5d434) reverted, a cold run went past that point and refused nothing. Their replay of the five registration requests gives, without #6243, 2 or 3 images (1 or 2 through image tables, 1 direct), 4-6 samplers and 5-7 pairs. With it, every one stops at 64 images and 64 pairs, all of them sampled only.How it happens (
main9caecfd2d5):TryMakeTableColumn(ResourceTracker.cpp) setsselectedand interns aselectionfrom that read's own offset, andTableColumn::operator==(ControlFlowInfo.hpp) compares both.InternSourcededupes sources by their column, so N reads of one heap at N such keys become N column sources, wheremainbefore #6243 had one.Collectadds an image for each, andAssignTablesa table. Past 64 images,AddImagerefuses with "image resource limit exceeded"; past 64 image/sampler pairs,AddSampledPairrefuses with "sampled image/sampler pair limit exceeded".The change: #6243's split stays where it fits. Its own tests require two keys of one heap to plan as two one-record tables.
PlanTableColumnsnow estimates the images and sampled pairs the program would add, direct images and samplers included, keyed the wayAddImageandAddSampledPairkey them.mainbefore #6243 wouldn't have had.AddImage's image key is factored out (ImageKey,SameImageKey), so the estimate andCollectkey images the same way.ARCHITECTURE.mdand theshaderdebt entry say so.What stays as it is:
ShaderDiskCache::StorePlanruns only afterResourceProgramreturns, and the failure memo is per process.Related: #5424 (Death Stranding 2: On the Beach bring-up; the A/B, the replay and the refused shader list are TripyFox's).
Tested
ResourceTracker.cppas onmain. With the fix, they pass 10 of 10, along with the otheragc_shader_memory_testsctests andagc_driver_image_table, which skips on Windows (no Vulkan device).precise_waitfailed once in the suite run with the fix and passed withmain's code. It's a timing test that doesn't link the recompiler, and an earlier run of the first two commits failed it on both sides.check_skipsexpects on a runner with no Vulkan driver or display.main9caecfd2d5. The only differences are the fix's two tests, absent onmainand passing here. The 5 failures on both are that machine's IPv6 tests. The third commit only adds two moreagc_shader_memory_testscases (see Repeats).mainand this branch plan and emit identically.tests/ShaderMemory.cpp. The shader samples a heap of 128 distinct T#s, each read keyed from its own SRT word, and optionally T#s loaded straight from the SRT (direct images):agc_shader_selected_records_image_limit:agc_shader_selected_records_pair_limit: 32 reads with 2 samplers keep 32 tables and 64 pairs. 33 reads plan as one table and 2 pairs.agc_shader_selected_records_direct_image_limit: 63 reads and 1 direct image (64 images) keep the split: 63 selected tables beside the direct image. With 2 direct images (65 images, over the limit only because of them), the 63 reads share one table: 3 images and 3 pairs, in which keys 2, 33 and 64 bind their T#s.agc_shader_selected_records_direct_pair_limit: 31 reads and 1 direct image, each with 2 samplers (64 pairs), keep the split. A third sampler on the direct image (65 pairs) makes the reads share one table: 2 images and 5 pairs, in which keys 2, 17 and 32 bind.ResourceTracker.cppas onmain, the four tests fail, the image ones with "image resource limit exceeded" and the pair ones with "sampled image/sampler pair limit exceeded". The direct tests' cases within the limits pass there too, as boundary cases should; they fail at their case over the limit.agc_shader_memory_testsctests andagc_driver_image_tablepass 10 of 10.Checklist
main9caecfd2d5, and merges cleanly with9b6837704f; no other open PR implements the same functions. Overlaps (git merge-tree, each PR merged ontomain9b6837704ffirst):image.volumeArraySampleCompatible = true;toAddImage's new-image branch, which this PR rebuilds aroundImageKey. Whichever merges second keeps that line aftersingleMipPlaneBiasCompatibleand drops theimage.source = source;next to it, sinceImageKeynow sets the source. The flag isn't part of the image key, and #7381's other hunk, inMerge, merges cleanly.docs/dev/debt/shader.mdright after the image-table bullet this PR edits; whichever merges second keeps this PR's edited bullet and #7388's new one.tests/ShaderMemory.cppand #7395 (ours)docs/dev/debt/shader.md: textual only.ResourceTracker.cpp, for nested tables, pointer chains and waterfall loops. None of them changes the selected-record split orAddImage's image key.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T12:36:37Z.
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.
main)core/shader/recompiler/Optimization/src/ResourceTracker.cppL1593-1595docs/dev/debt/shader.mdL36Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdocs/dev/ARCHITECTURE.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txt