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:
authorAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 19:46:53 +0100
committerAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 19:46:53 +0100
commita8fae90809846d72cef15f156b9255d84c27c068 (patch)
tree5517972a06f068a82558549256ec8087d0a3b981 /runtime/src/vulkan_bindless.h
parent21f2585a48ce74c9a585fc90320e36a7658ec9ca (diff)
Order the bindless table upload across queues, bound retired generations, keep the in-use set on failure (review of #2740)
Other queues' next submission waits on the timeline value of the submission that carries a new generation's table upload; the submit result is committed under tracker_mutex_; at most 8 retired generations are kept before the flush waits for the oldest one's ticket (queue timelines, not the device); a failed new generation leaves the in-use set and the pending writes alone. The churn test gains an async-compute case (no D3D12 fence from compute to the direct queue), a check that a retired generation is pending right after its submit, and a --validated ctest. Docs: only public sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/vulkan_bindless.h')
-rw-r--r--runtime/src/vulkan_bindless.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h
index 1043f9c05..cb5b61f65 100644
--- a/runtime/src/vulkan_bindless.h
+++ b/runtime/src/vulkan_bindless.h
@@ -493,7 +493,12 @@ public:
493 bool flush(VkCommandBuffer command_buffer, std::uint64_t retire_ticket = 0) { 493 bool flush(VkCommandBuffer command_buffer, std::uint64_t retire_ticket = 0) {
494 bool replaced = false; 494 bool replaced = false;
495 bool written = true; 495 bool written = true;
496 const bool must_replace = flush_replaces_table();
496 if (table_dirty_ || !table_uploaded_) written = upload_table(command_buffer, retire_ticket, replaced); 497 if (table_dirty_ || !table_uploaded_) written = upload_table(command_buffer, retire_ticket, replaced);
498 last_flush_replaced_ = replaced;
499 // The new generation could not be made: the current set is the one running work reads, so its descriptors are
500 // not written in place either. The pending writes and the table's changes stay for the next flush.
501 if (!written && must_replace) return false;
497 for (const Pending& pending : pending_) { 502 for (const Pending& pending : pending_) {
498 if (pending.binding >= shadow_.size() || pending.index >= shadow_[pending.binding].size()) continue; 503 if (pending.binding >= shadow_.size() || pending.index >= shadow_[pending.binding].size()) continue;
499 shadow_[pending.binding][pending.index] = pending.info; 504 shadow_[pending.binding][pending.index] = pending.info;
@@ -534,6 +539,11 @@ public:
534 retired_.resize(kept); 539 retired_.resize(kept);
535 } 540 }
536 bool has_retired() const { return !retired_.empty(); } 541 bool has_retired() const { return !retired_.empty(); }
542 // True when the last flush() started a new generation: its table upload is in that flush's command buffer, so
543 // work on other queues that binds the new set must run after it (the owner orders them).
544 bool last_flush_replaced() const { return last_flush_replaced_; }
545 // The ticket of the oldest retired generation (0 when there is none).
546 std::uint64_t oldest_retired_ticket() const { return retired_.empty() ? 0 : retired_.front().ticket; }
537 // How many generations flush() has made after the first, and how many wait for release_retired(). 547 // How many generations flush() has made after the first, and how many wait for release_retired().
538 std::uint64_t generations_made() const { return generations_made_; } 548 std::uint64_t generations_made() const { return generations_made_; }
539 std::size_t retired_count() const { return retired_.size(); } 549 std::size_t retired_count() const { return retired_.size(); }
@@ -1034,6 +1044,7 @@ private:
1034 }; 1044 };
1035 std::vector<Generation> retired_; 1045 std::vector<Generation> retired_;
1036 std::uint64_t generations_made_ = 0; 1046 std::uint64_t generations_made_ = 0;
1047 bool last_flush_replaced_ = false;
1037 std::array<VkDescriptorPoolSize, bindless::bindings.size()> pool_sizes_{}; 1048 std::array<VkDescriptorPoolSize, bindless::bindings.size()> pool_sizes_{};
1038 std::uint32_t pool_size_count_ = 0; 1049 std::uint32_t pool_size_count_ = 0;
1039 // Every descriptor written to the set (the table's binding aside), to fill the next generation's set. 1050 // Every descriptor written to the set (the table's binding aside), to fill the next generation's set.