From 41c3cb30d4aa19fab15f5e46f85a2ff50939e729 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 14 Dec 2015 18:20:23 +1100 Subject: [PATCH] glbuffer: bind/unbind on map/unmap for GL mappings Bind the handle to the GL target on map/unmap to save the caller from handling this themselves. --- gst-libs/gst/gl/gstglbuffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gst-libs/gst/gl/gstglbuffer.c b/gst-libs/gst/gl/gstglbuffer.c index 32305c52b2..5d8db2ede7 100644 --- a/gst-libs/gst/gl/gstglbuffer.c +++ b/gst-libs/gst/gl/gstglbuffer.c @@ -201,10 +201,13 @@ gst_gl_buffer_upload_cpu_write (GstGLBuffer * mem, GstMapInfo * info, static gpointer _gl_buffer_map (GstGLBuffer * mem, GstMapInfo * info, gsize size) { + const GstGLFuncs *gl = mem->mem.context->gl_vtable; + if ((info->flags & GST_MAP_GL) != 0) { if (info->flags & GST_MAP_READ) { gst_gl_buffer_upload_cpu_write (mem, info, size); } + gl->BindBuffer (mem->target, mem->id); return &mem->id; } else { return gst_gl_buffer_cpu_access (mem, info, size); @@ -216,6 +219,11 @@ _gl_buffer_map (GstGLBuffer * mem, GstMapInfo * info, gsize size) static void _gl_buffer_unmap (GstGLBuffer * mem, GstMapInfo * info) { + const GstGLFuncs *gl = mem->mem.context->gl_vtable; + + if ((info->flags & GST_MAP_GL) != 0) { + gl->BindBuffer (mem->target, 0); + } /* XXX: optimistically transfer data */ }