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

GPU to raster rename, patch 2 (#17428)

上级 6bdbe167
......@@ -63,7 +63,7 @@ RasterThreadStatus RasterThreadMerger::DecrementLease() {
lease_term_--;
if (lease_term_ == 0) {
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;
return RasterThreadStatus::kUnmergedNow;
}
......
......@@ -33,7 +33,7 @@ class RasterThreadMerger
void ExtendLeaseTo(size_t lease_term);
// 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();
bool IsMerged() const;
......
......@@ -188,8 +188,8 @@ SceneHost::SceneHost(fml::RefPtr<zircon::dart::Handle> viewHolderToken,
scene_host_bindings.emplace(std::make_pair(key, scene_host));
};
// Pass the raw handle to the GPU thead; destroying a |zircon::dart::Handle|
// on that thread can cause a race condition.
// Pass the raw handle to the raster thread; destroying a
// |zircon::dart::Handle| on that thread can cause a race condition.
raster_task_runner_->PostTask(
[id = koid_,
ui_task_runner =
......
......@@ -115,7 +115,7 @@ Dart_Handle Picture::RasterizeToImage(sk_sp<SkPicture> picture,
delete image_callback;
});
// Kick things off on the GPU.
// Kick things off on the raster rask runner.
fml::TaskRunner::RunNowOrPostTask(
raster_task_runner,
[ui_task_runner, snapshot_delegate, picture, picture_bounds, ui_task] {
......
......@@ -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
// a synchronous fashion.
fml::AutoResetWaitableEvent latch;
auto gpu_task =
auto raster_task =
fml::MakeCopyable([& waiting_for_first_frame = waiting_for_first_frame_,
rasterizer = rasterizer_->GetWeakPtr(), //
surface = std::move(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
// 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
// platform threads are the same this results in a deadlock as the gpu_task
// will never be posted to the plaform/raster thread that is blocked on a
// latch. To avoid the described deadlock, if the raster and the platform
// threads are the same, should_post_gpu_task will be false, and then instead
// of posting a task to the raster thread, the ui thread just signals the
// latch and the platform/raster thread follows with executing gpu_task.
bool should_post_gpu_task = task_runners_.GetRasterTaskRunner() !=
task_runners_.GetPlatformTaskRunner();
// raster_task to the raster thread which signals the latch. If the raster and
// the platform threads are the same this results in a deadlock as the
// raster_task will never be posted to the plaform/raster thread that is
// blocked on a latch. To avoid the described deadlock, if the raster and the
// platform threads are the same, should_post_raster_task will be false, and
// then instead of posting a task to the raster thread, the ui thread just
// signals the latch and the platform/raster thread follows with executing
// raster_task.
bool should_post_raster_task = task_runners_.GetRasterTaskRunner() !=
task_runners_.GetPlatformTaskRunner();
auto ui_task = [engine = engine_->GetWeakPtr(), //
raster_task_runner = task_runners_.GetRasterTaskRunner(), //
gpu_task, should_post_gpu_task,
raster_task, should_post_raster_task,
&latch //
] {
if (engine) {
......@@ -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
// its rasterizer.
if (should_post_gpu_task) {
fml::TaskRunner::RunNowOrPostTask(raster_task_runner, gpu_task);
if (should_post_raster_task) {
fml::TaskRunner::RunNowOrPostTask(raster_task_runner, raster_task);
} 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.
latch.Signal();
}
......@@ -674,11 +675,11 @@ void Shell::OnPlatformViewCreated(std::unique_ptr<Surface> surface) {
fml::TaskRunner::RunNowOrPostTask(task_runners_.GetIOTaskRunner(), io_task);
latch.Wait();
if (!should_post_gpu_task) {
// See comment on should_post_gpu_task, in this case the gpu_task
if (!should_post_raster_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
// is the raster thread.
gpu_task();
raster_task();
}
}
......@@ -706,9 +707,9 @@ void Shell::OnPlatformViewDestroyed() {
latch.Signal();
};
auto gpu_task = [rasterizer = rasterizer_->GetWeakPtr(),
io_task_runner = task_runners_.GetIOTaskRunner(),
io_task]() {
auto raster_task = [rasterizer = rasterizer_->GetWeakPtr(),
io_task_runner = task_runners_.GetIOTaskRunner(),
io_task]() {
if (rasterizer) {
rasterizer->Teardown();
}
......@@ -718,29 +719,29 @@ void Shell::OnPlatformViewDestroyed() {
// 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
// gpu_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
// deadlock as the gpu_task will never be posted to the plaform/raster thread
// that is blocked on a latch. To avoid the described deadlock, if the raster
// and the platform threads are the same, should_post_gpu_task will be false,
// and then instead of posting a task to the raster thread, the ui thread just
// signals the latch and the platform/raster thread follows with executing
// gpu_task.
bool should_post_gpu_task = task_runners_.GetRasterTaskRunner() !=
task_runners_.GetPlatformTaskRunner();
// raster_task to the raster thread triggers signaling the latch(on the IO
// thread). If the raster and the platform threads are the same this results
// in a deadlock as the raster_task will never be posted to the plaform/raster
// thread that is blocked on a latch. To avoid the described deadlock, if the
// raster and the platform threads are the same, should_post_raster_task will
// be false, and then instead of posting a task to the raster thread, the ui
// thread just signals the latch and the platform/raster thread follows with
// executing raster_task.
bool should_post_raster_task = task_runners_.GetRasterTaskRunner() !=
task_runners_.GetPlatformTaskRunner();
auto ui_task = [engine = engine_->GetWeakPtr(),
raster_task_runner = task_runners_.GetRasterTaskRunner(),
gpu_task, should_post_gpu_task, &latch]() {
raster_task, should_post_raster_task, &latch]() {
if (engine) {
engine->OnOutputSurfaceDestroyed();
}
// Step 1: Next, tell the raster thread that its rasterizer should suspend
// access to the underlying surface.
if (should_post_gpu_task) {
fml::TaskRunner::RunNowOrPostTask(raster_task_runner, gpu_task);
if (should_post_raster_task) {
fml::TaskRunner::RunNowOrPostTask(raster_task_runner, raster_task);
} 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.
latch.Signal();
}
......@@ -750,11 +751,11 @@ void Shell::OnPlatformViewDestroyed() {
// surface is about to go away.
fml::TaskRunner::RunNowOrPostTask(task_runners_.GetUITaskRunner(), ui_task);
latch.Wait();
if (!should_post_gpu_task) {
// See comment on should_post_gpu_task, in this case the gpu_task
if (!should_post_raster_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
// is the raster thread.
gpu_task();
raster_task();
latch.Wait();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册