Commit graph

65 commits

Author SHA1 Message Date
Alessandro Decina 966cad27d7 gl: initial support for texture targets other than GL_TEXTURE_2D
Make GstGLMemory hold the texture target (tex_target) the texture it represents
(tex_id) is bound to. Modify gst_gl_memory_wrapped_texture and
gst_gl_download_perform_with_data to take the texture target as an argument.

This change is needed to support wrapping textures created outside libgstgl,
which might be bound to a target other than GL_TEXTURE_2D. For example on OSX
textures coming from VideoToolbox have target GL_TEXTURE_RECTANGLE.

With this change we still keep (and sometimes imply) GL_TEXTURE_2D as the
target of textures created with libgstgl.

API: modify GstGLMemory
API: modify gst_gl_memory_wrapped_texture
API: gst_gl_download_perform_with_data
2017-12-09 19:31:53 +00:00
Matthew Waters 3f52b33c7a glmemory: more compatibility defines for gles2 systems 2017-12-09 19:31:53 +00:00
Matthew Waters 03135a2238 glmemory: add some thread safety for gl operations 2017-12-09 19:31:53 +00:00
Matthew Waters d8cc4cfc47 glmemory: use pbo's for download
In order to use pbo's efficiently, the transfer operation has to
be separated from the use of the downloaded data which requires some
rearchitecturing around glcolorconvert/gldownload and elements
2017-12-09 19:31:53 +00:00
Matthew Waters e3d3049641 glmemory: use the correct size for the pbo
It was missing the GstVideoAlignment padding which could cause GL
errors related to overrunning the size of the pbo.
2017-12-09 19:31:52 +00:00
Matthew Waters aedfadd972 glmemory: remove spurious gst_video_info_align
That will be taken care of by the calling code (typically a bufferpool).
The GstVideoAlignment is purely informational to compute plane data sizes.
2017-12-09 19:31:52 +00:00
Matthew Waters 19fbe2afbc glmemory: offset the data pointer for upload for GstVideoAlignment
otherwise we attempt to read from the padding data
2017-12-09 19:31:52 +00:00
Matthew Waters a2af67aef0 glmemory: use pbo's for upload 2017-12-09 19:31:52 +00:00
Nicolas Dufresne a1e02726ee gl: Add support for GstVideoAlignment
This allow saving a copy with libav video decoders or decoders with
similar padding requirement.

https://bugzilla.gnome.org/show_bug.cgi?id=740900
2017-12-09 19:31:52 +00:00
Nicolas Dufresne 45ac36ca26 glmemory: Handle upload/download flags from map
Problem was that if buffer was mapped READWRITE (state of buffers from
libav right now), mapping it READ/GL will not upload. This is because the
flag is only set when the buffer is unmapped. We can fix this by setting
the flags in map. This result in already mapped buffer that get mapped
to be read in GL will be uploaded. The problem is that if the write
mapper makes modification afterward, the modification will never get
uploaded.

https://bugzilla.gnome.org/show_bug.cgi?id=740900
2017-12-09 19:31:52 +00:00
Nicolas Dufresne 197e8de6e6 glmemory: Handle custom stride with OPENGL3
https://bugzilla.gnome.org/show_bug.cgi?id=740900
2017-12-09 19:31:52 +00:00
Sebastian Dröge 5b13dca0ce glmemory: Handle failure of memory allocation gracefully 2017-12-09 19:31:50 +00:00
Sebastian Dröge 47a8242399 glmemory: Use g_try_malloc() in the appropriate places
g_malloc() aborts if allocation fails, it's pointless to check against NULL
afterwards. That's why g_try_malloc() exists.
2017-12-09 19:31:50 +00:00
Wang Xin-yu (王昕宇) 77682a51e6 glcolorconvert: support RGB16/BGR16 video format upload
https://bugzilla.gnome.org/show_bug.cgi?id=738842
2017-12-09 19:31:48 +00:00
Matthew Waters 5c7b5e0210 glmemory: unset the opposite corresponding transfer flags when mapped with write
fixes consistency with consecutive gst_memory_map()'s with
flags & GST_MAP_WRITE
2017-12-09 19:31:47 +00:00
Matthew Waters a793bda9b4 glmemory: add debug line for freeing textures 2017-12-09 19:31:46 +00:00
Matthew Waters 9426c0793e glmemory: use the plane offsets to compute the size of the data pointer
Certain elements expect that there be a certain number of lines
that they can write into.  e.g. for odd heights, I420, YV12, NV12,
NV21 (and others) Y lines are expected to have exactly twice the
number of U/UV lines.

https://bugzilla.gnome.org/show_bug.cgi?id=733717
2017-12-09 19:31:45 +00:00
Matthew Waters c216799b20 glmemory: use GstVideoInfo everywhere
Simplifies a lot of the calling code

https://bugzilla.gnome.org/show_bug.cgi?id=733717
2017-12-09 19:31:45 +00:00
Matthew Waters 2b82b78ef5 glmemory: reenable the texture_rg support for !eagl
The GST_GL_HAVE_PLATFORM_EAGL is always defined we need to compare
against the value instead.
2017-12-09 19:31:44 +00:00
Sebastian Dröge f6ae4ab243 eagl: Disable usage of R and RG textures on iOS
They don't work currently and just render zeroes, while the
fallback code path with LUM and LUM_ALPHA textures still works.

https://bugzilla.gnome.org/show_bug.cgi?id=732390
2017-12-09 19:31:44 +00:00
Matthew Waters ea8c49f106 glmemory: remove uneeded gl api ifdefs 2017-12-09 19:31:42 +00:00
Matthew Waters 4a8b31afd6 glfeature: remove GST_GL_API_GLES3
instead check the gl version using gst_gl_context_check_gl_version()
2017-12-09 19:31:42 +00:00
Matthew Waters ee04a6e6eb gl/memory: allocate the correct memory size
and avoid wasting resources we will never need

https://bugzilla.gnome.org/show_bug.cgi?id=730703
2017-12-09 19:31:41 +00:00
Matthew Waters 146c666ba2 gl/memory: provide compatability defines
fixes build on android/OS X
2017-12-09 19:31:41 +00:00
Matthew Waters b3d9563d6b gl/memory: RGBA/UNSIGNED_BYTE only format supported by ReadPixels GLES2
Error out in case we attempt to read with any other invalid format.
2017-12-09 19:31:41 +00:00
Matthew Waters b3df031908 gl/memory: generate textures with a sized internal format
Required in order to generate RG and RED textured with GLES3.
2017-12-09 19:31:41 +00:00
Matthew Waters 132a233f7b gl/memory: implement GL_EXT_texture_rg support
Which is used by default over the Luminance formats due to it
being color renderable with fbos (and deprecation/removal with
GL 3.x).

https://bugzilla.gnome.org/show_bug.cgi?id=729750
https://bugzilla.gnome.org/show_bug.cgi?id=704222
https://bugzilla.gnome.org/show_bug.cgi?id=728890
2017-12-09 19:31:41 +00:00
Matthew Waters 313dfbb500 gl/upload: switch the 'master' texture for YUY2, UYVY
From d4bcef3204 on, using a RGBA
texture to hold the data causes the glmemory to have half width
and a scaling of [2, 1].  Using a LA texture solves this problem
however cannot be attached to the framebuffer for copying into
a RGBA texture.  Which will be solved by moving to EXT_texture_rg.

https://bugzilla.gnome.org/show_bug.cgi?id=728890
2017-12-09 19:31:41 +00:00
Nicolas Dufresne 157607989a glmemory: Fix handling of stride with alignement larger then 8
Setting a scaled factor for X coordinate is not enough as the indexer
will still think stride is shorter and will not fully skip it. Instead,
update width, so the lines are as expected. Combined with the scale, it
will hide the cropped portion.

https://bugzilla.gnome.org/show_bug.cgi?id=729896
2017-12-09 19:31:40 +00:00
Matthew Waters 6c1a4e30c4 gl/upload: implement lazy init
Rename init_format to set_format
2017-12-09 19:31:39 +00:00
Matthew Waters 33091ff6a5 gl/mem: implement texture copying between formats with strides properly
Previously, we used the width to determine the amount of data to be
copied using pbos.  This, makes it allocate enough data for the
the strides as well.
2017-12-09 19:31:38 +00:00
Nicolas Dufresne 4372ba8999 glmemory: User g_slice_new0 to ensure fully initilized structure
The pbo pointer not being initialized would trigger a use of unitilialized variable
in valgrind.
2017-12-09 19:31:37 +00:00
Vincent Penquerc'h c728fd3b8d gl: prevent division by 0 on unsupported texture type
Coverity 1199697
2017-12-09 19:31:37 +00:00
Matthew Waters 6c73fa0b5f gl/mem: cache the stride/unpack length for upload 2017-12-09 19:31:36 +00:00
Matthew Waters 94371dc204 gl/mem: provide defines for tokens not defined in GLES2/ancient platforms 2017-12-09 19:31:36 +00:00
Matthew Waters 30c6efc432 gl/mem: allocate the memory per plane
This patch provides the basic infrastructure required for this.
Upload and Download has been ported to this.

Has the nice effect of allowing GstGLMemory to be our
refcounted texture object for any texture type (not just RGBA).

Should not lose any features/video formats.
2017-12-09 19:31:36 +00:00
Matthew Waters a20a5d36e2 gl: pass video info's by reference 2017-12-09 19:31:35 +00:00
Matthew Waters e225af3e0d gl: silence all the compiler warnings 2017-12-09 19:31:34 +00:00
Matthew Waters d233bb66a9 [876/906] glmem: use GstVideoInfo for format configuration
Allows use of strides
2017-12-09 19:31:33 +00:00
Matthew Waters 2eb7938db9 [873/906] upload: use GstVideoInfo for choosing the format 2017-12-09 19:31:33 +00:00
Matthew Waters 89a203abe3 [865/906] glmem: report successful copy to the caller 2017-12-09 19:31:33 +00:00
Matthew Waters 148607f6da [858/906] glmem: update the docs 2017-12-09 19:31:32 +00:00
Matthew Waters 36c62b32e5 [843/906] memory: provide copy_into_texture 2017-12-09 19:31:32 +00:00
Matthew Waters efa22442a9 [838/906] gl: Use GL_TEXTURE_2D instead of GL_TEXTURE_RECTANGLE
We create our textures (in Desktop GL) with GL_TEXTURE_RECTANGLE,
vaapi attempts to bind our texture to GL_TEXTURE_2D which throws a
GL_INVALID_OPERATION error and as thus, no video.

Also, by moving exclusively to GL_TEXTURE_2D and the npot extension
we also remove a difference between the Desktop GL and GLES2 code.

https://bugzilla.gnome.org/show_bug.cgi?id=712287
2017-12-09 19:31:32 +00:00
Matthew Waters 56384a0db3 [819/906] make gen_texture/del_texture threadsafe
Use stack allocated instead of static variables

Conflicts:
	gst-libs/gst/gl/gstglutils.c
2017-12-09 19:31:31 +00:00
Matthew Waters 711ad485b2 [812/906] move the GL vtable from GstGLDisplay to GstGLContext
Conflicts:
	tests/check/libs/gstglcontext.c
2017-12-09 19:31:31 +00:00
Matthew Waters 7c4d51edf4 [780/906] up/download: check return values
So we fail properly
2017-12-09 19:31:30 +00:00
Matthew Waters 8577de136e [763/906] memory: copy properly depending on where the most recent data is 2017-12-09 19:31:30 +00:00
Julien Isorce d17a4381b1 [732/906] build: fix repeated typedefs
Write forward declarations in another way to avoid
repeated typedefs "error: redefinition of typedef".
Raised when using i686-apple-darwin11-llvm-gcc-4.2
It seems that C apple compiler does not support
C11 feature.

https://bugzilla.gnome.org/show_bug.cgi?id=703885
2017-12-09 19:31:29 +00:00
Matthew Waters 9e7af77dc8 [703/906] x11: don't segfault if destroy_cb is NULL 2017-12-09 19:31:28 +00:00