Commit graph

123 commits

Author SHA1 Message Date
Alessandro Decina 966cad27d7 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
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
Luis de Bethencourt 9d9d07168f glfilter: remove logically dead code
Soon after setting two variables to 1, the code checks if their values are
different from each other. This would never be true. Removing this.

CID 1226443
2017-12-09 19:31:52 +00:00
Wang Xin-yu (王昕宇) fc09b8b93c glfilter: fix position/texcoord attrib index usage
https://bugzilla.gnome.org/show_bug.cgi?id=741231
2017-12-09 19:31:52 +00:00
Matthew Waters ba3a3cd783 gl: fixup vao and vbo usage for legacy GL 2017-12-09 19:31:52 +00:00
Matthew Waters 4bd62ebb03 gldisplay: implement runtime GL api filtering
Needed so that the pipeline/application can limit the choice of GL api
to what it supports
2017-12-09 19:31:51 +00:00
Matthew Waters 6bb113f685 gl: add a sync meta for synchronizing across GL contexts
A context can create a GLsync object that can be waited on in order
to ensure that GL resources created in one context are able to be
used in another shared context without any chance of reading invalid
data.

This meta would be placed on buffers that are known to cross from
one context to another.  The receiving element would then wait
on the sync object to ensure that the data to be used is complete.
2017-12-09 19:31:51 +00:00
Matthew Waters 8e98591153 glfilter: add a gl3 code path using vao's and vbo's 2017-12-09 19:31:51 +00:00
Matthew Waters e252c908e7 glfilter: support fixed dimensions on both sides of the element
Fixes:

  width=320,height=240 ! glfilter ! width=800,height=600
  width=230,height=240 ! glfilter ! width=600
  ... ! glfilter ! width=800
2017-12-09 19:31:50 +00:00
Matthew Waters 00506bf183 glupload: rearchitecture for non GLMemory inputs/outputs
Allows other memory types to be implemented/returned/used by the caller.
2017-12-09 19:31:50 +00:00
Matthew Waters e731762984 glfilter: add read-only context property 2017-12-09 19:31:50 +00:00
Matthew Waters af9b73043e gl: remove the width/height fields from the caps to support frame resizing
It was previously only occuring with sysmem caps features

https://bugzilla.gnome.org/show_bug.cgi?id=739334
2017-12-09 19:31:49 +00:00
Matthew Waters 59e4a039c9 glfilter: get the config from the correct pool 2017-12-09 19:31:48 +00:00
Matthew Waters cc2e0a7288 glfilter: avoid uninitialized variable size when chaining multiple glfilters
https://bugzilla.gnome.org/show_bug.cgi?id=739277
2017-12-09 19:31:48 +00:00
Matthew Waters f1dddf4f6b glfilter: gst-indent file 2017-12-09 19:31:48 +00:00
Matthew Waters 62e3c40d97 gl: propogate other-context using GstContext 2017-12-09 19:31:48 +00:00
Matthew Waters 0806de5c75 glbufferpool: add the GstVideoGLTextureUploadMeta buffer pool option 2017-12-09 19:31:48 +00:00
Matthew Waters 6663967994 glfilter: add uploaded_buffer field 2017-12-09 19:31:48 +00:00
Matthew Waters 80be2d046b glfilter: silence a warning with empty input caps
discovered with the doublecube example

gst_caps_get_features: assertion 'index < GST_CAPS_LEN (caps)' failed
2017-12-09 19:31:47 +00:00
Matthew Waters ae919f4475 gl: download whenever we have sysmem capsfeatures
Otherwise we could pass on a RGBA formatted buffer and downstream would
misinterpret that as some other video format.

Fixes pipelines of the form

    gleffects ! tee ! xvimagesink
2017-12-09 19:31:46 +00:00
Anuj Jaiswal e9e84da30a gl: consecutive return, break statement
Signed-off-by: Anuj Jaiswal <anuj.jaiswal@samsung.com>

https://bugzilla.gnome.org/show_bug.cgi?id=736939
2017-12-09 19:31:46 +00:00
Matthew Waters 6491af9ffc glupload: provide the output buffer that is rendered into
Allows callers to properly reference count the buffers used for
rendering.

Fixes a redraw race in glimagesink where the previous buffer
(the one used for redraw operations) is freed as soon as the next
buffer is uploaded.

1. glimagesink uploads in _prepare() to texture n
1.1 glupload holds buffer n
2. glimagesink _render()s texture n
3. glimagesink uploads texture n+1
3.1 glupload free previous buffer which deletes texture n
3.2 glupload holds buffer n+1
4. glwindow resize/expose
5. glimagesink redraws with texture n

The race is that the buffer n (the one used for redrawing) is freed as soon as
the buffer n+1 arrives.  There could be any amount of time and number of
redraws between this event and when buffer n+1 is actually rendered and thus
replaces buffer n as the redraw source.

https://bugzilla.gnome.org/show_bug.cgi?id=736740
2017-12-09 19:31:46 +00:00
Ognyan Tonchev 7e21e35eac glfilter: do not leak pool in error cases
https://bugzilla.gnome.org/show_bug.cgi?id=736732
2017-12-09 19:31:46 +00:00
Wang Xin-yu (王昕宇) 2ce11e4bac gl: fix multi gl object leaks
1. fix FBO leaks in decide_allocation
2. fix texture leaks in decide_allocation and reset
3. fix texture leaks in FBO incomplete error path
2017-12-09 19:31:44 +00:00
Matthew Waters 730b88a677 glfilter: pass through the allocation query when in passthrough mode
Otherwise two GL elements on either side will fail to use the same
GL context.
2017-12-09 19:31:44 +00:00
Matthew Waters 3a20e70cbd glfilter: prefer passthrough for non-sysmem caps 2017-12-09 19:31:43 +00:00
Julien Isorce 7cdce1bdfc glfilter: handle NULL decide_query which means passthrough
See https://bugzilla.gnome.org/show_bug.cgi?id=732178
2017-12-09 19:31:43 +00:00
Julien Isorce e016324d31 glfilter: prepend intersection to src caps
Prefer to stay in the same memory space if possible.
Also it let a chance to do passthrough.

See https://bugzilla.gnome.org/show_bug.cgi?id=732178
2017-12-09 19:31:43 +00:00
Matthew Waters 30a9843c02 gl/filter: also remove the width/height in transform_caps
allows scaling in the filters
2017-12-09 19:31:42 +00:00
Matthew Waters 32343333aa gl/upload: add GstGLUploadMeta object
That simply deals with the provider aspect of GstVideoGLTextureUploadMeta.
2017-12-09 19:31:41 +00:00
Nicolas Dufresne d85c344204 glfilter: Remove format information to allow color convert again
We also need to remove the format information,  as glfilter can do
color convertion. This code was imported from videoconvert.

https://bugzilla.gnome.org/show_bug.cgi?id=729861
2017-12-09 19:31:41 +00:00
Matthew Waters 9cfd5e5d04 gl/filter: fixup passthrough bufferpool
In a pipeline like so:
  videotestsrc ! gleffects ! videoconvert ! sink
gleffects was simply passing the videoconvert bufferpool to videotestsrc
and not creating a glbufferpool. videobufferpool would then fail
to allocate from the glallocator.
2017-12-09 19:31:41 +00:00
Matthew Waters 51fdeef98b gl/eglimage: add eglimage context feature
Allows us to selectively use EGLImages only when available

https://bugzilla.gnome.org/show_bug.cgi?id=728234
2017-12-09 19:31:41 +00:00
Matthew Waters 9172cb8839 gl/download: update to be similar to the glupload semantics 2017-12-09 19:31:40 +00:00
Nicolas Dufresne b4a0a26ddd glfilter: Fix building without EGL support
This fixes the OSX build and any builds with --disable-egl. That issue
was introduced in "glfilter: rewrite transform_caps to preserve caps fields".

https://bugzilla.gnome.org/show_bug.cgi?id=729861
2017-12-09 19:31:40 +00:00
Julien Isorce a7156df9f4 glfilter: rewrite transform_caps to preserve caps fields
https://bugzilla.gnome.org/show_bug.cgi?id=729861
2017-12-09 19:31:40 +00:00
Matthew Waters 6c1a4e30c4 gl/upload: implement lazy init
Rename init_format to set_format
2017-12-09 19:31:39 +00:00
Matthew Waters 6e5494d729 gl/filter: attempt to passthrough the pool if the caps are the same
Reduces the number of glbufferpool instances required for >=2
consecutive GL elements in a pipeline.
2017-12-09 19:31:39 +00:00
Matthew Waters 6872ad5ff5 gl/filter: always initialize the upload object 2017-12-09 19:31:39 +00:00
Matthew Waters 8fd450b941 gl: advertise GstGLMemory usage in the caps as capsfeatures
https://bugzilla.gnome.org/show_bug.cgi?id=729658
2017-12-09 19:31:39 +00:00
Matthew Waters bf9c8544e3 gl: use the bufferpool's upload when available
Avoids duplicating GL resources

https://bugzilla.gnome.org/show_bug.cgi?id=728872
2017-12-09 19:31:39 +00:00
Julien Isorce 391661b626 gl: use gst_gl_platform_from_string because we support gl shareList on all platforms 2017-12-09 19:31:38 +00:00
Julien Isorce c441afdc6b glfilter: only warn when other_context attribute is set
Fix false positive
2017-12-09 19:31:38 +00:00
Matthew Waters 30c6efc432 gl/mem: allocate the memory per plane
This patch provides the basic infrastructure required for this.
Upload and Download has been ported to this.

Has the nice effect of allowing GstGLMemory to be our
refcounted texture object for any texture type (not just RGBA).

Should not lose any features/video formats.
2017-12-09 19:31:36 +00:00
Matthew Waters fba49c3463 gl: add colorconvert object that converts between color spaces/formats
Currently used by both upload and download objects separately.
2017-12-09 19:31:36 +00:00
Matthew Waters a20a5d36e2 gl: pass video info's by reference 2017-12-09 19:31:35 +00:00
Matthew Waters 71548893bf gl: avoid adding a NULL pool to propose allocation 2017-12-09 19:31:35 +00:00
Julien Isorce 0233939eaa gl: only set CAPS_FEATURE_MEMORY_EGL_IMAGE on egl platform 2017-12-09 19:31:35 +00:00
Julien Isorce 6614df6478 gl: let the user includes itself our egl headers if needed
Forgot to address this change.

https://bugzilla.gnome.org/show_bug.cgi?id=703343
2017-12-09 19:31:35 +00:00
Julien Isorce c2471aec81 gl: add EGLImage support
* picked from old libgstegl:
  - GstEGLImageMemory
  - GstEGLImageAllocator
  - last_buffer management from removed GstEGLImageBufferPool

* add-ons:
  - GstEGLImageMemory now old a reference on GstGLContext
    so that it can delete the EGLImage and its gltexture source
    while having the associated gl context being current.
  - add EGLImage support for GstVideoGLTextureUploadMeta which
    mainly call EGLImageTargetTexture2D
  - GstGLBufferPool now supports GstEGLImageAllocator
  - glimagesink / glfilters / etc.. now propose GstEGLImageAllocator
    to upstream

https://bugzilla.gnome.org/show_bug.cgi?id=703343
2017-12-09 19:31:35 +00:00