glmemory: Handle upload/download flags from map

Problem was that if buffer was mapped READWRITE (state of buffers from
libav right now), mapping it READ/GL will not upload. This is because the
flag is only set when the buffer is unmapped. We can fix this by setting
the flags in map. This result in already mapped buffer that get mapped
to be read in GL will be uploaded. The problem is that if the write
mapper makes modification afterward, the modification will never get
uploaded.

https://bugzilla.gnome.org/show_bug.cgi?id=740900
This commit is contained in:
Nicolas Dufresne 2014-11-22 11:25:23 -05:00 committed by Nicolas Dufresne
parent 4f3c33af3a
commit da3ae06cd1
2 changed files with 11 additions and 16 deletions

View file

@ -653,9 +653,13 @@ _gl_mem_map (GstGLMemory * gl_mem, gsize maxsize, GstMapFlags flags)
(GstGLContextThreadFunc) _upload_memory, gl_mem);
GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD);
}
} else {
}
if ((flags & GST_MAP_WRITE) == GST_MAP_WRITE) {
GST_CAT_TRACE (GST_CAT_GL_MEMORY, "mapping GL texture:%u for writing",
gl_mem->tex_id);
GST_GL_MEMORY_FLAG_SET (gl_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD);
}
data = &gl_mem->tex_id;
@ -669,33 +673,25 @@ _gl_mem_map (GstGLMemory * gl_mem, gsize maxsize, GstMapFlags flags)
(GstGLContextThreadFunc) _download_memory, gl_mem);
GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
}
} else {
}
if ((flags & GST_MAP_WRITE) == GST_MAP_WRITE) {
GST_CAT_TRACE (GST_CAT_GL_MEMORY,
"mapping GL texture:%u for writing to system memory", gl_mem->tex_id);
GST_GL_MEMORY_FLAG_SET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD);
GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
}
data = gl_mem->data;
}
gl_mem->map_flags = flags;
return data;
}
static void
_gl_mem_unmap (GstGLMemory * gl_mem)
{
if ((gl_mem->map_flags & GST_MAP_WRITE) == GST_MAP_WRITE) {
if ((gl_mem->map_flags & GST_MAP_GL) == GST_MAP_GL) {
GST_GL_MEMORY_FLAG_SET (gl_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD);
} else {
GST_GL_MEMORY_FLAG_SET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD);
GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
}
}
gl_mem->map_flags = 0;
/* nothing to do here */
}
static void

View file

@ -90,7 +90,6 @@ struct _GstGLMemory
gfloat tex_scaling[2];
/* <private> */
GstMapFlags map_flags;
gpointer data;
gboolean data_wrapped;