feat(agc): bind storage buffers update-after-bind above the per-stage limit #1580

Merged
Zheorgyan merged 1 commit from upstream-pr/1580 into main 2026-10-10 01:12:02 +00:00
Zheorgyan commented 2026-10-08 13:26:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zheorgyan on 2026-10-08T13:26:35Z.


What

agc_driver_many_buffers fails on Apple GPUs with "shader descriptors exceed per-stage limits". MoltenVK reports maxPerStageDescriptorStorageBuffers 31 and maxDescriptorSetStorageBuffers 155 on every Apple GPU, while the test binds 124 buffers in one stage. its update-after-bind limits are 1000000, and the guest buffers are one constant-indexed array binding, so the shaders don't need to change

when a stage's storage buffers or resources go above the regular per-stage limit, or the set's storage buffers above the per-set limit, and the device has descriptorBindingStorageBufferUpdateAfterBind, the set now uses the update-after-bind limits instead of throwing

  • VulkanDevice enables descriptorBindingStorageBufferUpdateAfterBind when available and passes VkPhysicalDeviceDescriptorIndexingProperties through the context. without the feature those limits stay 0 and the old error is thrown
  • such a set's layout gets UPDATE_AFTER_BIND_POOL with UPDATE_AFTER_BIND on its storage-buffer bindings, and is allocated from a separate chain of pools created with UPDATE_AFTER_BIND. the layout key carries the flag. the two places that created layouts share CreateSetLayout now, and the two that created single-set pools share CreateSetPool
  • a set within the regular limits takes the same path as before, so devices with large limits, like the AMD, NVIDIA and lavapipe ones, are unchanged
  • image bindings after an update-after-bind buffer binding are checked against the update-after-bind resource limit
  • ValidateDescriptorLayout, added on main since this PR was opened, takes the same flag and checks such a set against maxPerStageUpdateAfterBindResources instead of maxPerStageResources

Tested

  • macOS 15.6.1 on an M1 Pro, MoltenVK from Vulkan SDK 1.4.363.0, on top of mugurc's macos-port branch, before the rebase. agc_driver_many_buffers fails before and passes after. the rest of the suite ran with -j1 --timeout 30 without the flip and display tests and agc_driver_lds_atomics64. 427 tests, and the 2 that fail, agc_driver_pixel_interlock and agc_driver_sdwa_float_selectors, fail the same way without this change
  • agc_driver_graphics has a new case on the mock device. 17 buffers over a per-stage limit of 16 get the update-after-bind layout, binding flag and pool, an update-after-bind limit of 16 still throws, and one buffer keeps the regular layout. with the switch to update-after-bind removed, the new case fails
  • Linux, Ubuntu 24.04 in Docker, GCC 14.2, lavapipe, after the rebase on a8b032b2. builds, agc_driver_graphics, agc_driver_many_buffers, agc_driver_typed_heaps, agc_driver_oversized_descriptor_sets and agc_driver_prepared_graphics pass. 26 of the 207 agc_driver tests fail, with illegal instruction and segfault crashes of this x86-64 emulated container and wrong values in image_sint8 and shader_clock, none of them in descriptor code
  • the upstream run is waiting for approval, so the same Build ran in my fork on 910a777f and passed on linux and windows: https://github.com/Zheorgyan/AnyPS5/actions/runs/37902941264
  • tools/check_conventions.py passes

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 (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4787505823 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1580). Originally posted by [Zheorgyan](https://github.com/Zheorgyan) on 2026-10-08T13:26:35Z. --- ### What `agc_driver_many_buffers` fails on Apple GPUs with "shader descriptors exceed per-stage limits". MoltenVK reports `maxPerStageDescriptorStorageBuffers` 31 and `maxDescriptorSetStorageBuffers` 155 on every Apple GPU, while the test binds 124 buffers in one stage. its update-after-bind limits are 1000000, and the guest buffers are one constant-indexed array binding, so the shaders don't need to change when a stage's storage buffers or resources go above the regular per-stage limit, or the set's storage buffers above the per-set limit, and the device has `descriptorBindingStorageBufferUpdateAfterBind`, the set now uses the update-after-bind limits instead of throwing - `VulkanDevice` enables `descriptorBindingStorageBufferUpdateAfterBind` when available and passes `VkPhysicalDeviceDescriptorIndexingProperties` through the context. without the feature those limits stay 0 and the old error is thrown - such a set's layout gets `UPDATE_AFTER_BIND_POOL` with `UPDATE_AFTER_BIND` on its storage-buffer bindings, and is allocated from a separate chain of pools created with `UPDATE_AFTER_BIND`. the layout key carries the flag. the two places that created layouts share `CreateSetLayout` now, and the two that created single-set pools share `CreateSetPool` - a set within the regular limits takes the same path as before, so devices with large limits, like the AMD, NVIDIA and lavapipe ones, are unchanged - image bindings after an update-after-bind buffer binding are checked against the update-after-bind resource limit - `ValidateDescriptorLayout`, added on main since this PR was opened, takes the same flag and checks such a set against `maxPerStageUpdateAfterBindResources` instead of `maxPerStageResources` ### Tested - macOS 15.6.1 on an M1 Pro, MoltenVK from Vulkan SDK 1.4.363.0, on top of mugurc's `macos-port` branch, before the rebase. `agc_driver_many_buffers` fails before and passes after. the rest of the suite ran with `-j1 --timeout 30` without the flip and display tests and `agc_driver_lds_atomics64`. 427 tests, and the 2 that fail, `agc_driver_pixel_interlock` and `agc_driver_sdwa_float_selectors`, fail the same way without this change - `agc_driver_graphics` has a new case on the mock device. 17 buffers over a per-stage limit of 16 get the update-after-bind layout, binding flag and pool, an update-after-bind limit of 16 still throws, and one buffer keeps the regular layout. with the switch to update-after-bind removed, the new case fails - Linux, Ubuntu 24.04 in Docker, GCC 14.2, lavapipe, after the rebase on `a8b032b2`. builds, `agc_driver_graphics`, `agc_driver_many_buffers`, `agc_driver_typed_heaps`, `agc_driver_oversized_descriptor_sets` and `agc_driver_prepared_graphics` pass. 26 of the 207 `agc_driver` tests fail, with illegal instruction and segfault crashes of this x86-64 emulated container and wrong values in `image_sint8` and `shader_clock`, none of them in descriptor code - the upstream run is waiting for approval, so the same Build ran in my fork on `910a777f` and passed on linux and windows: https://github.com/Zheorgyan/AnyPS5/actions/runs/37902941264 - `tools/check_conventions.py` passes ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
yahya308 commented 2026-10-08 15:28:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yahya308 on 2026-10-08T15:28:59Z.


Tested on top of main 9e2ffe0d, Windows 11, MinGW-w64 GCC 16.2.0, full ctest with ANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3, NVIDIA RTX 4070 Laptop (32.0.16.1074) and AMD Radeon 780M (32.0.31041.1004). vopc_compare_table fails on the 780M on main too (#825, #1473).

Head cb7bb927: no change from main on either GPU. many_buffers passes on both.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6063311915 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1580#issuecomment-6063311915). Originally posted by [yahya308](https://github.com/yahya308) on 2026-10-08T15:28:59Z. --- Tested on top of main `9e2ffe0d`, Windows 11, MinGW-w64 GCC 16.2.0, full ctest with `ANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3`, NVIDIA RTX 4070 Laptop (32.0.16.1074) and AMD Radeon 780M (32.0.31041.1004). `vopc_compare_table` fails on the 780M on main too (#825, #1473). Head `cb7bb927`: no change from main on either GPU. `many_buffers` passes on both. AI-assisted: yes (Claude Code).
adriadam10 commented 2026-10-10 00:18:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T00:18:55Z.


Checked the limit logic (per-stage, per-set, ValidateDescriptorLayout), the layout key, the separate update-after-bind pool chain and cleanup; agc_driver_graphics and agc_driver_prepared_graphics pass on the PR merged onto main, and the new case doesn't build without the change. The red linux/windows jobs were agc_shader_fusion_tests missing spirv/unified1/spirv.hpp, a main breakage fixed in 37bc6f2e7, not this PR.

Rebased onto current main (no code changes) to get a clean CI run; merging once it's green. Not verified here: MoltenVK/Apple at runtime.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091517343 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1580#issuecomment-6091517343). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T00:18:55Z. --- Checked the limit logic (per-stage, per-set, `ValidateDescriptorLayout`), the layout key, the separate update-after-bind pool chain and cleanup; `agc_driver_graphics` and `agc_driver_prepared_graphics` pass on the PR merged onto main, and the new case doesn't build without the change. The red `linux`/`windows` jobs were `agc_shader_fusion_tests` missing `spirv/unified1/spirv.hpp`, a main breakage fixed in 37bc6f2e7, not this PR. Rebased onto current main (no code changes) to get a clean CI run; merging once it's green. Not verified here: MoltenVK/Apple at runtime.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1580
No description provided.