Skip to content

Commit

Permalink
[Impeller] Do not free a Vulkan command buffer if its command pool ha…
Browse files Browse the repository at this point in the history
…s already been destroyed (flutter#41761)

Fixes flutter/flutter#125519
  • Loading branch information
jason-simmons committed May 5, 2023
1 parent 67d18ed commit 758cbad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions impeller/renderer/backend/vulkan/command_encoder_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class TrackedObjectsVK {
if (!pool) {
VALIDATION_LOG
<< "Command pool died before a command buffer could be recycled.";
// The buffer can not be freed if its command pool has been destroyed.
buffer_.release();
return;
}
pool->CollectGraphicsCommandBuffer(std::move(buffer_));
Expand Down
5 changes: 5 additions & 0 deletions impeller/renderer/backend/vulkan/command_pool_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ vk::UniqueCommandBuffer CommandPoolVK::CreateGraphicsCommandBuffer() {
void CommandPoolVK::CollectGraphicsCommandBuffer(
vk::UniqueCommandBuffer buffer) {
Lock lock(buffers_to_collect_mutex_);
if (!graphics_pool_) {
// If the command pool has already been destroyed, then its command buffers
// have been freed and are now invalid.
buffer.release();
}
buffers_to_collect_.insert(MakeSharedVK(std::move(buffer)));
GarbageCollectBuffersIfAble();
}
Expand Down

0 comments on commit 758cbad

Please sign in to comment.