Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] vk::CommandPool resets via ResourceManager #45654

Merged
merged 33 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bf2238a
WIP for discussion.
matanlurey Sep 8, 2023
4f8d143
The hackiest hacks that ever hacked, but it works.
matanlurey Sep 8, 2023
2603a87
Checkpoint.
matanlurey Sep 9, 2023
3e7cb5e
Checkpoint: Runs, but segfaults in EncoderVK::Track.
matanlurey Sep 9, 2023
f35dc1f
Checkpoint: Runs, but segfaults in EncoderVK::Track.
matanlurey Sep 9, 2023
bfe727e
Ah, the old forgot to finish implementing... Fun.
matanlurey Sep 9, 2023
1af1878
Back in action. Good night for now.
matanlurey Sep 9, 2023
df64736
Remove FML_LOG statements.
matanlurey Sep 11, 2023
2264669
Merge remote-tracking branch 'upstream/main' into impeller-command-po…
matanlurey Sep 11, 2023
8d22f90
Rewrite comment, fix race condition in destruction of ContextVK.
matanlurey Sep 11, 2023
12d456d
Restore commented-out test.
matanlurey Sep 11, 2023
443ac71
Add unit tests, fix bugs.
matanlurey Sep 11, 2023
8fdd836
Merge branch 'main' into impeller-command-pool-vk-recycle
matanlurey Sep 11, 2023
2ca3c67
Fix licenses.
matanlurey Sep 11, 2023
538e5a3
Merge remote-tracking branch 'upstream/main' into impeller-command-po…
matanlurey Sep 11, 2023
be87e63
Merge.
matanlurey Sep 12, 2023
adb61c1
It appears... to be working.
matanlurey Sep 12, 2023
7251349
Fix race condition by using context->Shutdown().
matanlurey Sep 12, 2023
2a3922b
Address feedback, fix race conditions.
matanlurey Sep 12, 2023
8f6ba9c
Merge remote-tracking branch 'upstream/main' into impeller-command-po…
matanlurey Sep 12, 2023
74438e6
Fix renames.
matanlurey Sep 12, 2023
a4c6c1d
Re-order ptr resets.
matanlurey Sep 12, 2023
852482f
Re-order fence waiter loop to termintae last.
matanlurey Sep 12, 2023
c27bedd
Address feedback, tweak the waiter.
matanlurey Sep 12, 2023
15472ac
Tweak fence waiter and try on CI again.
matanlurey Sep 12, 2023
82a8944
Try another CI tweak.
matanlurey Sep 12, 2023
d2ab1c4
Command encoder tests are passing.
matanlurey Sep 13, 2023
869d5c0
Try another variant.
matanlurey Sep 13, 2023
3bc4f0a
Avoid holding on to buffers on collected pools.
matanlurey Sep 13, 2023
692b85d
Merge branch 'main' into impeller-command-pool-vk-recycle
matanlurey Sep 14, 2023
46e6d80
Merge.
matanlurey Sep 16, 2023
6e1a89b
Fix test.
matanlurey Sep 16, 2023
2d04529
Revert fence waiter changes.
matanlurey Sep 16, 2023
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
1 change: 1 addition & 0 deletions ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
../../../flutter/impeller/playground
../../../flutter/impeller/renderer/backend/vulkan/blit_command_vk_unittests.cc
../../../flutter/impeller/renderer/backend/vulkan/command_encoder_vk_unittests.cc
../../../flutter/impeller/renderer/backend/vulkan/command_pool_vk_unittests.cc
../../../flutter/impeller/renderer/backend/vulkan/context_vk_unittests.cc
../../../flutter/impeller/renderer/backend/vulkan/fence_waiter_vk_unittests.cc
../../../flutter/impeller/renderer/backend/vulkan/pass_bindings_cache_unittests.cc
Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/backend/vulkan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impeller_component("vulkan_unittests") {
sources = [
"blit_command_vk_unittests.cc",
"command_encoder_vk_unittests.cc",
"command_pool_vk_unittests.cc",
"context_vk_unittests.cc",
"fence_waiter_vk_unittests.cc",
"pass_bindings_cache_unittests.cc",
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/backend/vulkan/blit_command_vk_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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 "flutter/testing/testing.h" // IWYU pragma: keep
#include "impeller/renderer/backend/vulkan/blit_command_vk.h"
#include "impeller/renderer/backend/vulkan/command_encoder_vk.h"
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
Expand All @@ -12,7 +12,7 @@ namespace testing {

TEST(BlitCommandVkTest, BlitCopyTextureToTextureCommandVK) {
auto context = MockVulkanContextBuilder().Build();
auto pool = CommandPoolVK::GetThreadLocal(context.get());
auto pool = context->GetCommandPoolRecycler()->Get();
auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
BlitCopyTextureToTextureCommandVK cmd;
cmd.source = context->GetResourceAllocator()->CreateTexture({
Expand Down
11 changes: 7 additions & 4 deletions impeller/renderer/backend/vulkan/command_encoder_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "impeller/renderer/backend/vulkan/command_encoder_vk.h"

#include "flutter/fml/closure.h"
#include "flutter/fml/trace_event.h"
#include "impeller/renderer/backend/vulkan/context_vk.h"
#include "impeller/renderer/backend/vulkan/fence_waiter_vk.h"
#include "impeller/renderer/backend/vulkan/texture_vk.h"
Expand All @@ -21,7 +20,7 @@ class TrackedObjectsVK {
if (!pool) {
return;
}
auto buffer = pool->CreateGraphicsCommandBuffer();
auto buffer = pool->CreateCommandBuffer();
if (!buffer) {
return;
}
Expand All @@ -34,7 +33,7 @@ class TrackedObjectsVK {
if (!buffer_) {
return;
}
pool_->CollectGraphicsCommandBuffer(std::move(buffer_));
pool_->CollectCommandBuffer(std::move(buffer_));
}

bool IsValid() const { return is_valid_; }
Expand Down Expand Up @@ -105,7 +104,11 @@ std::shared_ptr<CommandEncoderVK> CommandEncoderFactoryVK::Create() {
return nullptr;
}
auto& context_vk = ContextVK::Cast(*context);
auto tls_pool = CommandPoolVK::GetThreadLocal(&context_vk);
auto recycler = context_vk.GetCommandPoolRecycler();
if (!recycler) {
return nullptr;
}
auto tls_pool = recycler->Get();
if (!tls_pool) {
return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#include <thread>

#include "flutter/fml/synchronization/count_down_latch.h"
#include "flutter/testing/testing.h"
#include "flutter/testing/testing.h" // IWYU pragma: keep
#include "fml/synchronization/waitable_event.h"
#include "impeller/renderer/backend/vulkan/command_encoder_vk.h"
#include "impeller/renderer/backend/vulkan/fence_waiter_vk.h"
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"

namespace impeller {
Expand All @@ -26,6 +25,7 @@ TEST(CommandEncoderVKTest, DeleteEncoderAfterThreadDies) {
encoder = factory.Create();
});
thread.join();
context->Shutdown();
}
auto destroy_pool =
std::find(called_functions->begin(), called_functions->end(),
Expand Down Expand Up @@ -60,7 +60,9 @@ TEST(CommandEncoderVKTest, CleanupAfterSubmit) {
wait_for_thread_join.Signal();
wait_for_submit.Wait();
called_functions = GetMockVulkanFunctions(context->GetDevice());
context->Shutdown();
}

auto destroy_pool =
std::find(called_functions->begin(), called_functions->end(),
"vkDestroyCommandPool");
Expand Down
Loading