Commit graph

111 commits

Author SHA1 Message Date
Matthew Waters
8ccf3dc589 glmemory: add wrapped data pointers to setup_buffer
Allows creating wrapped memories with GstGLAllocationParams.

The wrapped pointers will be set in the parameters before being passed
to the memory allocation function.
2016-05-04 12:51:59 +10:00
Matthew Waters
c9d9077a5f glbasememory: take a pointer as the wrapped gpu handle
Allows passing arbitrary data to wrap the the specific memory implementation
which is required for some memory implementations.
2016-05-04 12:51:59 +10:00
Matthew Waters
9ea15579ec glmemory: add checking the read implementation format/type on gles2 platforms
By default, reading GL_RED or GL_RG us unsupported by glReadPixels unless
exposed through GL_COLOR_READ_IMPLEMENTATION_FORMAT/TYPE.  This allows
downloading multiple-planar video frames where possible.
2016-03-31 20:52:42 +11:00
Matthew Waters
a9cf8476ea glmemory: unset GL_UNPACK_ROW_LENGTH in opengl3
If the user uploads their own texture without setting the unpack length, then
then the result will have the appearance of stride mismanagement due to
an incorrect row length.
2016-03-17 22:56:05 +11:00
Matthew Waters
dff43480ee gl*memory: document new functionality and objects 2016-03-06 19:36:17 +11:00
Matthew Waters
eb7ac03a91 glmemory: log the time for glTexSubImage/glReadPixels 2016-01-15 13:21:56 +11:00
Matthew Waters
e8a251db4b glmemory: expose gst_gl_memory_texsubimage
Removes extremely similar code from glmemorypbo.
2016-01-11 20:40:39 +11:00
Matthew Waters
6917b3b35a glmemory: small code reformat
makes the alloc_params selections fit on a single line.
2015-12-30 12:16:29 +11:00
Alessandro Decina
6961945110 glmemory: add gst_gl_memory_allocator_get_default
Add gst_gl_memory_allocator_get_default to get the default allocator based on
the opengl version. Allows us to stop hardcoding the PBO allocator which isn't
supported on gles2.

Fixes GL upload on iOS9 among other things.
2015-12-18 14:25:32 +11:00
Matthew Waters
5dcd500257 gl*memory*: reverse the parameter order of user_data and destroy notify
The convention is to have the destroy notify last after any user data
2015-12-17 15:44:22 +11:00
Matthew Waters
78fb4326eb glmemory: document gst_gl_memory_init 2015-12-17 13:49:56 +11:00
Matthew Waters
3aaec5b1d6 glmemory: add a default copy implementation
Subclasses still need to override this to copy into the correct memory type.
2015-12-17 13:49:56 +11:00
Matthew Waters
650e5c4fe5 glmemory: implement GstGLBaseMemory::alloc
- Create GstGLVideoAllocationParams which is a GstGLAllocationParams subclass.
- Make it possible to allocate glmemory objects directly if no frills are
  needed.
2015-12-17 13:49:55 +11:00
Matthew Waters
2b7495bbc1 glmemory: base classify and add the pbo memory on top
The base class is useful for having multiple backing memory types other
than the default.  e.g. IOSurface, EGLImage, dmabuf?

The PBO transfer logic is now inside GstGLMemoryPBO which uses GstGLBuffer
to manage the PBO memory.

This also moves the format utility functions into their own file.
2015-12-14 16:35:32 +11:00
Alessandro Decina
5cd0601dd5 glmemory: take subsampling into account for rectangle textures
Rectangle textures don't use normalized coordinates so subsampling needs to be
factored in explicitly.

Fixes YUV => RGB conversion for rectangle textures.
2015-12-10 14:46:27 +11:00
Matthew Waters
b429654a37 glbufferpool: add bufferpool options for the various texture targets
This was chosen over relying solely on the caps as glupload needs to propose an
allocation and set the texture target based on the output caps.  Setting the
caps in the config is currently pointless as they are overwritten in a lot of
element's decide_allocation functions.

This provides a mechanism for the buffer pool to be configured for a certain
texture target when none has been configured.
2015-10-30 14:24:54 +11:00
Matthew Waters
e61d504556 glmemory: add support for rectangle textures
Add the various tokens/strings for the differnet texture types (2D, rect, oes)

Changes the GLmemory api to include the GstGLTextureTarget in all relevant
functions.

Update the relevant caps/templates for 2D only textures.
2015-10-30 14:24:53 +11:00
Julien Isorce
04856e6c8a glmemory: fix texture leak in _gl_mem_copy
https://bugzilla.gnome.org/show_bug.cgi?id=755456
2015-09-25 20:41:33 +10:00
Tim-Philipp Müller
fe8de1857a gl: bufferpool take into account video stride alignment requirements
when allocating memory. Fixes crashes with avdec_h265 in the AVX2
code path which requires 32-byte stride alignment, but the
GstAllocationParams only specified a 16-byte alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=754120
2015-09-15 16:11:23 +01:00
Nicolas Dufresne
adbd9d3c05 glupload: Keep input frame mapped as long as needed
When performing a raw upload, we need to keep the raw data mapped as
long as needed.

https://bugzilla.gnome.org/show_bug.cgi?id=752937
2015-07-28 08:54:29 -04:00
Matthew Waters
d13201fedb glmemory: check for pbo availability before attempting pbo download
https://bugzilla.gnome.org/show_bug.cgi?id=751165
2015-07-20 18:19:02 +10:00
Julien Isorce
2d62f1c479 glmemory: fix consistency about pbo availability.
https://bugzilla.gnome.org/show_bug.cgi?id=751165
2015-06-22 15:12:11 +01:00
Matthew Waters
c3a47c910d glmemory: separate pbo transfer from texture transfers
When supported, the potentially longer pbo upload/download can be
initiated before the texture upload/download, potentially increasing
throughput.
2015-06-12 16:59:20 +10:00
Matthew Waters
7d8d1f8206 glmemory: implement on top of glbasebuffer
Provides convenient access to PBO usage.

Currently texture updates are coupled tightly to data transfers.
2015-06-12 16:59:20 +10:00
Jan Schmidt
e2ce1eff36 gl: Add support for multiple views in upload, colour convert and download
Support multiple attached views on input/output buffers
by processing each one, not just the first.
2015-06-12 00:39:15 +10:00
Matthew Waters
ab2656ebe5 glmemory: provide compatibility definition for GLES2 for GL_RGBA8 2015-06-02 17:24:18 +10:00
Matthew Waters
d914cc6e72 gl: consolidate internal_rgba_format into glmemory
Expose some useful value format conversion functions available in
GstGLMemory.
2015-06-02 16:33:44 +10:00
Julien Isorce
ba5bf50d5f gl: add and use gst_gl_internal_format_rgba
Previously when compiling GstGL with both GL and GLES2,
GL_RGBA8 was picked from GL/gl.h. But a clash may happen at
runtime when one is selecting GLES2.

gst_gl_internal_format_rgba allows to check at runtime
if it should use GL_RGBA or GL_RGBA8.
2015-05-27 17:20:05 +01:00
Matthew Waters
ba5130fe01 glmemory: properly detect (hopefully) the correct ext_rg/arb_rg variant
GL_EXT_texture_rg is only valid for GLES2. GLES3 uses similar wording to
the GL_ARB_texture_rg which requires a sized internal format that the
GL_EXT_texture_rg does not require.

https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_rg.txt
https://www.opengl.org/registry/specs/ARB/texture_rg.txt
2015-05-14 14:58:07 +10:00
Matthew Waters
17084a4608 glmemory: remove uneeded unref
The call to _gl_mem_alloc_data will unref and NULLify 'dest' for us.
We just need to return.

https://bugzilla.gnome.org/show_bug.cgi?id=744246
2015-04-28 20:47:55 +10:00
Sebastian Dröge
a557a546ac gl: Remove iOS/EAGL workaround for R/RG textures
This should be unneeded now after https://bugzilla.gnome.org/show_bug.cgi?id=732507
2015-04-11 19:17:00 +02:00
Matthew Waters
0ee027b6ee gl/docs: update some doc comments 2015-03-18 10:13:25 -07:00
Matthew Waters
48f8b5b46b glmemory: fix the slight difference between EXT_rg and ARB_rg
GL_EXT_texture_rg doesn't take sized formats for the internalformat
parameter of TexImage* but GL_ARB_texture_rg and GL(ES)3 do.

https://bugzilla.gnome.org/show_bug.cgi?id=732507
2015-03-14 18:59:27 +00:00
Nicolas Dufresne
04377cfc5e glmemory: Support offset when downloading
Make sure we support offset and video alignment when downloading too.
This is currently not used (plane_start is always 0), but it makes
the code correct if we want to use that later.
2015-02-28 15:01:59 -05:00
Nicolas Dufresne
8c0fcef818 glmemory: Provide correct size on upload
Provide the right size to GL when uploading. Using maxsize is wrong
since we offset the data point with the memory offset and video
alignement offset.

https://bugzilla.gnome.org/show_bug.cgi?id=744246
2015-02-28 14:32:40 -05:00
Nicolas Dufresne
e9bec9ec0e glmemory: Provide correct size on download
Provide the right size to GL when downloading. This fixes downloading
from GLMemory that where created for libav.

https://bugzilla.gnome.org/show_bug.cgi?id=744246
2015-02-28 14:32:40 -05:00
Nicolas Dufresne
4db0ef5789 glmemory: Use fallback for partial copy
When the memory is partial copy, the texture size and videoinfo no
longer make sense. As we cannot guess what the application wants, we
safely copy into a sysmem memory.

https://bugzilla.gnome.org/show_bug.cgi?id=744246
2015-02-28 14:32:40 -05:00
Nicolas Dufresne
b8f168cd65 glmemory: Add GstAllocationParams and alignment support
This implements support for GstAllocationParams and memory alignments.
The parameters where simply ignored which could lead to crash on
certain platform when used with libav and no luck.

https://bugzilla.gnome.org/show_bug.cgi?id=744246
2015-02-28 14:32:39 -05:00
Matthew Waters
08b1d27e14 glmemory: allow sharing between buffers
There was no real reason why the flag was set.  We should be able
to handle it.  Fixes last-sample handling on gl sinks
2015-02-25 00:00:48 +11:00
Vasilis Liaskovitis
c55689ad16 glmemory: Fix transfer_pbo memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=744977
2015-02-23 18:44:39 +02:00
Mathieu Duponchelle
3baa710638 gstglmemory: Remove now unused transfer_upload function. 2015-02-21 14:42:05 +01:00
Matthew Waters
c6f548326d glmemory: disable automatic pbo upload
until we can track where the data is/or is going to be.
2015-02-21 23:32:41 +11:00
Matthew Waters
a4040f2ee9 glememory: only store and act on the map flags on first/last map/unmap
Anytime else, we have no idea how to match up map and unmaps.
We also don't know exactly how the calling code is using us.
Also fixes the case where we're trying to transfer while someone else
is accessing our data pointer or texture resulting in mismatched video
frames.

https://bugzilla.gnome.org/show_bug.cgi?id=744839
2015-02-20 18:48:15 +11:00
Edward Hervey
f09272f434 gl: Add/Update more debug statements
Where possible, use the _OBJECT variants in order to track better from
which object the debug statement is coming from

Define (and use) GST_CAT_DEFAULT where applicable

Use GST_PTR_FORMAT where applicable
2015-02-12 15:57:55 +01:00
Alessandro Decina
ad08cdf8e1 libgstgl: set user data and GDestroyNotify for wrapped textures 2015-02-09 20:46:51 +11:00
Matthew Waters
46ecf99a8a glmemory: add missing initilisation of tex_target when copying
fixes:

glcolorscale ! video/x-raw\(meta:GstVideoGLTextureUploadMeta\) !
glimagesink
2015-02-03 14:32:55 +11:00
Alessandro Decina
5f547c5600 gl: initial support for texture targets other than GL_TEXTURE_2D
Make GstGLMemory hold the texture target (tex_target) the texture it represents
(tex_id) is bound to. Modify gst_gl_memory_wrapped_texture and
gst_gl_download_perform_with_data to take the texture target as an argument.

This change is needed to support wrapping textures created outside libgstgl,
which might be bound to a target other than GL_TEXTURE_2D. For example on OSX
textures coming from VideoToolbox have target GL_TEXTURE_RECTANGLE.

With this change we still keep (and sometimes imply) GL_TEXTURE_2D as the
target of textures created with libgstgl.

API: modify GstGLMemory
API: modify gst_gl_memory_wrapped_texture
API: gst_gl_download_perform_with_data
2015-01-30 00:34:08 +11:00
Matthew Waters
08dbd8bbd7 glmemory: more compatibility defines for gles2 systems 2015-01-27 14:52:47 +11:00
Matthew Waters
eea03967e4 glmemory: add some thread safety for gl operations 2015-01-27 12:26:05 +11:00
Matthew Waters
9a55a3f98c glmemory: use pbo's for download
In order to use pbo's efficiently, the transfer operation has to
be separated from the use of the downloaded data which requires some
rearchitecturing around glcolorconvert/gldownload and elements
2015-01-27 12:26:04 +11:00