Commit 5addbd55 authored by dbehr's avatar dbehr Committed by Commit bot

Add EGL_ARM_implicit_external_sync extension support

And use it to flush rendering before page flip.

BUG=412508,442605
TEST=build and run Chrome on jerry/freon. It should render one frame.
R=alexst@chromium.org
R=dnicoara@chromium.org
R=kbr@chromium.org
R=piman@chromium.org
Signed-off-by: default avatarDominik Behr <dbehr@chromium.org>

Review URL: https://codereview.chromium.org/903063003

Cr-Commit-Position: refs/heads/master@{#315171}
parent b8be6ae0
......@@ -563,6 +563,11 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy,
#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285
#endif
#ifndef EGL_ARM_implicit_external_sync
#define EGL_ARM_implicit_external_sync 1
#define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A
#endif /* EGL_ARM_implicit_external_sync */
#ifdef __cplusplus
}
#endif
......
......@@ -33,6 +33,8 @@ GLES2/gl2ext.h
EGL/eglplatform.h
- Added EGLNative*Type for Mac.
- Added EGLNative*Type for native linux framebuffers.
EGL/eglext.h
- Added EGL_ARM_implicit_external_sync extension tokens
KHR/khrplatform.h
- Modified KHRONOS_APICALL and KHRONOS_APIENTRY
DEPS
......
......@@ -105,7 +105,9 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL {
AcceleratedWidget widget)
: SurfacelessEGL(gfx::Size()),
ozone_surface_(ozone_surface.Pass()),
widget_(widget) {}
widget_(widget),
has_implicit_external_sync_(
HasEGLExtension("EGL_ARM_implicit_external_sync")) {}
bool Initialize() override {
if (!SurfacelessEGL::Initialize())
......@@ -122,8 +124,8 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL {
return SurfacelessEGL::Resize(size);
}
bool SwapBuffers() override {
// TODO: this should be replaced by a fence when supported by the driver.
glFlush();
if (!Flush())
return false;
return ozone_surface_->OnSwapBuffers();
}
bool ScheduleOverlayPlane(int z_order,
......@@ -143,8 +145,8 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL {
return true;
}
bool SwapBuffersAsync(const SwapCompletionCallback& callback) override {
// TODO: this should be replaced by a fence when supported by the driver.
glFlush();
if (!Flush())
return false;
return ozone_surface_->OnSwapBuffersAsync(callback);
}
bool PostSubBufferAsync(int x,
......@@ -160,11 +162,35 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL {
Destroy(); // EGL surface must be destroyed before SurfaceOzone
}
bool Flush() {
glFlush();
// TODO: the following should be replaced by a per surface flush as it gets
// implemented in GL drivers.
if (has_implicit_external_sync_) {
const EGLint attrib_list[] = {
EGL_SYNC_CONDITION_KHR,
EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM,
EGL_NONE};
EGLSyncKHR fence =
eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attrib_list);
if (fence) {
// TODO(dbehr): piman@ suggests we could improve here by moving
// following wait to right before drmModePageFlip crbug.com/456417.
eglClientWaitSyncKHR(GetDisplay(), fence,
EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
eglDestroySyncKHR(GetDisplay(), fence);
} else {
return false;
}
}
return true;
}
// The native surface. Deleting this is allowed to free the EGLNativeWindow.
scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_;
AcceleratedWidget widget_;
scoped_ptr<VSyncProvider> vsync_provider_;
bool has_implicit_external_sync_;
DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfaceless);
};
......
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