_pbo_download_transfer (GstGLMemory * gl_mem, GstMapInfo * info, gsize size)
{
GstGLBaseBufferAllocatorClass *alloc_class;
- gpointer data;
-
- GST_DEBUG ("downloading texture %u using pbo %u", gl_mem->tex_id,
- gl_mem->mem.id);
+ gpointer data = NULL;
alloc_class =
GST_GL_BASE_BUFFER_ALLOCATOR_CLASS (gst_gl_allocator_parent_class);
/* texture -> pbo */
- if (info->flags & GST_MAP_READ)
+ if (info->flags & GST_MAP_READ
+ && gl_mem->transfer_state & GST_GL_MEMORY_TRANSFER_NEED_DOWNLOAD) {
+ GST_CAT_TRACE (GST_CAT_GL_MEMORY, "attempting download of texture %u "
+ "using pbo %u", gl_mem->tex_id, gl_mem->mem.id);
+
if (!_read_pixels_to_pbo (gl_mem))
return NULL;
+ }
/* get a cpu accessible mapping from the pbo */
gl_mem->mem.target = GL_PIXEL_PACK_BUFFER;
&& gl_mem->tex_type != GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA)
return NULL;
- gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) gl_mem);
-
if (info->flags & GST_MAP_READ
&& gl_mem->transfer_state & GST_GL_MEMORY_TRANSFER_NEED_DOWNLOAD) {
guint format, type;
+ GST_CAT_TRACE (GST_CAT_GL_MEMORY, "attempting download of texture %u "
+ "using glGetTexImage", gl_mem->tex_id);
+
format = gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
type = GL_UNSIGNED_BYTE;
if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
if (size != -1 && size != ((GstMemory *) gl_mem)->maxsize)
return NULL;
- gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) gl_mem);
-
if (info->flags & GST_MAP_READ
&& gl_mem->transfer_state & GST_GL_MEMORY_TRANSFER_NEED_DOWNLOAD) {
+ GST_CAT_TRACE (GST_CAT_GL_MEMORY, "attempting download of texture %u "
+ "using glReadPixels", gl_mem->tex_id);
if (!_gl_mem_read_pixels (gl_mem, gl_mem->mem.data))
return NULL;
}
static gpointer
_gl_mem_map_cpu_access (GstGLMemory * gl_mem, GstMapInfo * info, gsize size)
{
- gpointer data;
+ gpointer data = NULL;
+
+ gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) gl_mem);
- data = _pbo_download_transfer (gl_mem, info, size);
+ if (!data && gl_mem->mem.id
+ && CONTEXT_SUPPORTS_PBO_DOWNLOAD (gl_mem->mem.context))
+ data = _pbo_download_transfer (gl_mem, info, size);
if (!data)
data = _gl_mem_download_get_tex_image (gl_mem, info, size);
GstGLBaseBuffer *mem = (GstGLBaseBuffer *) gl_mem;
g_mutex_lock (&mem->lock);
- _read_pixels_to_pbo (gl_mem);
+ if (_read_pixels_to_pbo (gl_mem))
+ GST_CAT_TRACE (GST_CAT_GL_MEMORY, "optimistic download of texture %u "
+ "using pbo %u", gl_mem->tex_id, gl_mem->mem.id);
g_mutex_unlock (&mem->lock);
}