Commit graph

1600 commits

Author SHA1 Message Date
Matthew Waters 18ac98c58b gl: GST_GL_TYPE -> GST_TYPE_GL
Some deprecated symbols are kept for backwards compatibility
2017-12-09 19:32:23 +00:00
Matthew Waters 9bafa08a5d gl/docs: massive update
- add Since: markers where necessary.
- document structs
- add documentation headers for each module (short_description,
  see_also, etc)
- reduce the number of warnings gtk-doc outputs
- fix spelling mistakes
2017-12-09 19:32:23 +00:00
Matthew Waters 51a6f47bf8 gl/docs: document new API added in 1.10
GstGLRenderbuffer
GstGLFramebuffer
GstGLQuery
GstEGLImage
GstGLMemoryEGL
2017-12-09 19:32:23 +00:00
Matthew Waters 8faebcf915 glsl: fix #version 150 not working with profiles
The spec allows the core/compatibility profiles to be used
with #version 150.

Also tighten up the tests to check for default profiles being chosen
correctly.
2017-12-09 19:32:23 +00:00
Nirbheek Chauhan a3968fa896 build: Also need to define GST_EXPORTS for Autotools
The change to use GST_EXPORT for symbols under Windows requires
GST_EXPORTS for internal use, and that is also needed under Autotools.
The same thing is done for gstreamer-1.0.dll in -core.
2017-12-09 19:32:23 +00:00
Nirbheek Chauhan d57808385c gstgl: Re-enable WINAPI on _MSC_VER
The calling convention may be deprecated, but we still need it for
OpenGL. The build issue was caused by an incorrect syntax being used for
the WINAPI (__stdcall) prototype in function pointers which was accepted
by GCC but is rejected by MSVC.
2017-12-09 19:32:23 +00:00
Nirbheek Chauhan 503822eb20 Explicitly define float constants as float
With MSVC, this gives the following warning:

warning C4305: 'function': truncation from 'double' to 'gfloat'

Apparently, MSVC does not figure out what type to use for constants
based on the assignment. This warning is very spammy, so let's try to
fix it.
2017-12-09 19:32:23 +00:00
Nirbheek Chauhan 6106816f50 gstgl: Add GST_EXPORT to all symbols used on Windows
This is a requirement for those symbols to be exported in gstgl-1.0.dll
when building with the MSVC compiler
2017-12-09 19:32:23 +00:00
Nirbheek Chauhan c7c2a68de2 meson: Add support for building WGL on Windows
Currently only tested with MSVC.
2017-12-09 19:32:23 +00:00
Nirbheek Chauhan 45ad33c94c gstgl: Porting fixes for MSVC with Meson
GL/gl.h needs windows.h on MSVC

WINAPI should not be used with MSVC. It also causes a build error.
2017-12-09 19:32:23 +00:00
Matthew Waters 08e20ff131 glsyncmeta: don't glFinish() everytime a sync point is set
At minimum, we only need to glFlush() if we are in a shared GL context
environment.  Move the glFinish() to when the actual wait is requested
which may be never.  Improves the throughput on older GL systems without
GL3/GLES3 and/or fence sync objects.
2017-12-09 19:32:23 +00:00
Matthew Waters 99f5ac40db meson: gl: add support for building with dispmanx on the rpi 2017-12-09 19:32:23 +00:00
Matthew Waters 36b8ed8712 gl/eglimage: Fix passing the destroy function to gst_egl_image_new_wrapped
The function pointer and the user data arguments were swapped in both
uses.

https://bugzilla.gnome.org/show_bug.cgi?id=769382
2017-12-09 19:32:23 +00:00
Munez e49f723a07 Implemented gst_video_overlay_set_window_handle()
https://bugzilla.gnome.org/show_bug.cgi?id=772608
2017-12-09 19:32:23 +00:00
Matthew Waters 78d8e895df meson: gl: fix detection of glx without gl
We need to check for libGL if we may use desktop OpenGL *or* GLX.
2017-12-09 19:32:23 +00:00
Matthew Waters f70d4ec22d meson: gl: fix incorrect error string
Use the winsys variable for an incorrect winsys provided
2017-12-09 19:32:23 +00:00
Munez 0207ce9818 gl/dispmanx: egl_show should resize the window only if there is no render rectangle set
https://bugzilla.gnome.org/show_bug.cgi?id=772699
2017-12-09 19:32:23 +00:00
Munez 7a41cbd599 gl/dispmanx: Fix set_render_rectangle typo
https://bugzilla.gnome.org/show_bug.cgi?id=772698
2017-12-09 19:32:23 +00:00
Matthew Waters 126ee924c0 glwindow: don't use g_thread_join() to join the navigation thread
Using g_thread_join() in _finalize() handlers may result in a deadlock
joining the current thread when the last reference is held by a signal
handler.

e.g.:

error 'Resource deadlock avoided' during 'pthread_join (pt->system_thread, NULL)'

The backtrace looks like this:
[...]
g_thread_join ()
gst_gl_window_finalize ()
gst_gl_window_x11_finalize ()
g_object_unref ()
g_value_unset ()
g_signal_emit_valist ()
g_signal_emit ()
gst_gl_window_send_mouse_event ()
gst_gl_window_mouse_event_cb ()
g_main_dispatch ()
[..]
g_main_loop_run ()
gst_gl_window_navigation_thread ()
g_thread_proxy ()
start_thread ()
clone ()
2017-12-09 19:32:23 +00:00
Matthew Waters 112f85a474 gl/win32: remove egl implementation
It hasn't been used in ages and is dead code.
2017-12-09 19:32:22 +00:00
Gwang Yoon Hwang 485dffa6d5 gl/dispmanx: Implements set_render_rectangle to adjust the position of window
We cannot set the x, y coordinate of the video frame at the dispmanx at
this point. We need to teach dispmanx backend to understand about
set_render_rectangle API to draw a video with other UI.

This patch keeps the current behavior which places video frame at the
center of the display if there is no set_render_rectangle call to the
dispmanx window.

https://bugzilla.gnome.org/show_bug.cgi?id=766018
2017-12-09 19:32:22 +00:00
Matthew Waters 1e8c7e0f31 gl: add necessary padding bytes to all public structs 2017-12-09 19:32:22 +00:00
Matthew Waters 7cbac97b94 gldisplay: also free the GWeakRef when removing dead contexts
Otherwise we leak GWeakRef's.

Found with make -C tests/check libs/gstglcontext.valgrind
2017-12-09 19:32:22 +00:00
Matthew Waters f678dcaf2b meson/gl: use separate deps for gl and glx
e.g. passing with_gl_api=gles2 would still build the glx code but not be
linking against the libGL library which is where the glX* functions are
located and would result in a linker error.

Solved by checking for the libGL library if either opengl or glx may be
needed and then disabling the corresponding deps as requested.
2017-12-09 19:32:22 +00:00
Matthew Waters 8d60fa2327 meson: add some starting build files for GL
Currently only works on linux with egl/glx + wayland/x11 but the general
principals have been layed out for adding the other GL platforms/winsys'.
2017-12-09 19:32:22 +00:00
Alistair Buxton 94f5fc5d83 gl: Remove duplicate GL_CFLAGS in Makefile.am.
https://bugzilla.gnome.org/show_bug.cgi?id=771021
2017-12-09 19:32:22 +00:00
Jan Schmidt ae89055e67 gl: Remove extra duplicate typedef of GstGLFramebuffer
It's triggering a warning building git master on OSX
2017-12-09 19:32:22 +00:00
Alessandro Decina 29d6825f11 glupload: fix tests and check for the new RECONFIGURE behaviour
The tests were broken since 91fea30, which changed glupload to return
GST_GL_UPLOAD_RECONFIGURE if the texture target in the input buffers doesn't
match the texture-target configured in the output caps.

This commit fixes that and adds more checks for the new behaviour.
2017-12-09 19:32:22 +00:00
Alessandro Decina cc9f65f191 gstglupload: make the GLMemoryUpload method output the correct texture-target
Now when used with video/x-raw as input, the GLMemoryUpload method checks for
->tex_target in input GLMemory(es) and sets the output texture-target
accordingly.

Fixes video corruption with a pipeline like avfvideosrc ! video/x-raw !
glimagesink where on macos avfvideosrc pushes RECTANGLE textures but glupload
was configuring texture-target=2D as output.
2017-12-09 19:32:22 +00:00
Jan Schmidt 179f7c00fe glviewconvert: Fix texture target fixation
Don't set the chosen texture-target into the wrong structure.
The input caps may not be writable, and in any case - the
intention was to configure the othercaps. Also, remove an
extra unref - the othercaps ref is consumed by
gst_caps_make_writable already.
2017-12-09 19:32:22 +00:00
Nirbheek Chauhan 598f8e0121 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Matej Knopp <matej.knopp@gmail.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2017-12-09 19:32:22 +00:00
Matthew Waters 792299d9ae glwindow: marshal gst_gl_window_resize through the window loop
saves having every caller do it themselves.
2017-12-09 19:32:22 +00:00
Matthew Waters 2763baf439 gl/wayland: use multi-threaded safe event wayland API
Multiple threads may be accessing the wayland fd at the same time which
requires the use of special wayland API to deal with to ensure nobody
will steal reads and cause a stall for anyone else.
2017-12-09 19:32:22 +00:00
Matthew Waters 19f32c0f49 gl/egl: fix inverted typedef
2b6841d had an inverted typedef defining ginptr and EGLAttrib.  Fix that.
2017-12-09 19:32:22 +00:00
Matthew Waters 1a7333173a gl/build: add configure check for possibly missing EGLAttrib
Fixes the build on older android targets.
2017-12-09 19:32:22 +00:00
Song Bing 15c34b0ab1 gl/egl/dmabuf: Wrong attribute list type for EGL 1.5
For EGL 1.5 spec, the attribute list type should be EGLAttrib.

https://bugzilla.gnome.org/show_bug.cgi?id=768602
2017-12-09 19:32:22 +00:00
Vincent Penquerc'h b9224e62b5 glcontext: fix race joining thread on finalize
https://bugzilla.gnome.org/show_bug.cgi?id=769939
2017-12-09 19:32:21 +00:00
Matthew Waters 6b635559cd glcolorconvert: add missing rgb16 and bgr16 video formats in switch
Fixes an assertion that code should not be reached

https://bugzilla.gnome.org/show_bug.cgi?id=769462
2017-12-09 19:32:21 +00:00
Haihua Hu 4cd94ddd25 glwindow: Fix glimagesink cannot show frame when connect to qmlglsrc
When connect to qmlglsrc, x11 event loop will be replace by qt event loop
which will cause the window cannot receive event from xserver, such as resize

https://bugzilla.gnome.org/show_bug.cgi?id=768160
2017-12-09 19:32:21 +00:00
Hyunjun Ko d875e0a727 glupload: Use bufferpool to allocate new buffer in GLTextureUploadMeta
To improve performace of upload with GLTextureUploadMeta,
use bufferpool instead of allocating new buffer every time.

https://bugzilla.gnome.org/show_bug.cgi?id=769293
2017-12-09 19:32:21 +00:00
Matthew Waters 85d5489f58 glwindow: move unsetting queue_resize to _resize() instead of _draw()
Makes infinitely more sense and implementation were expecting that behaviour
anyway and would enter a resize, draw, resize, draw, ... cycle instead of only
resizing once.
2017-12-09 19:32:21 +00:00
Matthew Waters 9eda7912b4 glframebuffer: add compatibility definition for GL_DEPTH_STENCIL_ATTACHMENT
GLES2 doesn't have it defined...
2017-12-09 19:32:21 +00:00
Matthew Waters b3d8e09839 glfilter: rewrite subclasses for filter_texture() occuring on GL thread
There's no need for the jump to an extra thread in most cases, especially
when relying solely on a shader to render.  We can use the provided
render_to_target() functions to simplify filter writing.
2017-12-09 19:32:21 +00:00
Matthew Waters 1ffbc2f1ae glutils: remove unused GstGLDisplayProjection 2017-12-09 19:32:21 +00:00
Matthew Waters 3c1c5e9d83 glcontext: remove not thread-safe get/set_error()
Use GError's instead if necessary.
2017-12-09 19:32:21 +00:00
Matthew Waters 4bbda2b626 glframebuffer: rewrite for a more consistent API
Facilities are given to create fbo's and attach GL memory (renderbuffers
or textures).  It also keeps track of the renderable size for use with
effective use with glViewport().
2017-12-09 19:32:21 +00:00
Matthew Waters 7f10822de4 gl: use GLMemory for accessing textures everywhere
This simplifies and consolidates a lot of duplicated code creating
and modifying textures.
2017-12-09 19:32:21 +00:00
Matthew Waters c7dd43f21a glfilter: rename draw_texture to draw_fullscreen_quad
And remove unused arguments.
2017-12-09 19:32:21 +00:00
Matthew Waters 7004e44be9 gl: add memory type for renderbuffer's
Soon to be used for framebuffers for e.g. depth buffers or throwaway color
buffers.
2017-12-09 19:32:21 +00:00
Matthew Waters 6485accb47 glformat: define our own set of formats from the GL defines
also add some depth/stencil formats
2017-12-09 19:32:21 +00:00
Matthew Waters adf47ea728 glbasememory: assert for a valid allocator instead of segfaulting 2017-12-09 19:32:21 +00:00
Tim-Philipp Müller 2c3a31c483 gl: wayland: improve debug message when connecting to display
And another copy'n'paste-o.

https://bugzilla.gnome.org/show_bug.cgi?id=768929
2017-12-09 19:32:21 +00:00
Matthew Waters ba00657e9d glviewconvert: fix transformation matrix usage
Calling glUniformMatrix before the shader is bound is invalid and
would result in errors like:

GL_INVALID_OPERATION in glUniformMatrix(program not linked)

Move glUniformMatrix() to after the gst_gl_shader_use() call.
2017-12-09 19:32:21 +00:00
Matthew Waters d9ed4ed447 glupload: fix raw data uploader with addition of GstVideoGLTextureType
Fixes regression from 989200820d

https://bugzilla.gnome.org/show_bug.cgi?id=768217
2017-12-09 19:32:21 +00:00
Olivier Crête 06b2871fcc glvideoconvert: RG/LA is available in OpenGL ES 3, so let that through 2017-12-09 19:32:21 +00:00
Matthew Waters 9554725cc2 Revert "Revert "gl/eagl: try getting a gles3 context""
This reverts commit eb14273631.

vtdec now successfully outputs textures that can be converted by
glcolorconvert in GLES3 contexts.
2017-12-09 19:32:21 +00:00
Matthew Waters 1153684a94 glmemory: add the texture type to allocate to parameters
Rather than assuming something.  e.g. zerocopy on iOS with GLES3 requires
the use of Luminance/Luminance Alpha formats and does not work with
Red/RG textures.
2017-12-09 19:32:21 +00:00
Matthew Waters 2ba0926385 glcolorconvert: don't assume Red/RG textures will be used
Take the used texture type from the memory instead.

Fixes conversion from multi-planar YUV formats with two components per plane
(NV12, NV21, YUY2, UYVY, GRAY16_*, etc) with Luminance Alpha input textures.

This is also needed for zerocopy decoding on iOS with GLES 3.x.
2017-12-09 19:32:21 +00:00
Matthew Waters db51c90d5d glcontext: correct precondition for get_gl_version
The intention was to assert if both maj and min were NULL (as there would be no
point calling the function).  Instead if either maj or min were NULL, the assert
would occur.

Fix that.
2017-12-09 19:32:21 +00:00
Sebastian Dröge f457e29192 eglimage: Only register debug category if dmabuf support is enabled
It's not used otherwise currently and causes compiler warnings.
2017-12-09 19:32:20 +00:00
Wang Xin-yu (王昕宇) 0decbc5c49 glcontext/wgl: try wglCreateContextAttribsARB even not gl3 core profile
https://bugzilla.gnome.org/show_bug.cgi?id=764018
2017-12-09 19:32:20 +00:00
Matthew Waters 4a6b20cc42 glcontext: fix get_current_gl_api() on win32
Another case of incorrect calling conventions.

Using this function on win32 would corrupt the stack pointer and end in
massive hilarity.
2017-12-09 19:32:20 +00:00
Matthew Waters dfd6565b4b glsl: fixup external-oes shaders by mangling the required extension
Newer devices require using a different GLSL extension for accessing
external-oes textures in a shader using the texture() functions.

While the GL_OES_EGL_image_external_essl3 should supposedly be supported
on a any GLES3 android device, the extension was defined after a lot of the
older drivers were built so they will not know about it.  Thus there are two
possible interpretations of which of texture[2D]() should be supported for
external-oes textures.  Strict adherence to the GL_OES_EGL_image_external
extension spec which uses texture2D() or following GLES3's pattern, also
allowing texture() as a function for accessing external-oes textures

This adds another mangling pass to convert
 #extension GL_OES_EGL_image_external : ...
into
 #extension GL_OES_EGL_image_external_essl3 : ...
on GLES3 and when the GL_OES_EGL_image_external_essl3 extension is supported.

Only uses texture() when the GLES3 and the GL_OES_EGL_image_external_essl3
extension is supported for external-oes textures.
Uses GLES2 + texture2D() + GL_OES_EGL_image_external in all other external-oes
cases.

https://bugzilla.gnome.org/show_bug.cgi?id=766993
2017-12-09 19:32:20 +00:00
Sergey Borovkov 0731b0937d qml: Enable qmlglsink for eglfs
https://bugzilla.gnome.org/show_bug.cgi?id=763044
2017-12-09 19:32:20 +00:00
Matthew Waters e9ba0b88e7 glsl: add some debugging 2017-12-09 19:32:20 +00:00
Matthew Waters 072b47d5b8 glutils: remove unused functions for texture creation/deletion
Everyone uses GstGLMemory now and any future code should as well.
2017-12-09 19:32:20 +00:00
Matthew Waters 632cc16767 glfilter: remove unused class fields in/out_tex_id
The functionality is not used by any subclass nor are the values set anywhere.
2017-12-09 19:32:20 +00:00
Matthew Waters 1da12235c3 gl/upload/meta: remove unneeded texture deletion
The textures are managed by the GstGLMemory inside the output buffer.  Freeing
them prematurely may result in a use-after-free.
2017-12-09 19:32:20 +00:00
Guillaume Desmottes b23a008ab6 gst-libs: gl, video: use MAY_BE_LEAKED flag
https://bugzilla.gnome.org/show_bug.cgi?id=767162
2017-12-09 19:32:20 +00:00
Havard Graff c8eef7bf44 gl: glquery: cast to silence compiler warning
https://bugzilla.gnome.org/show_bug.cgi?id=766973
2017-12-09 19:32:20 +00:00
Matthew Waters 57acec4b1c gldisplay: always unref the context on a collision
Otherwise we will leak GstGLContext's when adding the same context more than
once.

Fixes a regression caused by 5f9d10f603 in the
gstglcontext unit test that failed with:

Assertion 'tmp == NULL' failed
2017-12-09 19:32:20 +00:00
Xavier Claessens 1f58a480c9 gl: win32: Add debug category in gstglcontext_wgl.c
https://bugzilla.gnome.org/show_bug.cgi?id=766867
2017-12-09 19:32:20 +00:00
Haihua Hu 3cf27dd1c8 glimagesink: support video rotation using transform matrix
Add "rotate-method" to glimagesink and apply transform matrix
to vertex coordinate to control rotation.

https://bugzilla.gnome.org/show_bug.cgi?id=765795
2017-12-09 19:32:20 +00:00
Matthew Waters 537d1996e9 gldisplay: add some debugging about retrieving GL contexts 2017-12-09 19:32:20 +00:00
Sebastian Dröge 0ea3706901 eglimage: Re-add accidentially removed GST_DEFINE_MINI_OBJECT_TYPE() 2017-12-09 19:32:20 +00:00
Sebastian Dröge b054da4c96 eglimage: Ensure that the debug category is always initalized
Before the initializer was only run if dmabuf support was used.

https://bugzilla.gnome.org/show_bug.cgi?id=766794
2017-12-09 19:32:20 +00:00
Tim-Philipp Müller 7bf17ac500 g-i: pass compiler env to g-ir-scanner
It's what introspection.mak does as well. Should
fix spurious build failures on gnome-continuous.
2017-12-09 19:32:20 +00:00
Xavier Claessens 719298af98 gl: win32: Unparent internal window before destroying it
For some reason DestroyWindow() deadlock if it's called from
parent window's KeyPress event.

https://bugzilla.gnome.org/show_bug.cgi?id=766533
2017-12-09 19:32:19 +00:00
Xavier Claessens e2731f35bf gl: win32: Don't steal parent focus when creating internal window
This fix regression introduced by 0acc18c60f.

https://bugzilla.gnome.org/show_bug.cgi?id=766520
2017-12-09 19:32:19 +00:00
Matthew Waters 7e7aef92c2 gldisplay: demote no platform display debug to info
Avoids confusing everyone with a warning that's not always fatal.

https://bugzilla.gnome.org/show_bug.cgi?id=746933
2017-12-09 19:32:19 +00:00
Matthew Waters 2d62b2910c gl: take the affine transformation in NDC
Provide a function to get the affine matrix in the meta in terms of NDC
coordinates and use as a standard opengl matrix.

Also advertise support for the affine transformation meta in the allocation
query.
2017-12-09 19:32:19 +00:00
Matthew Waters 5efc2e8705 gl/egl: replace gsteglimagememory with an EGLImage wrapper
That can be passed to GstGLMemoryEGL.

This also ports the dmabuf uploader to GstEGLImage and GstGLMemoryEGL.
2017-12-09 19:32:19 +00:00
Gwang Yoon Hwang ecfe5b0801 gl: implement GstGLMemoryEGL
Because current GstEGLImageMemory does not inherit GstGLMemory, GLUpload
allocates additional GLMemory and upload the decoded contents from the decoder
which uses EGLImage (e.g. gst-omx in RPi).

This work adds GstGLMemoryEGL to avoid this overhead. Decoders allocate
GstGLMemoryEGL and decode its contents to the EGLImage of GstGLMemoryEGL.  And
GLUpload uses this memory without allocation of additional textures and blit
operations.

[Matthew Waters]: gst-indent the sources and fix a critical retreiving the egl
display from the memory.

https://bugzilla.gnome.org/show_bug.cgi?id=760916
2017-12-09 19:32:19 +00:00
Matthew Waters 2753b4243e glmemory: add wrapped data pointers to setup_buffer
Allows creating wrapped memories with GstGLAllocationParams.

The wrapped pointers will be set in the parameters before being passed
to the memory allocation function.
2017-12-09 19:32:19 +00:00
Matthew Waters 04e92acd3b glbasememory: take a pointer as the wrapped gpu handle
Allows passing arbitrary data to wrap the the specific memory implementation
which is required for some memory implementations.
2017-12-09 19:32:19 +00:00
Matthew Waters c459894f78 gl: fix gles3 header usage for older platforms
Some platforms provide an old version of GLES2/gl2.h and GLES2/gl2ext.h that
will fail when including GLES3/gl3.h due to missing typedef's.

Seen on the RPi.
2017-12-09 19:32:19 +00:00
Sebastian Dröge 1066b2a860 glviewconvert: Port more things to GLES/GL 3 compatibility
And move the shader mangling code into a single place instead of having a copy
in glcolorconvert and glviewconvert.

https://bugzilla.gnome.org/show_bug.cgi?id=765266
2017-12-09 19:32:19 +00:00
Sebastian Dröge 64c320ca3c glcolorconvert: GLES3 deprecates texture2D() and it does not work at all in newer versions than 3.3
Use the newer texture() function instead. This fixes glimagesink and other
things on various Android devices.

https://bugzilla.gnome.org/show_bug.cgi?id=765266
2017-12-09 19:32:19 +00:00
Hyunjun Ko 84be275c4f gl/cocoa: Fix incompatible type warning
https://bugzilla.gnome.org/show_bug.cgi?id=765292
2017-12-09 19:32:19 +00:00
Heinrich Fink caa9ad59e6 gl/caopengllayer: Apply layer.contentsScale to viewport dims
Fixes blurry content on HiDPI screens

https://bugzilla.gnome.org/show_bug.cgi?id=765194
2017-12-09 19:32:19 +00:00
Matthew Waters 614f80cbcf gl/cocoa/eagl: don't leak GThread's when dispatching messages
gst_gl_context_get_thread() returns a refed pointer, we need to unref it.
2017-12-09 19:32:19 +00:00
Matthew Waters 3ee2183038 glupload: keep the parent buffer around when converting EGLImage to 2D textures
e.g. receiving and releasing a buffer from OMX too early will potentially
cause textures to be overwritten while/before they are displayed.
2017-12-09 19:32:19 +00:00
Alessandro Decina 5c506cd857 libgstgl: cocoa, eagl: use libdispatch to schedule GL calls
Use libdispatch instead of GMainLoop to dispatch GL calls. libdispatch is more
optimized and cuts a lot of poll()/pthread_* overhead.
2017-12-09 19:32:19 +00:00
Alessandro Decina 3d124f498a glwindow: reduce the number of GMutexes and GConds in send_message()
Don't create many short lived locks/conds in gst_gl_window_send_message. This is
a micro optimization to save a bunch of pthread_* calls which are expensive on
OSX/iOS and possibly other platforms.
2017-12-09 19:32:19 +00:00
Matthew Waters b1a60af720 eglimage: perform eglCreateImage in the gl thread
while calling eglCreateImage without a GL context current in the executing
thread works on the RPi, some other implementations will return errors.

Marshall the eglCreateImage to the GL thread to appease these implementations.
2017-12-09 19:32:18 +00:00
Matthew Waters cbf3a986ca glviewconvert: support outputting to multiple draw buffers on GLES3
A similar change that was done to glcolorconvert adding the necessary shader
mangling.
2017-12-09 19:32:18 +00:00
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
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