summaryrefslogtreecommitdiffstats
path: root/src/core/chromium_gpu_helper.cpp
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-28 19:43:36 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-09-01 15:48:54 +0200
commit5b8e3ecf388d9f8921412822049ef90565553067 (patch)
treea6d98800f9095dd79ab355e8831d92c565a48458 /src/core/chromium_gpu_helper.cpp
parent41efc54901905167d312e5a1974215efd592fee1 (diff)
Wait on sync point fences instead of creating a new fence
Posting a runnable on the GPU thread's message loop and creating a GL fence sync there assumes that there is a current GL context, and that synchronizing with this context will make sure that we wait for all GL context producing any of our consumed texture mailboxes. This is however not always the case like when: - The current GL context on the GPU thread is destroyed right before our runnable is handled, displaying errors on the console that glFlush needs a current context. - The GL driver will do extra scheduling and let the scene graph thread synchronize its GL command stream only with the GL context in which the fence sync was created. To remedy the situation, make sure that Chromium creates a fence sync for every sync points associated with a mailbox that we consume and do so directly in the GL context associated with the originating glInsertSyncPointCHROMIUM call. Wait for all those syncs on the Qt side afterward. This might also help with a few erratic behaviors noticed on some embedded GL drivers. Change-Id: I5fc60fcf51497477b2e1b3a535d0a141954fc6e5 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/core/chromium_gpu_helper.cpp')
-rw-r--r--src/core/chromium_gpu_helper.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/core/chromium_gpu_helper.cpp b/src/core/chromium_gpu_helper.cpp
index c4cb2ec0b..6287bd7c0 100644
--- a/src/core/chromium_gpu_helper.cpp
+++ b/src/core/chromium_gpu_helper.cpp
@@ -57,27 +57,17 @@ static void addSyncPointCallbackDelegate(content::SyncPointManager *syncPointMan
syncPointManager->AddSyncPointCallback(sync_point, callback);
}
-FenceSync createFence()
+QMap<uint32, gfx::TransferableFence> transferFences()
{
- FenceSync ret;
- // Logic taken from chromium/ui/gl/gl_fence.cc
-#if !defined(OS_MACOSX)
- if (gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync) {
- ret.type = FenceSync::EglSync;
- ret.egl.display = eglGetCurrentDisplay();
- ret.egl.sync = eglCreateSyncKHR(ret.egl.display, EGL_SYNC_FENCE_KHR, NULL);
- } else
-#endif
- if (gfx::g_driver_gl.ext.b_GL_ARB_sync) {
- ret.type = FenceSync::ArbSync;
- ret.arb.sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+ QMap<uint32, gfx::TransferableFence> ret;
+ content::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->ChannelManager();
+ content::GpuChannelManager::SyncPointGLFences::iterator it = gpuChannelManager->sync_point_gl_fences_.begin();
+ content::GpuChannelManager::SyncPointGLFences::iterator end = gpuChannelManager->sync_point_gl_fences_.end();
+ for (; it != end; ++it) {
+ ret[it->first] = it->second->Transfer();
+ delete it->second;
}
-
- // glFlush is necessary to make sure that our fence creation reaches the GL server
- // before we try waiting on it from a different context, which could deadlock.
- // In cases where no fence extension is available, this also serves as flushing
- // Chromium's GL context command stream before yielding to the SG thread.
- glFlush();
+ gpuChannelManager->sync_point_gl_fences_.clear();
return ret;
}