diff options
author | Matthew Waters <matthew@centricular.com> | 2015-07-20 18:19:02 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2015-07-20 18:19:02 +1000 |
commit | d13201fedb87100e2fd2c3a9f1363ee2e2c95d97 (patch) | |
tree | c323aced09baf043f430b50e6f64c6ca62b98d13 /gst-libs | |
parent | d5996de5d7b2153f70edda60e993406137ee19b8 (diff) | |
download | gstreamer-plugins-bad-d13201fedb87100e2fd2c3a9f1363ee2e2c95d97.tar.gz |
glmemory: check for pbo availability before attempting pbo download
https://bugzilla.gnome.org/show_bug.cgi?id=751165
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/gl/gstglmemory.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index d2f768703..e1818fbc8 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -740,18 +740,20 @@ static gpointer _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; @@ -779,12 +781,13 @@ _gl_mem_download_get_tex_image (GstGLMemory * gl_mem, GstMapInfo * info, && 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) @@ -805,10 +808,10 @@ _gl_mem_download_read_pixels (GstGLMemory * gl_mem, GstMapInfo * info, 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; } @@ -819,9 +822,13 @@ _gl_mem_download_read_pixels (GstGLMemory * gl_mem, GstMapInfo * info, 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); @@ -1347,7 +1354,9 @@ _download_transfer (GstGLContext * context, GstGLMemory * gl_mem) 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); } |