Repository navigation
fix(agc): bind a stage's samplers above the per-stage limit after bind - #227
Merged
utkuhalis merged 1 commit intoDec 3, 2026
Merged
Conversation
A stage whose guest sampler array was larger than maxPerStageDescriptorSamplers was refused. MoltenVK reports 16 there but 500000 for update-after-bind samplers, so a compute shader with 17 samplers stopped PPSA04263 on macOS. When the device supports update-after-bind sampled images and the array fits maxPerStageDescriptorUpdateAfterBindSamplers, the set now takes an update-after-bind layout and pool, as it already does for storage buffers above their limit; the pipeline's sampler total is checked against the matching set limit. DescribeSetLayouts counts samplers per stage and per set and makes the same choice. Other devices are refused as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Thanks. Looked through it:
Small note, not blocking: We'll merge once CI is green. |
Collaborator
|
Merged, thanks! GTA V's 17-sampler compute shader builds on MoltenVK now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On MoltenVK a shader stage with more than 16 guest samplers is refused, although the device can bind many more. MoltenVK reports
maxPerStageDescriptorSamplers16, butmaxPerStageDescriptorUpdateAfterBindSamplers500000, withdescriptorBindingSampledImageUpdateAfterBindsupported;MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS, which the driver already turns on, doesn't change either number. A compute shader in Grand Theft Auto V needs 17, so the game stops with:The driver already falls back to an update-after-bind set when a stage's storage buffers go over their per-stage limit. This does the same for samplers:
ShaderResources::addImageBinding: a sampler array abovemaxPerStageDescriptorSamplersswitches the set to update-after-bind when the device supports update-after-bind sampled images and the array fitsmaxPerStageDescriptorUpdateAfterBindSamplers. Otherwise it's refused as before; the message then names whichever limit applies. The pipeline's sampler total is checked againstSetDescriptorLimit, which already returns the update-after-bind set limit for such a set.DescribeSetLayoutscounts samplers per stage and per set and makes the same choice, so a described layout matches the one the build creates.Only the set layout's
UPDATE_AFTER_BIND_POOLbit and the pool's flag change. Under the Vulkan spec, descriptors in such a layout count against the update-after-bind limits, so the sampler binding itself needs no update-after-bind flag.Tested
macOS 27.2.1, Apple M5 Pro, MoltenVK 1.4.2, x86-64 build under Rosetta 2 (AppleClang 21.0.0, Release):
agc_driver_graphics: the existing 17-sampler test now also checks four cases on the mock device.VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BITand an update-after-bind pool, and nothing leaks.It passed 10 runs out of 11. The failing run stopped on
BdaResources.cpp's host-import budget check ("two ranges under a budget for two were not imported"), which this change doesn't touch;mainpassed 5 runs out of 5 in the same session.addImageBinding, the test fails ("required 17, device limit 16").ctest -R 'agc_driver_graphics|sampler|Sampler|descriptor|image_table|pipeline_library|shader_resources|table_sampler|update_after|stencil_ref_export': 91 tests pass.python3 tools/check_conventions.py --base origin/main: all checks passed.libc, and upstream fix(shader): synchronize GLC and DLC buffer accesses on MoltenVK with device atomics and the guest's release and acquire boykopovar/AnyPS5#14217 applied locally, which fixes its look-back scans; without those it doesn't reach this scene.VK_LAYER_KHRONOS_validationcomparison from AGENTS.md, because no validation layer is installed on this Mac. There's no MoltenVK device test with a real 17-sampler shader either; the game run is the device evidence.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)agc_driver_graphics🤖 Generated with Claude Code