mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
d3d12: Add compositor element
Adding d3d12compositor element. d3d12compositor will build GPU commands asynchronously and each command is serialized at final render stage. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5875>
This commit is contained in:
parent
996346f8d3
commit
a1ba38cd64
10 changed files with 3007 additions and 0 deletions
|
@ -11349,6 +11349,78 @@
|
|||
},
|
||||
"rank": "none"
|
||||
},
|
||||
"d3d12compositor": {
|
||||
"author": "Seungha Yang <seungha@centricular.com>",
|
||||
"description": "A Direct3D12 compositor",
|
||||
"hierarchy": [
|
||||
"GstD3D12Compositor",
|
||||
"GstVideoAggregator",
|
||||
"GstAggregator",
|
||||
"GstElement",
|
||||
"GstObject",
|
||||
"GInitiallyUnowned",
|
||||
"GObject"
|
||||
],
|
||||
"interfaces": [
|
||||
"GstChildProxy"
|
||||
],
|
||||
"klass": "Filter/Editor/Video/Compositor",
|
||||
"pad-templates": {
|
||||
"sink_%%u": {
|
||||
"caps": "video/x-raw(memory:D3D12Memory):\n format: { RGBA64_LE, RGB10A2_LE, Y410, VUYA, RGBA, BGRA, RBGA, P016_LE, P012_LE, P010_10LE, RGBx, BGRx, NV12, AYUV64, GBRA_12LE, GBRA_10LE, AYUV, ABGR, ARGB, GBRA, Y444_16LE, GBR_16LE, Y444_12LE, GBR_12LE, I422_12LE, I420_12LE, Y444_10LE, GBR_10LE, I422_10LE, I420_10LE, Y444, BGRP, GBR, RGBP, xBGR, xRGB, Y42B, NV21, I420, YV12, GRAY16_LE, GRAY8 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-raw:\n format: { RGBA64_LE, RGB10A2_LE, Y410, VUYA, RGBA, BGRA, RBGA, P016_LE, P012_LE, P010_10LE, RGBx, BGRx, NV12, AYUV64, GBRA_12LE, GBRA_10LE, AYUV, ABGR, ARGB, GBRA, Y444_16LE, GBR_16LE, Y444_12LE, GBR_12LE, I422_12LE, I420_12LE, Y444_10LE, GBR_10LE, I422_10LE, I420_10LE, Y444, BGRP, GBR, RGBP, xBGR, xRGB, Y42B, NV21, I420, YV12, GRAY16_LE, GRAY8 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
|
||||
"direction": "sink",
|
||||
"presence": "request",
|
||||
"type": "GstD3D12CompositorPad"
|
||||
},
|
||||
"src": {
|
||||
"caps": "video/x-raw(memory:D3D12Memory):\n format: { RGBA64_LE, RGB10A2_LE, BGRA, RGBA, BGRx, RGBx, VUYA, NV12, NV21, P010_10LE, P012_LE, P016_LE, I420, YV12, Y42B, Y444, Y444_16LE, GRAY8, GRAY16_LE }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-raw:\n format: { RGBA64_LE, RGB10A2_LE, BGRA, RGBA, BGRx, RGBx, VUYA, NV12, NV21, P010_10LE, P012_LE, P016_LE, I420, YV12, Y42B, Y444, Y444_16LE, GRAY8, GRAY16_LE }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
|
||||
"direction": "src",
|
||||
"presence": "always",
|
||||
"type": "GstAggregatorPad"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"adapter": {
|
||||
"blurb": "Adapter index for creating device (-1 for default)",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "-1",
|
||||
"max": "2147483647",
|
||||
"min": "-1",
|
||||
"mutable": "ready",
|
||||
"readable": true,
|
||||
"type": "gint",
|
||||
"writable": true
|
||||
},
|
||||
"background": {
|
||||
"blurb": "Background type",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "checker (0)",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "GstD3D12CompositorBackground",
|
||||
"writable": true
|
||||
},
|
||||
"ignore-inactive-pads": {
|
||||
"blurb": "Avoid timing out waiting for inactive pads",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "false",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gboolean",
|
||||
"writable": true
|
||||
}
|
||||
},
|
||||
"rank": "none"
|
||||
},
|
||||
"d3d12convert": {
|
||||
"author": "Seungha Yang <seungha@centricular.com>",
|
||||
"description": "Performs resizing, colorspace conversion, cropping and flipping/rotating using Direct3D12",
|
||||
|
@ -11881,6 +11953,169 @@
|
|||
],
|
||||
"kind": "object"
|
||||
},
|
||||
"GstD3D12CompositorBackground": {
|
||||
"kind": "enum",
|
||||
"values": [
|
||||
{
|
||||
"desc": "Checker pattern",
|
||||
"name": "checker",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"desc": "Black",
|
||||
"name": "black",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"desc": "White",
|
||||
"name": "white",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"desc": "Transparent Background to enable further compositing",
|
||||
"name": "transparent",
|
||||
"value": "3"
|
||||
}
|
||||
]
|
||||
},
|
||||
"GstD3D12CompositorOperator": {
|
||||
"kind": "enum",
|
||||
"values": [
|
||||
{
|
||||
"desc": "Source",
|
||||
"name": "source",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"desc": "Over",
|
||||
"name": "over",
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"GstD3D12CompositorPad": {
|
||||
"hierarchy": [
|
||||
"GstD3D12CompositorPad",
|
||||
"GstVideoAggregatorPad",
|
||||
"GstAggregatorPad",
|
||||
"GstPad",
|
||||
"GstObject",
|
||||
"GInitiallyUnowned",
|
||||
"GObject"
|
||||
],
|
||||
"kind": "object",
|
||||
"properties": {
|
||||
"alpha": {
|
||||
"blurb": "Alpha of the picture",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "1",
|
||||
"max": "1",
|
||||
"min": "0",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gdouble",
|
||||
"writable": true
|
||||
},
|
||||
"height": {
|
||||
"blurb": "Height of the picture",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "0",
|
||||
"max": "2147483647",
|
||||
"min": "-2147483648",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gint",
|
||||
"writable": true
|
||||
},
|
||||
"operator": {
|
||||
"blurb": "Blending operator to use for blending this pad over the previous ones",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "over (1)",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "GstD3D12CompositorOperator",
|
||||
"writable": true
|
||||
},
|
||||
"sizing-policy": {
|
||||
"blurb": "Sizing policy to use for image scaling",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "none (0)",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "GstD3D12CompositorSizingPolicy",
|
||||
"writable": true
|
||||
},
|
||||
"width": {
|
||||
"blurb": "Width of the picture",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "0",
|
||||
"max": "2147483647",
|
||||
"min": "-2147483648",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gint",
|
||||
"writable": true
|
||||
},
|
||||
"xpos": {
|
||||
"blurb": "X position of the picture",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "0",
|
||||
"max": "2147483647",
|
||||
"min": "-2147483648",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gint",
|
||||
"writable": true
|
||||
},
|
||||
"ypos": {
|
||||
"blurb": "Y position of the picture",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": true,
|
||||
"default": "0",
|
||||
"max": "2147483647",
|
||||
"min": "-2147483648",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gint",
|
||||
"writable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"GstD3D12CompositorSizingPolicy": {
|
||||
"kind": "enum",
|
||||
"values": [
|
||||
{
|
||||
"desc": "None: Image is scaled to fill configured destination rectangle without padding or keeping the aspect ratio",
|
||||
"name": "none",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"desc": "Keep Aspect Ratio: Image is scaled to fit destination rectangle specified by GstD3D12CompositorPad:{xpos, ypos, width, height} with preserved aspect ratio. Resulting image will be centered in the destination rectangle with padding if necessary",
|
||||
"name": "keep-aspect-ratio",
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"GstD3D12SamplingMethod": {
|
||||
"kind": "enum",
|
||||
"values": [
|
||||
|
|
2546
subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp
Normal file
2546
subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp
Normal file
File diff suppressed because it is too large
Load diff
38
subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.h
Normal file
38
subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/video/gstvideoaggregator.h>
|
||||
#include "gstd3d12.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_D3D12_COMPOSITOR_PAD (gst_d3d12_compositor_pad_get_type())
|
||||
G_DECLARE_FINAL_TYPE (GstD3D12CompositorPad, gst_d3d12_compositor_pad,
|
||||
GST, D3D12_COMPOSITOR_PAD, GstVideoAggregatorPad)
|
||||
|
||||
#define GST_TYPE_D3D12_COMPOSITOR (gst_d3d12_compositor_get_type())
|
||||
G_DECLARE_FINAL_TYPE (GstD3D12Compositor, gst_d3d12_compositor,
|
||||
GST, D3D12_COMPOSITOR, GstVideoAggregator)
|
||||
|
||||
G_END_DECLS
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
static const float blocksize = 8.0;
|
||||
static const float4 high = float4 (0.667, 0.0, 0.0, 1.0);
|
||||
static const float4 low = float4 (0.333, 0.0, 0.0, 1.0);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 Plane : SV_TARGET;
|
||||
};
|
||||
|
||||
PS_OUTPUT PSMain_checker_luma (PS_INPUT input)
|
||||
{
|
||||
PS_OUTPUT output;
|
||||
if ((input.Position.x % (blocksize * 2.0)) >= blocksize) {
|
||||
if ((input.Position.y % (blocksize * 2.0)) >= blocksize)
|
||||
output.Plane = low;
|
||||
else
|
||||
output.Plane = high;
|
||||
} else {
|
||||
if ((input.Position.y % (blocksize * 2.0)) < blocksize)
|
||||
output.Plane = low;
|
||||
else
|
||||
output.Plane = high;
|
||||
}
|
||||
return output;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
static const float blocksize = 8.0;
|
||||
static const float4 high = float4 (0.667, 0.667, 0.667, 1.0);
|
||||
static const float4 low = float4 (0.333, 0.333, 0.333, 1.0);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 Plane : SV_TARGET;
|
||||
};
|
||||
|
||||
PS_OUTPUT PSMain_checker_rgb (PS_INPUT input)
|
||||
{
|
||||
PS_OUTPUT output;
|
||||
if ((input.Position.x % (blocksize * 2.0)) >= blocksize) {
|
||||
if ((input.Position.y % (blocksize * 2.0)) >= blocksize)
|
||||
output.Plane = low;
|
||||
else
|
||||
output.Plane = high;
|
||||
} else {
|
||||
if ((input.Position.y % (blocksize * 2.0)) < blocksize)
|
||||
output.Plane = low;
|
||||
else
|
||||
output.Plane = high;
|
||||
}
|
||||
return output;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
static const float blocksize = 8.0;
|
||||
static const float4 high = float4 (0.5, 0.5, 0.667, 1.0);
|
||||
static const float4 low = float4 (0.5, 0.5, 0.333, 1.0);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 Plane : SV_TARGET;
|
||||
};
|
||||
|
||||
PS_OUTPUT PSMain_checker_vuya (PS_INPUT input)
|
||||
{
|
||||
PS_OUTPUT output;
|
||||
if ((input.Position.x % (blocksize * 2.0)) >= blocksize) {
|
||||
if ((input.Position.y % (blocksize * 2.0)) >= blocksize)
|
||||
output.Plane = low;
|
||||
else
|
||||
output.Plane = high;
|
||||
} else {
|
||||
if ((input.Position.y % (blocksize * 2.0)) < blocksize)
|
||||
output.Plane = low;
|
||||
else
|
||||
output.Plane = high;
|
||||
}
|
||||
return output;
|
||||
}
|
33
subprojects/gst-plugins-bad/sys/d3d12/hlsl/VSMain_pos.hlsl
Normal file
33
subprojects/gst-plugins-bad/sys/d3d12/hlsl/VSMain_pos.hlsl
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
};
|
||||
|
||||
VS_OUTPUT VSMain_pos (VS_INPUT input)
|
||||
{
|
||||
return input;
|
||||
}
|
|
@ -148,6 +148,10 @@ hlsl_sources = [
|
|||
['VSMain_color', 'vs_6_0'],
|
||||
['PSMain_snow', 'ps_6_0'],
|
||||
['PSMain_checker', 'ps_6_0'],
|
||||
['PSMain_checker_luma', 'ps_6_0'],
|
||||
['PSMain_checker_rgb', 'ps_6_0'],
|
||||
['PSMain_checker_vuya', 'ps_6_0'],
|
||||
['VSMain_pos', 'vs_6_0'],
|
||||
]
|
||||
|
||||
foreach shader : hlsl_sources
|
||||
|
|
|
@ -6,6 +6,7 @@ d3d12_sources = [
|
|||
'gstd3d12commandallocatorpool.cpp',
|
||||
'gstd3d12commandlistpool.cpp',
|
||||
'gstd3d12commandqueue.cpp',
|
||||
'gstd3d12compositor.cpp',
|
||||
'gstd3d12converter-builder.cpp',
|
||||
'gstd3d12converter.cpp',
|
||||
'gstd3d12convert.cpp',
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "gstd3d12upload.h"
|
||||
#include "gstd3d12videosink.h"
|
||||
#include "gstd3d12testsrc.h"
|
||||
#include "gstd3d12compositor.h"
|
||||
#include "gstd3d12h264dec.h"
|
||||
#include "gstd3d12h265dec.h"
|
||||
#include "gstd3d12vp9dec.h"
|
||||
|
@ -116,6 +117,8 @@ plugin_init (GstPlugin * plugin)
|
|||
"d3d12videosink", GST_RANK_NONE, GST_TYPE_D3D12_VIDEO_SINK);
|
||||
gst_element_register (plugin,
|
||||
"d3d12testsrc", GST_RANK_NONE, GST_TYPE_D3D12_TEST_SRC);
|
||||
gst_element_register (plugin,
|
||||
"d3d12compositor", GST_RANK_NONE, GST_TYPE_D3D12_COMPOSITOR);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue