feat(shader): accept more than 32 buffers per shader up to the device limit #1066

Merged
Celegans12 merged 1 commit from upstream-pr/1066 into main 2026-10-07 12:20:35 +00:00
Celegans12 commented 2026-10-07 07:22:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T07:22:26Z.


What

A program with more than 32 distinct buffer descriptors (V#s) throws buffer resource limit exceeded. The 32 is a recompiler constant, ShaderInfo::MaxBuffers, not a Vulkan limit, so this PR drops it.

  • Each buffer is a constant-indexed element of one storage buffer array (no descriptor indexing); ShaderResources already throws above the storage-buffer limits: 1,048,576 per stage on an RTX 3080 Laptop, 1,015,808 on lavapipe, 200 on Intel UHD.
  • buildPrepare counted only storage buffers against maxPerStageResources (also 200 on Intel UHD) and now adds the stage's sampled and storage images, not samplers. A pixel shader's colour attachments still aren't counted (TechnicalDebt).
  • The SPIR-V emitter's memoryByteOffsets is sized from the binding layout, not 32 entries. When the user data and offsets no longer fit in the push constants, the whole block moves to the shader data buffer, as before.
  • PPSA26344 v1.008: the setup compute shader 0x80003c3100 reads two constant buffers, writes counts into 52 more and throws that message on main.
  • #639 adds its own AddBuffer limit and per-stage count; whichever lands second drops the duplicate. #285, #448, #757-#759, #815, #832, #866, #896, #920, #944, #997, #1043 and #1059 edit other lines of these files and merge cleanly.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main db3e6598: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 383/383 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 382/382 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • New agc_driver_many_buffers reads and writes 52 buffers (push constants) and 124 (shader data), three in four not 16-byte aligned.
  • agc_driver_graphics: two buffers and a sampled or storage image throw at maxPerStageResources 2, not 3; samplers don't count. Both fail on main.
  • PPSA26344 v1.008: VALIDATION_PENDING
  • Not tested: Linux (CI), console behaviour.

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:4769348866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1066). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-07T07:22:26Z. --- ### What A program with more than 32 distinct buffer descriptors (V#s) throws `buffer resource limit exceeded`. The 32 is a recompiler constant, `ShaderInfo::MaxBuffers`, not a Vulkan limit, so this PR drops it. - Each buffer is a constant-indexed element of one storage buffer array (no descriptor indexing); `ShaderResources` already throws above the storage-buffer limits: 1,048,576 per stage on an RTX 3080 Laptop, 1,015,808 on lavapipe, 200 on Intel UHD. - `buildPrepare` counted only storage buffers against `maxPerStageResources` (also 200 on Intel UHD) and now adds the stage's sampled and storage images, not samplers. A pixel shader's colour attachments still aren't counted (TechnicalDebt). - The SPIR-V emitter's `memoryByteOffsets` is sized from the binding layout, not 32 entries. When the user data and offsets no longer fit in the push constants, the whole block moves to the shader data buffer, as before. - PPSA26344 v1.008: the setup compute shader 0x80003c3100 reads two constant buffers, writes counts into 52 more and throws that message on `main`. - #639 adds its own `AddBuffer` limit and per-stage count; whichever lands second drops the duplicate. #285, #448, #757-#759, #815, #832, #866, #896, #920, #944, #997, #1043 and #1059 edit other lines of these files and merge cleanly. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` db3e6598: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 383/383 tests pass (`ctest --output-on-failure`) - Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, `VK_DRIVER_FILES`): 382/382 pass; `agc_driver_flat_store` is left out there because it takes several minutes on Windows llvmpipe - New `agc_driver_many_buffers` reads and writes 52 buffers (push constants) and 124 (shader data), three in four not 16-byte aligned. - `agc_driver_graphics`: two buffers and a sampled or storage image throw at `maxPerStageResources` 2, not 3; samplers don't count. Both fail on `main`. - PPSA26344 v1.008: VALIDATION_PENDING - Not tested: Linux (CI), console behaviour. ### 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
adriadam10 commented 2026-10-07 12:20:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T12:20:31Z.


Checked on RADV (merged onto current main, 395/395): no other per-buffer 32-entry table or mask is left, both new tests fail without the change, and agc_driver_many_buffers runs in 1.4 s cold on CI's lavapipe. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6037773727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1066#issuecomment-6037773727). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T12:20:31Z. --- Checked on RADV (merged onto current `main`, 395/395): no other per-buffer 32-entry table or mask is left, both new tests fail without the change, and `agc_driver_many_buffers` runs in 1.4 s cold on CI's lavapipe. Merging.
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!1066
No description provided.