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:
authorCodex <codex@localhost>2026-11-22 00:21:48 +0100
committerCodex <codex@localhost>2026-11-22 00:21:48 +0100
commitbb65ea6c35b9e67e7d6883a647a013fbc580c708 (patch)
treee28d27caf360158aa68df38f3c33c0adf328185b /runtime/src/vulkan_bindless.h
parent8bd0087d2d0e45fc18fa78fb40b70ecfc6648854 (diff)
runtime: require idle for bindless key replacements
Diffstat (limited to 'runtime/src/vulkan_bindless.h')
-rw-r--r--runtime/src/vulkan_bindless.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h
index 8cb895adb..fc7682e2f 100644
--- a/runtime/src/vulkan_bindless.h
+++ b/runtime/src/vulkan_bindless.h
@@ -211,22 +211,24 @@ public:
211 // T# and S# keys to the indices above: the table of binding 2 (descriptor_table.h). Changes reach the shaders 211 // T# and S# keys to the indices above: the table of binding 2 (descriptor_table.h). Changes reach the shaders
212 // at flush(). 212 // at flush().
213 bool insert_key(const DescriptorKey& key, std::uint32_t index) { 213 bool insert_key(const DescriptorKey& key, std::uint32_t index) {
214 table_dirty_ = true; 214 const auto result = table_.insert_or_update(key.data(), index);
215 return table_.insert(key, index); 215 table_dirty_ |= result != DescriptorTable::InsertResult::unchanged;
216 existing_entries_changed_ |= result == DescriptorTable::InsertResult::replaced;
217 return true;
216 } 218 }
217 // Erasing compacts the key's probe cluster, so other keys' entries may change slots. 219 // Erasing compacts the key's probe cluster, so other keys' entries may change slots.
218 bool erase_key(const DescriptorKey& key) { 220 bool erase_key(const DescriptorKey& key) {
219 if (!table_.erase(key)) return false; 221 if (!table_.erase(key)) return false;
220 table_dirty_ = entries_moved_ = true; 222 table_dirty_ = existing_entries_changed_ = true;
221 return true; 223 return true;
222 } 224 }
223 const DescriptorTable& table() const { return table_; } 225 const DescriptorTable& table() const { return table_; }
224 226
225 // True when the next flush() will move entries a running shader may be probing, or replace the table's 227 // True when the next flush() will change entries a running shader may be probing, or replace the table's
226 // buffer: the caller then flushes only once no command buffer that uses the set is still executing. Without 228 // buffer: the caller then flushes only once no command buffer that uses the set is still executing. Without
227 // it the flush only adds entries to the buffer in place, which a running lookup cannot see half done. 229 // it the flush only adds entries to the buffer in place, which a running lookup cannot see half done.
228 bool flush_needs_idle() const { 230 bool flush_needs_idle() const {
229 return table_dirty_ && (entries_moved_ || table_.size_bytes() > table_buffer_.size); 231 return table_dirty_ && (existing_entries_changed_ || table_.size_bytes() > table_buffer_.size);
230 } 232 }
231 233
232 // Writes the pending descriptor changes and the table: before the commands that use the set are executed. 234 // Writes the pending descriptor changes and the table: before the commands that use the set are executed.
@@ -250,7 +252,7 @@ public:
250 } 252 }
251 if (written) { 253 if (written) {
252 std::memcpy(table_buffer_.mapped, words.data(), bytes); 254 std::memcpy(table_buffer_.mapped, words.data(), bytes);
253 table_dirty_ = entries_moved_ = false; 255 table_dirty_ = existing_entries_changed_ = false;
254 } 256 }
255 } 257 }
256 if (!pending_.empty()) { 258 if (!pending_.empty()) {
@@ -468,7 +470,7 @@ private:
468 const VkDeviceSize bytes = words.size() * sizeof(std::uint32_t); 470 const VkDeviceSize bytes = words.size() * sizeof(std::uint32_t);
469 if (!create(table_buffer_, bytes)) return false; 471 if (!create(table_buffer_, bytes)) return false;
470 std::memcpy(table_buffer_.mapped, words.data(), bytes); 472 std::memcpy(table_buffer_.mapped, words.data(), bytes);
471 table_dirty_ = entries_moved_ = false; 473 table_dirty_ = existing_entries_changed_ = false;
472 return true; 474 return true;
473 } 475 }
474 476
@@ -572,7 +574,7 @@ private:
572 DescriptorTable table_{64}; 574 DescriptorTable table_{64};
573 TableBuffer table_buffer_; 575 TableBuffer table_buffer_;
574 bool table_dirty_ = false; // the table differs from the buffer 576 bool table_dirty_ = false; // the table differs from the buffer
575 bool entries_moved_ = false; // ... and not only by entries added 577 bool existing_entries_changed_ = false; // ... and not only by entries added
576 std::vector<TableBuffer> retired_; 578 std::vector<TableBuffer> retired_;
577}; 579};
578 580