mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-13 12:51:16 +00:00
d3d12: Format table refactoring
Hide format table from header. This is a preparation for compute shader based format support Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7088>
This commit is contained in:
parent
9e1abc0797
commit
ec06b0445e
4 changed files with 590 additions and 305 deletions
|
@ -215,7 +215,6 @@ struct DeviceInner
|
|||
void RemoveClient (GstD3D12Device * client)
|
||||
{
|
||||
std::lock_guard <std::mutex> lk (lock);
|
||||
auto it = clients.begin ();
|
||||
for (auto it = clients.begin (); it != clients.end(); it++) {
|
||||
if (*it == client) {
|
||||
clients.erase (it);
|
||||
|
@ -758,169 +757,105 @@ gst_d3d12_device_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_format_support (GstD3D12Device * self, DXGI_FORMAT format,
|
||||
guint flags, D3D12_FEATURE_DATA_FORMAT_SUPPORT * support)
|
||||
static void
|
||||
make_buffer_format (GstVideoFormat format, GstD3D12Format * d3d12_format)
|
||||
{
|
||||
auto device = self->priv->inner->device;
|
||||
HRESULT hr;
|
||||
|
||||
support->Format = format;
|
||||
hr = device->CheckFeatureSupport (D3D12_FEATURE_FORMAT_SUPPORT, support,
|
||||
sizeof (D3D12_FEATURE_DATA_FORMAT_SUPPORT));
|
||||
if (FAILED (hr)) {
|
||||
GST_INFO_OBJECT (self,
|
||||
"Failed to check feature support for DXGI format %d", format);
|
||||
return FALSE;
|
||||
d3d12_format->format = format;
|
||||
d3d12_format->dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
d3d12_format->dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
d3d12_format->support1 = D3D12_FORMAT_SUPPORT1_NONE;
|
||||
d3d12_format->support2 = D3D12_FORMAT_SUPPORT2_NONE;
|
||||
for (guint i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
d3d12_format->resource_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
d3d12_format->uav_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
if (((guint) support->Support1 & flags) != flags) {
|
||||
GST_INFO_OBJECT (self,
|
||||
"DXGI format %d supports1 flag 0x%x, required 0x%x", format,
|
||||
support->Support1, flags);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_d3d12_device_setup_format_table (GstD3D12Device * self)
|
||||
{
|
||||
auto priv = self->priv->inner;
|
||||
auto & fs = priv->feature_support;
|
||||
HRESULT hr;
|
||||
|
||||
for (guint i = 0; i < GST_D3D12_N_FORMATS; i++) {
|
||||
const auto iter = &g_gst_d3d12_default_format_map[i];
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT support[GST_VIDEO_MAX_PLANES];
|
||||
gboolean native = true;
|
||||
for (guint f = 0; f < GST_VIDEO_FORMAT_LAST; f++) {
|
||||
GstD3D12Format format = { };
|
||||
if (!gst_d3d12_get_format ((GstVideoFormat) f, &format))
|
||||
continue;
|
||||
|
||||
switch (iter->format) {
|
||||
/* RGB/GRAY */
|
||||
case GST_VIDEO_FORMAT_BGRA:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_RGBA:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_RGB10A2_LE:
|
||||
case GST_VIDEO_FORMAT_RGBA64_LE:
|
||||
case GST_VIDEO_FORMAT_GRAY8:
|
||||
case GST_VIDEO_FORMAT_GRAY16_LE:
|
||||
if (!check_format_support (self, iter->dxgi_format,
|
||||
iter->format_support1[0], &support[0])) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
/* YUV DXGI native formats */
|
||||
case GST_VIDEO_FORMAT_VUYA:
|
||||
case GST_VIDEO_FORMAT_Y410:
|
||||
case GST_VIDEO_FORMAT_NV12:
|
||||
case GST_VIDEO_FORMAT_P010_10LE:
|
||||
case GST_VIDEO_FORMAT_P012_LE:
|
||||
case GST_VIDEO_FORMAT_P016_LE:
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
case GST_VIDEO_FORMAT_Y210:
|
||||
case GST_VIDEO_FORMAT_Y212_LE:
|
||||
case GST_VIDEO_FORMAT_Y412_LE:
|
||||
case GST_VIDEO_FORMAT_BGRA64_LE:
|
||||
case GST_VIDEO_FORMAT_BGR10A2_LE:
|
||||
case GST_VIDEO_FORMAT_RBGA:
|
||||
{
|
||||
if (!check_format_support (self, iter->dxgi_format,
|
||||
iter->format_support1[0], &support[0])) {
|
||||
bool supported = true;
|
||||
for (guint j = 0; j < GST_VIDEO_MAX_PLANES; j++) {
|
||||
if (iter->resource_format[j] == DXGI_FORMAT_UNKNOWN)
|
||||
break;
|
||||
g_assert (format.dimension == D3D12_RESOURCE_DIMENSION_BUFFER ||
|
||||
format.dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D);
|
||||
|
||||
if (!check_format_support (self, iter->resource_format[j],
|
||||
iter->format_support1[0], &support[j])) {
|
||||
supported = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!supported)
|
||||
continue;
|
||||
|
||||
native = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* non-DXGI native formats */
|
||||
case GST_VIDEO_FORMAT_NV21:
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
case GST_VIDEO_FORMAT_I420_10LE:
|
||||
case GST_VIDEO_FORMAT_I420_12LE:
|
||||
case GST_VIDEO_FORMAT_Y42B:
|
||||
case GST_VIDEO_FORMAT_I422_10LE:
|
||||
case GST_VIDEO_FORMAT_I422_12LE:
|
||||
case GST_VIDEO_FORMAT_Y444:
|
||||
case GST_VIDEO_FORMAT_Y444_10LE:
|
||||
case GST_VIDEO_FORMAT_Y444_12LE:
|
||||
case GST_VIDEO_FORMAT_Y444_16LE:
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_AYUV64:
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
case GST_VIDEO_FORMAT_VYUY:
|
||||
case GST_VIDEO_FORMAT_YVYU:
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_ABGR:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
case GST_VIDEO_FORMAT_RGB:
|
||||
case GST_VIDEO_FORMAT_BGR:
|
||||
case GST_VIDEO_FORMAT_v210:
|
||||
case GST_VIDEO_FORMAT_v216:
|
||||
case GST_VIDEO_FORMAT_v308:
|
||||
case GST_VIDEO_FORMAT_IYU2:
|
||||
case GST_VIDEO_FORMAT_RGB16:
|
||||
case GST_VIDEO_FORMAT_BGR16:
|
||||
case GST_VIDEO_FORMAT_RGB15:
|
||||
case GST_VIDEO_FORMAT_BGR15:
|
||||
case GST_VIDEO_FORMAT_r210:
|
||||
/* RGB planar formats */
|
||||
case GST_VIDEO_FORMAT_RGBP:
|
||||
case GST_VIDEO_FORMAT_BGRP:
|
||||
case GST_VIDEO_FORMAT_GBR:
|
||||
case GST_VIDEO_FORMAT_GBR_10LE:
|
||||
case GST_VIDEO_FORMAT_GBR_12LE:
|
||||
case GST_VIDEO_FORMAT_GBR_16LE:
|
||||
case GST_VIDEO_FORMAT_GBRA:
|
||||
case GST_VIDEO_FORMAT_GBRA_10LE:
|
||||
case GST_VIDEO_FORMAT_GBRA_12LE:
|
||||
{
|
||||
bool supported = true;
|
||||
native = false;
|
||||
|
||||
for (guint j = 0; j < GST_VIDEO_MAX_PLANES; j++) {
|
||||
if (iter->resource_format[j] == DXGI_FORMAT_UNKNOWN)
|
||||
break;
|
||||
|
||||
if (!check_format_support (self, iter->resource_format[j],
|
||||
iter->format_support1[0], &support[j])) {
|
||||
supported = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!supported)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return;
|
||||
D3D12_FORMAT_SUPPORT1 support1 = D3D12_FORMAT_SUPPORT1_NONE;
|
||||
D3D12_FORMAT_SUPPORT2 support2 = D3D12_FORMAT_SUPPORT2_NONE;
|
||||
bool supported = false;
|
||||
auto dxgi_format = format.dxgi_format;
|
||||
if (format.dimension == D3D12_RESOURCE_DIMENSION_BUFFER) {
|
||||
/* Buffer type is always supported */
|
||||
supported = true;
|
||||
}
|
||||
|
||||
auto format = *iter;
|
||||
if (!supported && dxgi_format != DXGI_FORMAT_UNKNOWN) {
|
||||
/* packed or yuv semi-planar */
|
||||
hr = fs.FormatSupport (format.dxgi_format, support1, support2);
|
||||
if (SUCCEEDED (hr) && (support1 & format.support1) == format.support1 &&
|
||||
(support2 & format.support2) == format.support2) {
|
||||
supported = true;
|
||||
} else {
|
||||
format.dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
if (!native)
|
||||
if (!supported) {
|
||||
bool check_failed = false;
|
||||
for (guint i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
auto resource_format = format.resource_format[i];
|
||||
if (resource_format == DXGI_FORMAT_UNKNOWN)
|
||||
break;
|
||||
|
||||
hr = fs.FormatSupport (resource_format, support1, support2);
|
||||
if (FAILED (hr) || (support1 & format.support1) != format.support1 ||
|
||||
(support2 & format.support2) != format.support2) {
|
||||
check_failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!check_failed)
|
||||
supported = true;
|
||||
}
|
||||
|
||||
if (!supported) {
|
||||
/* Use buffer format */
|
||||
format.dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
format.dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
format.support1 = D3D12_FORMAT_SUPPORT1_NONE;
|
||||
format.support2 = D3D12_FORMAT_SUPPORT2_NONE;
|
||||
for (guint i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
format.resource_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
format.uav_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
format.support1 = support1;
|
||||
format.support2 = support2;
|
||||
}
|
||||
|
||||
for (guint j = 0; j < GST_VIDEO_MAX_PLANES; j++) {
|
||||
format.format_support1[j] = support[j].Support1;
|
||||
format.format_support2[j] = support[j].Support2;
|
||||
if (format.dimension == D3D12_RESOURCE_DIMENSION_BUFFER) {
|
||||
GST_LOG_OBJECT (self, "Format %s support: buffer",
|
||||
gst_video_format_to_string (format.format));
|
||||
} else {
|
||||
GST_LOG_OBJECT (self, "Format %s support: dxgi-format: %s, "
|
||||
"resource-format: [%s, %s, %s, %s]",
|
||||
gst_video_format_to_string (format.format),
|
||||
D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetName (format.dxgi_format),
|
||||
D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::
|
||||
GetName (format.resource_format[0]),
|
||||
D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::
|
||||
GetName (format.resource_format[1]),
|
||||
D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::
|
||||
GetName (format.resource_format[2]),
|
||||
D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::
|
||||
GetName (format.resource_format[3]));
|
||||
}
|
||||
|
||||
priv->format_table[format.format] = format;
|
||||
|
@ -1158,6 +1093,13 @@ dump_feature_support (GstD3D12Device * self)
|
|||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
struct TestFormatInfo
|
||||
{
|
||||
DXGI_FORMAT format;
|
||||
D3D12_FORMAT_SUPPORT1 support1;
|
||||
D3D12_FORMAT_SUPPORT2 support2;
|
||||
};
|
||||
|
||||
static GstD3D12Device *
|
||||
gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
|
||||
{
|
||||
|
@ -1167,6 +1109,56 @@ gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
|
|||
HRESULT hr;
|
||||
UINT factory_flags = 0;
|
||||
guint index = 0;
|
||||
/* *INDENT-OFF* */
|
||||
const TestFormatInfo required_formats[] = {
|
||||
{ DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D |
|
||||
D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW |
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE
|
||||
},
|
||||
{ DXGI_FORMAT_R10G10B10A2_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D |
|
||||
D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW |
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE
|
||||
},
|
||||
{ DXGI_FORMAT_R16G16B16A16_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D |
|
||||
D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW |
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE
|
||||
},
|
||||
{ DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_NONE
|
||||
},
|
||||
{ DXGI_FORMAT_R8_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_NONE
|
||||
},
|
||||
{ DXGI_FORMAT_R8G8_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_NONE
|
||||
},
|
||||
{ DXGI_FORMAT_R16_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_NONE
|
||||
},
|
||||
{ DXGI_FORMAT_R16G16_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
|
||||
D3D12_FORMAT_SUPPORT2_NONE
|
||||
}
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
gst_d3d12_device_enable_debug ();
|
||||
gst_d3d12_device_enable_dred ();
|
||||
|
@ -1211,10 +1203,8 @@ gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
|
|||
priv->device_id = desc.DeviceId;
|
||||
priv->adapter_index = index;
|
||||
|
||||
if (desc.Description) {
|
||||
std::wstring_convert < std::codecvt_utf8 < wchar_t >, wchar_t >converter;
|
||||
priv->description = converter.to_bytes (desc.Description);
|
||||
}
|
||||
std::wstring_convert < std::codecvt_utf8 < wchar_t >, wchar_t >converter;
|
||||
priv->description = converter.to_bytes (desc.Description);
|
||||
|
||||
priv->feature_support.Init (device.Get ());
|
||||
|
||||
|
@ -1227,6 +1217,25 @@ gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
|
|||
priv->feature_support.MaxSupportedFeatureLevel (),
|
||||
priv->description.c_str ());
|
||||
|
||||
/* Minimum required format support. Feature level 11.0 device should support
|
||||
* below formats */
|
||||
for (guint i = 0; i < G_N_ELEMENTS (required_formats); i++) {
|
||||
D3D12_FORMAT_SUPPORT1 support1;
|
||||
D3D12_FORMAT_SUPPORT2 support2;
|
||||
const auto & format = required_formats[i];
|
||||
hr = priv->feature_support.FormatSupport (format.format,
|
||||
support1, support2);
|
||||
if (FAILED (hr) || (support1 & format.support1) != format.support1 ||
|
||||
(support2 & format.support2) != format.support2) {
|
||||
auto format_name =
|
||||
D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetName (format.format);
|
||||
GST_WARNING_OBJECT (self, "Device does not support DXGI format %d (%s)",
|
||||
format.format, format_name);
|
||||
gst_object_unref (self);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
if (gst_debug_category_get_threshold (GST_CAT_DEFAULT) >= GST_LEVEL_DEBUG)
|
||||
dump_feature_support (self);
|
||||
|
@ -1293,7 +1302,7 @@ gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
|
|||
for (guint i = 0; i < G_N_ELEMENTS (priv->decode_queue); i++) {
|
||||
priv->decode_queue[i] = gst_d3d12_command_queue_new (device.Get (),
|
||||
&queue_desc, D3D12_FENCE_FLAG_NONE, 8);
|
||||
if (!priv->decode_queue)
|
||||
if (!priv->decode_queue[i])
|
||||
break;
|
||||
|
||||
GST_OBJECT_FLAG_SET (priv->decode_queue[i],
|
||||
|
|
|
@ -60,143 +60,13 @@ gboolean gst_d3d12_color_primaries_matrix_unorm (const GstVideoColorPrima
|
|||
const GstVideoColorPrimariesInfo * out_info,
|
||||
GstD3D12ColorMatrix * matrix);
|
||||
|
||||
#define MAKE_FORMAT_MAP_YUV(g,d,r0,r1,r2,r3) \
|
||||
{ GST_VIDEO_FORMAT_ ##g, DXGI_FORMAT_ ##d, \
|
||||
{ DXGI_FORMAT_ ##r0, DXGI_FORMAT_ ##r1, DXGI_FORMAT_ ##r2, DXGI_FORMAT_ ##r3 }, \
|
||||
{ DXGI_FORMAT_ ##r0, DXGI_FORMAT_ ##r1, DXGI_FORMAT_ ##r2, DXGI_FORMAT_ ##r3 }, \
|
||||
(D3D12_FORMAT_SUPPORT1) (D3D12_FORMAT_SUPPORT1_RENDER_TARGET | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE) }
|
||||
|
||||
#define MAKE_FORMAT_MAP_FULL(g,d,r0,r1,r2,r3,f) \
|
||||
{ g, DXGI_FORMAT_ ##d, \
|
||||
{ DXGI_FORMAT_ ##r0, DXGI_FORMAT_ ##r1, DXGI_FORMAT_ ##r2, DXGI_FORMAT_ ##r3 }, \
|
||||
{ DXGI_FORMAT_ ##r0, DXGI_FORMAT_ ##r1, DXGI_FORMAT_ ##r2, DXGI_FORMAT_ ##r3 }, \
|
||||
(D3D12_FORMAT_SUPPORT1) (f) }
|
||||
|
||||
#define MAKE_FORMAT_MAP_RGB(g,d) \
|
||||
{ GST_VIDEO_FORMAT_ ##g, DXGI_FORMAT_ ##d, \
|
||||
{ DXGI_FORMAT_ ##d, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, \
|
||||
{ DXGI_FORMAT_ ##d, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, \
|
||||
(D3D12_FORMAT_SUPPORT1) (D3D12_FORMAT_SUPPORT1_RENDER_TARGET | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE) }
|
||||
|
||||
#define MAKE_FORMAT_MAP_RGBP(g,d,a) \
|
||||
{ GST_VIDEO_FORMAT_ ##g, DXGI_FORMAT_UNKNOWN, \
|
||||
{ DXGI_FORMAT_ ##d, DXGI_FORMAT_ ##d, DXGI_FORMAT_ ##d, DXGI_FORMAT_ ##a }, \
|
||||
{ DXGI_FORMAT_ ##d, DXGI_FORMAT_ ##d, DXGI_FORMAT_ ##d, DXGI_FORMAT_ ##a }, \
|
||||
(D3D12_FORMAT_SUPPORT1) (D3D12_FORMAT_SUPPORT1_RENDER_TARGET | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE) }
|
||||
|
||||
static const GstD3D12Format g_gst_d3d12_default_format_map[] = {
|
||||
MAKE_FORMAT_MAP_RGB (BGRA, B8G8R8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (RGBA, R8G8B8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (BGRx, B8G8R8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (RGBx, R8G8B8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (ARGB, R8G8B8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (xRGB, R8G8B8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (ABGR, R8G8B8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (xBGR, R8G8B8A8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (RGB10A2_LE, R10G10B10A2_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (RGBA64_LE, R16G16B16A16_UNORM),
|
||||
MAKE_FORMAT_MAP_YUV (AYUV, UNKNOWN, R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (AYUV64, UNKNOWN, R16G16B16A16_UNORM, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (VUYA, AYUV, R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (NV12, NV12, R8_UNORM, R8G8_UNORM, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (NV21, UNKNOWN, R8_UNORM, R8G8_UNORM, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (P010_10LE, P010, R16_UNORM, R16G16_UNORM, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (P012_LE, P016, R16_UNORM, R16G16_UNORM, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (P016_LE, P016, R16_UNORM, R16G16_UNORM, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (I420, UNKNOWN, R8_UNORM, R8_UNORM, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (YV12, UNKNOWN, R8_UNORM, R8_UNORM, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (I420_10LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (I420_12LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (Y42B, UNKNOWN, R8_UNORM, R8_UNORM, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (I422_10LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (I422_12LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (Y444, UNKNOWN, R8_UNORM, R8_UNORM, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (Y444_10LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (Y444_12LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (Y444_16LE, UNKNOWN, R16_UNORM, R16_UNORM, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (UYVY, UNKNOWN, R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (VYUY, UNKNOWN, R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_YUV (YVYU, UNKNOWN, R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGB (GRAY8, R8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGB (GRAY16_LE, R16_UNORM),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_Y410, Y410,
|
||||
R10G10B10A2_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_BGR10A2_LE, Y410,
|
||||
R10G10B10A2_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_YUY2, YUY2,
|
||||
R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_Y210, Y210,
|
||||
R16G16B16A16_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_Y212_LE, Y216,
|
||||
R16G16B16A16_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_Y412_LE, Y416,
|
||||
R16G16B16A16_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_BGRA64_LE, Y416,
|
||||
R16G16B16A16_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_RGB, UNKNOWN,
|
||||
R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_BGR, UNKNOWN,
|
||||
R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_v210, UNKNOWN,
|
||||
R10G10B10A2_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_v216, UNKNOWN,
|
||||
R16G16B16A16_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_v308, UNKNOWN,
|
||||
R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_IYU2, UNKNOWN,
|
||||
R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_RGB16, UNKNOWN,
|
||||
R16_UINT, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_BGR16, UNKNOWN,
|
||||
R16_UINT, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_RGB15, UNKNOWN,
|
||||
R16_UINT, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_BGR15, UNKNOWN,
|
||||
R16_UINT, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_r210, UNKNOWN,
|
||||
R32_UINT, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_FULL (GST_VIDEO_FORMAT_RBGA, AYUV,
|
||||
R8G8B8A8_UNORM, UNKNOWN, UNKNOWN, UNKNOWN,
|
||||
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE),
|
||||
MAKE_FORMAT_MAP_RGBP (RGBP, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGBP (BGRP, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGBP (GBR, R8_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGBP (GBR_10LE, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGBP (GBR_12LE, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGBP (GBR_16LE, R16_UNORM, UNKNOWN),
|
||||
MAKE_FORMAT_MAP_RGBP (GBRA, R8_UNORM, R8_UNORM),
|
||||
MAKE_FORMAT_MAP_RGBP (GBRA_10LE, R16_UNORM, R16_UNORM),
|
||||
MAKE_FORMAT_MAP_RGBP (GBRA_12LE, R16_UNORM, R16_UNORM),
|
||||
};
|
||||
|
||||
#undef MAKE_FORMAT_MAP_YUV
|
||||
#undef MAKE_FORMAT_MAP_FULL
|
||||
#undef MAKE_FORMAT_MAP_RGB
|
||||
#undef MAKE_FORMAT_MAP_RGBP
|
||||
|
||||
#define GST_D3D12_N_FORMATS G_N_ELEMENTS(g_gst_d3d12_default_format_map)
|
||||
GST_D3D12_API
|
||||
gboolean gst_d3d12_get_format (GstVideoFormat format,
|
||||
GstD3D12Format * d3d12_format);
|
||||
|
||||
GST_D3D12_API
|
||||
guint gst_d3d12_dxgi_format_get_resource_format (DXGI_FORMAT format,
|
||||
DXGI_FORMAT resource_format[GST_VIDEO_MAX_PLANES]);
|
||||
guint gst_d3d12_dxgi_format_get_resource_format (DXGI_FORMAT format,
|
||||
DXGI_FORMAT resource_format[GST_VIDEO_MAX_PLANES]);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -40,6 +40,368 @@ ensure_debug_category (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
const D3D12_FORMAT_SUPPORT1 kDefaultFormatSupport1 =
|
||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE |
|
||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET;
|
||||
|
||||
struct FormatBuilder : public GstD3D12Format
|
||||
{
|
||||
explicit FormatBuilder (const GstD3D12Format & other)
|
||||
: GstD3D12Format (other) {}
|
||||
|
||||
FormatBuilder ()
|
||||
{
|
||||
format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
dimension = D3D12_RESOURCE_DIMENSION_UNKNOWN;
|
||||
support1 = D3D12_FORMAT_SUPPORT1_NONE;
|
||||
support2 = D3D12_FORMAT_SUPPORT2_NONE;
|
||||
|
||||
for (guint i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
resource_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
uav_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
FormatBuilder (
|
||||
GstVideoFormat Format,
|
||||
GstD3D12FormatFlags FormatFlags,
|
||||
D3D12_RESOURCE_DIMENSION Dimension,
|
||||
DXGI_FORMAT DxgiFormat,
|
||||
const DXGI_FORMAT ResourceFormat[GST_VIDEO_MAX_PLANES],
|
||||
D3D12_FORMAT_SUPPORT1 Support1,
|
||||
D3D12_FORMAT_SUPPORT2 Support2
|
||||
)
|
||||
{
|
||||
format = Format;
|
||||
format_flags = FormatFlags;
|
||||
dimension = Dimension;
|
||||
dxgi_format = DxgiFormat;
|
||||
support1 = Support1;
|
||||
support2 = Support2;
|
||||
|
||||
for (guint i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
resource_format[i] = ResourceFormat[i];
|
||||
uav_format[i] = DXGI_FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static inline FormatBuilder NotSupported (
|
||||
GstVideoFormat Format
|
||||
)
|
||||
{
|
||||
auto f = FormatBuilder();
|
||||
f.format = Format;
|
||||
return f;
|
||||
}
|
||||
|
||||
static inline FormatBuilder RgbPacked (
|
||||
GstVideoFormat Format,
|
||||
DXGI_FORMAT DxgiFormat,
|
||||
D3D12_FORMAT_SUPPORT1 Support1 = kDefaultFormatSupport1,
|
||||
D3D12_FORMAT_SUPPORT2 Support2 = D3D12_FORMAT_SUPPORT2_NONE,
|
||||
GstD3D12FormatFlags FormatFlags = GST_D3D12_FORMAT_FLAG_NONE
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { DxgiFormat, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
|
||||
DXGI_FORMAT_UNKNOWN };
|
||||
|
||||
return FormatBuilder (Format, FormatFlags,
|
||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D,
|
||||
DxgiFormat, resource_format, Support1, Support2);
|
||||
}
|
||||
|
||||
static inline FormatBuilder Planar (
|
||||
GstVideoFormat Format,
|
||||
DXGI_FORMAT ResourceFormat = DXGI_FORMAT_R8_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1 Support1 = kDefaultFormatSupport1,
|
||||
D3D12_FORMAT_SUPPORT2 Support2 = D3D12_FORMAT_SUPPORT2_NONE
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { ResourceFormat, ResourceFormat,
|
||||
ResourceFormat, DXGI_FORMAT_UNKNOWN };
|
||||
return FormatBuilder (Format, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D, DXGI_FORMAT_UNKNOWN,
|
||||
resource_format, Support1, Support2);
|
||||
}
|
||||
|
||||
static inline FormatBuilder PlanarFull (
|
||||
GstVideoFormat Format,
|
||||
DXGI_FORMAT ResourceFormat = DXGI_FORMAT_R8_UNORM,
|
||||
D3D12_FORMAT_SUPPORT1 Support1 = kDefaultFormatSupport1,
|
||||
D3D12_FORMAT_SUPPORT2 Support2 = D3D12_FORMAT_SUPPORT2_NONE
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { ResourceFormat, ResourceFormat,
|
||||
ResourceFormat, ResourceFormat };
|
||||
return FormatBuilder (Format, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D, DXGI_FORMAT_UNKNOWN,
|
||||
resource_format, Support1, Support2);
|
||||
}
|
||||
|
||||
static inline FormatBuilder YuvSemiPlanar (
|
||||
GstVideoFormat Format,
|
||||
DXGI_FORMAT DxgiFormat,
|
||||
DXGI_FORMAT ResourceFormatY,
|
||||
DXGI_FORMAT ResourceFormatUV,
|
||||
D3D12_FORMAT_SUPPORT1 Support1 = kDefaultFormatSupport1,
|
||||
D3D12_FORMAT_SUPPORT2 Support2 = D3D12_FORMAT_SUPPORT2_NONE
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { ResourceFormatY, ResourceFormatUV,
|
||||
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN };
|
||||
return FormatBuilder (Format, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D, DxgiFormat, resource_format,
|
||||
Support1, Support2);
|
||||
}
|
||||
|
||||
static inline FormatBuilder YuvPacked (
|
||||
GstVideoFormat Format,
|
||||
DXGI_FORMAT DxgiFormat,
|
||||
DXGI_FORMAT ResourceFormat,
|
||||
GstD3D12FormatFlags FormatFlags = GST_D3D12_FORMAT_FLAG_OUTPUT_UAV,
|
||||
D3D12_FORMAT_SUPPORT1 Support1 = (D3D12_FORMAT_SUPPORT1_TEXTURE2D |
|
||||
D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW),
|
||||
D3D12_FORMAT_SUPPORT2 Support2 = D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { ResourceFormat, DXGI_FORMAT_UNKNOWN,
|
||||
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN };
|
||||
return FormatBuilder (Format, FormatFlags,
|
||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D,
|
||||
DxgiFormat, resource_format, Support1, Support2);
|
||||
}
|
||||
|
||||
static inline FormatBuilder Gray (
|
||||
GstVideoFormat Format,
|
||||
DXGI_FORMAT DxgiFormat,
|
||||
D3D12_FORMAT_SUPPORT1 Support1 = kDefaultFormatSupport1,
|
||||
D3D12_FORMAT_SUPPORT2 Support2 = D3D12_FORMAT_SUPPORT2_NONE
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { DxgiFormat, DXGI_FORMAT_UNKNOWN,
|
||||
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN };
|
||||
return FormatBuilder (Format, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D,
|
||||
DxgiFormat, resource_format, Support1, Support2);
|
||||
}
|
||||
|
||||
static inline FormatBuilder Buffer (
|
||||
GstVideoFormat Format
|
||||
)
|
||||
{
|
||||
DXGI_FORMAT resource_format[] = { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
|
||||
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN };
|
||||
return FormatBuilder (Format, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
D3D12_RESOURCE_DIMENSION_BUFFER, DXGI_FORMAT_UNKNOWN, resource_format,
|
||||
D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE);
|
||||
}
|
||||
};
|
||||
|
||||
static const GstD3D12Format g_format_map[] = {
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_UNKNOWN),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_ENCODED),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_I420),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_YV12),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_YUY2,
|
||||
DXGI_FORMAT_YUY2, DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_UYVY,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_AYUV,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_RGBx,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_BGRx,
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_xRGB,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_xBGR,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_RGBA,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_BGRA,
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_ARGB,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_ABGR,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_RGB),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_BGR),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_Y41B),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_Y42B),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_YVYU,
|
||||
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_Y444),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_v210),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_v216),
|
||||
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_NV12,
|
||||
DXGI_FORMAT_NV12, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM),
|
||||
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_NV21,
|
||||
DXGI_FORMAT_NV12, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM),
|
||||
FormatBuilder::Gray (GST_VIDEO_FORMAT_GRAY8,
|
||||
DXGI_FORMAT_R8_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GRAY16_BE),
|
||||
FormatBuilder::Gray (GST_VIDEO_FORMAT_GRAY16_LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_v308),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_RGB16,
|
||||
DXGI_FORMAT_B5G6R5_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_BGR16,
|
||||
DXGI_FORMAT_B5G6R5_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_RGB15,
|
||||
DXGI_FORMAT_B5G5R5A1_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_BGR15,
|
||||
DXGI_FORMAT_B5G5R5A1_UNORM),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_UYVP),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A420),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_RGB8P),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_YUV9),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_YVU9),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_IYU1),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_ARGB64,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_AYUV64,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_r210),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_I420_10BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_I420_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_I422_10BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_I422_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y444_10BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_Y444_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBR_10BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV16),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV24),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_64Z32),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A420_10BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A420_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A422_10BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A422_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A444_10BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A444_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV61),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_P010_10BE),
|
||||
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_P010_10LE,
|
||||
DXGI_FORMAT_P010, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM),
|
||||
FormatBuilder::Buffer (GST_VIDEO_FORMAT_IYU2),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_VYUY,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_GBRA),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBRA_10BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_GBRA_10LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBR_12BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBRA_12BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_GBRA_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_I420_12BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_I420_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_I422_12BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_I422_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y444_12BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_Y444_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GRAY10_LE32),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_10LE32),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV16_10LE32),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_10LE40),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_Y210,
|
||||
DXGI_FORMAT_Y210, DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_Y410,
|
||||
DXGI_FORMAT_Y410, DXGI_FORMAT_R10G10B10A2_UNORM),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_VUYA,
|
||||
DXGI_FORMAT_AYUV, DXGI_FORMAT_R8G8B8A8_UNORM, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
kDefaultFormatSupport1, D3D12_FORMAT_SUPPORT2_NONE),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_BGR10A2_LE,
|
||||
DXGI_FORMAT_Y410, DXGI_FORMAT_R10G10B10A2_UNORM),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_RGB10A2_LE,
|
||||
DXGI_FORMAT_R10G10B10A2_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y444_16BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_Y444_16LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_P016_BE),
|
||||
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_P016_LE,
|
||||
DXGI_FORMAT_P016, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_P012_BE),
|
||||
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_P012_LE,
|
||||
DXGI_FORMAT_P016, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y212_BE),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_Y212_LE,
|
||||
DXGI_FORMAT_Y216, DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y412_BE),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_Y412_LE,
|
||||
DXGI_FORMAT_Y416, DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_4L4),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_32L32),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_RGBP),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_BGRP),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_AV12),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_ARGB64_LE),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_ARGB64_BE),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_RGBA64_LE,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_RGBA64_BE),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_BGRA64_LE,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_BGRA64_BE),
|
||||
FormatBuilder::RgbPacked (GST_VIDEO_FORMAT_ABGR64_LE,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_ABGR64_BE),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_16L32S),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_8L128),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_10BE_8L128),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_10LE40_4L4),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_DMA_DRM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_MT2110T),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_MT2110R),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A422),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A444),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A444_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A444_12BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A422_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A422_12BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A420_12LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A420_12BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A444_16LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A444_16BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A422_16LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A422_16BE),
|
||||
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A420_16LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A420_16BE),
|
||||
FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR_16LE,
|
||||
DXGI_FORMAT_R16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBR_16BE),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_RBGA,
|
||||
DXGI_FORMAT_AYUV, DXGI_FORMAT_R8G8B8A8_UNORM, GST_D3D12_FORMAT_FLAG_NONE,
|
||||
kDefaultFormatSupport1, D3D12_FORMAT_SUPPORT2_NONE),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_Y216_LE,
|
||||
DXGI_FORMAT_Y216, DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y216_BE),
|
||||
FormatBuilder::YuvPacked (GST_VIDEO_FORMAT_Y416_LE,
|
||||
DXGI_FORMAT_Y416, DXGI_FORMAT_R16G16B16A16_UNORM),
|
||||
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_Y416_BE),
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
GstVideoFormat
|
||||
gst_d3d12_dxgi_format_to_gst (DXGI_FORMAT format)
|
||||
{
|
||||
|
@ -71,6 +433,23 @@ gst_d3d12_dxgi_format_to_gst (DXGI_FORMAT format)
|
|||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d12_get_format (GstVideoFormat format, GstD3D12Format * d3d12_format)
|
||||
{
|
||||
if ((guint) format >= G_N_ELEMENTS (g_format_map))
|
||||
return FALSE;
|
||||
|
||||
const auto & f = g_format_map[(guint) format];
|
||||
g_assert (f.format == format);
|
||||
|
||||
if (f.dimension == D3D12_RESOURCE_DIMENSION_UNKNOWN)
|
||||
return FALSE;
|
||||
|
||||
*d3d12_format = g_format_map[(guint) format];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
guint
|
||||
gst_d3d12_dxgi_format_get_resource_format (DXGI_FORMAT format,
|
||||
DXGI_FORMAT resource_format[GST_VIDEO_MAX_PLANES])
|
||||
|
@ -83,21 +462,21 @@ gst_d3d12_dxgi_format_get_resource_format (DXGI_FORMAT format,
|
|||
if (format == DXGI_FORMAT_UNKNOWN)
|
||||
return 0;
|
||||
|
||||
for (guint i = 0; i < GST_D3D12_N_FORMATS; i++) {
|
||||
const GstD3D12Format *fmt = &g_gst_d3d12_default_format_map[i];
|
||||
for (guint i = 0; i < G_N_ELEMENTS (g_format_map); i++) {
|
||||
const auto & f = g_format_map[i];
|
||||
if (f.dxgi_format != format)
|
||||
continue;
|
||||
|
||||
if (fmt->dxgi_format == format) {
|
||||
guint n_planes = 0;
|
||||
guint n_planes = 0;
|
||||
for (n_planes = 0; n_planes < GST_VIDEO_MAX_PLANES; n_planes++) {
|
||||
auto rf = f.resource_format[n_planes];
|
||||
if (rf == DXGI_FORMAT_UNKNOWN)
|
||||
break;
|
||||
|
||||
for (n_planes = 0; n_planes < GST_VIDEO_MAX_PLANES; n_planes++) {
|
||||
if (fmt->resource_format[n_planes] == DXGI_FORMAT_UNKNOWN)
|
||||
break;
|
||||
|
||||
resource_format[n_planes] = fmt->resource_format[n_planes];
|
||||
}
|
||||
|
||||
return n_planes;
|
||||
resource_format[n_planes] = rf;
|
||||
}
|
||||
|
||||
return n_planes;
|
||||
}
|
||||
|
||||
resource_format[0] = format;
|
||||
|
|
|
@ -25,10 +25,40 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GstD3D12FormatFlags:
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* GST_D3D12_FORMAT_FLAG_NONE:
|
||||
*
|
||||
* Default flag
|
||||
*/
|
||||
GST_D3D12_FORMAT_FLAG_NONE = 0,
|
||||
|
||||
/**
|
||||
* GST_D3D12_FORMAT_FLAG_OUTPUT_UAV:
|
||||
*
|
||||
* The format may or may not support RTV, but UAV binding is strictly required
|
||||
* for the format to be used as a conversion output.
|
||||
*/
|
||||
GST_D3D12_FORMAT_FLAG_OUTPUT_UAV = (1 << 0),
|
||||
} GstD3D12FormatFlags;
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS (GstD3D12FormatFlags);
|
||||
|
||||
struct _GstD3D12Format
|
||||
{
|
||||
GstVideoFormat format;
|
||||
|
||||
GstD3D12FormatFlags format_flags;
|
||||
|
||||
/* Texture2D or Buffer */
|
||||
D3D12_RESOURCE_DIMENSION dimension;
|
||||
|
||||
/* direct mapping to dxgi format if applicable */
|
||||
DXGI_FORMAT dxgi_format;
|
||||
|
||||
|
@ -38,11 +68,8 @@ struct _GstD3D12Format
|
|||
/* extra format used for unordered access view (unused) */
|
||||
DXGI_FORMAT uav_format[GST_VIDEO_MAX_PLANES];
|
||||
|
||||
/* D3D12_FORMAT_SUPPORT1 flags */
|
||||
guint format_support1[GST_VIDEO_MAX_PLANES];
|
||||
|
||||
/* D3D12_FORMAT_SUPPORT2 flags (unused) */
|
||||
guint format_support2[GST_VIDEO_MAX_PLANES];
|
||||
D3D12_FORMAT_SUPPORT1 support1;
|
||||
D3D12_FORMAT_SUPPORT2 support2;
|
||||
|
||||
/*< private >*/
|
||||
guint padding[GST_PADDING_LARGE];
|
||||
|
|
Loading…
Reference in a new issue