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

Commit 0e58418

Browse files
committed
gave ownership of the concurrent task queue to the context
1 parent f339f1e commit 0e58418

File tree

6 files changed

+17
-22
lines changed

6 files changed

+17
-22
lines changed

impeller/playground/backend/vulkan/playground_impl_vk.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ void PlaygroundImplVK::DestroyWindowHandle(WindowHandle handle) {
4949
}
5050

5151
PlaygroundImplVK::PlaygroundImplVK(PlaygroundSwitches switches)
52-
: PlaygroundImpl(switches),
53-
concurrent_loop_(fml::ConcurrentMessageLoop::Create()),
54-
handle_(nullptr, &DestroyWindowHandle) {
52+
: PlaygroundImpl(switches), handle_(nullptr, &DestroyWindowHandle) {
5553
if (!::glfwVulkanSupported()) {
5654
#ifdef TARGET_OS_MAC
5755
VALIDATION_LOG << "Attempted to initialize a Vulkan playground on macOS "
@@ -83,7 +81,8 @@ PlaygroundImplVK::PlaygroundImplVK(PlaygroundSwitches switches)
8381
&::glfwGetInstanceProcAddress);
8482
context_settings.shader_libraries_data = ShaderLibraryMappingsForPlayground();
8583
context_settings.cache_directory = fml::paths::GetCachesDirectory();
86-
context_settings.worker_task_runner = concurrent_loop_->GetTaskRunner();
84+
context_settings.worker_concurrent_loop =
85+
fml::ConcurrentMessageLoop::Create();
8786
context_settings.enable_validation = switches_.enable_vulkan_validation;
8887

8988
auto context = ContextVK::Create(std::move(context_settings));
@@ -115,11 +114,7 @@ PlaygroundImplVK::PlaygroundImplVK(PlaygroundSwitches switches)
115114
context_ = std::move(context);
116115
}
117116

118-
PlaygroundImplVK::~PlaygroundImplVK() {
119-
// Make sure to kill the concurrent loop before the context so that we don't
120-
// have threads talking to a dead context.
121-
concurrent_loop_.reset();
122-
};
117+
PlaygroundImplVK::~PlaygroundImplVK() = default;
123118

124119
// |PlaygroundImpl|
125120
std::shared_ptr<Context> PlaygroundImplVK::GetContext() const {

impeller/renderer/backend/vulkan/context_vk.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,12 @@ void ContextVK::Setup(Settings settings) {
305305
//----------------------------------------------------------------------------
306306
/// Setup the pipeline library.
307307
///
308+
worker_message_loop_ = std::move(settings.worker_concurrent_loop);
308309
auto pipeline_library = std::shared_ptr<PipelineLibraryVK>(
309-
new PipelineLibraryVK(device.value.get(), //
310-
caps, //
311-
std::move(settings.cache_directory), //
312-
settings.worker_task_runner //
310+
new PipelineLibraryVK(device.value.get(), //
311+
caps, //
312+
std::move(settings.cache_directory), //
313+
worker_message_loop_->GetTaskRunner() //
313314
));
314315

315316
if (!pipeline_library->IsValid()) {

impeller/renderer/backend/vulkan/context_vk.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
3636
PFN_vkGetInstanceProcAddr proc_address_callback = nullptr;
3737
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries_data;
3838
fml::UniqueFD cache_directory;
39-
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner;
39+
std::unique_ptr<fml::ConcurrentMessageLoop> worker_concurrent_loop;
4040
bool enable_validation = false;
4141

4242
Settings() = default;
@@ -137,6 +137,7 @@ class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
137137
std::shared_ptr<FenceWaiterVK> fence_waiter_;
138138
std::string device_name_;
139139
const uint64_t hash_;
140+
std::unique_ptr<fml::ConcurrentMessageLoop> worker_message_loop_;
140141

141142
bool is_valid_ = false;
142143

impeller/renderer/backend/vulkan/test/mock_vulkan.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ PFN_vkVoidFunction GetMockVulkanProcAddress(VkInstance instance,
272272

273273
std::shared_ptr<ContextVK> CreateMockVulkanContext(void) {
274274
ContextVK::Settings settings;
275-
auto message_loop = fml::ConcurrentMessageLoop::Create();
276-
settings.worker_task_runner = message_loop->GetTaskRunner();
275+
settings.worker_concurrent_loop = fml::ConcurrentMessageLoop::Create();
277276
settings.proc_address_callback = GetMockVulkanProcAddress;
278277
return ContextVK::Create(std::move(settings));
279278
}

shell/platform/android/android_surface_vulkan_impeller.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace flutter {
2222

2323
static std::shared_ptr<impeller::Context> CreateImpellerContext(
2424
const fml::RefPtr<vulkan::VulkanProcTable>& proc_table,
25-
const std::shared_ptr<fml::ConcurrentMessageLoop>& concurrent_loop,
25+
std::unique_ptr<fml::ConcurrentMessageLoop> concurrent_loop,
2626
bool enable_vulkan_validation) {
2727
std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
2828
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_vk_data,
@@ -40,7 +40,7 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
4040
settings.proc_address_callback = instance_proc_addr;
4141
settings.shader_libraries_data = std::move(shader_mappings);
4242
settings.cache_directory = fml::paths::GetCachesDirectory();
43-
settings.worker_task_runner = concurrent_loop->GetTaskRunner();
43+
settings.worker_concurrent_loop = std::move(concurrent_loop);
4444
settings.enable_validation = enable_vulkan_validation;
4545
return impeller::ContextVK::Create(std::move(settings));
4646
}
@@ -50,10 +50,10 @@ AndroidSurfaceVulkanImpeller::AndroidSurfaceVulkanImpeller(
5050
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade,
5151
bool enable_vulkan_validation)
5252
: AndroidSurface(android_context),
53-
proc_table_(fml::MakeRefCounted<vulkan::VulkanProcTable>()),
54-
workers_(fml::ConcurrentMessageLoop::Create()) {
53+
proc_table_(fml::MakeRefCounted<vulkan::VulkanProcTable>()) {
5554
impeller_context_ =
56-
CreateImpellerContext(proc_table_, workers_, enable_vulkan_validation);
55+
CreateImpellerContext(proc_table_, fml::ConcurrentMessageLoop::Create(),
56+
enable_vulkan_validation);
5757
is_valid_ =
5858
proc_table_->HasAcquiredMandatoryProcAddresses() && impeller_context_;
5959
}

shell/platform/android/android_surface_vulkan_impeller.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class AndroidSurfaceVulkanImpeller : public AndroidSurface {
5050
private:
5151
fml::RefPtr<vulkan::VulkanProcTable> proc_table_;
5252
fml::RefPtr<AndroidNativeWindow> native_window_;
53-
std::shared_ptr<fml::ConcurrentMessageLoop> workers_;
5453
std::shared_ptr<impeller::Context> impeller_context_;
5554
bool is_valid_ = false;
5655

0 commit comments

Comments
 (0)