[Impeller] Discard invalid command buffer handles after destroying a command pool (flutter/engine#44194)
Fixes https://github.com/flutter/flutter/issues/131522
This commit is contained in:
@@ -92,8 +92,15 @@ bool CommandPoolVK::IsValid() const {
|
||||
|
||||
void CommandPoolVK::Reset() {
|
||||
Lock lock(buffers_to_collect_mutex_);
|
||||
GarbageCollectBuffersIfAble();
|
||||
graphics_pool_.reset();
|
||||
|
||||
// When the command pool is destroyed, all of its command buffers are freed.
|
||||
// Handles allocated from that pool are now invalid and must be discarded.
|
||||
for (vk::UniqueCommandBuffer& buffer : buffers_to_collect_) {
|
||||
buffer.release();
|
||||
}
|
||||
buffers_to_collect_.clear();
|
||||
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
@@ -133,7 +140,7 @@ void CommandPoolVK::CollectGraphicsCommandBuffer(
|
||||
// have been freed and are now invalid.
|
||||
buffer.release();
|
||||
}
|
||||
buffers_to_collect_.insert(MakeSharedVK(std::move(buffer)));
|
||||
buffers_to_collect_.emplace_back(std::move(buffer));
|
||||
GarbageCollectBuffersIfAble();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class CommandPoolVK {
|
||||
std::weak_ptr<const DeviceHolder> device_holder_;
|
||||
vk::UniqueCommandPool graphics_pool_;
|
||||
Mutex buffers_to_collect_mutex_;
|
||||
std::set<SharedHandleVK<vk::CommandBuffer>> buffers_to_collect_
|
||||
std::vector<vk::UniqueCommandBuffer> buffers_to_collect_
|
||||
IPLR_GUARDED_BY(buffers_to_collect_mutex_);
|
||||
bool is_valid_ = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user