upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_bindless.h
diff options
context:
space:
mode:
authorjsthope <68657498+jsthope@users.noreply.github.com>2026-11-22 15:19:11 +0100
committerjsthope <68657498+jsthope@users.noreply.github.com>2026-11-22 15:19:11 +0100
commit1df4c3b0f16fd580837ff184904d2aba62d4eb5c (patch)
tree595f7d52fb1b9fa5431dae7e24d6150ef812dce2 /runtime/src/vulkan_bindless.h
parent89b047cd8fab50675a43d76722a6a8a881f55dc2 (diff)
runtime: erasing a bindless descriptor key no longer idles the GPU
DescriptorTable::erase backward-shifted the key's probe cluster, which moved other live entries, so BindlessSet::erase_key flagged the next flush as needing idle and every texture release ended in vkDeviceWaitIdle on the next submit. The shift is not needed: every lookup, on the CPU and in the translated shaders (rdna2spirv.py desc_probe), compares all eight probe slots and never stops at an empty one. Erase now empties only the key's own slot, and inserts reuse the hole. An erase uploads like an add (one slot, no idle). Replacing a live key's index, a relocating insert and table growth still require idle. Tests: descriptor_table_test checks that an erase in the middle of a cluster leaves every other slot byte-identical and marks one changed slot (it fails on the old erase); vk_bindless_test now expects no idle after an erase.
Diffstat (limited to 'runtime/src/vulkan_bindless.h')
-rw-r--r--runtime/src/vulkan_bindless.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h
index c599eb7c2..965a21c1c 100644
--- a/runtime/src/vulkan_bindless.h
+++ b/runtime/src/vulkan_bindless.h
@@ -400,19 +400,21 @@ public:
400 result == DescriptorTable::InsertResult::added_with_relocation; 400 result == DescriptorTable::InsertResult::added_with_relocation;
401 return true; 401 return true;
402 } 402 }
403 // Erasing compacts the key's probe cluster, so other keys' entries may change slots. 403 // Erasing empties only the key's own slot; no other entry moves (DescriptorTable::erase), so it needs no idle.
404 // The caller erases a key once no submitted work uses it (its texture is gone), like D3D12 requires.
404 bool erase_key(const DescriptorKey& key) { 405 bool erase_key(const DescriptorKey& key) {
405 if (!table_.erase(key)) return false; 406 if (!table_.erase(key)) return false;
406 table_dirty_ = existing_entries_changed_ = true; 407 table_dirty_ = true;
407 return true; 408 return true;
408 } 409 }
409 const DescriptorTable& table() const { return table_; } 410 const DescriptorTable& table() const { return table_; }
410 411
411 // True when the next flush() will change entries a running shader may be probing, or replace the table's 412 // True when the next flush() will change entries a running shader may be probing (a live key's index replaced
412 // buffer: the caller then flushes only once no command buffer that uses the set is still executing. Without 413 // or a live key moved by a relocating insert), or replace the table's buffer: the caller then flushes only once
413 // it the flush only adds entries, and the copy of an entry is not atomic: a shader probing a different key 414 // no command buffer that uses the set is still executing. Without it the flush only adds entries or empties the
414 // could in principle see a torn entry that matches it, which is accepted as vanishingly unlikely because the 415 // slots of erased keys, and the copy of an entry is not atomic: a shader probing a different key could in
415 // added key is new (there is no live key equal to it). 416 // principle see a torn entry that matches it, which is accepted as vanishingly unlikely because the added or
417 // erased key is not live (no running work uses it).
416 bool flush_needs_idle() const { 418 bool flush_needs_idle() const {
417 return table_dirty_ && (existing_entries_changed_ || force_full_upload_ || 419 return table_dirty_ && (existing_entries_changed_ || force_full_upload_ ||
418 table_.size_bytes() > table_buffers_.table.size); 420 table_.size_bytes() > table_buffers_.table.size);