Commit 23812061 authored by Robert Kroeger's avatar Robert Kroeger Committed by Commit Bot

Revert "[ozone/wayland] Use linux_explicit_synchronization_protocol for in-fence"

This reverts commit 4ff93eee.

Reason for revert: broke linux/ozone/wayland on non-exo compositors.

Original change's description:
> [ozone/wayland] Use linux_explicit_synchronization_protocol for in-fence
>
> If linux_explicit_synchronization_protocol is implemented by wayland
> server, submit access fence together with buffers. Otherwise, wait for
> fences in gpu process. It is preferred to defer waiting for buffer
> content ready in Wayland server, because waiting for access fences in
> client can be time-consuming.
>
> The access fence for primary plane should be inserted by the buffer queue.
>
> This is 7/? CL for overlay forwarding using wl_subsurface.
>
> Change-Id: I8a031c1941591c48eac8a51d12af195c345002e2
> Bug: 1063865
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2365994
> Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
> Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
> Reviewed-by: Maksim Sisov (GMT+2) <msisov@igalia.com>
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#822813}

TBR=rjkroege@chromium.org,tsepez@chromium.org,msisov@igalia.com,fangzhoug@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1063865
Change-Id: Id3fffcf4e06f2757cb7352177f0acca280c2ee7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517626Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823726}
parent 7ba203c1
...@@ -94,13 +94,11 @@ bool PresenterImageGL::Initialize( ...@@ -94,13 +94,11 @@ bool PresenterImageGL::Initialize(
overlay_representation_ = representation_factory->ProduceOverlay(mailbox); overlay_representation_ = representation_factory->ProduceOverlay(mailbox);
// If the backing doesn't support overlay, then fallback to GL. // If the backing doesn't support overlay, then fallback to GL.
if (!overlay_representation_) { if (!overlay_representation_)
LOG(ERROR) << "ProduceOverlay() failed";
gl_representation_ = representation_factory->ProduceGLTexture(mailbox); gl_representation_ = representation_factory->ProduceGLTexture(mailbox);
}
if (!overlay_representation_ && !gl_representation_) { if (!overlay_representation_ && !gl_representation_) {
LOG(ERROR) << "ProduceOverlay() and ProduceGLTexture() failed."; DLOG(ERROR) << "ProduceOverlay() and ProduceGLTexture() failed.";
return false; return false;
} }
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "ui/gfx/gpu_fence.h" #include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gl/gl_fence_android_native_fence_sync.h"
#include "ui/ozone/common/egl_util.h" #include "ui/ozone/common/egl_util.h"
#include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h" #include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h"
#include "ui/ozone/public/mojom/wayland/wayland_overlay_config.mojom.h" #include "ui/ozone/public/mojom/wayland/wayland_overlay_config.mojom.h"
...@@ -21,6 +19,12 @@ namespace ui { ...@@ -21,6 +19,12 @@ namespace ui {
namespace { namespace {
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) { void WaitForGpuFences(std::vector<std::unique_ptr<gfx::GpuFence>> fences) {
for (auto& fence : fences) for (auto& fence : fences)
fence->Wait(); fence->Wait();
...@@ -34,6 +38,8 @@ GbmSurfacelessWayland::GbmSurfacelessWayland( ...@@ -34,6 +38,8 @@ GbmSurfacelessWayland::GbmSurfacelessWayland(
: SurfacelessEGL(gfx::Size()), : SurfacelessEGL(gfx::Size()),
buffer_manager_(buffer_manager), buffer_manager_(buffer_manager),
widget_(widget), widget_(widget),
has_implicit_external_sync_(
HasEGLExtension("EGL_ARM_implicit_external_sync")),
weak_factory_(this) { weak_factory_(this) {
buffer_manager_->RegisterSurface(widget_, this); buffer_manager_->RegisterSurface(widget_, this);
unsubmitted_frames_.push_back(std::make_unique<PendingFrame>()); unsubmitted_frames_.push_back(std::make_unique<PendingFrame>());
...@@ -54,9 +60,9 @@ bool GbmSurfacelessWayland::ScheduleOverlayPlane( ...@@ -54,9 +60,9 @@ bool GbmSurfacelessWayland::ScheduleOverlayPlane(
const gfx::RectF& crop_rect, const gfx::RectF& crop_rect,
bool enable_blend, bool enable_blend,
std::unique_ptr<gfx::GpuFence> gpu_fence) { std::unique_ptr<gfx::GpuFence> gpu_fence) {
unsubmitted_frames_.back()->overlays.emplace_back( unsubmitted_frames_.back()->overlays.push_back(
z_order, transform, image, bounds_rect, crop_rect, enable_blend, gl::GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect,
std::move(gpu_fence)); enable_blend, std::move(gpu_fence)));
return true; return true;
} }
...@@ -115,34 +121,26 @@ void GbmSurfacelessWayland::SwapBuffersAsync( ...@@ -115,34 +121,26 @@ void GbmSurfacelessWayland::SwapBuffersAsync(
return; return;
} }
// If Wayland server supports linux_explicit_synchronization_protocol, fences
// should be shipped with buffers. Otherwise, we will wait for fences.
if (buffer_manager_->supports_acquire_fence()) {
DCHECK_LT(0, std::count_if(
frame->planes.begin(), frame->planes.end(),
[](const std::pair<const BufferId, OverlayPlane>& plane) {
return !!plane.second.gpu_fence;
}));
frame->ready = true;
MaybeSubmitFrames();
return;
}
// linux_explicit_synchronization_protocol is not supported, we need to wait
// for in-fences here.
std::vector<std::unique_ptr<gfx::GpuFence>> fences; std::vector<std::unique_ptr<gfx::GpuFence>> fences;
// Use in-fences provided in the overlays. If there are none, we insert our // Uset in-fences provided in the overlays. If there are none, we insert our
// own fence and wait. // own fence and wait.
for (auto& plane : frame->planes) { for (auto& plane : frame->planes) {
DCHECK(plane.second.z_order != 0 || plane.second.gpu_fence);
if (plane.second.gpu_fence) if (plane.second.gpu_fence)
fences.push_back(std::move(plane.second.gpu_fence)); fences.push_back(std::move(plane.second.gpu_fence));
} }
DCHECK(!fences.empty());
base::OnceClosure fence_wait_task; base::OnceClosure fence_wait_task;
fence_wait_task = base::BindOnce(&WaitForGpuFences, std::move(fences)); 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( base::OnceClosure fence_retired_callback = base::BindOnce(
&GbmSurfacelessWayland::FenceRetired, weak_factory_.GetWeakPtr(), frame); &GbmSurfacelessWayland::FenceRetired, weak_factory_.GetWeakPtr(), frame);
...@@ -192,10 +190,6 @@ void GbmSurfacelessWayland::SetRelyOnImplicitSync() { ...@@ -192,10 +190,6 @@ void GbmSurfacelessWayland::SetRelyOnImplicitSync() {
use_egl_fence_sync_ = false; use_egl_fence_sync_ = false;
} }
bool GbmSurfacelessWayland::SupportsPlaneGpuFences() const {
return true;
}
gfx::SurfaceOrigin GbmSurfacelessWayland::GetOrigin() const { gfx::SurfaceOrigin GbmSurfacelessWayland::GetOrigin() const {
// GbmSurfacelessWayland's y-axis is flipped compare to GL - (0,0) is at top // GbmSurfacelessWayland's y-axis is flipped compare to GL - (0,0) is at top
// left corner. // left corner.
...@@ -206,9 +200,9 @@ GbmSurfacelessWayland::~GbmSurfacelessWayland() { ...@@ -206,9 +200,9 @@ GbmSurfacelessWayland::~GbmSurfacelessWayland() {
buffer_manager_->UnregisterSurface(widget_); buffer_manager_->UnregisterSurface(widget_);
} }
GbmSurfacelessWayland::PendingFrame::PendingFrame() = default; GbmSurfacelessWayland::PendingFrame::PendingFrame() {}
GbmSurfacelessWayland::PendingFrame::~PendingFrame() = default; GbmSurfacelessWayland::PendingFrame::~PendingFrame() {}
void GbmSurfacelessWayland::PendingFrame::ScheduleOverlayPlanes( void GbmSurfacelessWayland::PendingFrame::ScheduleOverlayPlanes(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
...@@ -244,23 +238,28 @@ void GbmSurfacelessWayland::MaybeSubmitFrames() { ...@@ -244,23 +238,28 @@ void GbmSurfacelessWayland::MaybeSubmitFrames() {
} }
std::vector<ui::ozone::mojom::WaylandOverlayConfigPtr> overlay_configs; std::vector<ui::ozone::mojom::WaylandOverlayConfigPtr> overlay_configs;
for (auto& plane : submitted_frame->planes) { for (const auto& plane : submitted_frame->planes) {
overlay_configs.push_back( overlay_configs.push_back(
ui::ozone::mojom::WaylandOverlayConfig::From(plane.second)); ui::ozone::mojom::WaylandOverlayConfig::From(plane.second));
overlay_configs.back()->buffer_id = plane.first; overlay_configs.back()->buffer_id = plane.first;
if (plane.second.z_order == 0) { if (plane.second.z_order == 0) {
DCHECK(!buffer_manager_->supports_acquire_fence() ||
plane.second.gpu_fence);
overlay_configs.back()->damage_region = submitted_frame->damage_region_; overlay_configs.back()->damage_region = submitted_frame->damage_region_;
submitted_frame->buffer_id = plane.first;
} }
plane.second.gpu_fence.reset();
} }
buffer_manager_->CommitOverlays(widget_, std::move(overlay_configs)); buffer_manager_->CommitOverlays(widget_, std::move(overlay_configs));
submitted_frames_.push_back(std::move(submitted_frame)); submitted_frames_.push_back(std::move(submitted_frame));
} }
} }
EGLSyncKHR GbmSurfacelessWayland::InsertFence(bool implicit) {
const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR,
EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM,
EGL_NONE};
return eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR,
implicit ? attrib_list : nullptr);
}
void GbmSurfacelessWayland::FenceRetired(PendingFrame* frame) { void GbmSurfacelessWayland::FenceRetired(PendingFrame* frame) {
frame->ready = true; frame->ready = true;
MaybeSubmitFrames(); MaybeSubmitFrames();
......
...@@ -60,7 +60,6 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL, ...@@ -60,7 +60,6 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL,
PresentationCallback presentation_callback) override; PresentationCallback presentation_callback) override;
EGLConfig GetConfig() override; EGLConfig GetConfig() override;
void SetRelyOnImplicitSync() override; void SetRelyOnImplicitSync() override;
bool SupportsPlaneGpuFences() const override;
gfx::SurfaceOrigin GetOrigin() const override; gfx::SurfaceOrigin GetOrigin() const override;
private: private:
...@@ -89,6 +88,9 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL, ...@@ -89,6 +88,9 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL,
bool ready = false; bool ready = false;
// The id of the buffer, which represents this frame.
BufferId buffer_id = 0;
// A region of the updated content in a corresponding frame. It's used to // A region of the updated content in a corresponding frame. It's used to
// advice Wayland which part of a buffer is going to be updated. Passing {0, // advice Wayland which part of a buffer is going to be updated. Passing {0,
// 0, 0, 0} results in a whole buffer update on the Wayland compositor side. // 0, 0, 0} results in a whole buffer update on the Wayland compositor side.
...@@ -110,6 +112,7 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL, ...@@ -110,6 +112,7 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL,
void MaybeSubmitFrames(); void MaybeSubmitFrames();
EGLSyncKHR InsertFence(bool implicit);
void FenceRetired(PendingFrame* frame); void FenceRetired(PendingFrame* frame);
// Sets a flag that skips glFlush step in unittests. // Sets a flag that skips glFlush step in unittests.
...@@ -122,6 +125,7 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL, ...@@ -122,6 +125,7 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL,
std::vector<std::unique_ptr<PendingFrame>> unsubmitted_frames_; std::vector<std::unique_ptr<PendingFrame>> unsubmitted_frames_;
std::vector<std::unique_ptr<PendingFrame>> submitted_frames_; std::vector<std::unique_ptr<PendingFrame>> submitted_frames_;
std::vector<std::unique_ptr<PendingFrame>> pending_presentation_frames_; std::vector<std::unique_ptr<PendingFrame>> pending_presentation_frames_;
bool has_implicit_external_sync_;
bool last_swap_buffers_result_ = true; bool last_swap_buffers_result_ = true;
bool use_egl_fence_sync_ = true; bool use_egl_fence_sync_ = true;
......
...@@ -44,8 +44,7 @@ void WaylandBufferManagerGpu::Initialize( ...@@ -44,8 +44,7 @@ void WaylandBufferManagerGpu::Initialize(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host, mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host,
const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>& const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>&
buffer_formats_with_modifiers, buffer_formats_with_modifiers,
bool supports_dma_buf, bool supports_dma_buf) {
bool supports_acquire_fence) {
DCHECK(supported_buffer_formats_with_modifiers_.empty()); DCHECK(supported_buffer_formats_with_modifiers_.empty());
supported_buffer_formats_with_modifiers_ = buffer_formats_with_modifiers; supported_buffer_formats_with_modifiers_ = buffer_formats_with_modifiers;
...@@ -53,7 +52,6 @@ void WaylandBufferManagerGpu::Initialize( ...@@ -53,7 +52,6 @@ void WaylandBufferManagerGpu::Initialize(
if (!supports_dma_buf) if (!supports_dma_buf)
set_gbm_device(nullptr); set_gbm_device(nullptr);
#endif #endif
supports_acquire_fence_ = supports_acquire_fence;
BindHostInterface(std::move(remote_host)); BindHostInterface(std::move(remote_host));
......
...@@ -51,8 +51,7 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -51,8 +51,7 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host, mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host,
const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>& const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>&
buffer_formats_with_modifiers, buffer_formats_with_modifiers,
bool supports_dma_buf, bool supports_dma_buf) override;
bool supports_acquire_fence) override;
// These two calls get the surface, which backs the |widget| and notifies it // These two calls get the surface, which backs the |widget| and notifies it
// about the submission and the presentation. After the surface receives the // about the submission and the presentation. After the surface receives the
...@@ -125,8 +124,6 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -125,8 +124,6 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
} }
#endif #endif
bool supports_acquire_fence() const { return supports_acquire_fence_; }
// Adds a WaylandBufferManagerGpu binding. // Adds a WaylandBufferManagerGpu binding.
void AddBindingWaylandBufferManagerGpu( void AddBindingWaylandBufferManagerGpu(
mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver); mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver);
...@@ -181,8 +178,6 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { ...@@ -181,8 +178,6 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
// A DRM render node based gbm device. // A DRM render node based gbm device.
std::unique_ptr<GbmDevice> gbm_device_; std::unique_ptr<GbmDevice> gbm_device_;
#endif #endif
// Whether Wayland server allows buffer submission with acquire fence.
bool supports_acquire_fence_ = false;
mojo::Receiver<ozone::mojom::WaylandBufferManagerGpu> receiver_{this}; mojo::Receiver<ozone::mojom::WaylandBufferManagerGpu> receiver_{this};
......
...@@ -178,7 +178,7 @@ class WaylandSurfaceFactoryTest : public WaylandTest { ...@@ -178,7 +178,7 @@ class WaylandSurfaceFactoryTest : public WaylandTest {
WaylandTest::SetUp(); WaylandTest::SetUp();
auto manager_ptr = connection_->buffer_manager_host()->BindInterface(); auto manager_ptr = connection_->buffer_manager_host()->BindInterface();
buffer_manager_gpu_->Initialize(std::move(manager_ptr), {}, false, false); buffer_manager_gpu_->Initialize(std::move(manager_ptr), {}, false);
// Wait until initialization and mojo calls go through. // Wait until initialization and mojo calls go through.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
...@@ -84,9 +84,9 @@ void WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded( ...@@ -84,9 +84,9 @@ void WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded(
#if defined(WAYLAND_GBM) #if defined(WAYLAND_GBM)
supports_dma_buf = buffer_manager_host_->SupportsDmabuf(); supports_dma_buf = buffer_manager_host_->SupportsDmabuf();
#endif #endif
buffer_manager_gpu_remote->Initialize( buffer_manager_gpu_remote->Initialize(std::move(buffer_manager_host),
std::move(buffer_manager_host), buffer_formats_with_modifiers, buffer_formats_with_modifiers,
supports_dma_buf, buffer_manager_host_->SupportsAcquireFence()); supports_dma_buf);
} }
void WaylandBufferManagerConnector::OnTerminateGpuProcess(std::string message) { void WaylandBufferManagerConnector::OnTerminateGpuProcess(std::string message) {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/current_thread.h" #include "base/task/current_thread.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/linux/drm_util_linux.h" #include "ui/gfx/linux/drm_util_linux.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_drm.h" #include "ui/ozone/platform/wayland/host/wayland_drm.h"
...@@ -69,19 +68,16 @@ class WaylandBufferManagerHost::Surface { ...@@ -69,19 +68,16 @@ class WaylandBufferManagerHost::Surface {
buffer_manager_(buffer_manager) {} buffer_manager_(buffer_manager) {}
~Surface() = default; ~Surface() = default;
bool CommitBuffer( bool CommitBuffer(uint32_t buffer_id,
uint32_t buffer_id, const gfx::Rect& damage_region,
const gfx::Rect& damage_region, bool wait_for_frame_callback) {
bool wait_for_frame_callback,
gfx::GpuFenceHandle access_fence_handle = gfx::GpuFenceHandle()) {
// The window has already been destroyed. // The window has already been destroyed.
if (!wayland_surface_) if (!wayland_surface_)
return true; return true;
// This is a buffer-less commit, do not lookup buffers. // This is a buffer-less commit, do not lookup buffers.
if (buffer_id == kInvalidBufferId) { if (buffer_id == kInvalidBufferId) {
DCHECK(access_fence_handle.is_null()); pending_commits_.push_back({nullptr, wait_for_frame_callback});
pending_commits_.push_back({nullptr, wait_for_frame_callback, nullptr});
MaybeProcessPendingBuffer(); MaybeProcessPendingBuffer();
return true; return true;
} }
...@@ -111,9 +107,7 @@ class WaylandBufferManagerHost::Surface { ...@@ -111,9 +107,7 @@ class WaylandBufferManagerHost::Surface {
if (buffer->attached && !buffer->wl_buffer) if (buffer->attached && !buffer->wl_buffer)
return false; return false;
pending_commits_.push_back( pending_commits_.push_back({buffer, wait_for_frame_callback});
{buffer, wait_for_frame_callback,
std::make_unique<gfx::GpuFence>(std::move(access_fence_handle))});
MaybeProcessPendingBuffer(); MaybeProcessPendingBuffer();
return true; return true;
} }
...@@ -233,14 +227,9 @@ class WaylandBufferManagerHost::Surface { ...@@ -233,14 +227,9 @@ class WaylandBufferManagerHost::Surface {
// Whether this commit must wait for a wl_frame_callback and setup another // Whether this commit must wait for a wl_frame_callback and setup another
// wl_frame_callback. // wl_frame_callback.
bool wait_for_callback = false; bool wait_for_callback = false;
// Fence to wait on before the |buffer| content is available to read by
// Wayland host.
std::unique_ptr<gfx::GpuFence> access_fence;
}; };
bool CommitBufferInternal(WaylandBuffer* buffer, bool CommitBufferInternal(WaylandBuffer* buffer, bool wait_for_callback) {
bool wait_for_callback,
const gfx::GpuFenceHandle& access_fence_handle) {
DCHECK(buffer && wayland_surface_); DCHECK(buffer && wayland_surface_);
// If the same buffer has been submitted again right after the client // If the same buffer has been submitted again right after the client
...@@ -253,7 +242,7 @@ class WaylandBufferManagerHost::Surface { ...@@ -253,7 +242,7 @@ class WaylandBufferManagerHost::Surface {
// Once the BufferRelease is called, the buffer will be released. // Once the BufferRelease is called, the buffer will be released.
DCHECK(buffer->released); DCHECK(buffer->released);
buffer->released = false; buffer->released = false;
AttachBuffer(buffer, access_fence_handle); AttachBuffer(buffer);
} }
// If the client submits the same buffer twice, we need to store it twice, // If the client submits the same buffer twice, we need to store it twice,
...@@ -289,11 +278,8 @@ class WaylandBufferManagerHost::Surface { ...@@ -289,11 +278,8 @@ class WaylandBufferManagerHost::Surface {
buffer->size); buffer->size);
} }
void AttachBuffer(WaylandBuffer* buffer, void AttachBuffer(WaylandBuffer* buffer) {
const gfx::GpuFenceHandle& access_fence_handle) {
DCHECK(wayland_surface_ && configured_); DCHECK(wayland_surface_ && configured_);
if (!access_fence_handle.is_null())
wayland_surface_->SetAcquireFence(access_fence_handle);
wayland_surface_->AttachBuffer(buffer->wl_buffer.get()); wayland_surface_->AttachBuffer(buffer->wl_buffer.get());
} }
...@@ -566,19 +552,17 @@ class WaylandBufferManagerHost::Surface { ...@@ -566,19 +552,17 @@ class WaylandBufferManagerHost::Surface {
// //
// The third case happens if the window hasn't been configured until a // The third case happens if the window hasn't been configured until a
// request to attach a buffer to its surface is sent. // request to attach a buffer to its surface is sent.
const auto& pending_commit = pending_commits_.front(); auto pending_commit = std::move(pending_commits_.front());
if ((pending_commit.buffer && !pending_commit.buffer->wl_buffer) || if ((pending_commit.buffer && !pending_commit.buffer->wl_buffer) ||
(wl_frame_callback_ && pending_commit.wait_for_callback) || (wl_frame_callback_ && pending_commit.wait_for_callback) ||
!configured_) { !configured_) {
return; return;
} }
auto commit = std::move(pending_commits_.front());
pending_commits_.erase(pending_commits_.begin());
// A Commit without attaching buffers only needs to setup wl_frame_callback. // A Commit without attaching buffers only needs to setup wl_frame_callback.
if (!commit.buffer) { if (!pending_commit.buffer) {
if (commit.wait_for_callback) pending_commits_.erase(pending_commits_.begin());
if (pending_commit.wait_for_callback)
SetupFrameCallback(); SetupFrameCallback();
CommitSurface(); CommitSurface();
connection_->ScheduleFlush(); connection_->ScheduleFlush();
...@@ -586,8 +570,9 @@ class WaylandBufferManagerHost::Surface { ...@@ -586,8 +570,9 @@ class WaylandBufferManagerHost::Surface {
return; return;
} }
CommitBufferInternal(commit.buffer, commit.wait_for_callback, pending_commits_.erase(pending_commits_.begin());
commit.access_fence->GetGpuFenceHandle()); CommitBufferInternal(pending_commit.buffer,
pending_commit.wait_for_callback);
} }
// Widget this helper surface backs and has 1:1 relationship with the // Widget this helper surface backs and has 1:1 relationship with the
...@@ -742,10 +727,6 @@ bool WaylandBufferManagerHost::SupportsDmabuf() const { ...@@ -742,10 +727,6 @@ bool WaylandBufferManagerHost::SupportsDmabuf() const {
(connection_->drm() && connection_->drm()->SupportsDrmPrime()); (connection_->drm() && connection_->drm()->SupportsDrmPrime());
} }
bool WaylandBufferManagerHost::SupportsAcquireFence() const {
return !!connection_->linux_explicit_synchronization_v1();
}
void WaylandBufferManagerHost::SetWaylandBufferManagerGpu( void WaylandBufferManagerHost::SetWaylandBufferManagerGpu(
mojo::PendingAssociatedRemote<ozone::mojom::WaylandBufferManagerGpu> mojo::PendingAssociatedRemote<ozone::mojom::WaylandBufferManagerGpu>
buffer_manager_gpu_associated) { buffer_manager_gpu_associated) {
...@@ -826,16 +807,15 @@ bool WaylandBufferManagerHost::CommitBufferInternal( ...@@ -826,16 +807,15 @@ bool WaylandBufferManagerHost::CommitBufferInternal(
WaylandSurface* wayland_surface, WaylandSurface* wayland_surface,
uint32_t buffer_id, uint32_t buffer_id,
const gfx::Rect& damage_region, const gfx::Rect& damage_region,
bool wait_for_frame_callback, bool wait_for_frame_callback) {
gfx::GpuFenceHandle access_fence_handle) {
DCHECK(base::CurrentUIThread::IsSet()); DCHECK(base::CurrentUIThread::IsSet());
Surface* surface = GetSurface(wayland_surface); Surface* surface = GetSurface(wayland_surface);
if (!surface || !ValidateBufferIdFromGpu(buffer_id)) if (!surface || !ValidateBufferIdFromGpu(buffer_id))
return false; return false;
if (!surface->CommitBuffer(buffer_id, damage_region, wait_for_frame_callback, if (!surface->CommitBuffer(buffer_id, damage_region,
std::move(access_fence_handle))) { wait_for_frame_callback)) {
error_message_ = error_message_ =
base::StrCat({"Buffer with ", NumberToString(buffer_id), base::StrCat({"Buffer with ", NumberToString(buffer_id),
" id does not exist or failed to be created."}); " id does not exist or failed to be created."});
...@@ -881,8 +861,7 @@ void WaylandBufferManagerHost::CommitBuffer(gfx::AcceleratedWidget widget, ...@@ -881,8 +861,7 @@ void WaylandBufferManagerHost::CommitBuffer(gfx::AcceleratedWidget widget,
auto* window = connection_->wayland_window_manager()->GetWindow(widget); auto* window = connection_->wayland_window_manager()->GetWindow(widget);
if (!window) if (!window)
return; return;
CommitBufferInternal(window->root_surface(), buffer_id, damage_region, CommitBufferInternal(window->root_surface(), buffer_id, damage_region);
true);
} }
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/presentation_feedback.h" #include "ui/gfx/presentation_feedback.h"
#include "ui/gfx/swap_result.h" #include "ui/gfx/swap_result.h"
...@@ -110,7 +109,6 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost, ...@@ -110,7 +109,6 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost,
wl::BufferFormatsWithModifiersMap GetSupportedBufferFormats() const; wl::BufferFormatsWithModifiersMap GetSupportedBufferFormats() const;
bool SupportsDmabuf() const; bool SupportsDmabuf() const;
bool SupportsAcquireFence() const;
// ozone::mojom::WaylandBufferManagerHost overrides: // ozone::mojom::WaylandBufferManagerHost overrides:
// //
...@@ -165,15 +163,10 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost, ...@@ -165,15 +163,10 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost,
// commit will move an entire wl_surface tree from pending state to ready // commit will move an entire wl_surface tree from pending state to ready
// state. This root_surface commit must wait for wl_frame_callback, such that // state. This root_surface commit must wait for wl_frame_callback, such that
// in effect all other surface updates wait for this wl_frame_callback, too. // in effect all other surface updates wait for this wl_frame_callback, too.
// |access_fence_handle| specifies a gpu fence created by the gpu process. bool CommitBufferInternal(WaylandSurface* wayland_surface,
// It's to be waited on before content of the buffer is ready to be read by uint32_t buffer_id,
// Wayland host. const gfx::Rect& damage_region,
bool CommitBufferInternal( bool wait_for_frame_callback = true);
WaylandSurface* wayland_surface,
uint32_t buffer_id,
const gfx::Rect& damage_region,
bool wait_for_frame_callback = true,
gfx::GpuFenceHandle access_fence_handle = gfx::GpuFenceHandle());
// Does a wl_surface commit without attaching any buffers. This commit will // Does a wl_surface commit without attaching any buffers. This commit will
// still wait for previous wl_frame_callback. Similar to above but for // still wait for previous wl_frame_callback. Similar to above but for
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_surface.h" #include "ui/ozone/platform/wayland/host/wayland_surface.h"
#include <linux-explicit-synchronization-unstable-v1-client-protocol.h>
#include <viewporter-client-protocol.h> #include <viewporter-client-protocol.h>
#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_conversions.h"
...@@ -53,16 +52,6 @@ bool WaylandSurface::Initialize() { ...@@ -53,16 +52,6 @@ bool WaylandSurface::Initialize() {
} }
} }
// The server needs to support the linux_explicit_synchronization protocol.
if (!connection_->linux_explicit_synchronization_v1()) {
LOG(ERROR)
<< "Server doesn't support zwp_linux_explicit_synchronization_v1.";
return true;
}
surface_sync_.reset(zwp_linux_explicit_synchronization_v1_get_synchronization(
connection_->linux_explicit_synchronization_v1(), surface_.get()));
DCHECK(surface_sync());
return true; return true;
} }
...@@ -71,11 +60,6 @@ void WaylandSurface::UnsetRootWindow() { ...@@ -71,11 +60,6 @@ void WaylandSurface::UnsetRootWindow() {
root_window_ = nullptr; root_window_ = nullptr;
} }
void WaylandSurface::SetAcquireFence(const gfx::GpuFenceHandle& acquire_fence) {
zwp_linux_surface_synchronization_v1_set_acquire_fence(
surface_sync(), acquire_fence.owned_fd.get());
}
void WaylandSurface::AttachBuffer(wl_buffer* buffer) { void WaylandSurface::AttachBuffer(wl_buffer* buffer) {
// The logic in DamageBuffer currently relies on attachment coordinates of // The logic in DamageBuffer currently relies on attachment coordinates of
// (0, 0). If this changes, then the calculation in DamageBuffer will also // (0, 0). If this changes, then the calculation in DamageBuffer will also
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/overlay_transform.h" #include "ui/gfx/overlay_transform.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h" #include "ui/ozone/platform/wayland/common/wayland_object.h"
...@@ -30,9 +29,6 @@ class WaylandSurface { ...@@ -30,9 +29,6 @@ class WaylandSurface {
WaylandWindow* root_window() const { return root_window_; } WaylandWindow* root_window() const { return root_window_; }
wl_surface* surface() const { return surface_.get(); } wl_surface* surface() const { return surface_.get(); }
wp_viewport* viewport() const { return viewport_.get(); } wp_viewport* viewport() const { return viewport_.get(); }
zwp_linux_surface_synchronization_v1* surface_sync() const {
return surface_sync_.get();
}
int32_t buffer_scale() const { return buffer_scale_; } int32_t buffer_scale() const { return buffer_scale_; }
void set_buffer_scale(int32_t scale) { buffer_scale_ = scale; } void set_buffer_scale(int32_t scale) { buffer_scale_ = scale; }
...@@ -51,10 +47,6 @@ class WaylandSurface { ...@@ -51,10 +47,6 @@ class WaylandSurface {
// (e.g: window/tab dragging sessions). // (e.g: window/tab dragging sessions).
void UnsetRootWindow(); void UnsetRootWindow();
// Sets a non-null in-fence, must be combined with an AttachBuffer() and a
// Commit().
void SetAcquireFence(const gfx::GpuFenceHandle& acquire_fence);
// Attaches the given wl_buffer to the underlying wl_surface at (0, 0). // Attaches the given wl_buffer to the underlying wl_surface at (0, 0).
void AttachBuffer(wl_buffer* buffer); void AttachBuffer(wl_buffer* buffer);
...@@ -101,7 +93,6 @@ class WaylandSurface { ...@@ -101,7 +93,6 @@ class WaylandSurface {
WaylandWindow* root_window_ = nullptr; WaylandWindow* root_window_ = nullptr;
wl::Object<wl_surface> surface_; wl::Object<wl_surface> surface_;
wl::Object<wp_viewport> viewport_; wl::Object<wp_viewport> viewport_;
wl::Object<zwp_linux_surface_synchronization_v1> surface_sync_;
// Transformation for how the compositor interprets the contents of the // Transformation for how the compositor interprets the contents of the
// buffer. // buffer.
......
...@@ -588,8 +588,7 @@ bool WaylandWindow::CommitOverlays( ...@@ -588,8 +588,7 @@ bool WaylandWindow::CommitOverlays(
nullptr, reference_above); nullptr, reference_above);
connection_->buffer_manager_host()->CommitBufferInternal( connection_->buffer_manager_host()->CommitBufferInternal(
(*iter)->wayland_surface(), (*overlay_iter)->buffer_id, gfx::Rect(), (*iter)->wayland_surface(), (*overlay_iter)->buffer_id, gfx::Rect(),
/*wait_for_frame_callback=*/false, /*wait_for_frame_callback=*/false);
std::move((*overlay_iter)->access_fence_handle));
} else { } else {
// If there're more subsurfaces requested that we don't need at the // If there're more subsurfaces requested that we don't need at the
// moment, hide them. // moment, hide them.
...@@ -618,8 +617,7 @@ bool WaylandWindow::CommitOverlays( ...@@ -618,8 +617,7 @@ bool WaylandWindow::CommitOverlays(
reference_below, nullptr); reference_below, nullptr);
connection_->buffer_manager_host()->CommitBufferInternal( connection_->buffer_manager_host()->CommitBufferInternal(
(*iter)->wayland_surface(), (*overlay_iter)->buffer_id, gfx::Rect(), (*iter)->wayland_surface(), (*overlay_iter)->buffer_id, gfx::Rect(),
/*wait_for_frame_callback=*/false, /*wait_for_frame_callback=*/false);
std::move((*overlay_iter)->access_fence_handle));
} else { } else {
// If there're more subsurfaces requested that we don't need at the // If there're more subsurfaces requested that we don't need at the
// moment, hide them. // moment, hide them.
...@@ -641,9 +639,7 @@ bool WaylandWindow::CommitOverlays( ...@@ -641,9 +639,7 @@ bool WaylandWindow::CommitOverlays(
(*split)->enable_blend, nullptr, nullptr); (*split)->enable_blend, nullptr, nullptr);
connection_->buffer_manager_host()->CommitBufferInternal( connection_->buffer_manager_host()->CommitBufferInternal(
primary_subsurface_->wayland_surface(), (*split)->buffer_id, primary_subsurface_->wayland_surface(), (*split)->buffer_id,
(*split)->damage_region, (*split)->damage_region, /*wait_for_frame_callback=*/false);
/*wait_for_frame_callback=*/false,
std::move((*split)->access_fence_handle));
} }
root_surface_->SetViewportDestination(bounds_px_.size()); root_surface_->SetViewportDestination(bounds_px_.size());
......
...@@ -84,7 +84,7 @@ class WaylandBufferManagerTest : public WaylandTest { ...@@ -84,7 +84,7 @@ class WaylandBufferManagerTest : public WaylandTest {
// callback and bind the interface again if the manager failed. // callback and bind the interface again if the manager failed.
manager_host_->SetTerminateGpuCallback(callback_.Get()); manager_host_->SetTerminateGpuCallback(callback_.Get());
auto interface_ptr = manager_host_->BindInterface(); auto interface_ptr = manager_host_->BindInterface();
buffer_manager_gpu_->Initialize(std::move(interface_ptr), {}, false, false); buffer_manager_gpu_->Initialize(std::move(interface_ptr), {}, false);
} }
protected: protected:
...@@ -119,7 +119,7 @@ class WaylandBufferManagerTest : public WaylandTest { ...@@ -119,7 +119,7 @@ class WaylandBufferManagerTest : public WaylandTest {
// Recreate the gpu side manager (the production code does the // Recreate the gpu side manager (the production code does the
// same). // same).
buffer_manager_gpu_ = std::make_unique<WaylandBufferManagerGpu>(); buffer_manager_gpu_ = std::make_unique<WaylandBufferManagerGpu>();
buffer_manager_gpu_->Initialize(std::move(interface_ptr), {}, false, buffer_manager_gpu_->Initialize(std::move(interface_ptr), {},
false); false);
})); }));
} }
......
...@@ -95,14 +95,10 @@ interface WaylandBufferManagerGpu { ...@@ -95,14 +95,10 @@ interface WaylandBufferManagerGpu {
// instance to avoid using zwp_linux_dmabuf protocol by setting // instance to avoid using zwp_linux_dmabuf protocol by setting
// |supports_dma_buf| to false, which results in using wl_egl_surface in a // |supports_dma_buf| to false, which results in using wl_egl_surface in a
// single process mode, and software rendering in a multiple process mode. // single process mode, and software rendering in a multiple process mode.
// |supports_acquire_fence| indicates whether acquire fences can be submitted
// with buffers for wayland servers to wait on before accessing buffer
// contents.
Initialize(pending_remote<WaylandBufferManagerHost> remote_host, Initialize(pending_remote<WaylandBufferManagerHost> remote_host,
map<gfx.mojom.BufferFormat, map<gfx.mojom.BufferFormat,
array<uint64>> buffer_formats_with_modifiers, array<uint64>> buffer_formats_with_modifiers,
bool supports_dma_buf, bool supports_dma_buf);
bool supports_acquire_fence);
// Signals about swap completion. // Signals about swap completion.
OnSubmission(gfx.mojom.AcceleratedWidget widget, OnSubmission(gfx.mojom.AcceleratedWidget widget,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment