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.
This commit is contained in:
Matthew Waters 2015-12-14 18:20:23 +11:00
parent 5d0d2ec6ca
commit 41c3cb30d4

View file

@ -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 */
}