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

63 lines
2.5 KiB
Diff

From 762fd9a6ef1aabb5917f5ba5412c1e7561b85674 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/18] 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 5bfc19ef9..a2aecf88f 100644
--- a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
+++ b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
@@ -33,6 +33,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();
@@ -201,8 +207,9 @@ void GbmSurfacelessWayland::Present(SwapCompletionCallback completion_callback,
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& config : frame->configs) {
if (!config.access_fence_handle.is_null()) {
fences.push_back(std::make_unique<gfx::GpuFence>(
@@ -211,7 +218,17 @@ void GbmSurfacelessWayland::Present(SwapCompletionCallback completion_callback,
}
}
- 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