Commit graph

1404 commits

Author SHA1 Message Date
Matthew Waters 85cddc0891 glcolorconvert: implement multiple render targets for GLES3
There are numerous slight differences required between Desktop GL and GLES3 for
multiple render targets.

1. gl_FragData doesn't exist at all and one is required to use
   'layout (location = ?) out ...' instead.
2. gl_FragColor doesn't exist, same as 1
3. texture2D() has been deprecated

Fortunately most of these have been taken care of with GL3 and the shader
mangling already exists so just expand the conditions they are used in.  The
gl_FragData issue requires a new mangle pass though.  We also use this new
pass on desktop GL for consistency.
2017-12-09 19:32:18 +00:00
Matthew Waters 597e98b64a glcolorconvert: don't use the predefined variable name sample
Using 'sample' as a variable name is an error in GLES3
2017-12-09 19:32:18 +00:00
Matthew Waters 97e66be37d gl: add support for building against GLES3 headers
with a fallback to GLES2 headers if available.
2017-12-09 19:32:18 +00:00
Matthew Waters 0c2890cd34 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.
2017-12-09 19:32:18 +00:00
Matthew Waters f1737c8ad7 glbasememory: rollback map state when subclass map fails
Otherwise our state doesn't reflect reality.
2017-12-09 19:32:18 +00:00
Matthew Waters 99dfbf8ed9 glmemorypbo: unmap pbo memory on pbo read error
Otherwise we are returning failure with a dangling map!

Also only unset the NEED_DOWNLOAD flag in download_transfer() if the read actually
succeeds.
2017-12-09 19:32:18 +00:00
Matthew Waters ccbf43987f glshader: add glBindFragDataLocation
There are some cases where it's needed for binding in/out variables in shaders.
e.g. glsl 150 (gl 3.2) doesn't support the 'layout (location = ?)' specifiers in
the shader source so we have to bind them ourselves.
2017-12-09 19:32:18 +00:00
Vineeth TM e92bbb2a83 bad: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763081
2017-12-09 19:32:18 +00:00
Matthew Waters b5e8763a07 gl/proto: sync operations are available on GLES 3.0
Without the GST_GL_API_GLES2 bit set, we will not even attempt to look
for the function pointers in the core library and will fallback to
glFlush/glFinish.
2017-12-09 19:32:18 +00:00
Matthew Waters b1bfcac299 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.
2017-12-09 19:32:18 +00:00
Matthew Waters 2ba61c9049 glutils: remove custom code for setting caps features
Just use gst_caps_set_features() instead.
2017-12-09 19:32:17 +00:00
Matthew Waters d5cc277601 glfilter: only allow the same src/sink caps when we are in passthrough mode
If we are given caps with extra features (like the overlay composition
features), we can only deal with that when we are in passthrough mode.

Previously we were bailing entirely and not allowing passthrough filter elements
with things like textoverlay.

Fixes the following pipeline (assuming glfilter supports passthrough):
gl ! textoverlay ! glfilter ! ... ! glimagesinkelement

https://bugzilla.gnome.org/show_bug.cgi?id=763756
2017-12-09 19:32:17 +00:00
Matthew Waters 356494d967 glupload: deal with the ANY caps feature correctly
When transforming, xplode it out into the necessary caps features both
with and without the passthough features.

Fixes negotiation in the following class of pipelines:

gl ! textoverlay ! glupload ! glimagesinkelement

https://bugzilla.gnome.org/show_bug.cgi?id=763756
2017-12-09 19:32:17 +00:00
Matthew Waters fdca1dec0d glshader: some compatibility changes for GL 1.4
GL 1.4 (with GL_ARB_shader_objects) doesn't have glIsProgram or glIsShader
equivalents.  As they are simply assertions, skip them when there isn't a
valid function pointer.
2017-12-09 19:32:17 +00:00
Matthew Waters 4406730633 glfilter: retrieve the shader attributes from the GL thread
Otherwise we will receive bogus values

https://bugzilla.gnome.org/show_bug.cgi?id=763365
2017-12-09 19:32:17 +00:00
Matthew Waters eb1a9bb9b0 gldisplay: make readding the same context a no-op
With e38af23044 returning the correct contexts,
gst_gl_display_add_context() was susceptible to causing infinte loops when
adding the same GstGLContext more than once.  Fix and add a test for
gst_gl_display_add_context().

Fixes glvideomixer gst-validate tests.
2017-12-09 19:32:17 +00:00
Sebastian Dröge 95415270f0 Revert "libgstgl: cocoa, eagl: don't marshal GL calls to the context thread"
This reverts commit 797d6415df.

We're frozen for 1.8.0 release and this change might have bigger impact.
2017-12-09 19:32:17 +00:00
Alessandro Decina 90889bc73f libgstgl: cocoa, eagl: don't marshal GL calls to the context thread
Execute GL calls without marshalling them to the context thread. In the cocoa
and eagl backends calling gst_gl_context_activate is cheap and therefore calling
it on the current thread and serializing GL calls with a per-context lock is
more efficient (faster and has less overhead) than marshalling everything to the
context thread.

This optimization cuts a large overhead in g_poll (continuously waking up the
context thread) and in g_mutex_*/g_cond_* (waiting for results from the context
thread).
2017-12-09 19:32:17 +00:00
Mark Nauwelaerts 6d343abec8 gldisplay: really retrieve glcontext for a specific thread
When requesting a glcontext (regardless of thread), the result was correct.
However, when requesting current glcontext on a specific thread, it could
come up with a glcontext active on another thread.

https://bugzilla.gnome.org/show_bug.cgi?id=763168
2017-12-09 19:32:17 +00:00
Matthew Waters 31b1094744 gl: misc docs fixes/additions 2017-12-09 19:32:17 +00:00
Matthew Waters 18a812a30f gl*memory: document new functionality and objects 2017-12-09 19:32:17 +00:00
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