More rename from GPU thread to raster thread (flutter/engine#22819)

This commit is contained in:
zljj0818 2020-12-04 07:03:02 +08:00 committed by GitHub
parent 49935d5547
commit 0ef14f3ca3
18 changed files with 61 additions and 59 deletions

View File

@ -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(),

View File

@ -333,9 +333,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`.
///
@ -349,13 +349,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

View File

@ -275,13 +275,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

View File

@ -443,9 +443,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
@ -527,13 +527,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

View File

@ -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

View File

@ -685,7 +685,7 @@ class PlatformView {
fml::WeakPtrFactory<PlatformView> 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<Surface> CreateRenderingSurface();
private:

View File

@ -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.
///

View File

@ -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(),

View File

@ -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<fml::TimePoint> latest_frame_target_time_;
std::unique_ptr<PlatformView> platform_view_; // on platform task runner
std::unique_ptr<Engine> engine_; // on UI task runner
std::unique_ptr<Rasterizer> rasterizer_; // on GPU task runner
std::unique_ptr<Rasterizer> rasterizer_; // on raster task runner
std::unique_ptr<ShellIOManager> io_manager_; // on IO task runner
std::shared_ptr<fml::SyncSwitch> is_gpu_disabled_sync_switch_;

View File

@ -44,8 +44,8 @@ static void StartupAndShutdownShell(benchmark::State& state,
thread_host = std::make_unique<ThreadHost>(
"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(),

View File

@ -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,

View File

@ -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(),

View File

@ -20,7 +20,7 @@ ThreadHost::ThreadHost(std::string name_prefix_arg, uint64_t mask)
ui_thread = std::make_unique<fml::Thread>(name_prefix + ".ui");
}
if (mask & ThreadHost::Type::GPU) {
if (mask & ThreadHost::Type::RASTER) {
raster_thread = std::make_unique<fml::Thread>(name_prefix + ".raster");
}

View File

@ -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,
};

View File

@ -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<fml::TaskRunner> gpu_runner;
fml::RefPtr<fml::TaskRunner> raster_runner;
fml::RefPtr<fml::TaskRunner> ui_runner;
fml::RefPtr<fml::TaskRunner> io_runner;
fml::RefPtr<fml::TaskRunner> 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";
}
}
});

View File

@ -513,7 +513,7 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
// 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;

View File

@ -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<fml::RefPtr<fml::TaskRunner>>(
render_task_runner_pair.second)
@ -208,7 +208,7 @@ std::unique_ptr<EmbedderThreadHost>
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);

View File

@ -118,7 +118,7 @@ int RunTester(const flutter::Settings& settings,
if (multithreaded) {
threadhost = std::make_unique<ThreadHost>(
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();