未验证 提交 f003d9b4 编写于 作者: L liyuqian 提交者: GitHub

GPU to raster rename, patch 2 (#17428)

上级 6bdbe167
...@@ -63,7 +63,7 @@ RasterThreadStatus RasterThreadMerger::DecrementLease() { ...@@ -63,7 +63,7 @@ RasterThreadStatus RasterThreadMerger::DecrementLease() {
lease_term_--; lease_term_--;
if (lease_term_ == 0) { if (lease_term_ == 0) {
bool success = task_queues_->Unmerge(platform_queue_id_); bool success = task_queues_->Unmerge(platform_queue_id_);
FML_CHECK(success) << "Unable to un-merge the GPU and platform threads."; FML_CHECK(success) << "Unable to un-merge the raster and platform threads.";
is_merged_ = false; is_merged_ = false;
return RasterThreadStatus::kUnmergedNow; return RasterThreadStatus::kUnmergedNow;
} }
......
...@@ -33,7 +33,7 @@ class RasterThreadMerger ...@@ -33,7 +33,7 @@ class RasterThreadMerger
void ExtendLeaseTo(size_t lease_term); void ExtendLeaseTo(size_t lease_term);
// Returns |RasterThreadStatus::kUnmergedNow| if this call resulted in // Returns |RasterThreadStatus::kUnmergedNow| if this call resulted in
// splitting the GPU and platform threads. Reduces the lease term by 1. // splitting the raster and platform threads. Reduces the lease term by 1.
RasterThreadStatus DecrementLease(); RasterThreadStatus DecrementLease();
bool IsMerged() const; bool IsMerged() const;
......
...@@ -188,8 +188,8 @@ SceneHost::SceneHost(fml::RefPtr<zircon::dart::Handle> viewHolderToken, ...@@ -188,8 +188,8 @@ SceneHost::SceneHost(fml::RefPtr<zircon::dart::Handle> viewHolderToken,
scene_host_bindings.emplace(std::make_pair(key, scene_host)); scene_host_bindings.emplace(std::make_pair(key, scene_host));
}; };
// Pass the raw handle to the GPU thead; destroying a |zircon::dart::Handle| // Pass the raw handle to the raster thread; destroying a
// on that thread can cause a race condition. // |zircon::dart::Handle| on that thread can cause a race condition.
raster_task_runner_->PostTask( raster_task_runner_->PostTask(
[id = koid_, [id = koid_,
ui_task_runner = ui_task_runner =
......
...@@ -115,7 +115,7 @@ Dart_Handle Picture::RasterizeToImage(sk_sp<SkPicture> picture, ...@@ -115,7 +115,7 @@ Dart_Handle Picture::RasterizeToImage(sk_sp<SkPicture> picture,
delete image_callback; delete image_callback;
}); });
// Kick things off on the GPU. // Kick things off on the raster rask runner.
fml::TaskRunner::RunNowOrPostTask( fml::TaskRunner::RunNowOrPostTask(
raster_task_runner, raster_task_runner,
[ui_task_runner, snapshot_delegate, picture, picture_bounds, ui_task] { [ui_task_runner, snapshot_delegate, picture, picture_bounds, ui_task] {
......
...@@ -605,7 +605,7 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) { ...@@ -605,7 +605,7 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) {
// setup/suspension of all activities that may be interacting with the GPU in // setup/suspension of all activities that may be interacting with the GPU in
// a synchronous fashion. // a synchronous fashion.
fml::AutoResetWaitableEvent latch; fml::AutoResetWaitableEvent latch;
auto gpu_task = auto raster_task =
fml::MakeCopyable([& waiting_for_first_frame = waiting_for_first_frame_, fml::MakeCopyable([& waiting_for_first_frame = waiting_for_first_frame_,
rasterizer = rasterizer_->GetWeakPtr(), // rasterizer = rasterizer_->GetWeakPtr(), //
surface = std::move(surface), // surface = std::move(surface), //
...@@ -623,19 +623,20 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) { ...@@ -623,19 +623,20 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) {
// The normal flow executed by this method is that the platform thread is // The normal flow executed by this method is that the platform thread is
// starting the sequence and waiting on the latch. Later the UI thread posts // starting the sequence and waiting on the latch. Later the UI thread posts
// gpu_task to the raster thread which signals the latch. If the GPU the and // raster_task to the raster thread which signals the latch. If the raster and
// platform threads are the same this results in a deadlock as the gpu_task // the platform threads are the same this results in a deadlock as the
// will never be posted to the plaform/raster thread that is blocked on a // raster_task will never be posted to the plaform/raster thread that is
// latch. To avoid the described deadlock, if the raster and the platform // blocked on a latch. To avoid the described deadlock, if the raster and the
// threads are the same, should_post_gpu_task will be false, and then instead // platform threads are the same, should_post_raster_task will be false, and
// of posting a task to the raster thread, the ui thread just signals the // then instead of posting a task to the raster thread, the ui thread just
// latch and the platform/raster thread follows with executing gpu_task. // signals the latch and the platform/raster thread follows with executing
bool should_post_gpu_task = task_runners_.GetRasterTaskRunner() != // raster_task.
task_runners_.GetPlatformTaskRunner(); bool should_post_raster_task = task_runners_.GetRasterTaskRunner() !=
task_runners_.GetPlatformTaskRunner();
auto ui_task = [engine = engine_->GetWeakPtr(), // auto ui_task = [engine = engine_->GetWeakPtr(), //
raster_task_runner = task_runners_.GetRasterTaskRunner(), // raster_task_runner = task_runners_.GetRasterTaskRunner(), //
gpu_task, should_post_gpu_task, raster_task, should_post_raster_task,
&latch // &latch //
] { ] {
if (engine) { if (engine) {
...@@ -643,10 +644,10 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) { ...@@ -643,10 +644,10 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) {
} }
// Step 2: Next, tell the raster thread that it should create a surface for // Step 2: Next, tell the raster thread that it should create a surface for
// its rasterizer. // its rasterizer.
if (should_post_gpu_task) { if (should_post_raster_task) {
fml::TaskRunner::RunNowOrPostTask(raster_task_runner, gpu_task); fml::TaskRunner::RunNowOrPostTask(raster_task_runner, raster_task);
} else { } else {
// See comment on should_post_gpu_task, in this case we just unblock // See comment on should_post_raster_task, in this case we just unblock
// the platform thread. // the platform thread.
latch.Signal(); latch.Signal();
} }
...@@ -674,11 +675,11 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) { ...@@ -674,11 +675,11 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) {
fml::TaskRunner::RunNowOrPostTask(task_runners_.GetIOTaskRunner(), io_task); fml::TaskRunner::RunNowOrPostTask(task_runners_.GetIOTaskRunner(), io_task);
latch.Wait(); latch.Wait();
if (!should_post_gpu_task) { if (!should_post_raster_task) {
// See comment on should_post_gpu_task, in this case the gpu_task // See comment on should_post_raster_task, in this case the raster_task
// wasn't executed, and we just run it here as the platform thread // wasn't executed, and we just run it here as the platform thread
// is the raster thread. // is the raster thread.
gpu_task(); raster_task();
} }
} }
...@@ -706,9 +707,9 @@ void Shell::OnPlatformViewDestroyed() { ...@@ -706,9 +707,9 @@ void Shell::OnPlatformViewDestroyed() {
latch.Signal(); latch.Signal();
}; };
auto gpu_task = [rasterizer = rasterizer_->GetWeakPtr(), auto raster_task = [rasterizer = rasterizer_->GetWeakPtr(),
io_task_runner = task_runners_.GetIOTaskRunner(), io_task_runner = task_runners_.GetIOTaskRunner(),
io_task]() { io_task]() {
if (rasterizer) { if (rasterizer) {
rasterizer->Teardown(); rasterizer->Teardown();
} }
...@@ -718,29 +719,29 @@ void Shell::OnPlatformViewDestroyed() { ...@@ -718,29 +719,29 @@ void Shell::OnPlatformViewDestroyed() {
// The normal flow executed by this method is that the platform thread is // The normal flow executed by this method is that the platform thread is
// starting the sequence and waiting on the latch. Later the UI thread posts // starting the sequence and waiting on the latch. Later the UI thread posts
// gpu_task to the raster thread triggers signaling the latch(on the IO // raster_task to the raster thread triggers signaling the latch(on the IO
// thread). If the GPU the and platform threads are the same this results in a // thread). If the raster and the platform threads are the same this results
// deadlock as the gpu_task will never be posted to the plaform/raster thread // in a deadlock as the raster_task will never be posted to the plaform/raster
// that is blocked on a latch. To avoid the described deadlock, if the raster // thread that is blocked on a latch. To avoid the described deadlock, if the
// and the platform threads are the same, should_post_gpu_task will be false, // raster and the platform threads are the same, should_post_raster_task will
// and then instead of posting a task to the raster thread, the ui thread just // be false, and then instead of posting a task to the raster thread, the ui
// signals the latch and the platform/raster thread follows with executing // thread just signals the latch and the platform/raster thread follows with
// gpu_task. // executing raster_task.
bool should_post_gpu_task = task_runners_.GetRasterTaskRunner() != bool should_post_raster_task = task_runners_.GetRasterTaskRunner() !=
task_runners_.GetPlatformTaskRunner(); task_runners_.GetPlatformTaskRunner();
auto ui_task = [engine = engine_->GetWeakPtr(), auto ui_task = [engine = engine_->GetWeakPtr(),
raster_task_runner = task_runners_.GetRasterTaskRunner(), raster_task_runner = task_runners_.GetRasterTaskRunner(),
gpu_task, should_post_gpu_task, &latch]() { raster_task, should_post_raster_task, &latch]() {
if (engine) { if (engine) {
engine->OnOutputSurfaceDestroyed(); engine->OnOutputSurfaceDestroyed();
} }
// Step 1: Next, tell the raster thread that its rasterizer should suspend // Step 1: Next, tell the raster thread that its rasterizer should suspend
// access to the underlying surface. // access to the underlying surface.
if (should_post_gpu_task) { if (should_post_raster_task) {
fml::TaskRunner::RunNowOrPostTask(raster_task_runner, gpu_task); fml::TaskRunner::RunNowOrPostTask(raster_task_runner, raster_task);
} else { } else {
// See comment on should_post_gpu_task, in this case we just unblock // See comment on should_post_raster_task, in this case we just unblock
// the platform thread. // the platform thread.
latch.Signal(); latch.Signal();
} }
...@@ -750,11 +751,11 @@ void Shell::OnPlatformViewDestroyed() { ...@@ -750,11 +751,11 @@ void Shell::OnPlatformViewDestroyed() {
// surface is about to go away. // surface is about to go away.
fml::TaskRunner::RunNowOrPostTask(task_runners_.GetUITaskRunner(), ui_task); fml::TaskRunner::RunNowOrPostTask(task_runners_.GetUITaskRunner(), ui_task);
latch.Wait(); latch.Wait();
if (!should_post_gpu_task) { if (!should_post_raster_task) {
// See comment on should_post_gpu_task, in this case the gpu_task // See comment on should_post_raster_task, in this case the raster_task
// wasn't executed, and we just run it here as the platform thread // wasn't executed, and we just run it here as the platform thread
// is the raster thread. // is the raster thread.
gpu_task(); raster_task();
latch.Wait(); latch.Wait();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册