Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions impeller/renderer/backend/vulkan/command_pool_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class BackgroundCommandPoolVK final {
std::weak_ptr<CommandPoolRecyclerVK> recycler_;
};

static bool kResetOnBackgroundThread = false;

CommandPoolVK::~CommandPoolVK() {
auto const context = context_.lock();
if (!context) {
Expand All @@ -66,10 +68,13 @@ CommandPoolVK::~CommandPoolVK() {
return;
}

UniqueResourceVKT<BackgroundCommandPoolVK> pool(
context->GetResourceManager(),
BackgroundCommandPoolVK(std::move(pool_), std::move(collected_buffers_),
recycler));
auto reset_pool_when_dropped = BackgroundCommandPoolVK(
std::move(pool_), std::move(collected_buffers_), recycler);

if (kResetOnBackgroundThread) {
UniqueResourceVKT<BackgroundCommandPoolVK> pool(
context->GetResourceManager(), std::move(reset_pool_when_dropped));
}
}

// TODO(matanlurey): Return a status_or<> instead of {} when we have one.
Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/backend/vulkan/surface_context_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ std::unique_ptr<Surface> SurfaceContextVK::AcquireNextSurface() {
if (auto allocator = parent_->GetResourceAllocator()) {
allocator->DidAcquireSurfaceFrame();
}
parent_->GetCommandPoolRecycler()->Dispose();
return surface;
}

Expand Down
9 changes: 1 addition & 8 deletions impeller/renderer/backend/vulkan/swapchain_impl_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,6 @@ bool SwapchainImplVK::Present(const std::shared_ptr<SwapchainImageVK>& image,
//----------------------------------------------------------------------------
/// Transition the image to color-attachment-optimal.
///

// Increment the frame count right before allocating the cmd buffer below to
// force this to use the next frame's pool. This cmd buffer is completely
// untracked, and so we may end up resetting the cmd pool before all buffers
// have been collected.
context.GetCommandPoolRecycler()->Dispose();

sync->final_cmd_buffer = context.CreateCommandBuffer();
if (!sync->final_cmd_buffer) {
return false;
Expand Down Expand Up @@ -477,7 +470,7 @@ bool SwapchainImplVK::Present(const std::shared_ptr<SwapchainImageVK>& image,
}
}

auto task = [&, index, image, current_frame = current_frame_] {
auto task = [&, index, current_frame = current_frame_] {
auto context_strong = context_.lock();
if (!context_strong) {
return;
Expand Down