Commit ddd5a914 authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Commit Bot

ozone: Add support for using overlay plane fences in ozone_demo

This commit prepares ozone_demo to use GpuFences for overlay planes,
when support for them lands in any of the Ozone backends. The
--use-gpu-fences ozone_demo flag controls whether to enable the use of
fences or use the existing glFinish mechanism.

Bug: 828393
Test: Run ozone_demo on Ozone-DRM
Change-Id: I797e9445479ff4a9768cb89033d1dd6fd826b5ae
Reviewed-on: https://chromium-review.googlesource.com/1021693
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559412}
parent 44005800
...@@ -39,15 +39,16 @@ int main(int argc, char** argv) { ...@@ -39,15 +39,16 @@ int main(int argc, char** argv) {
logging::InitLogging(settings); logging::InitLogging(settings);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(kHelp)) { if (base::CommandLine::ForCurrentProcess()->HasSwitch(kHelp)) {
std::cout << std::cout << "Usage:\n\n"
"Usage:\n\n" " --disable-gpu Force software rendering\n"
" --disable-gpu Force software rendering\n" " --disable-surfaceless Don't use surfaceless EGL\n"
" --disable-surfaceless Don't use surfaceless EGL\n" " --window-size=WIDTHxHEIGHT Specify window size\n"
" --window-size=WIDTHxHEIGHT Specify window size\n" " --partial-primary-plane "
" --partial-primary-plane " "Use smaller than fullscreen primary plane\n"
"Use smaller than fullscreen primary plane\n" " --enable-overlay Use an overlay plane\n"
" --enable-overlay Use an overlay plane\n" " --disable-primary-plane Don't use the primary plane\n"
" --disable-primary-plane Don't use the primary plane\n"; " --use-gpu-fences "
"Use GpuFences for buffer display synchronization\n";
// TODO(hoegsberg): We should add a little more help text about how these // TODO(hoegsberg): We should add a little more help text about how these
// options interact and depend on each other. // options interact and depend on each other.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ui/gfx/gpu_fence.h" #include "ui/gfx/gpu_fence.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
#include "ui/gl/gl_image.h" #include "ui/gl/gl_image.h"
#include "ui/gl/gl_image_native_pixmap.h" #include "ui/gl/gl_image_native_pixmap.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
...@@ -173,11 +174,22 @@ bool SurfacelessGlRenderer::Initialize() { ...@@ -173,11 +174,22 @@ bool SurfacelessGlRenderer::Initialize() {
glViewport(0, 0, overlay_size.width(), overlay_size.height()); glViewport(0, 0, overlay_size.width(), overlay_size.height());
glClearColor(i, 1.0, 0.0, 1.0); glClearColor(i, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Ensure that the rendering has been committed to the buffer and thus
// that the buffer is ready for display without additional
// synchronization. This allows us to avoid using fences for display
// synchronization of the non-overlay buffers in RenderFrame.
glFinish();
} }
} }
disable_primary_plane_ = command_line->HasSwitch("disable-primary-plane"); disable_primary_plane_ = command_line->HasSwitch("disable-primary-plane");
use_gpu_fences_ = command_line->HasSwitch("use-gpu-fences");
// The GLSurface needs to be prepared to accept plane fences,
// otherwise any fences sent to it will be ignored.
if (use_gpu_fences_)
surface_->SetUsePlaneGpuFences();
// Schedule the initial render. // Schedule the initial render.
PostRenderFrameTask(gfx::SwapResult::SWAP_ACK); PostRenderFrameTask(gfx::SwapResult::SWAP_ACK);
return true; return true;
...@@ -229,10 +241,20 @@ void SurfacelessGlRenderer::RenderFrame() { ...@@ -229,10 +241,20 @@ void SurfacelessGlRenderer::RenderFrame() {
if (!disable_primary_plane_) { if (!disable_primary_plane_) {
CHECK(overlay_list.front().overlay_handled); CHECK(overlay_list.front().overlay_handled);
// Optionally use a fence to synchronize overlay plane display, if
// requested when invoking ozone_demo. Note that currently only the primary
// plane needs to use a fence, since its buffers are dynamically updated
// every frame. The buffers for non-primary planes are only drawn to during
// initialization and guaranteed to be ready for display (see Initialize),
// so no additional fence synchronization is needed for them.
std::unique_ptr<gl::GLFence> gl_fence =
use_gpu_fences_ ? gl::GLFence::CreateForGpuFence() : nullptr;
surface_->ScheduleOverlayPlane( surface_->ScheduleOverlayPlane(
0, gfx::OVERLAY_TRANSFORM_NONE, buffers_[back_buffer_]->image(), 0, gfx::OVERLAY_TRANSFORM_NONE, buffers_[back_buffer_]->image(),
primary_plane_rect_, gfx::RectF(0, 0, 1, 1), false, primary_plane_rect_, gfx::RectF(0, 0, 1, 1), false,
/* gpu_fence */ nullptr); gl_fence ? gl_fence->GetGpuFence() : nullptr);
} }
if (overlay_buffers_[0] && overlay_list.back().overlay_handled) { if (overlay_buffers_[0] && overlay_list.back().overlay_handled) {
......
...@@ -59,6 +59,7 @@ class SurfacelessGlRenderer : public RendererBase { ...@@ -59,6 +59,7 @@ class SurfacelessGlRenderer : public RendererBase {
std::unique_ptr<BufferWrapper> overlay_buffers_[2]; std::unique_ptr<BufferWrapper> overlay_buffers_[2];
bool disable_primary_plane_ = false; bool disable_primary_plane_ = false;
gfx::Rect primary_plane_rect_; gfx::Rect primary_plane_rect_;
bool use_gpu_fences_ = false;
std::unique_ptr<OverlayCandidatesOzone> overlay_checker_; std::unique_ptr<OverlayCandidatesOzone> overlay_checker_;
......
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