Commit graph

136 commits

Author SHA1 Message Date
Matthew Waters
86110c4765 glupload: always add texture-target field to GL caps
1. Various elements/base classes only perform a subset check on accept-caps
2. Some GL elements have texture-target in their pad template
3. When checking subsets, only the caps to check are allowed to contain extra
   fields.  If the 'template' caps have extra fields, the subset fails.
Thus without texture-target on the caps, various accept-caps implementations
were failing.

Also, add some convenience functions for setting and retrieving
texture targets to/from GValue.

https://bugzilla.gnome.org/show_bug.cgi?id=759860
2017-12-09 19:32:14 +00:00
Matthew Waters
ec5eb678d0 glupload: passthrough composition caps features
Don't unconditionally add it to any and all caps transformations.

https://bugzilla.gnome.org/show_bug.cgi?id=759860
2017-12-09 19:32:14 +00:00
Nicolas Dufresne
8492c045a4 glupload: Add dmabuf upload method.
This upload method detect and optimize uploads of DMABuf memory. This is
done by creating and caching EGLImages wrapper around DMABuf. The
EGLImages are then binded to a texture which get converter using
standard shader.

Example pipeline:

GST_GL_PLATFORM=egl \
gst-launch-1.0 v4l2src device=/dev/video1 io-mode=4 ! \
               video/x-raw,format=NV12 ! glimagesink

https://bugzilla.gnome.org/show_bug.cgi?id=743345
2017-12-09 19:32:13 +00:00
Alessandro Decina
28dbe4fffc 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.
2017-12-09 19:32:13 +00:00
Matthew Waters
09c8c23842 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
2017-12-09 19:32:13 +00:00
Matthew Waters
1673a6192f glmemorypbo: remove our own alloc()/wrapped()/etc functions
replaced by equivalent functionality within gst_gl_base_memory_alloc()
2017-12-09 19:32:13 +00:00
Alessandro Decina
b365425dc2 glupload: fix allocator name after GLMemory API changes 2017-12-09 19:32:12 +00:00
Matthew Waters
76a38dd66a 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.
2017-12-09 19:32:12 +00:00
Nicolas Dufresne
21df596b8b glupload: Only offer custom allocator with caps features
To use GLMemory and EGLImage allocators, one need to know the
libgstgl API. This is only expected if the associated caps features
have been negotiated. Generic element that otherwise receive those
allocators may fail, resulting in broken pieline. We don't want to
force all generic element to check if the allocator is a custom
allocator or a normal allocator (which implement the _alloc method).

https://bugzilla.gnome.org/show_bug.cgi?id=758877
2017-12-09 19:32:11 +00:00
Matthew Waters
434bbc9f01 glupload: explicitly configure the texture target on the gl buffer pool
If we don't, then the pool could end up allocating 2D textures when the
caps explictly state they should be rectangle textures.
2017-12-09 19:32:10 +00:00
Matthew Waters
681cb5b16d 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.
2017-12-09 19:32:10 +00:00
Matthew Waters
73bad9e856 glupload: remove useless release_buffer
It's a leftover from when we weren't outputting GstBuffer's and
returning raw texture id's.
2017-12-09 19:32:09 +00:00
Nicolas Dufresne
edd3c007ea glupload: Recalculate offset and size in raw upload
As we only expose the mapped portion of the frame into the GL
memory object (and not the original padding) we need to
re-calculate the size and offset.
2017-12-09 19:32:08 +00:00
Nicolas Dufresne
a342d95ca6 glsink: Enable sync meta on pools we offer
As the upload is asynchronous, we need to enable the sync meta to
gain correct rendering. The buffer pool receiver don't know about
that.
2017-12-09 19:32:07 +00:00
Sebastian Dröge
260104e485 glupload: Remove debug output from gst_gl_upload_transform_caps()
We can't know if the GstGLUpload type is initialized at this point already,
and thus our debug category might not be initialized yet... and cause an
assertion here.

As we don't print debug output for any of the other transform functions, let's
defer this problem for now.
2017-12-09 19:32:07 +00:00
Nicolas Dufresne
f8dbf10e9e glupload: Add fixme about using bufferpool for raw
http://bugzilla.gnome.org/show_bug.cgi?id=752937
2017-12-09 19:32:07 +00:00
Nicolas Dufresne
2b2048d601 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
2017-12-09 19:32:07 +00:00
Nicolas Dufresne
37cc53d26f Revert "glupload: memcpy on raw data upload"
This reverts commit 82c0189b28.

https://bugzilla.gnome.org/show_bug.cgi?id=752937
2017-12-09 19:32:07 +00:00
Jan Schmidt
3bacd64bf1 glupload: Check that caps contain desired caps features
Use 'contains' checks instead of equality checks on caps features
to allow for uploading when caps also contain GstVideoOverlayComposition
meta.

https://bugzilla.gnome.org/show_bug.cgi?id=752912
2017-12-09 19:32:06 +00:00
Luis de Bethencourt
1eeeadb24e glupload: fix memory leak
GstCapsFeatures need to be freed with gst_caps_features_free() after use.

CID #1312136, CID #1312136
2017-12-09 19:32:06 +00:00
Lubosz Sarnecki
076d0517c8 glupload: Detect overlay meta buffers correctly
https://bugzilla.gnome.org/show_bug.cgi?id=745107
2017-12-09 19:32:06 +00:00
Lubosz Sarnecki
dc47e6d3c0 glimagesinkbin: Add GstVideoOverlayCompositionMeta caps features
https://bugzilla.gnome.org/show_bug.cgi?id=745107
2017-12-09 19:32:06 +00:00
Lubosz Sarnecki
eb618aaac7 glupload: Move debug init to top of the file
https://bugzilla.gnome.org/show_bug.cgi?id=745107
2017-12-09 19:32:05 +00:00
Matthew Waters
5043800a1d glupload: memcpy on raw data upload
Anything else requires keeping track of the GstVideoFrame mapping
across possible multiple buffers to ensure correct data pointer
usage.
2017-12-09 19:32:05 +00:00
Nicolas Dufresne
b8d3c2d2a5 gl: Don't leak pool if set_config failed 2017-12-09 19:32:05 +00:00
Matthew Waters
2210ba5d46 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.
2017-12-09 19:32:04 +00:00
Matthew Waters
900bcea9de glmemory: implement on top of glbasebuffer
Provides convenient access to PBO usage.

Currently texture updates are coupled tightly to data transfers.
2017-12-09 19:32:04 +00:00
Jan Schmidt
8a1fc4ab4e 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.
2017-12-09 19:32:04 +00:00
Jan Schmidt
95b08b75ba glupload: Don't leak all memory uploaded via raw uploads.
Remove an extra ref missed when switching over to not
reusing output textures
2017-12-09 19:32:02 +00:00
Matthew Waters
62c2d98c52 glupload: don't reuse output textures for raw data upload
Causes stale textures to be used further down the chain.
2017-12-09 19:32:01 +00:00
Jan Schmidt
9958df5dd1 glupload: Make upload method static caps non-const.
Retrieving a GstStaticCaps does a one time internal
initialisation and caches it - they can't be stored as
const structures.
2017-12-09 19:32:00 +00:00
Matthew Waters
c902a6f525 glupload: provide the sink template caps that could be used
https://bugzilla.gnome.org/show_bug.cgi?id=746399
2017-12-09 19:32:00 +00:00
Matthew Waters
0b5c7e8b49 gl/docs: update some doc comments 2017-12-09 19:31:58 +00:00
Víctor Manuel Jáquez Leal
55dbb25dcc glupload: move meta-data copy into gst-gl library
In some upload implementations the out buffer has more than one references,
turning the buffer not writable, so it won't be possible to modify its
meta-data.

This patch moves the meta-data copy before increasing the reference of the out
buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=746173
2017-12-09 19:31:58 +00:00
Matthew Waters
7b9d70944b glupload: unref the bufferpool 2017-12-09 19:31:57 +00:00
Matthew Waters
1ba38bc10a glupload: implement propose_allocation pool handling for glmemory upload 2017-12-09 19:31:56 +00:00
Sebastian Dröge
86d1280f2c glupload: Simplify caps feature setting code 2017-12-09 19:31:56 +00:00
Nicolas Dufresne
de79830b05 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
2017-12-09 19:31:55 +00:00
Matthew Waters
05a4c89f25 glupload: perform egl upload on the gl thread
Fixes EGLImage usage on raspberry pi

https://bugzilla.gnome.org/show_bug.cgi?id=743914
2017-12-09 19:31:55 +00:00
Víctor Manuel Jáquez Leal
e3d457ec8e glupload: Set freed method implementation to NULL
When trying to render buffers with meta:GLTextureUpload the glimagesink crashes
with a segmentation fault.

This patch workarounds this crash setting to NULL the method implementation
after free.

https://bugzilla.gnome.org/show_bug.cgi?id=745206
2017-12-09 19:31:55 +00:00
Edward Hervey
f56c4c541a 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
2017-12-09 19:31:54 +00:00
Matthew Waters
608a3ddc7b glupload: restrict EGL and UploadMeta to RGBA
other formats are highly untested.
2017-12-09 19:31:54 +00:00
Matthew Waters
f180fe8dc8 glupload: only try the glmemory upload for sysmem/glmemory caps features
Allows selecting/testing the upload path with explicit caps features.
2017-12-09 19:31:54 +00:00
Matthew Waters
29ca0e8a44 glupload: allow NULL buffer for accept vfunc 2017-12-09 19:31:54 +00:00
Matthew Waters
45e6e77ff0 glupload: remove unsed convert field in private struct 2017-12-09 19:31:54 +00:00
Matthew Waters
530ae2cbb0 glupload/download/convert: provide transform_caps functions
Allows finer grain decisions about formats and features at each
stage of the pipeline.
Also provide propose_allocation for glupload besed on the supported
methods.
2017-12-09 19:31:54 +00:00
Sebastian Dröge
39e719fb33 Constify some static arrays everywhere 2017-12-09 19:31:53 +00:00
Matthew Waters
1dfeae2c42 gl: split glcolorconvert usage from glupload
the separation allows the transfer operation to occur in a separate
thread/time which may increase performance in specific circumstances.
2017-12-09 19:31:52 +00:00
Matthew Waters
4288866e55 glupload: relax the GLMemory uploader check for input caps features
As there may be a sysmem caps features with GLMemory filled buffers.
e.g.

videotestsrc ! glimagesink
2017-12-09 19:31:52 +00:00
Nicola Murino
209fbd950f glupload: fix some memory leaks
https://bugzilla.gnome.org/show_bug.cgi?id=741943
2017-12-09 19:31:52 +00:00