From cbaee81f9c7c6af8dcddfba0e87c524a4baf2ac2 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 21 Oct 2016 13:10:47 +1100 Subject: [PATCH] glsyncmeta: don't glFinish() everytime a sync point is set At minimum, we only need to glFlush() if we are in a shared GL context environment. Move the glFinish() to when the actual wait is requested which may be never. Improves the throughput on older GL systems without GL3/GLES3 and/or fence sync objects. --- gst-libs/gst/gl/gstglsyncmeta.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/gl/gstglsyncmeta.c b/gst-libs/gst/gl/gstglsyncmeta.c index b4061d344d..582784c94c 100644 --- a/gst-libs/gst/gl/gstglsyncmeta.c +++ b/gst-libs/gst/gl/gstglsyncmeta.c @@ -53,16 +53,11 @@ _default_set_sync_gl (GstGLSyncMeta * sync_meta, GstGLContext * context) } sync_meta->data = (gpointer) gl->FenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - - if (gst_gl_context_is_shared (context)) - /* if we only have a single context, the wait will flush for us */ - gl->Flush (); GST_LOG ("setting sync object %p", sync_meta->data); - } else { - /* XXX: this a little over the top if the CPU is never going to - * access the data, however this is the legacy path, so... */ - gl->Finish (); } + + if (gst_gl_context_is_shared (context)) + gl->Flush (); } static void @@ -89,6 +84,8 @@ _default_wait_cpu_gl (GstGLSyncMeta * sync_meta, GstGLContext * context) gl->ClientWaitSync ((GLsync) sync_meta->data, GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000 /* 1s */ ); } while (res == GL_TIMEOUT_EXPIRED); + } else { + gl->Finish (); } }