Commit graph

131 commits

Author SHA1 Message Date
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
Carlos Rafael Giani
d5a9ca8ef6 gl: Separate viv direct texture checks from viv-fb winsys check
Vivante direct textures do not depend on the viv-fb windowing system.
Decouple these two to be able to use direct textures even when viv-fb
is not enabled.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4950>
2023-07-03 05:25:13 +00:00
He Junyan
0b981a216c gl: Add a print function to dump all EGL image drm format
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4877>
2023-06-19 12:58:02 +00:00
Haihua Hu
5716ee3513 glfilter: add parent meta to output buffer for input buffer
glfilter will unref input buffer after _transform() call immidiately,
but gpu may still reading input buffer for rendering because gl
api is executed async. Need hold reference for input buffer by
adding parent meta to output buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4801>
2023-06-13 07:53:49 +00:00
He Junyan
1a2d136438 gl: EGL image methods to import dmabufs with modifiers
This patch adds gst_egl_image_from_dmabuf_direct_target_with_dma_drm() and
add gst_egl_image_from_dmabuf_with_dma_drm() functions

New function gst_egl_image_from_dmabuf_direct_target_with_dma_drm(), where
gst_egl_image_from_dmabuf_direct_target() is a specialization of the first.

And gst_egl_image_from_dmabuf() is a specialization of new function
gst_egl_image_from_dmabuf_with_dma_drm()

Co-authored-by: Victor Jaquez <vjaquez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4680>
2023-05-30 20:09:27 +00:00
Víctor Manuel Jáquez Leal
9f7f54174a gl: add gst_egl_image_check_dmabuf_direct_with_dma_drm()
It internally uses gst_gl_context_egl_get_dma_formats() instead of fetching
modifiers by itself.

Thus gst_egl_image_check_dmabuf_direct() is a decorator of this new function.

Co-authored-by: He Junyan <junyan.he@intel.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4680>
2023-05-30 20:09:27 +00:00
Víctor Manuel Jáquez Leal
af7b5023bd gl: replace _drm_direct_fourcc_from_info()
.. with gst_video_dma_drm_fourcc_from_format()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4680>
2023-05-30 20:09:27 +00:00
Víctor Manuel Jáquez Leal
7eed950caa gl: add a method to get DMA formats and modifiers
By calling the internal function gst_gl_context_egl_fetch_dma_formats() the an
array of structures holding a DMA fourcc format and its modifiers (another array of
structure holing modifier and if it's external only) will be stored.

Users would call gst_gl_context_egl_get_format_modifiers() to get the array of
modifiers of a specific DMA fourcc format.

Co-authored-by: He Junyan <junyan.he@intel.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4680>
2023-05-30 20:09:27 +00:00
He Junyan
e23964cb5f glupload: Fix a memory leak point in gst_egl_image_cache_unref()
The image cache itself should be freed when ref_count is 0.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4723>
2023-05-27 12:17:08 +00:00
Matthew Waters
8003acf5bb gl: update docs for mixer move
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
2023-05-18 19:34:15 +00:00
Matthew Waters
e9bf1c79cc glmixer: don't add rgba templates by default
Subclasses may want to override the pad template with different formats
or with a different pad subclass.

The original beahviour is still available by calling
gst_gl_mixer_class_add_rgba_pad_templates() in _class_init() of the
subclass.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
2023-05-18 19:34:15 +00:00
Matthew Waters
fc85b63c2b glmixer: remove set_caps() vfunc
All of its implementors can be moved to gl_start/stop() from
GstGLBaseMixer instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
2023-05-18 19:34:14 +00:00
Matthew Waters
331b1af468 glmixer: remove reset vfunc
This functionality is covered by GstGLBaseMixer's gl_stop() vfunc.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
2023-05-18 19:34:14 +00:00
Matthew Waters
14e7e991d3 gl/mixer: make fbo instance field private and provide accessor function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
2023-05-18 19:34:14 +00:00
Matthew Waters
007a602726 gl: move gl(base)mixer to library
For use by applications/libraries outside of the opengl plugin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
2023-05-18 19:34:14 +00:00
Nirbheek Chauhan
681f042f27 meson: Install viv-fb GL headers, needed by i.MX
Needed by qmlglsink at build time to allocate a viv-fb display.

Without this, the GL fastpath doesn't work, and performance is really
bad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4613>
2023-05-12 15:05:56 +05:30
Piotr Brzeziński
5e45a1b1bd macos: Set activation policy in osxvideosink and glimagesink
Upon creating a window, glimagesink and osxvideosink now set the policy to
NSApplicationActivationPolicyRegular, which lets us show an icon in the Dock
for convenience and appear in the top menu bar like other apps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4573>
2023-05-12 01:14:44 +02:00
Piotr Brzeziński
f60c87769f macos: Remove old NSApp workaround related code
This is no longer needed since the introduction of `gst_macos_main()` in 1.22.
Before that existed, we had a patch for GLib in Cerbero, which did work but made it
impossible to update GLib at all. The code being removed was a fail-safe in case of
running without said patch being applied. It's no longer needed, since for macOS
we just wrap our GStreamer with an NSApplication using `gst_macos_main()`.

Warnings will be displayed if no NSApp/NSRunLoop is found wherever needed,
pointing the user towards using the new API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4366>
2023-05-11 20:30:19 +02:00