From ee3163c792d21be8606bad576f5f054273967091 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sat, 18 Mar 2023 12:36:06 -0700 Subject: [PATCH 1/2] [Impeller] Remove work queues. --- ci/licenses_golden/licenses_flutter | 12 ------ impeller/base/BUILD.gn | 11 ------ .../base/platform/darwin/work_queue_darwin.cc | 38 ------------------- .../base/platform/darwin/work_queue_darwin.h | 36 ------------------ impeller/base/work_queue.cc | 13 ------- impeller/base/work_queue.h | 27 ------------- impeller/base/work_queue_common.cc | 25 ------------ impeller/base/work_queue_common.h | 33 ---------------- .../renderer/backend/gles/context_gles.cc | 15 -------- impeller/renderer/backend/gles/context_gles.h | 4 -- impeller/renderer/backend/metal/context_mtl.h | 4 -- .../renderer/backend/metal/context_mtl.mm | 15 -------- .../renderer/backend/vulkan/context_vk.cc | 14 ------- impeller/renderer/backend/vulkan/context_vk.h | 4 -- impeller/renderer/context.h | 3 -- impeller/renderer/testing/mocks.h | 2 - 16 files changed, 256 deletions(-) delete mode 100644 impeller/base/platform/darwin/work_queue_darwin.cc delete mode 100644 impeller/base/platform/darwin/work_queue_darwin.h delete mode 100644 impeller/base/work_queue.cc delete mode 100644 impeller/base/work_queue.h delete mode 100644 impeller/base/work_queue_common.cc delete mode 100644 impeller/base/work_queue_common.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 42f618b964509..ed1bd9549e3ee 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1040,8 +1040,6 @@ ORIGIN: ../../../flutter/impeller/base/backend_cast.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/comparable.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/comparable.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/config.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/base/platform/darwin/work_queue_darwin.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/base/platform/darwin/work_queue_darwin.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/promise.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/promise.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/strings.cc + ../../../flutter/LICENSE @@ -1055,10 +1053,6 @@ ORIGIN: ../../../flutter/impeller/base/validation.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/validation.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/version.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/base/version.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/base/work_queue.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/base/work_queue.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/base/work_queue_common.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/base/work_queue_common.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/blobcat/blob.fbs + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/blobcat/blob_library.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/blobcat/blob_library.h + ../../../flutter/LICENSE @@ -3575,8 +3569,6 @@ FILE: ../../../flutter/impeller/base/backend_cast.h FILE: ../../../flutter/impeller/base/comparable.cc FILE: ../../../flutter/impeller/base/comparable.h FILE: ../../../flutter/impeller/base/config.h -FILE: ../../../flutter/impeller/base/platform/darwin/work_queue_darwin.cc -FILE: ../../../flutter/impeller/base/platform/darwin/work_queue_darwin.h FILE: ../../../flutter/impeller/base/promise.cc FILE: ../../../flutter/impeller/base/promise.h FILE: ../../../flutter/impeller/base/strings.cc @@ -3590,10 +3582,6 @@ FILE: ../../../flutter/impeller/base/validation.cc FILE: ../../../flutter/impeller/base/validation.h FILE: ../../../flutter/impeller/base/version.cc FILE: ../../../flutter/impeller/base/version.h -FILE: ../../../flutter/impeller/base/work_queue.cc -FILE: ../../../flutter/impeller/base/work_queue.h -FILE: ../../../flutter/impeller/base/work_queue_common.cc -FILE: ../../../flutter/impeller/base/work_queue_common.h FILE: ../../../flutter/impeller/blobcat/blob.fbs FILE: ../../../flutter/impeller/blobcat/blob_library.cc FILE: ../../../flutter/impeller/blobcat/blob_library.h diff --git a/impeller/base/BUILD.gn b/impeller/base/BUILD.gn index 1083b79a80b2d..c021a96e355c0 100644 --- a/impeller/base/BUILD.gn +++ b/impeller/base/BUILD.gn @@ -25,19 +25,8 @@ impeller_component("base") { "validation.h", "version.cc", "version.h", - "work_queue.cc", - "work_queue.h", - "work_queue_common.cc", - "work_queue_common.h", ] - if (is_ios || is_mac) { - sources += [ - "platform/darwin/work_queue_darwin.cc", - "platform/darwin/work_queue_darwin.h", - ] - } - deps = [ "//flutter/fml" ] } diff --git a/impeller/base/platform/darwin/work_queue_darwin.cc b/impeller/base/platform/darwin/work_queue_darwin.cc deleted file mode 100644 index 6ac76520530ed..0000000000000 --- a/impeller/base/platform/darwin/work_queue_darwin.cc +++ /dev/null @@ -1,38 +0,0 @@ -// 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 "impeller/base/platform/darwin/work_queue_darwin.h" - -namespace impeller { - -std::shared_ptr WorkQueueDarwin::Create() { - auto queue = std::shared_ptr(new WorkQueueDarwin()); - if (!queue->IsValid()) { - return nullptr; - } - return queue; -} - -WorkQueueDarwin::WorkQueueDarwin() - : queue_(::dispatch_queue_create( - "io.flutter.impeller.wq", - ::dispatch_queue_attr_make_with_qos_class( - DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL, - QOS_CLASS_USER_INITIATED, - -1))) {} - -WorkQueueDarwin::~WorkQueueDarwin() = default; - -bool WorkQueueDarwin::IsValid() const { - return queue_ != NULL; -} - -// |WorkQueue| -void WorkQueueDarwin::PostTask(fml::closure task) { - dispatch_async(queue_, ^() { - task(); - }); -} - -} // namespace impeller diff --git a/impeller/base/platform/darwin/work_queue_darwin.h b/impeller/base/platform/darwin/work_queue_darwin.h deleted file mode 100644 index c82aca9eb285f..0000000000000 --- a/impeller/base/platform/darwin/work_queue_darwin.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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. - -#pragma once - -#include - -#include - -#include "flutter/fml/macros.h" -#include "impeller/base/work_queue.h" - -namespace impeller { - -class WorkQueueDarwin final : public WorkQueue { - public: - static std::shared_ptr Create(); - - // |WorkQueue| - ~WorkQueueDarwin(); - - bool IsValid() const; - - private: - dispatch_queue_t queue_ = NULL; - - WorkQueueDarwin(); - - // |WorkQueue| - void PostTask(fml::closure task) override; - - FML_DISALLOW_COPY_AND_ASSIGN(WorkQueueDarwin); -}; - -} // namespace impeller diff --git a/impeller/base/work_queue.cc b/impeller/base/work_queue.cc deleted file mode 100644 index f4a375496207a..0000000000000 --- a/impeller/base/work_queue.cc +++ /dev/null @@ -1,13 +0,0 @@ -// 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/impeller/base/work_queue.h" - -namespace impeller { - -WorkQueue::WorkQueue() = default; - -WorkQueue::~WorkQueue() = default; - -} // namespace impeller diff --git a/impeller/base/work_queue.h b/impeller/base/work_queue.h deleted file mode 100644 index afd31c7acd53c..0000000000000 --- a/impeller/base/work_queue.h +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#pragma once - -#include - -#include "flutter/fml/closure.h" -#include "flutter/fml/macros.h" - -namespace impeller { - -class WorkQueue : public std::enable_shared_from_this { - public: - virtual ~WorkQueue(); - - virtual void PostTask(fml::closure task) = 0; - - protected: - WorkQueue(); - - private: - FML_DISALLOW_COPY_AND_ASSIGN(WorkQueue); -}; - -} // namespace impeller diff --git a/impeller/base/work_queue_common.cc b/impeller/base/work_queue_common.cc deleted file mode 100644 index e23e95ad9e2f6..0000000000000 --- a/impeller/base/work_queue_common.cc +++ /dev/null @@ -1,25 +0,0 @@ -// 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 "impeller/base/work_queue_common.h" - -namespace impeller { - -std::shared_ptr WorkQueueCommon::Create() { - return std::shared_ptr(new WorkQueueCommon()); -} - -WorkQueueCommon::WorkQueueCommon() - : loop_(fml::ConcurrentMessageLoop::Create(2u)) {} - -WorkQueueCommon::~WorkQueueCommon() { - loop_->Terminate(); -} - -// |WorkQueue| -void WorkQueueCommon::PostTask(fml::closure task) { - loop_->GetTaskRunner()->PostTask(task); -} - -} // namespace impeller diff --git a/impeller/base/work_queue_common.h b/impeller/base/work_queue_common.h deleted file mode 100644 index 952f6ecbadacd..0000000000000 --- a/impeller/base/work_queue_common.h +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -#pragma once - -#include - -#include "flutter/fml/concurrent_message_loop.h" -#include "flutter/fml/macros.h" -#include "impeller/base/work_queue.h" - -namespace impeller { - -class WorkQueueCommon : public WorkQueue { - public: - static std::shared_ptr Create(); - - // |WorkQueue| - ~WorkQueueCommon(); - - private: - std::shared_ptr loop_; - - WorkQueueCommon(); - - // |WorkQueue| - void PostTask(fml::closure task) override; - - FML_DISALLOW_COPY_AND_ASSIGN(WorkQueueCommon); -}; - -} // namespace impeller diff --git a/impeller/renderer/backend/gles/context_gles.cc b/impeller/renderer/backend/gles/context_gles.cc index 85e1bd3ee8f78..43fa560f71b63 100644 --- a/impeller/renderer/backend/gles/context_gles.cc +++ b/impeller/renderer/backend/gles/context_gles.cc @@ -6,7 +6,6 @@ #include "impeller/base/config.h" #include "impeller/base/validation.h" -#include "impeller/base/work_queue_common.h" #include "impeller/renderer/device_capabilities.h" namespace impeller { @@ -60,15 +59,6 @@ ContextGLES::ContextGLES(std::unique_ptr gl, std::shared_ptr(new SamplerLibraryGLES()); } - // Create the work queue. - { - work_queue_ = WorkQueueCommon::Create(); - if (!work_queue_) { - VALIDATION_LOG << "Could not create work queue."; - return; - } - } - // Create the device capabilities. { device_capabilities_ = @@ -139,11 +129,6 @@ std::shared_ptr ContextGLES::CreateCommandBuffer() const { new CommandBufferGLES(weak_from_this(), reactor_)); } -// |Context| -std::shared_ptr ContextGLES::GetWorkQueue() const { - return work_queue_; -} - // |Context| const IDeviceCapabilities& ContextGLES::GetDeviceCapabilities() const { return *device_capabilities_; diff --git a/impeller/renderer/backend/gles/context_gles.h b/impeller/renderer/backend/gles/context_gles.h index 39e1384d97512..188798b4e6afc 100644 --- a/impeller/renderer/backend/gles/context_gles.h +++ b/impeller/renderer/backend/gles/context_gles.h @@ -39,7 +39,6 @@ class ContextGLES final : public Context, std::shared_ptr shader_library_; std::shared_ptr pipeline_library_; std::shared_ptr sampler_library_; - std::shared_ptr work_queue_; std::shared_ptr resource_allocator_; std::unique_ptr device_capabilities_; bool is_valid_ = false; @@ -66,9 +65,6 @@ class ContextGLES final : public Context, // |Context| std::shared_ptr CreateCommandBuffer() const override; - // |Context| - std::shared_ptr GetWorkQueue() const override; - // |Context| const IDeviceCapabilities& GetDeviceCapabilities() const override; diff --git a/impeller/renderer/backend/metal/context_mtl.h b/impeller/renderer/backend/metal/context_mtl.h index bd75e585d86c0..9ef79b0361876 100644 --- a/impeller/renderer/backend/metal/context_mtl.h +++ b/impeller/renderer/backend/metal/context_mtl.h @@ -44,7 +44,6 @@ class ContextMTL final : public Context, std::shared_ptr pipeline_library_; std::shared_ptr sampler_library_; std::shared_ptr resource_allocator_; - std::shared_ptr work_queue_; std::shared_ptr gpu_tracer_; std::unique_ptr device_capabilities_; bool is_valid_ = false; @@ -71,9 +70,6 @@ class ContextMTL final : public Context, // |Context| std::shared_ptr CreateCommandBuffer() const override; - // |Context| - std::shared_ptr GetWorkQueue() const override; - // |Context| std::shared_ptr GetGPUTracer() const override; diff --git a/impeller/renderer/backend/metal/context_mtl.mm b/impeller/renderer/backend/metal/context_mtl.mm index 70c76592aa5fa..e8fea4c5c4cd0 100644 --- a/impeller/renderer/backend/metal/context_mtl.mm +++ b/impeller/renderer/backend/metal/context_mtl.mm @@ -9,7 +9,6 @@ #include "flutter/fml/file.h" #include "flutter/fml/logging.h" #include "flutter/fml/paths.h" -#include "impeller/base/platform/darwin/work_queue_darwin.h" #include "impeller/renderer/backend/metal/sampler_library_mtl.h" #include "impeller/renderer/device_capabilities.h" #include "impeller/renderer/sampler_descriptor.h" @@ -74,15 +73,6 @@ } } - // Setup the work queue. - { - work_queue_ = WorkQueueDarwin::Create(); - if (!work_queue_) { - VALIDATION_LOG << "Could not setup the work queue."; - return; - } - } - #if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || \ (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE) // Setup the gpu tracer. @@ -256,11 +246,6 @@ return CreateCommandBufferInQueue(command_queue_); } -// |Context| -std::shared_ptr ContextMTL::GetWorkQueue() const { - return work_queue_; -} - std::shared_ptr ContextMTL::GetGPUTracer() const { return gpu_tracer_; } diff --git a/impeller/renderer/backend/vulkan/context_vk.cc b/impeller/renderer/backend/vulkan/context_vk.cc index a7974915d1f81..b6680599bee54 100644 --- a/impeller/renderer/backend/vulkan/context_vk.cc +++ b/impeller/renderer/backend/vulkan/context_vk.cc @@ -15,7 +15,6 @@ #include "flutter/fml/string_conversion.h" #include "flutter/fml/trace_event.h" #include "impeller/base/validation.h" -#include "impeller/base/work_queue_common.h" #include "impeller/renderer/backend/vulkan/allocator_vk.h" #include "impeller/renderer/backend/vulkan/capabilities_vk.h" #include "impeller/renderer/backend/vulkan/command_buffer_vk.h" @@ -479,13 +478,6 @@ ContextVK::ContextVK( return; } - auto work_queue = WorkQueueCommon::Create(); - - if (!work_queue) { - VALIDATION_LOG << "Could not create workqueue."; - return; - } - //---------------------------------------------------------------------------- /// Setup the command pool. /// @@ -541,7 +533,6 @@ ContextVK::ContextVK( shader_library_ = std::move(shader_library); sampler_library_ = std::move(sampler_library); pipeline_library_ = std::move(pipeline_library); - work_queue_ = std::move(work_queue); graphics_queue_ = device_->getQueue(graphics_queue->family, graphics_queue->index); compute_queue_ = @@ -591,11 +582,6 @@ std::shared_ptr ContextVK::GetPipelineLibrary() const { return pipeline_library_; } -// |Context| -std::shared_ptr ContextVK::GetWorkQueue() const { - return work_queue_; -} - std::shared_ptr ContextVK::CreateCommandBuffer() const { return std::shared_ptr( new CommandBufferVK(shared_from_this(), // diff --git a/impeller/renderer/backend/vulkan/context_vk.h b/impeller/renderer/backend/vulkan/context_vk.h index 3cd22bb490b2b..446fa325a1194 100644 --- a/impeller/renderer/backend/vulkan/context_vk.h +++ b/impeller/renderer/backend/vulkan/context_vk.h @@ -67,9 +67,6 @@ class ContextVK final : public Context, public BackendCast { // |Context| PixelFormat GetColorAttachmentPixelFormat() const override; - // |Context| - std::shared_ptr GetWorkQueue() const override; - // |Context| const IDeviceCapabilities& GetDeviceCapabilities() const override; @@ -139,7 +136,6 @@ class ContextVK final : public Context, public BackendCast { vk::Queue compute_queue_ = {}; vk::Queue transfer_queue_ = {}; std::shared_ptr swapchain_; - std::shared_ptr work_queue_; std::unique_ptr device_capabilities_; vk::UniqueCommandPool graphics_command_pool_; vk::UniqueDescriptorPool descriptor_pool_; diff --git a/impeller/renderer/context.h b/impeller/renderer/context.h index a6a485c3e6de3..04622228a7910 100644 --- a/impeller/renderer/context.h +++ b/impeller/renderer/context.h @@ -19,7 +19,6 @@ class CommandBuffer; class PipelineLibrary; class Allocator; class GPUTracer; -class WorkQueue; class Context : public std::enable_shared_from_this { public: @@ -40,8 +39,6 @@ class Context : public std::enable_shared_from_this { virtual std::shared_ptr CreateCommandBuffer() const = 0; - virtual std::shared_ptr GetWorkQueue() const = 0; - //---------------------------------------------------------------------------- /// @return A GPU Tracer to trace gpu rendering. /// diff --git a/impeller/renderer/testing/mocks.h b/impeller/renderer/testing/mocks.h index 1f387ee58e05a..3714874bffb8f 100644 --- a/impeller/renderer/testing/mocks.h +++ b/impeller/renderer/testing/mocks.h @@ -93,8 +93,6 @@ class MockImpellerContext : public Context { MOCK_CONST_METHOD0(CreateCommandBuffer, std::shared_ptr()); - MOCK_CONST_METHOD0(GetWorkQueue, std::shared_ptr()); - MOCK_CONST_METHOD0(GetGPUTracer, std::shared_ptr()); MOCK_CONST_METHOD0(GetColorAttachmentPixelFormat, PixelFormat()); From a2c45ee6419dcf68fd01789174d27630d3a15508 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sat, 18 Mar 2023 12:41:16 -0700 Subject: [PATCH 2/2] Fix iOS issues. --- shell/platform/darwin/ios/ios_surface_metal_impeller.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/platform/darwin/ios/ios_surface_metal_impeller.mm b/shell/platform/darwin/ios/ios_surface_metal_impeller.mm index c1696ff309d70..88438be7ba120 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_surface_metal_impeller.mm @@ -54,8 +54,6 @@ return context_->CreateCommandBuffer(); } - std::shared_ptr GetWorkQueue() const override { return context_->GetWorkQueue(); } - std::shared_ptr GetGPUTracer() const override { return context_->GetGPUTracer(); } PixelFormat GetColorAttachmentPixelFormat() const override {