File tree Expand file tree Collapse file tree
impeller/renderer/backend/vulkan Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,8 +92,15 @@ bool CommandPoolVK::IsValid() const {
9292
9393void CommandPoolVK::Reset () {
9494 Lock lock (buffers_to_collect_mutex_);
95- GarbageCollectBuffersIfAble ();
9695 graphics_pool_.reset ();
96+
97+ // When the command pool is destroyed, all of its command buffers are freed.
98+ // Handles allocated from that pool are now invalid and must be discarded.
99+ for (vk::UniqueCommandBuffer& buffer : buffers_to_collect_) {
100+ buffer.release ();
101+ }
102+ buffers_to_collect_.clear ();
103+
97104 is_valid_ = false ;
98105}
99106
@@ -133,7 +140,7 @@ void CommandPoolVK::CollectGraphicsCommandBuffer(
133140 // have been freed and are now invalid.
134141 buffer.release ();
135142 }
136- buffers_to_collect_.insert ( MakeSharedVK ( std::move (buffer) ));
143+ buffers_to_collect_.emplace_back ( std::move (buffer));
137144 GarbageCollectBuffersIfAble ();
138145}
139146
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ class CommandPoolVK {
4242 std::weak_ptr<const DeviceHolder> device_holder_;
4343 vk::UniqueCommandPool graphics_pool_;
4444 Mutex buffers_to_collect_mutex_;
45- std::set<SharedHandleVK< vk::CommandBuffer> > buffers_to_collect_
45+ std::vector< vk::UniqueCommandBuffer > buffers_to_collect_
4646 IPLR_GUARDED_BY (buffers_to_collect_mutex_);
4747 bool is_valid_ = false ;
4848
You can’t perform that action at this time.
0 commit comments