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

Open
github-bot wants to merge 2 commits from github-bot/gh-425 into main AGit
Owner

@⁠Kokonotcu on GitHub · 2026-11-24 05:03 UTC · original
Kokonotcu:pr/bindless-delta-log → main · +305 −8 · 5 files · 2 commits · open

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

**@⁠Kokonotcu** on GitHub · 2026-11-24 05:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/425) `Kokonotcu:pr/bindless-delta-log` → `main` · +305 −8 · 5 files · 2 commits · open 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)
Every generation of set 0 has its own pool of the whole set's size, and up to 8
retired generations wait for their submissions, plus the current one and the
one a replacing flush makes: about 10 x 94k descriptors. On a driver whose
maxUpdateAfterBindDescriptorsInAllPools is below that, the replacing flush's
vkCreateDescriptorPool fails, bindless_prepare fails, and ExecuteCommandLists
is dropped.

Of the review's two options (size every binding against limit / (max_retired +
2), or a ring of sets with a delta log), this takes neither in full: the
smaller, safer change is to keep the set's size and lower the number of retired
generations instead. size_bindings records the pool limit in BindlessFeatures;
bindless::retired_generation_cap gives min(8, limit / set size - 2), and the
device's existing cap (wait for the oldest retired generation's submissions)
uses it, now as a loop that stops on device loss. Drivers with room (an RTX 5070:
1048576, 10 sets of 93793) behave as before; tighter ones wait sooner instead of
failing. The per-generation cost of rewriting ~94k descriptors (I8) is unchanged.

Test: bindless_sizing_test (no GPU): the cap fits retired + 2 sets in the limit,
gives 1 for room for three sets, 0 for one, and 8 with room or without
update-after-bind pools.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every generation of set 0 (a flush that changes a live hash-table entry) was a
new 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 CPU of the submitting thread.

Now a retired generation whose submissions are done keeps its pool and set as a
spare (one, where bindless::spare_sets says the pool budget has room), and the
next generation takes it instead of making one. A log of the descriptor writes
applied since (binding, index; numbered, so each set knows how far it is
synced) brings it up to date: write_delta writes each element changed since,
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 in maxUpdateAfterBindDescriptorsInAllPools.

Measured (vk_bindless_generation_test, RTX 3080 Laptop, 3000 images,
partially bound): descriptors written per new generation 3788 before, now 3769
for the first (no spare yet) and 1 (the table binding) for each one after.

Not done: BindlessSet::allocate is still a linear scan.

Tests: vk_bindless_generation_test (real GPU, vkUpdateDescriptorSets counted;
fails before: every round wrote 3788); bindless_sizing_test checks the cap
with the spare.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:59:26 +00:00
Author
Owner

@⁠moffington on GitHub · 2026-11-24 05:14 UTC · original

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.

**@⁠moffington** on GitHub · 2026-11-24 05:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/425#issuecomment-7122757974) 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.
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
  • runtime/src/vulkan_bindless.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/425/head:github-bot/gh-425'
git switch 'github-bot/gh-425'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-425'
git switch 'github-bot/gh-425'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-425'
git switch 'github-bot/gh-425'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-425'
git switch 'main'
git merge --squash 'github-bot/gh-425'
git switch 'main'
git merge --ff-only 'github-bot/gh-425'
git switch 'main'
git merge 'github-bot/gh-425'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.