diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-11-05 18:55:49 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 13:02:20 +0200 |
commit | b8930be6cf6eac7c6182cf84f33aedd23f28558e (patch) | |
tree | 65ad17550c3a623c07ee3ab680ad1d1dfe236b0d | |
parent | 91c671e04316caeeded9357c925c0b5714a94410 (diff) | |
download | qtwebengine-chromium-b8930be6cf6eac7c6182cf84f33aedd23f28558e.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: Alexandru Croitor <alexandru.croitor@qt.io>
-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 | 10 | ||||
-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, 61 insertions, 1 deletions
diff --git a/chromium/ui/gl/gl_fence.h b/chromium/ui/gl/gl_fence.h index 81d80ca9139..66716e16b1e 100644 --- a/chromium/ui/gl/gl_fence.h +++ b/chromium/ui/gl/gl_fence.h @@ -11,8 +11,34 @@ #include "ui/gfx/gpu_fence.h" #include "ui/gl/gl_export.h" +typedef void *EGLDisplay; +typedef void *EGLSyncKHR; +typedef struct __GLsync *GLsync; + namespace gl { +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(); @@ -31,6 +57,8 @@ class GL_EXPORT GLFence { // Create a new GLFence that can be used with GetGpuFence. static std::unique_ptr<GLFence> CreateForGpuFence(); + 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 0a53f493bd6..e47efd8a8a5 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 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 88086052d98..4918105cdca 100644 --- a/chromium/ui/gl/gl_fence_apple.h +++ b/chromium/ui/gl/gl_fence_apple.h @@ -18,6 +18,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 7bc089d8bfc..52d9394df86 100644 --- a/chromium/ui/gl/gl_fence_arb.cc +++ b/chromium/ui/gl/gl_fence_arb.cc @@ -30,6 +30,16 @@ GLFenceARB::GLFenceARB() { glFlush(); } +TransferableFence GLFenceARB::Transfer() { + TransferableFence ret; + if (sync_) { + ret.type = TransferableFence::ArbSync; + ret.arb.sync = sync_; + sync_ = 0; + } + return ret; +} + bool GLFenceARB::HasCompleted() { // Handle the case where FenceSync failed. if (!sync_) diff --git a/chromium/ui/gl/gl_fence_arb.h b/chromium/ui/gl/gl_fence_arb.h index 6b44c01143a..ca4562e7088 100644 --- a/chromium/ui/gl/gl_fence_arb.h +++ b/chromium/ui/gl/gl_fence_arb.h @@ -18,6 +18,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 5973b6e9482..8219cd3d71b 100644 --- a/chromium/ui/gl/gl_fence_egl.cc +++ b/chromium/ui/gl/gl_fence_egl.cc @@ -48,6 +48,15 @@ bool GLFenceEGL::InitializeInternal(EGLenum type, EGLint* attribs) { return sync_ != EGL_NO_SYNC_KHR; } +TransferableFence GLFenceEGL::Transfer() { + TransferableFence ret; + ret.type = 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) != @@ -97,7 +106,8 @@ void GLFenceEGL::Invalidate() { } GLFenceEGL::~GLFenceEGL() { - eglDestroySyncKHR(display_, sync_); + if (sync_ != EGL_NO_SYNC_KHR) + eglDestroySyncKHR(display_, sync_); } } // namespace gl diff --git a/chromium/ui/gl/gl_fence_egl.h b/chromium/ui/gl/gl_fence_egl.h index 946469aeec9..1e2fe996880 100644 --- a/chromium/ui/gl/gl_fence_egl.h +++ b/chromium/ui/gl/gl_fence_egl.h @@ -25,6 +25,7 @@ class GL_EXPORT GLFenceEGL : public GLFence { static std::unique_ptr<GLFenceEGL> Create(EGLenum type, EGLint* attribs); // 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 7a856c39992..431490e7d48 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 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 0831eeaed0a..b2c18312baf 100644 --- a/chromium/ui/gl/gl_fence_nv.h +++ b/chromium/ui/gl/gl_fence_nv.h @@ -18,6 +18,7 @@ class GL_EXPORT GLFenceNV : public GLFence { ~GLFenceNV() override; // GLFence implementation: + TransferableFence Transfer() override; bool ResetSupported() override; void ResetState() override; bool HasCompleted() override; |