vulkan_bindless: a new set-0 generation reuses a spare set and writes only the delta; retired generations fit the pool limit (BINDLESS-SPARE-SET-DELTA) #425

Closed
Kokonotcu wants to merge 2 commits from upstream-pr/425 into main
Kokonotcu commented 2026-11-24 05:03:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kokonotcu on 2026-11-24T05:03:41Z.


Claim: BINDLESS-SPARE-SET-DELTA

What was wrong

Every generation of the bindless set 0 (a flush that changes a live hash-table entry: a live key's index replaced, or a key moved by a relocating insert) was a new descriptor pool and set into which every descriptor written so far was written again (write_shadow): up to the whole set (~94k descriptors at full size without partially bound) for a one-entry change, on the submitting thread. And the number of retired generations kept alive (each a pool of the whole set's size) was capped at 8 whatever maxUpdateAfterBindDescriptorsInAllPools allows, so on a device whose limit holds fewer, a replacing flush could fail to make its pool.

What changed (two commits)

  1. bindless::retired_generation_cap (D4): how many retired generations may wait for their submissions, at most 8, and fewer where their pools, the current set's and the new one's would not fit maxUpdateAfterBindDescriptorsInAllPools (BindlessFeatures::pool_limit, set by size_bindings). The device waits for the oldest past that cap, as it did at 8. BindlessSet::features() exposes the sizing for it.
  2. Spare set and delta log (I8): a retired generation whose submissions are done keeps its pool and set as a spare (one, where bindless::spare_sets says the budget has room), and the next generation takes it instead of making one. A numbered log of the descriptor writes applied since (binding, index) brings it up to date: write_delta writes each element changed since its last sync, once. The log is pruned to what the spare and the retired generations still need, and dropped when it grows past four times the shadow (those sets then take write_shadow, as before). retired_generation_cap leaves room for the spare.

Note: open draft #113 (bindless zero-allocation pending writes, vulkan_bindless.h) edits the same flush / pending-write code; the two will conflict textually, not in what they do.

Testing

RTX 3080 Laptop GPU, i7-11800H, Windows 10 19045, NVIDIA driver, MSVC 2022 RelWithDebInfo, Vulkan SDK 1.4.350.

  • New vk_bindless_generation_test (real GPU, vkUpdateDescriptorSets counted, 3000 images, partially bound): descriptors written per new generation: 3788 every round before; 3769 for the first (no spare yet) and 1 (the table binding) for each one after.
  • bindless_sizing_test: the cap with synthetic pool limits, the spare included (8 retired generations within 1048576 on this GPU).
  • d3d12_set0_compute (four dispatches through set 0, every texel matched) and d3d12_bindless_churn (96 frames on a direct and a compute queue, 3 new generations, every sampled texel matched): pass.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5466426756 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/425). Originally posted by [Kokonotcu](https://github.com/Kokonotcu) on 2026-11-24T05:03:41Z. --- Claim: BINDLESS-SPARE-SET-DELTA ## What was wrong Every generation of the bindless set 0 (a flush that changes a live hash-table entry: a live key's index replaced, or a key moved by a relocating insert) was a new descriptor pool and set into which every descriptor written so far was written again (`write_shadow`): up to the whole set (~94k descriptors at full size without partially bound) for a one-entry change, on the submitting thread. And the number of retired generations kept alive (each a pool of the whole set's size) was capped at 8 whatever `maxUpdateAfterBindDescriptorsInAllPools` allows, so on a device whose limit holds fewer, a replacing flush could fail to make its pool. ## What changed (two commits) 1. `bindless::retired_generation_cap` (D4): how many retired generations may wait for their submissions, at most 8, and fewer where their pools, the current set's and the new one's would not fit `maxUpdateAfterBindDescriptorsInAllPools` (`BindlessFeatures::pool_limit`, set by `size_bindings`). The device waits for the oldest past that cap, as it did at 8. `BindlessSet::features()` exposes the sizing for it. 2. Spare set and delta log (I8): a retired generation whose submissions are done keeps its pool and set as a spare (one, where `bindless::spare_sets` says the budget has room), and the next generation takes it instead of making one. A numbered log of the descriptor writes applied since (binding, index) brings it up to date: `write_delta` writes each element changed since its last sync, once. The log is pruned to what the spare and the retired generations still need, and dropped when it grows past four times the shadow (those sets then take `write_shadow`, as before). `retired_generation_cap` leaves room for the spare. Note: open draft #113 (bindless zero-allocation pending writes, `vulkan_bindless.h`) edits the same flush / pending-write code; the two will conflict textually, not in what they do. ## Testing RTX 3080 Laptop GPU, i7-11800H, Windows 10 19045, NVIDIA driver, MSVC 2022 RelWithDebInfo, Vulkan SDK 1.4.350. - New `vk_bindless_generation_test` (real GPU, `vkUpdateDescriptorSets` counted, 3000 images, partially bound): descriptors written per new generation: 3788 every round before; 3769 for the first (no spare yet) and 1 (the table binding) for each one after. - `bindless_sizing_test`: the cap with synthetic pool limits, the spare included (8 retired generations within 1048576 on this GPU). - `d3d12_set0_compute` (four dispatches through set 0, every texel matched) and `d3d12_bindless_churn` (96 frames on a direct and a compute queue, 3 new generations, every sampled texel matched): pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
moffington commented 2026-11-24 05:14:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-24T05:14:22Z.


Tested 5ab98b38 on Linux with an RTX 3060 (driver 615.78.08) and Vulkan validation enabled. vk_bindless_generation_test passed with zero validation errors. The merge-base implementation (d2cd6c0d) wrote 3,788 descriptors in each of the eight measured generations and tripped the test’s write-count assertion as expected. With the PR, the first measured generation wrote 3,769 descriptors and each of the next seven wrote one.

vk_bindless_test also passed, including draw/readback with a reused spare set (24 draws, zero bad pixels). Validation was limited to the Linux Vulkan path.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7122757974 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/425#issuecomment-7122757974). Originally posted by [moffington](https://github.com/moffington) on 2026-11-24T05:14:22Z. --- Tested 5ab98b38 on Linux with an RTX 3060 (driver 615.78.08) and Vulkan validation enabled. vk_bindless_generation_test passed with zero validation errors. The merge-base implementation (d2cd6c0d) wrote 3,788 descriptors in each of the eight measured generations and tripped the test’s write-count assertion as expected. With the PR, the first measured generation wrote 3,769 descriptors and each of the next seven wrote one. vk_bindless_test also passed, including draw/readback with a reused spare set (24 draws, zero bad pixels). Validation was limited to the Linux Vulkan path.
MoonEyes commented 2026-11-27 23:19:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T23:19:39Z.


Hi @Kokonotcu, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/CMakeLists.txt, runtime/src/vulkan_bindless.h), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230054121 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/425#issuecomment-7230054121). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T23:19:39Z. --- Hi @Kokonotcu, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/CMakeLists.txt`, `runtime/src/vulkan_bindless.h`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 11:15:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:15:35Z.

Review: CHANGES_REQUESTED


The spare-set reuse and delta descriptor write log in runtime/src/vulkan_bindless.h / runtime/shims/d3d12_vulkan_device.cpp look well-tested (including RTX 3060 validation). However, this PR currently has merge conflicts with main in runtime/CMakeLists.txt and runtime/src/vulkan_bindless.h, and needs a fresh CI run after rebasing. Please rebase onto current main and resolve the conflicts so CI can run and we can complete final review.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130130312 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/425#pullrequestreview-6130130312). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:15:35Z. **Review:** CHANGES_REQUESTED --- The spare-set reuse and delta descriptor write log in `runtime/src/vulkan_bindless.h` / `runtime/shims/d3d12_vulkan_device.cpp` look well-tested (including RTX 3060 validation). However, this PR currently has merge conflicts with `main` in `runtime/CMakeLists.txt` and `runtime/src/vulkan_bindless.h`, and needs a fresh CI run after rebasing. Please rebase onto current `main` and resolve the conflicts so CI can run and we can complete final review. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:30:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:30:11Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317713254 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/425#issuecomment-7317713254). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:30:11Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!425
No description provided.