Commit graph

148 commits

Author SHA1 Message Date
Slava Andrejev 3dd9411b36 glcolorconvert: add reordering for plain GBR color format
Fixes #2991

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5582>
2023-11-01 06:02:20 +00:00
Loïc Le Page e1ca575408 gl: add support for surfaceless display in GstGL
Use of the EGL_MESA_platform_surfaceless EGL extension to create an EGL
display that is not depending on any kind of windowing system.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5511>
2023-10-20 12:46:48 +00:00
Loïc Le Page 34694bbfcf gl: fix "winrt" string comparison in gst_gl_display_type_from_environment
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5511>
2023-10-20 12:46:48 +00:00
He Junyan c5f50b1602 gl: upload: gl memory method should not provide pool for system memory caps
In _gl_memory_upload_propose_allocation(), when output target is "external-oes",
then we should not provide GL allocator and pool in the allocation query.
This is because the "external-oes" kind memory can never be mapped directly
and the upstream element may misuse it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5468>
2023-10-18 19:56:30 +00:00
He Junyan ea35adc55f gl: upload: Implement the fixate_caps virtual function
We now prefer the 2D target than other targets when fixating src caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5468>
2023-10-18 19:56:30 +00:00
He Junyan b46d84ee7f gl: upload: rename the _dma_buf_check_target() helper function
Make it a common helper function, not only for the DMA buffer method.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5468>
2023-10-18 19:56:30 +00:00
Jan Schmidt 23097e35e6 glfiter: Protect GstGLContext access
The propose and decide allocation vfuncs are called directly from
basetransform and need to use the locked accessor function for
retrieving a reliable reference to the GstGLContext (if available)

Fixes spurious crashes on shutdown during pad reconfiguration

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5437>
2023-10-18 11:22:31 +00:00
Nicolas Dufresne 516073f9d0 glupload: egl: Use n_plane values from the GstVideoInfo
The number of planes is a meta we carry around in the GstVideoMeta with
DMA_DRM format. In cannot be decuded correctly from knowledge of the
base format. Notably, some compression modifier may introduce an extra
plane to store the compression parameters.

So use n_planes from GstVideoMeta and pass this explicitly when
importing to EGLImage.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5461>
2023-10-16 17:30:32 +00:00
Nicolas Dufresne 0e5f5b413c glupload: Plane size is not known for DMA_DRM
For these format, the plane size is not known, simply use 1 when
searching for the memory object in the GstBuffer array.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5461>
2023-10-16 17:30:32 +00:00
Nicolas Dufresne e00682a4c0 egl: Fix direct dmabuf upload without DMABuf caps feature
The DMAbuf accept function was ensuring the in_dma_info values was valid if
the in_caps have change. But the check was bogus since the in_caps was being
modified without a pointer change. As a side effect, on the second accept
call, the drm_fourcc was reset to 0, which cause the uploader to fallback.

Fix this by ensuring we always have a valid dma_frm info directly in the
set_caps() function. Also remove the bogus caps changed check and remove any
modification to the info structure and always do that inner checks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5461>
2023-10-16 17:30:32 +00:00
Nicolas Dufresne a869760199 egl: Fix indirect dmabuf importation of none DRM formats
DRM Modifiers are not generically transferrable from a format like NV12 to
their indirect shading format (R8 / RG88). So the helper to this do needs
to be removed from our API.

To make things worse, we support indirect formats that aren't DRM format in
the first place. Notably NV12_16L32 (aka MM21) is not (yet) a DRM format. Yet,
each plane can be indirectly imported using R8/RG88 and a detiling shader.
This patch also removes this constraint restoring zero-copy playback on
Mediatek SoC.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5461>
2023-10-16 17:30:32 +00:00
Matthew Waters 714c78ac51 glcolorconvert: add A422/A444 to output switch statement
Fixes glcolorconvert writing to A422 or A444 formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5455>
2023-10-10 22:47:59 +11:00
Piotr Brzeziński 64a58c37ac glfilter: Only add parent meta if inbuf != outbuf
This was causing a memory leak in cases like `gltestsrc ! gltransformation scale-x=0.5 ! glimagesink`.
Parent meta was being added in assumption that those buffers are different, which was not the case here,
creating a reference loop and never freeing the buffer.

Co-authored-by: Matthew Waters <matthew@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5445>
2023-10-10 03:17:07 +00:00
Nicolas Dufresne 63da298b84 glupload: Fix always true compiler warning
There was an if case that was always true. After re-reading the Khronos
spec, this case is actually undefined. It is better to just always ignore
the format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5410>
2023-09-28 20:56:35 +00:00
Matthew Waters 237d195209 gl/format: fix swizzle indices for RGB10A2/BGR10A2
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3003
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5400>
2023-09-27 19:45:57 +10:00
He Junyan 0ace130107 glcolorconvert: Calculate correct swizzles for Y410, Y412 formats
The GST_VIDEO_FORMAT_Y410, GST_VIDEO_FORMAT_Y412_LE and GST_VIDEO_FORMAT_Y412_BE
formats in fact are packed formats, which have just 1 plane. But we have special
setting for them rather than using get_single_planar_format_gl_swizzle_order().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5314>
2023-09-11 22:01:20 +00:00
Nicolas Dufresne 1eaa671feb glupload: Only allow non-linear formats with direct dmabuf uploaders
As we don't have any mapping from YUV formats + modifiers to an equivalent
emulated format (e.g. NV12 + modifier -> R8+modifier/RG88+modifier), do no
allow these formats to be used with the indirect DMABuf uploader.

Fixes #2942

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5270>
2023-09-11 19:55:19 +00:00
Matthew Waters fac5a83fd9 gl: add support for I420 10/12 bit formats
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5292>
2023-09-07 17:03:19 +00:00
Matthew Waters 95db85e664 gl/mixer: use the pad's video info instead of creating our own
The pad's video info will match the actual video format in use.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5290>
2023-09-07 02:12:29 +00:00
Philippe Normand bb5d5e0066 glcontext_egl: Remove spurious mutex unlock
The context is not locked in any call site of the "failed" goto.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5291>
2023-09-06 12:03:42 +01:00
Matthew Waters 9d867356df gl/bufferpool: add configuration to extend buffer lifetime before reuse
Fixes a potential GPU stall if an immediately freed texture/buffer is
attempted to be reused immediately by the CPU, e.g. when uploading.

Problematic scenario is this:
1. element does GPU processing reading from texture
2. frees the buffer back to the pool
3. pool acquire returns the just released buffer
4. GPU processing then has to wait for the previous GPU operation to
   complete causing a stall

If there was a reliable way to know whether a buffer had been finished
with across all GPU drivers, we would use it.  However as that does not
exist, this workaround is to keep the released buffer unusable until the
next released buffer.

This is the same approach as is used in the qml (Qt5) elements.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5144>
2023-08-31 01:24:38 +00:00
Matthew Waters a49cd5f94d gl: add support for 16-bit A420/A422/A444
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5233>
2023-08-24 12:13:19 +10:00
Matthew Waters e67bdaf4d5 glcolorconvert: fix writing to subsampled yuv formats >8-bit
It's not quite enough to have the GstVideoInfo use a RGBA64 format, the
GstGLFormat (texture format) also needs to match as that's what actually
is used for allocation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5226>
2023-08-24 00:56:44 +00:00
Matthew Waters 4c627ea2bb gl: add support for 12-bit A444/A422/A420
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5226>
2023-08-24 00:56:44 +00:00
Matthew Waters 746d99b932 gl: add support A422/A444
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5224>
2023-08-23 15:00:05 +10:00
Hou Qi 93e1bc94ae gl: wayland: fix memory leak when do egl_close
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5219>
2023-08-22 20:39:06 +00:00
Matthew Waters 3981257bc5 glcolorconvert: add support for 10-bit A420/A422/A444
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5209>
2023-08-22 12:18:42 +00:00
Matthew Waters cc59841a45 gl/format: add support for RGBA64_LE/BE
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5209>
2023-08-22 12:18:42 +00:00
Matthew Waters 1f9a13da55 gl: support uploading/downloading 10-bit A420/A422/A444
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5193>
2023-08-17 01:55:12 +00:00
He Junyan 3cebfc7e84 glupload: Delete the flag of METHOD_FLAG_CAN_ACCEPT_RAW for DMABuf
When this flag is enabled, the transform_caps() simply set passthrough
to generate the raw caps. This is not correct, because the sink and
src have different format/drm-format fields.
We already add system memory conversion for DMABuf manner, so no more
need for this flag.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 094270322b glupload: make nvmm upload manner only consider system memory
The current _nvmm_upload_transform_caps() only simply apply
"memory:NVMM" to all input caps to transform the output caps.
This is not precise and may cause problem. For example, if the
input caps include:

  video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

it will be changed as

  video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

For GLMemory kind caps, no drm-format should appear.

So we should let it only transforms which it can recognize.

And in _nvmm_upload_accept(), we should only accept the "memory:NVMM"
feature in input caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 122ffa56ed glupload: make directviv upload manner only consider system memory
The current _directviv_upload_transform_caps() only simply apply
"memory:GLMemory" to all input caps to transform the output caps.
This is not precise and may cause problem. For example, if the
input caps include:

  video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

it will be changed as

  video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

For GLMemory kind caps, no drm-format should appear.

So we should let it only transforms which it can recognize.

And in _directviv_upload_accept(), we should only accept the system
memory as input caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan b9c97ba76d glupload: make gl memory upload manner only consider memory:GLMemory feature
The current _gl_memory_upload_transform_caps() only simply apply
"memory:GLMemory" to all input caps to transform the output caps.
This is not precise and may cause problem. For example, if the
input caps include:

  video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

it will be changed as

  video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

For GLMemory kind caps, no drm-format should appear.

So we should let it only transforms which it can recognize.

And in _gl_memory_upload_propose_allocation(), we should only allocate
the allocator and buffer pool for the caps with "memory:GLMemory"
feature.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 414f91d0fa glupload: make meta upload manner only consider TextureUploadMeta feature
The current _upload_meta_upload_transform_caps() only simply apply
"memory:GLMemory" to all input caps to transform the output caps.
This is not precise and may cause problem. For example, if the
input caps include:

  video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

it will be changed as

  video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

For GLMemory kind caps, no drm-format should appear.

So we should let it only transforms which it can recognize.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan fe07763fd8 glupload: make raw manner only consider system memory
The current _raw_data_upload_transform_caps() only simply apply
"memory:GLMemory" to all input caps to transform the output caps.
This is not precise and may cause problem. For example, if the
input caps include:

  video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

it will be changed as

  video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

For GLMemory kind caps, no drm-format should appear.

So we should let it only transforms which it can recognize.
We also should recognize the system memory caps in _accept() early, if
the input is not system memory, we just return early.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan cae46d36b5 glupload: change the accept function to import dmabuf with modifier
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 21faad5eca glupload: enable drm kind caps in glupload plugin for DMA buf
Most of the time, the RGB kind formats are OpenGL native supported
format which has only one plane. They can be imported at one shot
using no matter DIRECT or INDIRECT mode.
While YUV kind formats which have multi planes have two ways to import.
They can be DIRECT imported, which requires GL_OES_EGL_image_external
extension. The output format should be RGBA and TARGET should be set
as OES after imported. The other way, they can be INDIRECT imported,
which makes each plane as a texture. In this mode, the imported textures
have different fourcc from the original format. For example, the NV12
format can be imported as a R8 texture for the first plane and RG88
texture for the second plane. The output TARGET should be sets as 2D
in this mode.

When converting sink caps to src caps, we first filter the feature of
"video/x-raw(memory:DMABuf)" and system memory. Then Based on the
external_only flag (INDIRECT mode does not care while DIRECT mode cares),
we transform the drm-format into the gst video format.

When converting src caps into sink caps, we first filter the correct
TARGET(INDIRECT mode contains 2D only while DIRECT mode contains 2D,
OES or both of them) gstructure. Then Based on the include_external flag
(INDIRECT mode always true while DIRECT mode depends on TARGET), we
transform the gst video format into drm-format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 96ea1b8da9 glupload: Add a helper function of _filter_caps_with_features()
We sometimes need to filter some special feature for the next step.
This helper function can help us to filter out un-needed features
in a caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 95707bb80d glupload: add a helper function to convert drm formats into gst formats
Co-authored-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 6dd3d6f1c1 glupload: add a helper function to convert gst formats into drm formats
Co-authored-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
He Junyan 22bb3107d7 gl: add a method to check whether DMA modifier is supported in EGL
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
2023-08-03 20:58:23 +00:00
Nirbheek Chauhan eb9be6de78 glcolorconvert: Fix syntax for GLSL shaders
Shader compilation was failing on macOS:

gstglslstage.c:519:_compile_shader:<glslstage1> fragment shader compilation failed:
ERROR: 0:10: 'input_swizzle' : syntax error: Array size must appear after variable name

Co-authored-by: Matthew Waters <matthew@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5123>
2023-07-31 17:33:20 +05:30
Matthew Waters 7fcef3818e glcolorconvert: expose the swizzle glsl functions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5109>
2023-07-28 03:29:09 +00:00
Matthew Waters bff5d6d725 glcolorconvert: expose the YUV->RGB glsl function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5109>
2023-07-28 03:29:09 +00:00
Matthew Waters b32e2cd9dd gl: expose calculating swizzle indices to/from RGBA/YUVA
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5109>
2023-07-28 03:29:09 +00:00
Matthew Waters a90f6d5d67 gl/format: add helper for returning the number of components in a GL format
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5109>
2023-07-28 03:29:09 +00:00
Matthew Waters 5bf85e7588 gl/colorconvert: use swizzle indices instead of chars
Allows using a uniform to control which value goes where and not rewrite
the shader for every format combination.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5109>
2023-07-28 03:29:08 +00:00
Matthew Waters 00316db5e5 gl/eagl: ignore OpenGLES deprecation on ios
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5111>
2023-07-27 13:05:37 +00:00
Matthew Waters a2d9584b27 gl: provide a pkg-config/gir file for the viv-fb backend
Required to be able to generate coherent bindings for window system
specific APIs due to limitations in gobject-introspection.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5020>
2023-07-12 21:35:55 +10:00
Matthew Waters ffb2e87fd4 gl: don't install the viv-fb window header file
It is not needed at all by any external implementations and should not
be exposed to the outside world.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5020>
2023-07-12 21:31:45 +10:00