Commit graph

1276 commits

Author SHA1 Message Date
Matthew Waters dc02d47092 glbasebuffer: remove unsed memory subclass
The functionality has been split into GstGLBaseMemory and GstGLBuffer.
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
Matthew Waters 5ab3a38973 gl: add a GL buffer based GstMemory
Heavily based on GstGLBaseBuffer that is a subclass of GstGLBaseMemory.
Provides GPU and CPU accessible GL buffer objects by GL handle or by
sysmem data pointer.
2017-12-09 19:32:12 +00:00
Matthew Waters af7015602a gl: add a base memory object
It handles the following
- GstAllocationParams -> gst_memory_init transformation
- Makes sure that map/unmap/create/destroy happen on the GL thread with
  a GL context current.
- Holds a possible sysmem accessible data pointer with alignment.
- Holds the need upload/download transfer state
2017-12-09 19:32:12 +00:00
Matthew Waters caee3e41f9 gl: add convenience function for the start of a video frame
Get's the start of the video frame based on a GstVideoInfo and
GstVideoAlignment.
2017-12-09 19:32:12 +00:00
Matthew Waters cd584d215c gluploadmeta; remove convenience helper API
It was not really useful as if one knows about libgstgl, one can just use
GLMemory objects directly.
2017-12-09 19:32:12 +00:00
Matthew Waters 3545d340b6 gldownload: remove helper api from the library
It was never used by anyone and is not needed anymore with the element
and GstGLMemory's transparent support for downloading textures.
2017-12-09 19:32:12 +00:00
Alessandro Decina 610f965be8 libgstgl: gstglcontext_cocoa: kCGLPFAStereo has been deprecated in 10.11
Also since the version scheme has changed (to include the micro number) since
10.10, use the MAC_OS_X_VERSION_* macro to avoid confusion.
2017-12-09 19:32:12 +00:00
Alessandro Decina b8e06e7311 glbufferpool: relax check for multiple texture targets
Only complain about multiple texture targets when _different_ texture targets
are configured.
2017-12-09 19:32:12 +00:00
Alessandro Decina fa1c4e552c 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.
2017-12-09 19:32:11 +00:00
Matthew Waters e8f966dcab glproto: include function definitions for GL_APPLE_sync
Provides a performance improvement on iOS where we were falling back to glFinish
on settting sync points.
2017-12-09 19:32:11 +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 953be21a22 glcolorconvert: improve the YUY2/UYVY->RGBA conversion shader
Don't offset the y-axis.  We only need to offset on the x-axis.

Removes a sawtooth pattern on horizontal and vertical edges.

https://bugzilla.gnome.org/show_bug.cgi?id=755486
2017-12-09 19:32:11 +00:00
Matthew Waters bb7422e91b glcolorconvert: improve RGBA->YUY2/UYVY conversion shader
We should only average the chroma samples not the luma sample.

https://bugzilla.gnome.org/show_bug.cgi?id=758904
2017-12-09 19:32:11 +00:00
Reynaldo H. Verdejo Pinochet 8ab57b5b23 Drop usage of deprecated g-ir-scanner --strip-prefix flag 2017-12-09 19:32:11 +00:00
Reynaldo H. Verdejo Pinochet 68e668168d Remove unnecessary NULL checks before g_free()
g_free() is NULL-safe
2017-12-09 19:32:11 +00:00
Sebastian Dröge e7b63b1397 glviewconvert: String literals are const
gstglviewconvert.c: In function '_mangle_extensions':
gstglviewconvert.c:1511:13: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
     ext_str = "#extension GL_OES_EGL_image_external : require\n";
             ^
2017-12-09 19:32:11 +00:00
Sebastian Dröge 316c2c3418 glsyncmeta: Actually return the newly created meta from gst_buffer_add_gl_sync_meta()
gstglsyncmeta.c  -fPIC -DPIC -o .libs/libgstgl_1.0_la-gstglsyncmeta.o
gstglsyncmeta.c: In function 'gst_buffer_add_gl_sync_meta':
gstglsyncmeta.c:131:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
2017-12-09 19:32:11 +00:00
Matthew Waters 0e404ae3fc glsyncmeta: add vfuncs for all operations
there could be other ways/requirements for synchronising two GPU command
streams (whether GL or platform specific).

e.g. glfencesync/eglwaitnative/cond/etc
2017-12-09 19:32:11 +00:00
Matthew Waters 975e96db44 glviewconvert: add support rectangle/external-oes textures
https://bugzilla.gnome.org/show_bug.cgi?id=757285
2017-12-09 19:32:11 +00:00
Vineeth TM a0a8b8873b glsl: fix possible string overrun in gst_glsl_version_profile_from_string
given a NULL-terminated string, s.
s[i] = '\0';
i++;
does not guarentee that s[i] is NULL terminated and thus string operations
could read off the end of the array.

https://bugzilla.gnome.org/show_bug.cgi?id=758039
2017-12-09 19:32:11 +00:00
Matthew Waters 148940c456 glshader: don't read invalid list pointers (use after free)
gst_gl_shader_detach_unlocked already removes the list entry so attempting to
use the element to iterate to the next stage could read invalid data.

Based on patch by Vineeth TM <vineeth.tm@samsung.com>

https://bugzilla.gnome.org/show_bug.cgi?id=758039
2017-12-09 19:32:11 +00:00
Vineeth TM d5c1ff4bf2 glsl: free str while returning error
https://bugzilla.gnome.org/show_bug.cgi?id=758039
2017-12-09 19:32:11 +00:00
Vineeth TM 7a75684566 glslstage: Fix vertex_sources memory leak
vertex_sources is being allocated but not freed resulting in leak

https://bugzilla.gnome.org/show_bug.cgi?id=757974
2017-12-09 19:32:11 +00:00
Vineeth TM 7b0125ab11 glcolorconvert: remove unnecessary free
version_str is already being freed. So no need to call again

https://bugzilla.gnome.org/show_bug.cgi?id=757974
2017-12-09 19:32:11 +00:00
Vineeth TM 07901d8eed glcolorconvert: Fix string leak
String got using gst_glsl_version_profile_to_string, is allocated
memory and should be freed

https://bugzilla.gnome.org/show_bug.cgi?id=757974
2017-12-09 19:32:11 +00:00
Vineeth TM 1f245c3d2e glcolorconvert: Fix frag_prog and frag_body memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=757974
2017-12-09 19:32:11 +00:00
Matthew Waters b30deff7e1 glcolorconvert: mangle gl_FragColor for GL3
Some drivers don't provide the compatibility definition and we need to provide
our own 'out vec4' variable to put the results of the fragment shader into.

https://bugzilla.gnome.org/show_bug.cgi?id=757938
2017-12-09 19:32:11 +00:00
Matthew Waters b8c1ecf268 glviewconvert: remove set_format
We need the caps to be able to
1. check the caps features
2. get the requested texture-target on input/output
2017-12-09 19:32:11 +00:00
Matthew Waters 117fc0409a glshader: properly unref the stages on failure
When failing in the varargs functions, all the stage objects not handled need to
be unreffed to prevent a leak.
2017-12-09 19:32:11 +00:00
Matthew Waters 1f35fcf06d glslstage: properly return an error when we could not create the shader stage
While it was erroring out correctly later, there were GLib warnings about
setting a GError over the top of another GError.
2017-12-09 19:32:10 +00:00
Matthew Waters ef319c7b8f glshaderstrings: fixup the external-oes fragment shader
The wrong sampler type was used
s/sampler2DExternalOES/samplerExternalOES/
2017-12-09 19:32:10 +00:00
Matthew Waters 105497de60 glcolorconvert: try to keep the same texture-target if possible
Fixes issues attempting to passthrough external-oes textures
2017-12-09 19:32:10 +00:00
Matthew Waters 46b84c6035 glcolorconvert: fix rendering rectangular textures with GL3
Rectangular textures are unavailable in unextended
GLES2 #version 100 shaders.

Fixes
texture-target=rectangle ! glcolorconvert ! texture-target=2D

There's a couple of differences between GL3 and GLES2/GL

- varying -> in or out depending on the stage (vertex/fragment)
- attribute -> in
- filtered texture access is a single function, texture()
2017-12-09 19:32:10 +00:00
Matthew Waters e32fcfbf3c glcolorconvert: properly use the other texture-target on fixation 2017-12-09 19:32:10 +00:00
Matthew Waters ec0a93dd7e glslstage: add debug as to why _set_strings() failed 2017-12-09 19:32:10 +00:00
Matthew Waters 5d7556a08d glsl: fix check for glsl version against GL context inversion
Any GLSL version that was less than the provided GL version would fail
2017-12-09 19:32:10 +00:00
Matthew Waters 9a3ea0adb7 gl: forward declare some enums
Specifically the GstGLTextureTarget enum
2017-12-09 19:32:10 +00:00
Matthew Waters b1ac029b87 glslstage: expose the default shader strings as public
Add some other simple strings for external-oes textures or transforming
the texture coordinates with a transformation matrix
2017-12-09 19:32:10 +00:00
Matthew Waters 6a75a07815 glcolorconvert: wait on the sync meta for input buffers 2017-12-09 19:32:10 +00:00
Matthew Waters c5f3406186 glcolorconvert: use the correct oes target string in the template caps 2017-12-09 19:32:10 +00:00
Tim-Philipp Müller 7a166e019b glshader, tsdemux: simplify code
Jus use _delete_link() instead of _remove_link() + _free1()
2017-12-09 19:32:10 +00:00
Alessandro Decina 7fedb34bea gstglutils: fix shader compilation on Mountain Lion
Make gst_gl_context_gen_shader/_compile_shader assume GST_GLSL_PROFILE_ES |
GST_GLSL_PROFILE_COMPATIBILITY as the profile. Without this, the shader compiler
doesn't inject the #version tag resulting in a compilation error on Mountain
Lion.

This is a workaround for old code using gst_gl_context_gen_shader. New code
should use the gst_glsl_stage_* API directly which allows the caller to
explicitly specify version/profile.
2017-12-09 19:32:10 +00:00
Matthew Waters d41e6a5579 glbufferpool: explicitly initialize a possibly uninitialized variable
The ret variable may be uninitialized and so its contents were undefined and
the results were erratic (failing with glvideomixer, succeeding in other cases)

P.S. No idea why gcc/clang et al never picked up on this like they normally do
(probably due to some optimisation pass figuring out it's only set once...)
2017-12-09 19:32:10 +00:00
Matthew Waters b0d40019f9 glslstage: remove typedefs from the header
They are already defined in the forward decleration header and defining them
more than once will give an error with OSX's clang about typedef redefinition
being a C11 feature.
2017-12-09 19:32:10 +00:00
Matthew Waters 2595f73fd0 glcolorconvert: follow the correct texture target names 2017-12-09 19:32:10 +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 18f9dfdfe5 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.
2017-12-09 19:32:10 +00:00
Matthew Waters 6141d3fc7e glcolorconvert: add support for converting texture targets
Solved with a simple shader templating mechanism and string replacements
of the necessary sampler types/texture accesses and texture coordinate
mangling for rectangular and external-oes 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