From 5e283fa41b17942d2ce5282e1fe48be21648607a Mon Sep 17 00:00:00 2001 From: zhouliang3 Date: Wed, 2 Dec 2020 16:15:03 +0800 Subject: [PATCH] More rename from GPU thread to raster thread --- lib/ui/ui_benchmarks.cc | 2 +- lib/ui/window/platform_configuration.h | 12 ++++----- runtime/runtime_controller.h | 6 ++--- shell/common/engine.h | 12 ++++----- shell/common/engine_unittests.cc | 2 +- shell/common/platform_view.h | 2 +- shell/common/rasterizer.h | 25 ++++++++++--------- shell/common/rasterizer_unittests.cc | 10 ++++---- shell/common/shell.h | 4 +-- shell/common/shell_benchmarks.cc | 4 +-- shell/common/shell_test.cc | 2 +- shell/common/shell_unittests.cc | 4 +-- shell/common/thread_host.cc | 2 +- shell/common/thread_host.h | 2 +- .../platform/android/android_shell_holder.cc | 13 +++++----- .../ios/framework/Source/FlutterEngine.mm | 2 +- .../platform/embedder/embedder_thread_host.cc | 14 +++++------ shell/testing/tester_main.cc | 2 +- 18 files changed, 61 insertions(+), 59 deletions(-) diff --git a/lib/ui/ui_benchmarks.cc b/lib/ui/ui_benchmarks.cc index 293251400bcd3..9c0a189f31531 100644 --- a/lib/ui/ui_benchmarks.cc +++ b/lib/ui/ui_benchmarks.cc @@ -21,7 +21,7 @@ class Fixture : public testing::FixtureTest { static void BM_PlatformMessageResponseDartComplete( benchmark::State& state) { // NOLINT ThreadHost thread_host("test", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), thread_host.raster_thread->GetTaskRunner(), diff --git a/lib/ui/window/platform_configuration.h b/lib/ui/window/platform_configuration.h index 693ec18bcbd95..bec513c9e2a1f 100644 --- a/lib/ui/window/platform_configuration.h +++ b/lib/ui/window/platform_configuration.h @@ -312,9 +312,9 @@ class PlatformConfiguration final { /// The frame time given as the argument indicates the point at /// which the current frame interval began. It is very slightly /// (because of scheduling overhead) in the past. If a new layer - /// tree is not produced and given to the GPU task runner within - /// one frame interval from this point, the Flutter application - /// will jank. + /// tree is not produced and given to the raster task runner + /// within one frame interval from this point, the Flutter + /// application will jank. /// /// This method calls the `::_beginFrame` method in `hooks.dart`. /// @@ -328,13 +328,13 @@ class PlatformConfiguration final { /// @brief Dart code cannot fully measure the time it takes for a /// specific frame to be rendered. This is because Dart code only /// runs on the UI task runner. That is only a small part of the - /// overall frame workload. The GPU task runner frame workload is - /// executed on a thread where Dart code cannot run (and hence + /// overall frame workload. The raster task runner frame workload + /// is executed on a thread where Dart code cannot run (and hence /// instrument). Besides, due to the pipelined nature of rendering /// in Flutter, there may be multiple frame workloads being /// processed at any given time. However, for non-Timeline based /// profiling, it is useful for trace collection and processing to - /// happen in Dart. To do this, the GPU task runner frame + /// happen in Dart. To do this, the raster task runner frame /// workloads need to be instrumented separately. After a set /// number of these profiles have been gathered, they need to be /// reported back to Dart code. The engine reports this extra diff --git a/runtime/runtime_controller.h b/runtime/runtime_controller.h index 22941c7388a1b..cc802f4133100 100644 --- a/runtime/runtime_controller.h +++ b/runtime/runtime_controller.h @@ -274,13 +274,13 @@ class RuntimeController : public PlatformConfigurationClient { /// @brief Dart code cannot fully measure the time it takes for a /// specific frame to be rendered. This is because Dart code only /// runs on the UI task runner. That is only a small part of the - /// overall frame workload. The GPU task runner frame workload is - /// executed on a thread where Dart code cannot run (and hence + /// overall frame workload. The raster task runner frame workload + /// is executed on a thread where Dart code cannot run (and hence /// instrument). Besides, due to the pipelined nature of rendering /// in Flutter, there may be multiple frame workloads being /// processed at any given time. However, for non-Timeline based /// profiling, it is useful for trace collection and processing to - /// happen in Dart. To do this, the GPU task runner frame + /// happen in Dart. To do this, the raster task runner frame /// workloads need to be instrumented separately. After a set /// number of these profiles have been gathered, they need to be /// reported back to Dart code. The engine reports this extra diff --git a/shell/common/engine.h b/shell/common/engine.h index 93a5f2367dbc3..5f3b7831d98cc 100644 --- a/shell/common/engine.h +++ b/shell/common/engine.h @@ -436,9 +436,9 @@ class Engine final : public RuntimeDelegate, /// The frame time given as the argument indicates the point at /// which the current frame interval began. It is very slightly /// (because of scheduling overhead) in the past. If a new layer - /// tree is not produced and given to the GPU task runner within - /// one frame interval from this point, the Flutter application - /// will jank. + /// tree is not produced and given to the raster task runner + /// within one frame interval from this point, the Flutter + /// application will jank. /// /// If a root isolate is running, this method calls the /// `::_beginFrame` method in `hooks.dart`. If a root isolate is @@ -520,13 +520,13 @@ class Engine final : public RuntimeDelegate, /// @brief Dart code cannot fully measure the time it takes for a /// specific frame to be rendered. This is because Dart code only /// runs on the UI task runner. That is only a small part of the - /// overall frame workload. The GPU task runner frame workload is - /// executed on a thread where Dart code cannot run (and hence + /// overall frame workload. The raster task runner frame workload + /// is executed on a thread where Dart code cannot run (and hence /// instrument). Besides, due to the pipelined nature of rendering /// in Flutter, there may be multiple frame workloads being /// processed at any given time. However, for non-Timeline based /// profiling, it is useful for trace collection and processing to - /// happen in Dart. To do this, the GPU task runner frame + /// happen in Dart. To do this, the raster task runner frame /// workloads need to be instrumented separately. After a set /// number of these profiles have been gathered, they need to be /// reported back to Dart code. The shell reports this extra diff --git a/shell/common/engine_unittests.cc b/shell/common/engine_unittests.cc index e563a92a454a4..dbf9382d6017b 100644 --- a/shell/common/engine_unittests.cc +++ b/shell/common/engine_unittests.cc @@ -98,7 +98,7 @@ class EngineTest : public ::testing::Test { EngineTest() : thread_host_("EngineTest", ThreadHost::Type::Platform | ThreadHost::Type::IO | - ThreadHost::Type::UI | ThreadHost::Type::GPU), + ThreadHost::Type::UI | ThreadHost::Type::RASTER), task_runners_({ "EngineTest", thread_host_.platform_thread->GetTaskRunner(), // platform diff --git a/shell/common/platform_view.h b/shell/common/platform_view.h index dd200b5948fdb..de4587bcf057a 100644 --- a/shell/common/platform_view.h +++ b/shell/common/platform_view.h @@ -667,7 +667,7 @@ class PlatformView { fml::WeakPtrFactory weak_factory_; // Unlike all other methods on the platform view, this is called on the - // GPU task runner. + // raster task runner. virtual std::unique_ptr CreateRenderingSurface(); private: diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index 0637ad37ca955..208e455d1591c 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -27,9 +27,10 @@ namespace flutter { //------------------------------------------------------------------------------ -/// The rasterizer is a component owned by the shell that resides on the GPU +/// The rasterizer is a component owned by the shell that resides on the raster /// task runner. Each shell owns exactly one instance of a rasterizer. The -/// rasterizer may only be created, used and collected on the GPU task runner. +/// rasterizer may only be created, used and collected on the raster task +/// runner. /// /// The rasterizer owns the instance of the currently active on-screen render /// surface. On this surface, it renders the contents of layer trees submitted @@ -48,8 +49,8 @@ class Rasterizer final : public SnapshotDelegate { /// It can then forward these events to the engine. /// /// Like all rasterizer operation, the rasterizer delegate call - /// are made on the GPU task runner. Any delegate must ensure that - /// they can handle the threading implications. + /// are made on the raster task runner. Any delegate must ensure + /// that they can handle the threading implications. /// class Delegate { public: @@ -92,9 +93,9 @@ class Rasterizer final : public SnapshotDelegate { //---------------------------------------------------------------------------- /// @brief Creates a new instance of a rasterizer. Rasterizers may only - /// be created on the GPU task runner. Rasterizers are currently - /// only created by the shell (which also sets itself up as the - /// rasterizer delegate). + /// be created on the raster task runner. Rasterizers are + /// currently only created by the shell (which also sets itself up + /// as the rasterizer delegate). /// /// @param[in] delegate The rasterizer delegate. /// @@ -103,9 +104,9 @@ class Rasterizer final : public SnapshotDelegate { #if defined(LEGACY_FUCHSIA_EMBEDDER) //---------------------------------------------------------------------------- /// @brief Creates a new instance of a rasterizer. Rasterizers may only - /// be created on the GPU task runner. Rasterizers are currently - /// only created by the shell (which also sets itself up as the - /// rasterizer delegate). + /// be created on the raster task runner. Rasterizers are + /// currently only created by the shell (which also sets itself up + /// as the rasterizer delegate). /// /// @param[in] delegate The rasterizer delegate. /// @param[in] compositor_context The compositor context used to hold all @@ -116,7 +117,7 @@ class Rasterizer final : public SnapshotDelegate { #endif //---------------------------------------------------------------------------- - /// @brief Destroys the rasterizer. This must happen on the GPU task + /// @brief Destroys the rasterizer. This must happen on the raster task /// runner. All GPU resources are collected before this call /// returns. Any context setup by the embedder to hold these /// resources can be immediately collected as well. @@ -158,7 +159,7 @@ class Rasterizer final : public SnapshotDelegate { //---------------------------------------------------------------------------- /// @brief Gets a weak pointer to the rasterizer. The rasterizer may only - /// be accessed on the GPU task runner. + /// be accessed on the raster task runner. /// /// @return The weak pointer to the rasterizer. /// diff --git a/shell/common/rasterizer_unittests.cc b/shell/common/rasterizer_unittests.cc index 357a0f38e2da0..3098a19256533 100644 --- a/shell/common/rasterizer_unittests.cc +++ b/shell/common/rasterizer_unittests.cc @@ -77,7 +77,7 @@ TEST(RasterizerTest, drawEmptyPipeline) { std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), thread_host.raster_thread->GetTaskRunner(), @@ -102,7 +102,7 @@ TEST(RasterizerTest, std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), thread_host.raster_thread->GetTaskRunner(), @@ -160,7 +160,7 @@ TEST( std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), thread_host.raster_thread->GetTaskRunner(), @@ -214,7 +214,7 @@ TEST( std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); fml::MessageLoop::EnsureInitializedForCurrentThread(); TaskRunners task_runners("test", @@ -268,7 +268,7 @@ TEST(RasterizerTest, externalViewEmbedderDoesntEndFrameWhenNoSurfaceIsSet) { std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), thread_host.raster_thread->GetTaskRunner(), diff --git a/shell/common/shell.h b/shell/common/shell.h index 7ac297e5d07c6..47cf806c6ba49 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -253,7 +253,7 @@ class Shell final : public PlatformView::Delegate, const TaskRunners& GetTaskRunners() const override; //---------------------------------------------------------------------------- - /// @brief Rasterizers may only be accessed on the GPU task runner. + /// @brief Rasterizers may only be accessed on the raster task runner. /// /// @return A weak pointer to the rasterizer. /// @@ -394,7 +394,7 @@ class Shell final : public PlatformView::Delegate, std::optional latest_frame_target_time_; std::unique_ptr platform_view_; // on platform task runner std::unique_ptr engine_; // on UI task runner - std::unique_ptr rasterizer_; // on GPU task runner + std::unique_ptr rasterizer_; // on raster task runner std::unique_ptr io_manager_; // on IO task runner std::shared_ptr is_gpu_disabled_sync_switch_; diff --git a/shell/common/shell_benchmarks.cc b/shell/common/shell_benchmarks.cc index 012e8bdfd8ec2..3842507f27022 100644 --- a/shell/common/shell_benchmarks.cc +++ b/shell/common/shell_benchmarks.cc @@ -44,8 +44,8 @@ static void StartupAndShutdownShell(benchmark::State& state, thread_host = std::make_unique( "io.flutter.bench.", ThreadHost::Type::Platform | - ThreadHost::Type::GPU | ThreadHost::Type::IO | - ThreadHost::Type::UI); + ThreadHost::Type::RASTER | + ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host->platform_thread->GetTaskRunner(), diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index aadfd6db0e683..7c455f1b77c95 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -22,7 +22,7 @@ namespace testing { ShellTest::ShellTest() : thread_host_("io.flutter.test." + GetCurrentTestName() + ".", ThreadHost::Type::Platform | ThreadHost::Type::IO | - ThreadHost::Type::UI | ThreadHost::Type::GPU) {} + ThreadHost::Type::UI | ThreadHost::Type::RASTER) {} void ShellTest::SendEnginePlatformMessage( Shell* shell, diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 5149a19412b7a..9fef249047449 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -130,7 +130,7 @@ TEST_F(ShellTest, InitializeWithDifferentThreads) { ASSERT_FALSE(DartVMRef::IsInstanceRunning()); Settings settings = CreateSettingsForFixture(); ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | + ThreadHost::Type::Platform | ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), thread_host.raster_thread->GetTaskRunner(), @@ -178,7 +178,7 @@ TEST_F(ShellTest, Settings settings = CreateSettingsForFixture(); ThreadHost thread_host( "io.flutter.test." + GetCurrentTestName() + ".", - ThreadHost::Type::GPU | ThreadHost::Type::IO | ThreadHost::Type::UI); + ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); fml::MessageLoop::EnsureInitializedForCurrentThread(); TaskRunners task_runners("test", fml::MessageLoop::GetCurrent().GetTaskRunner(), diff --git a/shell/common/thread_host.cc b/shell/common/thread_host.cc index 225a2271181c6..fdae202a53cce 100644 --- a/shell/common/thread_host.cc +++ b/shell/common/thread_host.cc @@ -20,7 +20,7 @@ ThreadHost::ThreadHost(std::string name_prefix_arg, uint64_t mask) ui_thread = std::make_unique(name_prefix + ".ui"); } - if (mask & ThreadHost::Type::GPU) { + if (mask & ThreadHost::Type::RASTER) { raster_thread = std::make_unique(name_prefix + ".raster"); } diff --git a/shell/common/thread_host.h b/shell/common/thread_host.h index fce933e44c3e9..c5db31938563e 100644 --- a/shell/common/thread_host.h +++ b/shell/common/thread_host.h @@ -17,7 +17,7 @@ struct ThreadHost { enum Type { Platform = 1 << 0, UI = 1 << 1, - GPU = 1 << 2, + RASTER = 1 << 2, IO = 1 << 3, Profiler = 1 << 4, }; diff --git a/shell/platform/android/android_shell_holder.cc b/shell/platform/android/android_shell_holder.cc index cc81849549f05..aa5145658809d 100644 --- a/shell/platform/android/android_shell_holder.cc +++ b/shell/platform/android/android_shell_holder.cc @@ -42,7 +42,8 @@ AndroidShellHolder::AndroidShellHolder( if (is_background_view) { thread_host_ = {thread_label, ThreadHost::Type::UI}; } else { - thread_host_ = {thread_label, ThreadHost::Type::UI | ThreadHost::Type::GPU | + thread_host_ = {thread_label, ThreadHost::Type::UI | + ThreadHost::Type::RASTER | ThreadHost::Type::IO}; } @@ -87,25 +88,25 @@ AndroidShellHolder::AndroidShellHolder( // The current thread will be used as the platform thread. Ensure that the // message loop is initialized. fml::MessageLoop::EnsureInitializedForCurrentThread(); - fml::RefPtr gpu_runner; + fml::RefPtr raster_runner; fml::RefPtr ui_runner; fml::RefPtr io_runner; fml::RefPtr platform_runner = fml::MessageLoop::GetCurrent().GetTaskRunner(); if (is_background_view) { auto single_task_runner = thread_host_.ui_thread->GetTaskRunner(); - gpu_runner = single_task_runner; + raster_runner = single_task_runner; ui_runner = single_task_runner; io_runner = single_task_runner; } else { - gpu_runner = thread_host_.raster_thread->GetTaskRunner(); + raster_runner = thread_host_.raster_thread->GetTaskRunner(); ui_runner = thread_host_.ui_thread->GetTaskRunner(); io_runner = thread_host_.io_thread->GetTaskRunner(); } flutter::TaskRunners task_runners(thread_label, // label platform_runner, // platform - gpu_runner, // raster + raster_runner, // raster ui_runner, // ui io_runner // io ); @@ -117,7 +118,7 @@ AndroidShellHolder::AndroidShellHolder( // Defensive fallback. Depending on the OEM, it may not be possible // to set priority to -5. if (::setpriority(PRIO_PROCESS, gettid(), -2) != 0) { - FML_LOG(ERROR) << "Failed to set GPU task runner priority"; + FML_LOG(ERROR) << "Failed to set raster task runner priority"; } } }); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index ea5de00c5d646..5ece908bf5993 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -513,7 +513,7 @@ + (NSString*)generateThreadLabel:(NSString*)labelPrefix { // initialized. fml::MessageLoop::EnsureInitializedForCurrentThread(); - uint32_t threadHostType = flutter::ThreadHost::Type::UI | flutter::ThreadHost::Type::GPU | + uint32_t threadHostType = flutter::ThreadHost::Type::UI | flutter::ThreadHost::Type::RASTER | flutter::ThreadHost::Type::IO; if ([FlutterEngine isProfilerEnabled]) { threadHostType = threadHostType | flutter::ThreadHost::Type::Profiler; diff --git a/shell/platform/embedder/embedder_thread_host.cc b/shell/platform/embedder/embedder_thread_host.cc index 15dd91d009b50..1f02eead41118 100644 --- a/shell/platform/embedder/embedder_thread_host.cc +++ b/shell/platform/embedder/embedder_thread_host.cc @@ -137,14 +137,14 @@ EmbedderThreadHost::CreateEmbedderManagedThreadHost( return nullptr; } - // If the embedder has not supplied a GPU task runner, one needs to be + // If the embedder has not supplied a raster task runner, one needs to be // created. if (!render_task_runner_pair.second) { - engine_thread_host_mask |= ThreadHost::Type::GPU; + engine_thread_host_mask |= ThreadHost::Type::RASTER; } - // If both the platform task runner and the GPU task runner are specified and - // have the same identifier, store only one. + // If both the platform task runner and the raster task runner are specified + // and have the same identifier, store only one. if (platform_task_runner_pair.second && render_task_runner_pair.second) { if (platform_task_runner_pair.second->GetEmbedderIdentifier() == render_task_runner_pair.second->GetEmbedderIdentifier()) { @@ -163,8 +163,8 @@ EmbedderThreadHost::CreateEmbedderManagedThreadHost( platform_task_runner_pair.second) : GetCurrentThreadTaskRunner(); - // If the embedder has supplied a GPU task runner, use that. If not, use the - // one from our thread host. + // If the embedder has supplied a raster task runner, use that. If not, use + // the one from our thread host. auto render_task_runner = render_task_runner_pair.second ? static_cast>( render_task_runner_pair.second) @@ -208,7 +208,7 @@ std::unique_ptr EmbedderThreadHost::CreateEngineManagedThreadHost() { // Create a thread host with the current thread as the platform thread and all // other threads managed. - ThreadHost thread_host(kFlutterThreadName, ThreadHost::Type::GPU | + ThreadHost thread_host(kFlutterThreadName, ThreadHost::Type::RASTER | ThreadHost::Type::IO | ThreadHost::Type::UI); diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index 8c970d59e22b9..f2635402e9379 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -118,7 +118,7 @@ int RunTester(const flutter::Settings& settings, if (multithreaded) { threadhost = std::make_unique( thread_label, ThreadHost::Type::Platform | ThreadHost::Type::IO | - ThreadHost::Type::UI | ThreadHost::Type::GPU); + ThreadHost::Type::UI | ThreadHost::Type::RASTER); platform_task_runner = current_task_runner; raster_task_runner = threadhost->raster_thread->GetTaskRunner(); ui_task_runner = threadhost->ui_thread->GetTaskRunner();