Commit graph

149 commits

Author SHA1 Message Date
Haihao Xiang f0cbb78770 glimagesink: add support for VUYA format 2019-03-21 23:05:09 +00:00
Matthew Waters 6a37bf9bb9 gl: Don't restore the viewport on function exit
Doing so involves retrieving the current viewport from OpenGL which as
with any glGet operation, is expensive.

This means that the various sinks need to reset the viewport on draw.

In the process, fix resizing on cocoa.
2019-03-08 17:49:05 +11:00
Matthew Waters 86aa568383 glcolorconvert: Ensure we free the internal convert object
If we only ever make it to READY, transform_caps can create an
internal convert object that will never be freed by basetransform's
stop vmethod (PAUSED->READY).
2019-03-06 23:32:18 +11:00
Matthew Waters 675415bf2e gl: try to use highp precision where supported
The use of mediump as a specifier in GLSL shaders will have limited
resolution and when used as texture coordinates may become inaccurate
over texture sizes of 1024.
2019-02-28 17:26:32 +11:00
Sebastian Dröge acc098a736 gl: Only unbind buffers/vertex attrib arrays if we can't directly bind the vertex array to 0
Binding the vertex array to 0 will unbind everything else already.

In the previous order older versions of the Intel GL driver caused
errors to be printed for every single call when disabling the vertex
attrib arrays after binding the vertex array to 0.
2019-01-16 14:09:18 +02:00
Sebastian Dröge 64774ece0c glcolorconvert: Don't copy overlay composition meta over to NULL outbufs 2018-09-25 17:01:15 +03:00
Tim-Philipp Müller d736bfc855 gl: Update for g_type_class_add_private() deprecation in recent GLib
https://gitlab.gnome.org/GNOME/glib/merge_requests/7
2018-06-23 22:58:44 +02:00
Matthew Waters e367d3e812 glcolorconvert: fix negotiation for a non list video format in caps
For a single format in the caps, we were returning some weird answers,
like only RGB formats for a RGB input when we can also support YUV from
RGB.

Fixup of 3cfff727b1 where I thought my
previous (~6month) self had got this right.  Don't trust your previous
self people!
2018-05-06 18:54:20 +10:00
Matthew Waters 3cfff727b1 glcolorconvert: add support for ARGB64 conversion 2018-05-05 21:24:25 +10:00
Edward Hervey 22c9e5f7c1 libs: Documentation cleanup
* Fix wrong naming, wrong types and typos
* Add missing sections
* Add missing documentation for entries
* Explicitely mark private structure entries
* Remove items that never existed
2018-04-02 08:53:28 +02:00
Jan Schmidt c920d994ab glcolorconvert: Fix a typo in a debug message 2018-03-01 02:14:07 +11:00
Tim-Philipp Müller c117460420 glcolorconvert: re-enable -Wformat-nonliteral warning
We can pass string constants here to g_strdup_printf(),
so do so and re-enable the -Wformat-nonliteral warning
we had to disable when merging the opengl libs.
2018-01-03 09:21:49 +00:00
Tim-Philipp Müller ae4f9aebcc glcolorconvert: fix missing printf arg for apple rectangular texture case
Found by -Wformat-nonliteral (to be re-enabled in a separate commit).
2018-01-03 09:21:38 +00:00
Julien Isorce 4952fdd956 gl: do not include GL headers in public gstgl headers
Except for gst/gl/gstglfuncs.h

It is up to the client app to include these headers.
It is coherent with the fact that gstreamer-gl.pc does not
require any egl.pc/gles.pc. I.e. it is the responsability
of the app to search these headers within its build setup.

For example gstreamer-vaapi includes explicitly EGL/egl.h
and search for it in its configure.ac.

For example with this patch, if an app includes the headers
  gst/gl/egl/gstglcontext_egl.h
  gst/gl/egl/gstgldisplay_egl.h
  gst/gl/egl/gstglmemoryegl.h
it will *no longer* automatically include EGL/egl.h and GLES2/gl2.h.
Which is good because the app might want to use the gstgl api only
without the need to bother about gl headers.

Also added a test: cd tests/check && make libs/gstglheaders.check

https://bugzilla.gnome.org/show_bug.cgi?id=784779
2017-12-09 19:32:29 +00:00
Matthew Waters 3200e2f00d gl/docs: correctly name our objects in the documentation GstGl -> GstGL 2017-12-09 19:32:29 +00:00
Matthew Waters 715639f78c gl: reset gl->DrawBuffer to the necessary values
GL_COLOR_ATTACHMENT0 when a framebuffer is bound
GL_BACK if no framebuffer is bound

https://bugzilla.gnome.org/show_bug.cgi?id=784210
2017-12-09 19:32:29 +00:00
Haihua Hu 2fc05e90d8 glframebuffer: check frame buffer status need use specific fbo target
https://bugzilla.gnome.org/show_bug.cgi?id=783065
2017-12-09 19:32:28 +00:00
Sebastian Dröge a9a05c01a9 gst: Clear floating flag in constructor of all GstObject subclasses that are not owned by any parent
https://bugzilla.gnome.org/show_bug.cgi?id=743062
2017-12-09 19:32:28 +00:00
Thibault Saunier 95ac4d5175 docs: Port all docstring to gtk-doc markdown 2017-12-09 19:32:27 +00:00
Matthew Waters 61ee2685c0 gl: GL_ARRAY_BUFFER is not a part of VAO state
As a result we need to bind it on every draw in order to have the
correct state in the GL state machine.
2017-12-09 19:32:27 +00:00
Matthew Waters 66468b4245 gl/format: use our own GL format enum's instead of gstvideo's
They can describe in more detail (such as component sizes) the requested format.
2017-12-09 19:32:27 +00:00
Sebastian Dröge f5ea12a471 glcolorconvert: Check return value of gst_gl_context_check_framebuffer_status()
CID 1401588
2017-12-09 19:32:26 +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
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
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
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
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 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 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
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
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 31b1094744 gl: misc docs fixes/additions 2017-12-09 19:32:17 +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 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
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
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 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 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
Nicolas Dufresne 35075fcb78 glconvert: Fix compilation of GRAY16_LE/BE shader 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 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 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
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