diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-11-05 18:55:49 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-05-10 17:16:28 +0200 |
commit | 29e1513a00a3356597a805dfecf96c3ba946afcc (patch) | |
tree | 5e8121a8aa9a970570dfd21bbbec9817c696e905 | |
parent | b970ab1d3af7f5c0ca7222c2a8aa20ef72a9951c (diff) | |
download | qtwebengine-chromium-29e1513a00a3356597a805dfecf96c3ba946afcc.tar.gz |
Add POD TransferableFence
Since Qt is consuming those textures in a different thread,
synchronizing when commands are handed down to GL isn't always enough.
The GL driver could decide to do additional scheduling and end up
executing Qt's consuming GL commands before Chromium's producing ones
even if they were sent to their respective context in the right order.
gfx::GLFence can now be converted to a POD TransferableFence to allow
waiting for or destroying the sync using a QOpenGLContext, which
gl_fence.cc wouldn't be able to use through Chromium's GL function
table.
Task-number: QTBUG-42295
Change-Id: I5aed0df7adca9c95eda71925399d39fd770fffa1
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
-rw-r--r-- | chromium/ui/gl/gl_fence.h | 28 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_apple.cc | 4 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_apple.h | 1 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_arb.cc | 15 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_arb.h | 1 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_egl.cc | 12 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_egl.h | 1 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_nv.cc | 4 | ||||
-rw-r--r-- | chromium/ui/gl/gl_fence_nv.h | 1 |
9 files changed, 64 insertions, 3 deletions
diff --git a/chromium/ui/gl/gl_fence.h b/chromium/ui/gl/gl_fence.h index 2f7a8772f9d..730e67929b2 100644 --- a/chromium/ui/gl/gl_fence.h +++ b/chromium/ui/gl/gl_fence.h @@ -8,8 +8,34 @@ #include "base/macros.h" #include "ui/gl/gl_export.h" +typedef void *EGLDisplay; +typedef void *EGLSyncKHR; +typedef struct __GLsync *GLsync; + namespace gfx { +union TransferableFence { + enum SyncType { + NoSync, + EglSync, + ArbSync + }; + SyncType type; + struct { + SyncType type; + EGLDisplay display; + EGLSyncKHR sync; + } egl; + struct { + SyncType type; + GLsync sync; + } arb; + + TransferableFence() : type(NoSync) { } + operator bool() { return type != NoSync; } + void reset() { type = NoSync; } +}; + class GL_EXPORT GLFence { public: GLFence(); @@ -18,6 +44,8 @@ class GL_EXPORT GLFence { static bool IsSupported(); static GLFence* Create(); + virtual TransferableFence Transfer() = 0; + virtual bool HasCompleted() = 0; virtual void ClientWait() = 0; diff --git a/chromium/ui/gl/gl_fence_apple.cc b/chromium/ui/gl/gl_fence_apple.cc index 3b5f697da50..086fd8a6145 100644 --- a/chromium/ui/gl/gl_fence_apple.cc +++ b/chromium/ui/gl/gl_fence_apple.cc @@ -15,6 +15,10 @@ GLFenceAPPLE::GLFenceAPPLE() { glFlush(); } +TransferableFence GLFenceAPPLE::Transfer() { + return gfx::TransferableFence(); +} + bool GLFenceAPPLE::HasCompleted() { DCHECK(glIsFenceAPPLE(fence_)); return !!glTestFenceAPPLE(fence_); diff --git a/chromium/ui/gl/gl_fence_apple.h b/chromium/ui/gl/gl_fence_apple.h index 5458e0d1c12..0beb90e7e45 100644 --- a/chromium/ui/gl/gl_fence_apple.h +++ b/chromium/ui/gl/gl_fence_apple.h @@ -17,6 +17,7 @@ class GL_EXPORT GLFenceAPPLE : public GLFence { ~GLFenceAPPLE() override; // GLFence implementation: + TransferableFence Transfer() override; bool HasCompleted() override; void ClientWait() override; void ServerWait() override; diff --git a/chromium/ui/gl/gl_fence_arb.cc b/chromium/ui/gl/gl_fence_arb.cc index 5c6b3371108..41d54cea212 100644 --- a/chromium/ui/gl/gl_fence_arb.cc +++ b/chromium/ui/gl/gl_fence_arb.cc @@ -29,6 +29,16 @@ GLFenceARB::GLFenceARB() { glFlush(); } +TransferableFence GLFenceARB::Transfer() { + gfx::TransferableFence ret; + if (sync_) { + ret.type = gfx::TransferableFence::ArbSync; + ret.arb.sync = sync_; + sync_ = 0; + } + return ret; +} + bool GLFenceARB::HasCompleted() { // Handle the case where FenceSync failed. if (!sync_) @@ -61,8 +71,9 @@ void GLFenceARB::ServerWait() { } GLFenceARB::~GLFenceARB() { - DCHECK_EQ(GL_TRUE, glIsSync(sync_)); - glDeleteSync(sync_); + DCHECK_EQ(GL_TRUE, !sync_ || glIsSync(sync_)); + if (sync_) + glDeleteSync(sync_); } } // namespace gfx diff --git a/chromium/ui/gl/gl_fence_arb.h b/chromium/ui/gl/gl_fence_arb.h index 3975efec7e1..3c97f0271c1 100644 --- a/chromium/ui/gl/gl_fence_arb.h +++ b/chromium/ui/gl/gl_fence_arb.h @@ -17,6 +17,7 @@ class GL_EXPORT GLFenceARB : public GLFence { ~GLFenceARB() override; // GLFence implementation: + TransferableFence Transfer() override; bool HasCompleted() override; void ClientWait() override; void ServerWait() override; diff --git a/chromium/ui/gl/gl_fence_egl.cc b/chromium/ui/gl/gl_fence_egl.cc index ce6583d6325..201f36261d9 100644 --- a/chromium/ui/gl/gl_fence_egl.cc +++ b/chromium/ui/gl/gl_fence_egl.cc @@ -27,6 +27,15 @@ GLFenceEGL::GLFenceEGL() { glFlush(); } +TransferableFence GLFenceEGL::Transfer() { + gfx::TransferableFence ret; + ret.type = gfx::TransferableFence::EglSync; + ret.egl.display = display_; + ret.egl.sync = sync_; + sync_ = EGL_NO_SYNC_KHR; + return ret; +} + bool GLFenceEGL::HasCompleted() { EGLint value = 0; if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) != @@ -66,7 +75,8 @@ void GLFenceEGL::ServerWait() { } GLFenceEGL::~GLFenceEGL() { - eglDestroySyncKHR(display_, sync_); + if (sync_ != EGL_NO_SYNC_KHR) + eglDestroySyncKHR(display_, sync_); } } // namespace gfx diff --git a/chromium/ui/gl/gl_fence_egl.h b/chromium/ui/gl/gl_fence_egl.h index 5b6006c1972..5e022f09ebd 100644 --- a/chromium/ui/gl/gl_fence_egl.h +++ b/chromium/ui/gl/gl_fence_egl.h @@ -19,6 +19,7 @@ class GL_EXPORT GLFenceEGL : public GLFence { ~GLFenceEGL() override; // GLFence implementation: + TransferableFence Transfer() override; bool HasCompleted() override; void ClientWait() override; void ServerWait() override; diff --git a/chromium/ui/gl/gl_fence_nv.cc b/chromium/ui/gl/gl_fence_nv.cc index df972bd4b5e..25156df1f58 100644 --- a/chromium/ui/gl/gl_fence_nv.cc +++ b/chromium/ui/gl/gl_fence_nv.cc @@ -33,6 +33,10 @@ void GLFenceNV::ResetState() { glFlush(); } +TransferableFence GLFenceNV::Transfer() { + return gfx::TransferableFence(); +} + bool GLFenceNV::HasCompleted() { DCHECK(glIsFenceNV(fence_)); return !!glTestFenceNV(fence_); diff --git a/chromium/ui/gl/gl_fence_nv.h b/chromium/ui/gl/gl_fence_nv.h index 488251b777a..b6fed9a3e47 100644 --- a/chromium/ui/gl/gl_fence_nv.h +++ b/chromium/ui/gl/gl_fence_nv.h @@ -17,6 +17,7 @@ class GL_EXPORT GLFenceNV : public GLFence { ~GLFenceNV() override; // GLFence implementation: + TransferableFence Transfer() override; bool ResetSupported() override; void ResetState() override; bool HasCompleted() override; |