Revert #46131, don't store vkImage, reset vkComandPool synchronously (flutter/engine#46166)

Closes https://github.com/flutter/flutter/issues/135086.

Reverts https://github.com/flutter/engine/pull/46131.

This PR bundles together 3 changes that removes all validation errors on the `macrobenchmark` apps I could manually find:

1. Reverts https://github.com/flutter/engine/pull/46131, which did not fix the original issue.
2. Added `kResetOnBackgroundThread = false`, which drops performance benefits, but doesn't cause threading issues.
3. Stop tracking `image` for Swapchain presentation (was hitting Vulkan assertion errors about acquired images).

/cc @gaaclarke I'd love to talk about how we could run the macrobenchmarks app on CI, with validation errors, after landing.
This commit is contained in:
Matan Lurey
2023-09-21 16:10:37 -07:00
committed by GitHub
parent 1515f2e53f
commit 6aa20016ac
3 changed files with 11 additions and 12 deletions

View File

@@ -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) {
@@ -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.

View File

@@ -80,6 +80,7 @@ std::unique_ptr<Surface> SurfaceContextVK::AcquireNextSurface() {
if (auto allocator = parent_->GetResourceAllocator()) {
allocator->DidAcquireSurfaceFrame();
}
parent_->GetCommandPoolRecycler()->Dispose();
return surface;
}

View File

@@ -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;
@@ -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;