[Impeller] started cleaning up pools when devices are deleted (flutter/engine#41857)
fixes https://github.com/flutter/flutter/issues/125571 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -145,6 +145,7 @@
|
||||
../../../flutter/impeller/image/README.md
|
||||
../../../flutter/impeller/playground
|
||||
../../../flutter/impeller/renderer/backend/vulkan/blit_command_vk_unittests.cc
|
||||
../../../flutter/impeller/renderer/backend/vulkan/context_vk_unittests.cc
|
||||
../../../flutter/impeller/renderer/backend/vulkan/test
|
||||
../../../flutter/impeller/renderer/capabilities_unittests.cc
|
||||
../../../flutter/impeller/renderer/compute_subgroup_unittests.cc
|
||||
|
||||
@@ -8,6 +8,7 @@ impeller_component("vulkan_unittests") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"blit_command_vk_unittests.cc",
|
||||
"context_vk_unittests.cc",
|
||||
"test/mock_vulkan.cc",
|
||||
"test/mock_vulkan.h",
|
||||
]
|
||||
|
||||
@@ -35,8 +35,6 @@ class TrackedObjectsVK {
|
||||
}
|
||||
auto pool = pool_.lock();
|
||||
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;
|
||||
@@ -159,7 +157,8 @@ bool CommandEncoderVK::Submit() {
|
||||
|
||||
return fence_waiter_->AddFence(
|
||||
std::move(fence), [tracked_objects = std::move(tracked_objects_)] {
|
||||
// Nothing to do, we just drop the tracked objects on the floor.
|
||||
// Nothing to do, we just drop the tracked
|
||||
// objects on the floor.
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
namespace impeller {
|
||||
|
||||
using CommandPoolMap = std::map<uint64_t, std::shared_ptr<CommandPoolVK>>;
|
||||
|
||||
// TODO(https://github.com/flutter/flutter/issues/125571): This is storing tons
|
||||
// of CommandPoolVK's in the test runner since many contexts are created on the
|
||||
// same thread. We need to come up with a different way to clean these up.
|
||||
FML_THREAD_LOCAL fml::ThreadLocalUniquePtr<CommandPoolMap> tls_command_pool;
|
||||
|
||||
static Mutex g_all_pools_mutex;
|
||||
@@ -52,6 +48,9 @@ std::shared_ptr<CommandPoolVK> CommandPoolVK::GetThreadLocal(
|
||||
}
|
||||
|
||||
void CommandPoolVK::ClearAllPools(const ContextVK* context) {
|
||||
if (tls_command_pool.get()) {
|
||||
tls_command_pool.get()->erase(context->GetHash());
|
||||
}
|
||||
Lock pool_lock(g_all_pools_mutex);
|
||||
if (auto found = g_all_pools.find(context); found != g_all_pools.end()) {
|
||||
for (auto& weak_pool : found->second) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "impeller/renderer/backend/vulkan/command_pool_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
|
||||
|
||||
namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
TEST(ContextVKTest, DeletesCommandPools) {
|
||||
std::weak_ptr<ContextVK> weak_context;
|
||||
std::weak_ptr<CommandPoolVK> weak_pool;
|
||||
{
|
||||
std::shared_ptr<ContextVK> context = CreateMockVulkanContext();
|
||||
std::shared_ptr<CommandPoolVK> pool =
|
||||
CommandPoolVK::GetThreadLocal(context.get());
|
||||
weak_pool = pool;
|
||||
weak_context = context;
|
||||
ASSERT_TRUE(weak_pool.lock());
|
||||
ASSERT_TRUE(weak_context.lock());
|
||||
}
|
||||
ASSERT_FALSE(weak_pool.lock());
|
||||
ASSERT_FALSE(weak_context.lock());
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
Reference in New Issue
Block a user