new/yocto/meta-rockchip/dynamic-layers/recipes-browser/chromium/chromium_97.0.4692/0010-Create-new-fence-when-there-s-no-in-fences.patch
2025-05-10 21:58:58 +08:00

61 lines
2.3 KiB
Diff

From 96e5f317bc2923f4bb8192ead3c67987314fc2f1 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Mon, 31 May 2021 01:29:11 +0800
Subject: [PATCH 10/14] Create new fence when there's no in-fences
There're cases that in-fences are not provided.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
.../wayland/gpu/gbm_surfaceless_wayland.cc | 21 +++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
index 0f2eb6ec..b283e438 100644
--- a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
+++ b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
@@ -30,6 +30,12 @@ static constexpr size_t kMaxSolidColorBuffers = 12;
static constexpr gfx::Size kSolidColorBufferSize{4, 4};
+void WaitForEGLFence(EGLDisplay display, EGLSyncKHR fence) {
+ eglClientWaitSyncKHR(display, fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
+ EGL_FOREVER_KHR);
+ eglDestroySyncKHR(display, fence);
+}
+
void WaitForGpuFences(std::vector<std::unique_ptr<gfx::GpuFence>> fences) {
for (auto& fence : fences)
fence->Wait();
@@ -211,14 +217,25 @@ void GbmSurfacelessWayland::SwapBuffersAsync(
return;
}
- base::OnceClosure fence_wait_task;
std::vector<std::unique_ptr<gfx::GpuFence>> fences;
+ // Uset in-fences provided in the overlays. If there are none, we insert our
+ // own fence and wait.
for (auto& plane : frame->planes) {
if (plane.second.gpu_fence)
fences.push_back(std::move(plane.second.gpu_fence));
}
- fence_wait_task = base::BindOnce(&WaitForGpuFences, std::move(fences));
+ base::OnceClosure fence_wait_task;
+ if (!fences.empty()) {
+ fence_wait_task = base::BindOnce(&WaitForGpuFences, std::move(fences));
+ } else {
+ // TODO(fangzhoug): the following should be replaced by a per surface flush
+ // as it gets implemented in GL drivers.
+ EGLSyncKHR fence = InsertFence(has_implicit_external_sync_);
+ CHECK_NE(fence, EGL_NO_SYNC_KHR) << "eglCreateSyncKHR failed";
+
+ fence_wait_task = base::BindOnce(&WaitForEGLFence, GetDisplay(), fence);
+ }
base::OnceClosure fence_retired_callback = base::BindOnce(
&GbmSurfacelessWayland::FenceRetired, weak_factory_.GetWeakPtr(), frame);
--
2.20.1