summaryrefslogtreecommitdiffstats
path: root/ui/gl
diff options
context:
space:
mode:
authorepenner@chromium.org <epenner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-22 13:47:20 +0000
committerepenner@chromium.org <epenner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-22 13:47:20 +0000
commit398fe4b95fab7cb60599380f75ac57b94fcc3d08 (patch)
tree1cd91ebe721a4f97862228d13e001272e472a1e1 /ui/gl
parent579d6996697140d5042b148ecab4bba5abc3c9e2 (diff)
downloadchromium_src-398fe4b95fab7cb60599380f75ac57b94fcc3d08.zip
chromium_src-398fe4b95fab7cb60599380f75ac57b94fcc3d08.tar.gz
chromium_src-398fe4b95fab7cb60599380f75ac57b94fcc3d08.tar.bz2
gpu: Add EGL fence support.
Adds fence support for EGL. BUG= Review URL: https://chromiumcodereview.appspot.com/14358014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl')
-rwxr-xr-xui/gl/generate_bindings.py4
-rw-r--r--ui/gl/gl_fence.cc51
-rw-r--r--ui/gl/gl_fence.h1
3 files changed, 51 insertions, 5 deletions
diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py
index 968ec77..173845d 100755
--- a/ui/gl/generate_bindings.py
+++ b/ui/gl/generate_bindings.py
@@ -678,6 +678,10 @@ GL_FUNCTIONS = [
'GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length,'
'GLint* values', },
{ 'return_type': 'void',
+ 'names': ['glClientWaitSync'],
+ 'arguments':
+ 'GLsync sync, GLbitfield flags, GLuint64 timeout', },
+{ 'return_type': 'void',
'names': ['glDrawArraysInstancedANGLE', 'glDrawArraysInstancedARB'],
'arguments': 'GLenum mode, GLint first, GLsizei count, GLsizei primcount', },
{ 'return_type': 'void',
diff --git a/ui/gl/gl_fence.cc b/ui/gl/gl_fence.cc
index 9a40ec2..68aa88b 100644
--- a/ui/gl/gl_fence.cc
+++ b/ui/gl/gl_fence.cc
@@ -32,6 +32,10 @@ class GLFenceNVFence: public gfx::GLFence {
return !!glTestFenceNV(fence_);
}
+ virtual void ClientWait() OVERRIDE {
+ glFinishFenceNV(fence_);
+ }
+
private:
virtual ~GLFenceNVFence() {
glDeleteFencesNV(1, &fence_);
@@ -62,6 +66,10 @@ class GLFenceARBSync: public gfx::GLFence {
return length == 1 && value == GL_SIGNALED;
}
+ virtual void ClientWait() OVERRIDE {
+ glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
+ }
+
private:
virtual ~GLFenceARBSync() {
glDeleteSync(sync_);
@@ -70,6 +78,37 @@ class GLFenceARBSync: public gfx::GLFence {
GLsync sync_;
};
+#if !defined(OS_MACOSX)
+class EGLFenceSync : public gfx::GLFence {
+ public:
+ EGLFenceSync() {
+ display_ = eglGetCurrentDisplay();
+ sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
+ }
+
+ virtual bool HasCompleted() OVERRIDE {
+ EGLint value = 0;
+ eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value);
+ DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR);
+ return !value || value == EGL_SIGNALED_KHR;
+ }
+
+ virtual void ClientWait() OVERRIDE {
+ EGLint flags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR;
+ EGLTimeKHR time = EGL_FOREVER_KHR;
+ eglClientWaitSyncKHR(display_, sync_, flags, time);
+ }
+
+ private:
+ virtual ~EGLFenceSync() {
+ eglDestroySyncKHR(display_, sync_);
+ }
+
+ EGLSyncKHR sync_;
+ EGLDisplay display_;
+};
+#endif // !OS_MACOSX
+
} // namespace
namespace gfx {
@@ -82,13 +121,15 @@ GLFence::~GLFence() {
// static
GLFence* GLFence::Create() {
- if (gfx::g_driver_gl.ext.b_GL_NV_fence) {
+#if !defined(OS_MACOSX)
+ if (gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync)
+ return new EGLFenceSync();
+#endif
+ if (gfx::g_driver_gl.ext.b_GL_NV_fence)
return new GLFenceNVFence();
- } else if (gfx::g_driver_gl.ext.b_GL_ARB_sync) {
+ if (gfx::g_driver_gl.ext.b_GL_ARB_sync)
return new GLFenceARBSync();
- } else {
- return NULL;
- }
+ return NULL;
}
} // namespace gfx
diff --git a/ui/gl/gl_fence.h b/ui/gl/gl_fence.h
index 6dec821..d4f3218 100644
--- a/ui/gl/gl_fence.h
+++ b/ui/gl/gl_fence.h
@@ -17,6 +17,7 @@ class GL_EXPORT GLFence {
static GLFence* Create();
virtual bool HasCompleted() = 0;
+ virtual void ClientWait() = 0;
protected:
static bool IsContextLost();