Commit graph

1483 commits

Author SHA1 Message Date
Mark Nauwelaerts
99f9d4ccc7 glfilter: handle some more unfixed fields when fixating caps 2017-12-09 19:32:17 +00:00
Nicolas Dufresne
910d990e4b glbasememory: Don't change maxsize at run-time
Maxsize is initialized once and should never change. Allocating data
should have no impact on the selected max size for this memory. This
causing memory map failure as the maxsize would become smaller then
size. This happened when using direct rendering in avviddec on GL that
does not support PBO transfer.

https://bugzilla.gnome.org/show_bug.cgi?id=763045
2017-12-09 19:32:17 +00:00
Matthew Waters
9d66a5ff06 eglimagememory: add compatibility definitions for EGL dmabuf
e.g. the RPi doesn't have them defined
2017-12-09 19:32:17 +00:00
Matthew Waters
5f87cc0b65 glcontext: add a method to add a context to another share group
Intended for use with wrapped contexts that are created shared with gst's
gl contexts in order to manage the internal sharegroup state correctly.

e.g. with caopengllayer (which is used in glimagesink and caopengllayersink
on OS X), we create a CGL context from the gst context and the sharing state
was not being correctly set on either GL context and gst_gl_context_is_shared()
was always returning FALSE.

With 11fb4fff80 only flushing with multiple
shared contexts, the required flush was not occuring causing screen
corruption or stuttering.

Note: this didn't affect GST_GL_API=opengl pipelines

https://bugzilla.gnome.org/show_bug.cgi?id=762620
2017-12-09 19:32:17 +00:00
Matthew Waters
7e108f4763 gl: fix the build
2d287812 was incomplete
2017-12-09 19:32:17 +00:00
Matthew Waters
e71e492413 gl: error out if the configured GL API is unsupported by our element
https://bugzilla.gnome.org/show_bug.cgi?id=759801
2017-12-09 19:32:17 +00:00
Julien Isorce
1377a0a4f9 gldebug: make sure debug is initialized when calling gst_gl_insert_debug_marker
Usually gl debug is initialized in gst_gl_context_create_thread.
But this function is not used when using the GstGLContextGPUProcess
from ChromiumGStreamerBackend.

Received signal 11 SEGV_MAPERR 000000000000
gst_debug_category_get_threshold
gst_gl_insert_debug_marker
gst_gl_base_filter_gl_start
2017-12-09 19:32:17 +00:00
Sebastian Dröge
adfd016d01 gl: Fix compiler warning about unused const variable with gcc 6
CC       libgstgl_x11_la-gstglcontext_glx.lo
In file included from gstglcontext_glx.c:39:0:
../utils/opengl_versions.h:52:43: error: ‘gles2_versions’ defined but not used [-Werror=unused-const-variable]
 static const struct { int major, minor; } gles2_versions[] = {
                                           ^~~~~~~~~~~~~~
2017-12-09 19:32:17 +00:00
Sebastian Dröge
af5eddc6e8 gl: Move private headers from SOURCES to noinst_HEADERS 2017-12-09 19:32:16 +00:00
Matthew Waters
86edea9725 glfilter: insert the debug marker from the GL thread
https://bugzilla.gnome.org/show_bug.cgi?id=761538
2017-12-09 19:32:16 +00:00
Sebastian Dröge
745071b5bf gl: Remove leftover g_prints
One was commented out, but we also don't use // comments :)
2017-12-09 19:32:16 +00:00
Matthew Waters
88d71c10ca gldebug: use the correct spelling for behavior
The headers use the american spelling of behavior not the UK/AUS version with
the extra U.
2017-12-09 19:32:16 +00:00
Matthew Waters
7dcdb1d29c glcontext: don't enable GL debug for messages that won't be logged
This is an optimization to avoid pointless string processing.
2017-12-09 19:32:16 +00:00
Tim-Philipp Müller
1390312037 gl: syncmeta: define GL_TIMEOUT_IGNORED in more portable way 2017-12-09 19:32:16 +00:00
Alessandro Decina
bc8d272aad gstglshader: cache uniform locations
Avoid redundant calls to glGetUniformLocation. The results can be cached once
the shader has been linked.
2017-12-09 19:32:16 +00:00
Alessandro Decina
7e1a42ce55 gstglcontext: micro optimization to gst_gl_context_thread_add
Invoke the callback right away when called on the context thread. Removes
overhead when nesting libgstgl calls (for example when working with the sync
meta).
2017-12-09 19:32:16 +00:00
Matthew Waters
fb34d8a04b glsyncmeta: add compatibility definition for GL_TIMEOUT_IGNORED 2017-12-09 19:32:16 +00:00
Matthew Waters
f4bd4434c4 glsyncmeta: separate out gpu/cpu waits.
CPU waits are more expensive and are only required if the CPU is ever going to
access the data. GPU waits perform inter-context synchronisation and are cheaper
as they don't require CPU intervention.
2017-12-09 19:32:16 +00:00
Matthew Waters
f4bab389c5 gl: add .def file for msvc builds
Also internalize some API from being exported.
2017-12-09 19:32:16 +00:00
Luis de Bethencourt
265005a5e1 glquery: remove unnecessary pointer check
All uses of query->context in gstglquery.c assume it exists. We can assume
this as well before unrefing it. Furthermore, gst_object_unref() will just
silently return if it ever were to not exist.
2017-12-09 19:32:16 +00:00
Matthew Waters
ed40eaca00 glbasefilter: enable qos by default
Improves the responsiveness of the pipeline when resources are close/above the
limitations of the hardware.

Any subclass that wishes not to enable qos can do so themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=761519
2017-12-09 19:32:16 +00:00
Matthew Waters
62588100fd Revert "gl/eagl: try getting a gles3 context"
This reverts commit 96b9666d59.
This reverts commit d11385d167.

This breaks the texture sharing with the applemedia elements as
CVOpenGLESTextureCache seems to have an arbitrary restriction on GLES2 only.
2017-12-09 19:32:16 +00:00
Matthew Waters
17f2b9b252 glcolorconvert: don't skip subset structures
We may need them to transform into a different set of formats.

Fixes YUV->YUV with two glcolorconverts, e.g:

format=I420 ! glcolorconvert ! glcolorconvert ! format=NV12
2017-12-09 19:32:16 +00:00
Matthew Waters
63f7d0a396 glbasefilter: always call gl_start when not called already
Fixes elements transitioning out of passthrough mode using GL resources that
hadn'e been allocated yet.
2017-12-09 19:32:16 +00:00
Matthew Waters
e2c9f4570c glcolorconvert: fix RGB,rectangle->planar YUV conversion
Converting to GRAY is no fun.  Another case of normalized vs unnormalized
texture coordinates.
2017-12-09 19:32:16 +00:00
Matthew Waters
b4704301c6 glcolorconvert: fix YUY2/UYVY,rectangle->RGB conversion
1.0 / width does not offset by one pixel in rectangular textures (which use
unnormalized coordinates).

Provide the actual pixel offset as a uniform to the shader.
2017-12-09 19:32:16 +00:00
Matthew Waters
32b71bd48d glcolorconvert: perform better negotiation
1. Correctly describe what we can caps we can transform to/from.
   i.e. no YUV->YUV or GRAY->YUV or YUV->GRAY (except for passthrough).
2. Prefer similar formats and ignore incompatible formats on fixation.
2017-12-09 19:32:16 +00:00
Julien Isorce
f2cfa7fb51 gstglwindow: initialize navigation_loop to NULL
Useful when gst_gl_window.c::gst_gl_window_new is not used.
This is the case when using a custom GstGLWindow.
(ex: GstGLWindowGPUProcess from Chromium)
2017-12-09 19:32:16 +00:00
Tim-Philipp Müller
a0d62ce32c gl: eagl: fix build
gstglcontext_eagl.m:238:45: error: too few arguments to function call,
expected at least 4, have 3
2017-12-09 19:32:16 +00:00
Matthew Waters
de5f87e72b gl/eagl: try getting a gles3 context
Fallback to a gles2 context if that fails
2017-12-09 19:32:15 +00:00
Wang Xin-yu (王昕宇)
1e4c9c1688 glprototypes: fix parameter type of glGenBuffers
The number of buffers should be GLsizei instead of GLuint.

https://bugzilla.gnome.org/show_bug.cgi?id=761272
2017-12-09 19:32:15 +00:00
Matthew Waters
d41c132dfa glcontext: back out unintended lost_context changes 2017-12-09 19:32:15 +00:00
Matthew Waters
5d2ddf7664 egl: implement selecting opengl3 contexts 2017-12-09 19:32:15 +00:00
Matthew Waters
786b2fb9f1 gl/egl: pass the error value to get_error_string() 2017-12-09 19:32:15 +00:00
Matthew Waters
2cef90184e gl: move control binding proxy implementation from glvideomixer
Other elements may need to use it's functionality
2017-12-09 19:32:15 +00:00
Holger Kaelberer
944923080b glwindow: Fix android build
https://bugzilla.gnome.org/show_bug.cgi?id=760972
2017-12-09 19:32:15 +00:00
Tim-Philipp Müller
370a151ee2 libs: g-i: fix init section to avoid compiler warnings
..GstPlayer-1.0.c: In function ‘main’:
..GstPlayer-1.0.c:587:3: warning: implicit declaration of function ‘gst_init’

https://bugzilla.gnome.org/show_bug.cgi?id=760090
2017-12-09 19:32:15 +00:00
Sebastian Dröge
72afdda3b3 glfilter: First make caps writable in fixate_caps(), then truncate them
Truncating requires writable caps.
2017-12-09 19:32:15 +00:00
Sebastian Dröge
f05da0fef7 glcolorconvert: Caps passed to fixate_caps() are not owned by us and guaranteed to be fixed
So don't try to fixate them, which takes ownership and steals them from
basetransform.

https://bugzilla.gnome.org/show_bug.cgi?id=760696
2017-12-09 19:32:15 +00:00
Sebastian Dröge
a208624354 Revert "glpool: fix caps refcount issue"
This reverts commit 3bdcdedfa0.

gst_caps_replace() takes a new reference already, if there is a problem then
it is elsewhere. And there are a few problems, see
https://bugzilla.gnome.org/show_bug.cgi?id=760696
2017-12-09 19:32:15 +00:00
Matthew Waters
554b23ae48 glquery: provide compat definition for GL_QUERY_RESULT
e.g. android doesn't have it

While we're here move a state specific assertion after the supported check.
Removes an assertion on GLES
2017-12-09 19:32:15 +00:00
Matthew Waters
fc882653b6 gl: add compatibility definition of GLint64
e.g. anrdoid doesn't have it
2017-12-09 19:32:15 +00:00
Matthew Waters
06d8000708 glpool: fix caps refcount issue
The caps are from an allocation query which are transfer none but were being
treated as transfer full.
2017-12-09 19:32:15 +00:00
Matthew Waters
575974aeaf glmemory: log the time for glTexSubImage/glReadPixels 2017-12-09 19:32:15 +00:00
Matthew Waters
65533b807c gl: add a gstglquery object for arbitrary GL queries
Currently only GL_TIME_ELAPSED and GL_TIMESTAMP are supported
2017-12-09 19:32:15 +00:00
Matthew Waters
a41f91253e gldebug: implement a delayed debug system
The messages are stored by gst_gl_async_debug_store_log_msg() and output later
by a corresponding store(), output() or an unset()/free().

Some wrapper macros are provided to avoid callers explicitly using __FILE__,
GST_FUNCTION and __LINE__
2017-12-09 19:32:15 +00:00
Matthew Waters
b804aa2399 gldebug: use gst_info_vasprintf in insert_debug_marker()
Allows expansion of GST_PTR_FORMAT and GST_SEGMENT_FORMAT arguments.
2017-12-09 19:32:15 +00:00
Matthew Waters
b56d9bd57b glfilter: recreate the fbo on caps changes
The width/height may change which requires recreating the depth buffer.
2017-12-09 19:32:15 +00:00
Matthew Waters
cb9463d1a2 glbasefilter: add a class function on set_caps (from GL)
This is simply a convenience to avoid duplicating the thread marshalling on
set_caps.
2017-12-09 19:32:14 +00:00
Matthew Waters
d5913f3048 gl/x11/navigation: add button press to the selected event mask
Otherwise we won't get the button press events and GstNavigation fails.
2017-12-09 19:32:14 +00:00
Alessandro Decina
c2a6c97a1d glcolorconvert: try harder to passthrough
This makes a pipeline like:

... ! video/x-raw(memory:GLMemory),format=UYVY ! glcolorconvert !
video/x-raw(memory:GLMemory),format={UYVY, NV12} ! ...

passthrough instead of converting UYVY => NV12. The conversion would happen
before this change since the element (and basetransform) transform the src caps
to format={NV12, UYVY} (since NV12 comes first in the glcolorconvert:src
template) and then the default caps fixate func would fixate to NV12. Blah.

Also there's no need to intersect against the template caps in ::transform_caps
since basetransform does that right after calling the vfunc.
2017-12-09 19:32:14 +00:00
Matthew Waters
1e94a8f0fb gldebug: add a specific category for the debug spam from the driver 2017-12-09 19:32:14 +00:00
Matthew Waters
0cf1eaf71a glbasememory: Free the actual memory object when requested
Otherwise we are leaking ~400B on each GstMemory allocation.

Freeing in the base class matches the GObject semantics.
2017-12-09 19:32:14 +00:00
Matthew Waters
880d2798b0 glmemorypbo: don't double read pixels
The optimistic download_transfer was not setting the required flag to not
perform glReadPixels on subsequent map (READ). resulting in glReadPixels
happening twice.
2017-12-09 19:32:14 +00:00
Matthew Waters
5ba0ab3da9 glmemory: expose gst_gl_memory_texsubimage
Removes extremely similar code from glmemorypbo.
2017-12-09 19:32:14 +00:00
Matthew Waters
1b49603d78 glfeature add a specific debug category
Saves having to trawl through the 'default' category when function retrieval
goes wrong.
2017-12-09 19:32:14 +00:00
Matthew Waters
6667408cb5 glsyncmeta: only flush with a shared context
The wait code will flush for us for single context pipelines.
2017-12-09 19:32:14 +00:00
Matthew Waters
472970324c glcontext: implement checking whether a context has been shared
Some operations are unnecessary when running with only a single GL
context.
e.g. glFlush when setting a fence object as the flush happens on wait.

API: gst_gl_context_is_shared
2017-12-09 19:32:14 +00:00
Matthew Waters
a0a0e51249 glcolorconvert: implement usage of a buffer pool
Saves unnecessary glGenTextures and glDeleteTextures which may have a
non-trivial cost.
2017-12-09 19:32:14 +00:00
Matthew Waters
3cefdd6673 glbasememory: fix copying GstGLAllocationParams
Fixes a GST_IS_GL_CONTEXT critical
2017-12-09 19:32:14 +00:00
Matthew Waters
48fbc9e096 glmemorypbo: remove unused code
https://bugzilla.gnome.org/show_bug.cgi?id=759679
2017-12-09 19:32:14 +00:00
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
Jan Schmidt
d7f508acbb glviewconvert: Fix stereoscopic handling w/ texture-target
The addition of texture-target negotiation broke stereoscopic
handling when not in passthrough mode, so fix that.
2017-12-09 19:32:14 +00:00
Matthew Waters
633c26884e glmemorypbo: fix wrapping data on GL 2.1
GL 2.1 only supports pbo upload.

The wrapped data pointer was only being set on the pbo memory and on the
glmemory so when a download was requested (in GL 2.1), glmemory was
allocating a new data pointer and thus not returning the wrapped data.
2017-12-09 19:32:14 +00:00
Matthew Waters
5aca58ce86 glmemorypbo: only create a pbo memory if the context actually supports it
e.g. GL <= 2.0 does not support pbo usage and GL 2.1 only supports pbo upload.
2017-12-09 19:32:14 +00:00
Matthew Waters
3695ab353d glmemory: small code reformat
makes the alloc_params selections fit on a single line.
2017-12-09 19:32:14 +00:00
Sebastian Dröge
0aa1373a61 glbasememory: Remove bogus NULL check
CID 1346534
2017-12-09 19:32:14 +00:00
Sebastian Dröge
04d5db14be gl: Add \0 terminators for the Apple sync extension
Otherwise GL initialization might check for extensions forever and never finishes.
2017-12-09 19:32:13 +00:00
Sebastian Dröge
5d38c24aaa glcontext: Add some debug output when the GL thread is actually running 2017-12-09 19:32:13 +00:00
Vineeth TM
8917f84993 glbufferpool: Fix build error
When GST_GL_HAVE_PLATFORM_EGL is not defined, then info variable
will not be used and this results in build error

https://bugzilla.gnome.org/show_bug.cgi?id=759913
2017-12-09 19:32:13 +00:00
Sebastian Dröge
45d7796949 glmemorypbo: Comment out unused functions to fix compilation with clang
It's not clear if these are intentionally unused or the code should be
changed, but this fixes compilation for the time being at least.

See https://bugzilla.gnome.org/show_bug.cgi?id=759679
2017-12-09 19:32:13 +00:00
Sebastian Dröge
039865fc03 glcontext: Signal context creation from inside the context loop and use g_thread_join() instead of a custom condition variable
Also protect against spurious condition variable wakeups during context
creation.
2017-12-09 19:32:13 +00:00
Sebastian Dröge
1403a6871f glwindow: Hide navigation specific internal API and add API to asynchronously send navigation events
Exposing the navigation thread's main context, GSourceFuncs and structs called
key_event and mouse_event is exposing a bit too much of the internals. Let's
just go with two functions to asynchronously send navigation events on the
window with the same API as the synchronous ones.
2017-12-09 19:32:13 +00:00
Sebastian Dröge
8b00b1347e glwindow: Use g_thread_join() instead of a custom condition variable for waiting for the navigation thread to finish
Also hide some internal functions and fields while we're at it and fix
a race condition with the startup condition variable.
2017-12-09 19:32:13 +00:00
Haihua Hu
9fcf5500b2 glwindow: Fix memory leak of navigation thread
When stopping the navigation thread, call g_thread_join() to release
the resources hold by it.

https://bugzilla.gnome.org/show_bug.cgi?id=758820
2017-12-09 19:32:13 +00:00
Nicolas Dufresne
35075fcb78 glconvert: Fix compilation of GRAY16_LE/BE shader 2017-12-09 19:32:13 +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
Nicolas Dufresne
f91b4eb4ff eglimagememory: Also import BGR16, ABGR, xBGR, AYUV, GRAY16_LE/BE and Y444
https://bugzilla.gnome.org/show_bug.cgi?id=743345
2017-12-09 19:32:13 +00:00
Nicolas Dufresne
9567542ca2 eglimagememory: Add RGB/BGR DMABuf importation support
https://bugzilla.gnome.org/show_bug.cgi?id=743345
2017-12-09 19:32:13 +00:00
Lubosz Sarnecki
0468dc6663 eglimagememory: Methods to create GstGLMemory from dmabufs
Maps GstVideoFormats to suitable DRM fourccs which work with
glcolorconvert, using gst_gl_memory_alloc(). We require mostly
only 4 formats to be supported by the driver. We require DRM
equivalent to RGB16, RGBA, R8 and RG88. This way it's compatible with
DesktopGL, since GL_TEXTURE_2D is used and limit driver requirements.
With this we can virtually support all formats the glcolorconvert
supports.

https://bugzilla.gnome.org/show_bug.cgi?id=743345
2017-12-09 19:32:13 +00:00
Lubosz Sarnecki
76129f11ea build: Add dmabuf build condition.
configure.ac: Build dmabuf when EGL and drm_fourcc.h is available.
gl: Link gst-allocators.

https://bugzilla.gnome.org/show_bug.cgi?id=743345
2017-12-09 19:32:13 +00:00
Lubosz Sarnecki
376b1eb262 gstglcontext_egl: Expose gst_gl_context_egl_get_error_string.
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
f5dfc0ca35 glbasememory: don't unconditionally add the alignment bytes to the size
e.g when wrapping a data pointer we don't want to map/unmap off the end of
pointer with the alignment bytes.

Instead track that information separately as maxsize is used for mapping by
GstMemory and thus represents a size without any alignment padding bytes.
2017-12-09 19:32:13 +00:00
Matthew Waters
a51eccc734 glbuffer: add a name to the allocator 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
Matthew Waters
2c5ae0c784 glmemory: document gst_gl_memory_init 2017-12-09 19:32:13 +00:00
Matthew Waters
c870a9cdd5 glbuffer: remove unneeded gst_gl_buffer_alloc()
Replaced by gst_gl_base_memory_alloc()
2017-12-09 19:32:13 +00:00
Matthew Waters
65afaf7e84 glbasememory: document some functions 2017-12-09 19:32:13 +00:00
Matthew Waters
12360432c6 glmemory: add a default copy implementation
Subclasses still need to override this to copy into the correct memory type.
2017-12-09 19:32:13 +00:00
Matthew Waters
1781e465a0 glbufferpool: use gst_gl_base_memory_alloc as a generic GL allocation framework
Requires the usage of GstGLVideoAllocationParams however any user can set their
own parameters along with an allocator which will be used to allocate the
correct memory type.
2017-12-09 19:32:12 +00:00
Matthew Waters
228481da18 glmemorypbo: implement GstGLBaseMemory:alloc
Uses the GstGLVideoAllocationParams parameters
2017-12-09 19:32:12 +00:00
Matthew Waters
9d862cb83f glbuffer: implements GstGLBaseMemory::alloc
Create GstGLBufferAllocationParams which is subclass of GstGLAllocationParams
2017-12-09 19:32:12 +00:00
Matthew Waters
8e79ad3248 glmemory: implement GstGLBaseMemory::alloc
- Create GstGLVideoAllocationParams which is a GstGLAllocationParams subclass.
- Make it possible to allocate glmemory objects directly if no frills are
  needed.
2017-12-09 19:32:12 +00:00
Matthew Waters
93215927a9 glbasememory: add a generic interface for allocating GL memories
This is made possible by a subclassable GstGLAllocationParams that holds
the allocation parameters

Every allocation would now go through gst_gl_base_memory_alloc with the
allocation parameters now being specified in a single struct to allow
extension by different allocators.
2017-12-09 19:32:12 +00:00
Matthew Waters
4cb42d34c6 Revert "glbuffer: Don't pass allocation params"
This reverts commit 052f41e5c2.

This is incorrect and will affect any other glbuffer user that needs/wants to
perform data alignment.
2017-12-09 19:32:12 +00:00
Nicolas Dufresne
81cb10aa05 glbuffer: Don't pass allocation params
The imported memory has already been allocated, passing allocation
parameters with alignment confuses the memory which endup with a
size different from maxsize and lead to overrun when the memory
is being copied.
2017-12-09 19:32:12 +00:00
Alessandro Decina
b365425dc2 glupload: fix allocator name after GLMemory API changes 2017-12-09 19:32:12 +00:00
Nicolas Dufresne
8f4ba29f97 gl: Allow using non-system mesa with both GL and GLES
GCC automatically disable redundance warnings for system headers. As
soon as we start using a non-system installed mesa, we would start
having issues. The test for both wasn't setting any flags, so it would
work but then fail at runtime.

This is being fixed by disabling in the code (where needed only) that
GCC warning. The test is also fixed to avoid the false positive we had.
2017-12-09 19:32:12 +00:00
Xavier Claessens
ac6e8e93a2 bad: Add g_autoptr() support to all types
https://bugzilla.gnome.org/show_bug.cgi?id=754464
2017-12-09 19:32:12 +00:00
Luis de Bethencourt
648c2e20dc glviewconvert: check pointer before dereferencing
priv->primary_out could be NULL, check before dereferencing it in
GST_BUFFER_FLAG_SET ()

CID 1308945
2017-12-09 19:32:12 +00:00
Matthew Waters
4fc012af19 glbuffer: bind/unbind on map/unmap for GL mappings
Bind the handle to the GL target on map/unmap to save the caller from
handling this themselves.
2017-12-09 19:32:12 +00:00
Matthew Waters
ab75223594 glbuffer: remove buffer specific transfer flags
Instead rely on GstGLBaseMemory's transfer handling
2017-12-09 19:32:12 +00:00
Matthew Waters
f83b834628 glmemorypbo: map/unmap pbo memory correctly for state tracking
Otherwise some downloads will fail to occur from the PBO.
2017-12-09 19:32:12 +00:00
Matthew Waters
d1812fc73c glformat: add compatibility definitions for OES/rectangle textures 2017-12-09 19:32:12 +00:00
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