fix(shader): allow 32 sampler pairs per shader #6083
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6083"
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 n-delic on 2026-10-14T21:29:32Z.
What
A shader can now use 32 samplers instead of 16. Each logical sampler takes two descriptors (both descriptor variants), so
RuntimeAbi::SamplerHeapCapacitygoes from 32 to 64.ShaderDatagrows by 32 sampler metadata records, from 14528 to 16064 bytes, soExportMappingsDwordmoves from 3624 to 4008.maxPerStageDescriptorSamplersormaxDescriptorSetSamplersare still capped by the existing clamp inShaderResources.cpp.A pixel shader of MXGP 26 (PPSA30839, Unreal Engine 5) uses 17 samplers. On
mainit fails to compile withshader sampler pairs exceed runtime heap capacity.Tested
Linux (Pop!_OS, kernel 7.1.5), GCC, Release.
agc_shader_device_profile: a new check allocates 17 logical samplers and expects 34 sampler descriptors. Onmain17 samplers are rejected (the existingSamplerHeapCapacity / 2 + 1check). The existing capacity checks use the constant, so they now cover 32 pairs.ctest -R 'agc|shader': 562 of 562 pass (one Vulkan test skipped as onmain).tools/check_conventions.py --base upstream/mainpasses.Not tested: Windows, AMD hardware, macOS/MoltenVK (its sampler limits may cap the heap through the existing clamp).
Checklist
main; no other open PR implements the same functionsNotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T00:30:54Z.
Review: COMMENTED
Apple silicon run, to answer the "Not tested: macOS/MoltenVK" line. On MoltenVK the 17-sampler case still fails, now in the driver's per-stage check instead of the recompiler.
Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta, Release.
Head:
f7b2ebd8b. Base: macos-port @ b7eb6b6b + ImportWatched + PR diff, not main. One conflict, in theRuntimeAbi::Versionline: the port is at 11, so I took 13 from the PR. The rest applied cleanly.Driver: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), checked with
VK_LOADER_DEBUG=driver.Device limits (vulkaninfo):
maxPerStageDescriptorSamplers = 16andmaxDescriptorSetSamplers = 80. The update-after-bind sampler limits are 1024.Suite:
ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 30agc_shader_device_profilepasses. With only the test change on the base, it fails withshader sampler pairs exceed runtime heap capacity, so the new check covers the change.Real-device probe: a throwaway execution test, not proposed for the repository. It is a compute shader that runs N
image_sample_lzthrough N distinct S# quads in user data, then checks the sampled value.shader sampler pairs exceed runtime heap capacity(recompiler)shader sampler descriptors exceed per-stage limits(driver,maxPerStageDescriptorSamplers)So on Apple the PR changes which check fails and nothing else. A stage with 17 samplers, like the MXGP 26 pixel shader, still cannot run under MoltenVK. I only probed the compute stage, not a pixel shader.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2), macOS 27.2
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T00:32:00Z.
Review: COMMENTED
Apple silicon run, to answer the "Not tested: macOS/MoltenVK" line. On MoltenVK the 17-sampler case still fails, now in the driver's per-stage check instead of the recompiler.
Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta, Release.
Head:
f7b2ebd8b. Base: macos-port @ b7eb6b6b + ImportWatched + PR diff, not main. One conflict, in theRuntimeAbi::Versionline: the port is at 11, so I took 13 from the PR. The rest applied cleanly.Driver: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), checked with
VK_LOADER_DEBUG=driver.Device limits (vulkaninfo):
maxPerStageDescriptorSamplers = 16andmaxDescriptorSetSamplers = 80. The update-after-bind sampler limits are 1024.Suite:
ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 30agc_shader_device_profilepasses. With only the test change on the base, it fails withshader sampler pairs exceed runtime heap capacity, so the new check covers the change.Real-device probe: a throwaway execution test, not proposed for the repository. It is a compute shader that runs N
image_sample_lzthrough N distinct S# quads in user data, then checks the sampled value.shader sampler pairs exceed runtime heap capacity(recompiler)shader sampler descriptors exceed per-stage limits(driver,maxPerStageDescriptorSamplers)So on Apple the PR changes which check fails and nothing else. A stage with 17 samplers, like the MXGP 26 pixel shader, still cannot run under MoltenVK. I only probed the compute stage, not a pixel shader.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2), macOS 27.2
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T01:02:50Z.
Ran this on PR head
f7b2ebd8b(merge base0ae1deb85, 77 commits behind mainab9a47684).Setup: PR head checked out as-is (not rebased), default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), Linux.
This is a Linux data point next to jotitadev's MoltenVK run above, where the 17-sampler case still fails in the driver's per-stage check. My run does not reach that check, so it does not speak to that.
Overlap: #5473 also changes RuntimeAbi::Version (from an older base), so it collides with this Version line. #5371 touches RuntimeAbi.hpp but not Version.
Not checked: whether any title uses more than the old limit, the memory cost of the larger heap, or other GPUs.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-15T11:49:09Z.
Windows run, for the "Not tested: Windows, AMD hardware, macOS/MoltenVK" line. Windows 11 (26200), RTX 3060 Laptop GPU (NVIDIA 617.42), WinLibs GCC 15.2.0 r7 (UCRT), Release,
BUILD_TESTING=ON. Headf7b2ebd8bmerged ontomain8856f180c(clean);ANYPS5_GPU=3060, and a verbose test log shows the RTX 3060 selected.vulkaninfogives this devicemaxPerStageDescriptorSamplers = 1048576andmaxDescriptorSetSamplers = 1048576, so the existing clamp does not lower the heap here.agc_shader_device_profile: passes.RuntimeAbi.hppfrommainand the PR's test (2 of 2 runs),agc_shader_device_profilefails:shader sampler pairs exceed runtime heap capacity.ctest -R "agc|shader|guest_memory|write_watch" -j4: 591/591 pass with the PR, and 591/591 onmain. Both skip the same 3 tests (agc_host_import_sparse,agc_driver_sparse_dma_buf_import,agc_driver_stencil_ref_export).Not run: MXGP 26, a draw or dispatch that binds more than 16 samplers on the GPU, AMD hardware.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:14:23Z.
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/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cppL170core/shader/recompiler/RuntimeAbi.hppL45Some 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/shader/recompiler/RuntimeAbi.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDeviceProfile.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T22:36:58Z.
Checked on the PR merged onto current
main: thestatic_assertlayout numbers compile (ShaderData16064 bytes,ExportMappingsDword4008), the 32-bit sampler masks inShaderResources.cppcover 32 logical samplers, andagc_shader_device_profilepasses. RevertingRuntimeAbi.hppmakes the new 17-sampler check fail, so it pins the change. The scoped agc ctest only failedagc_driver_tessellation(SEGFAULT on RADV, also seen on unrelated PRs); the other two failures passed on rerun. Thanks to @Dextroid17, @zaryabzip and @jotitadev for the extra runs. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T02:21:10Z.
Picking this up while @adriadam10 is away, following their note above: running the full Build on
f7b2ebd8b, and I'll merge once CI and review pass. #6699 shares theRuntimeAbihunk, so the two will land in sequence, with #6699 rebased after this one.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T03:35:29Z.
Merged after the full Build passed on this head, as you planned, @adriadam10. I picked it up while you were away. The MoltenVK limit jotitadev measured (
maxPerStageDescriptorSamplers = 16, so a 17-sampler shader still stops at the driver check, the same as on main) is now tracked in #7000.