Commit graph

1444 commits

Author SHA1 Message Date
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