mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
d3d11memory: Always use native DXGI format if device support it
Use consistent memory layout between dxva and other shader use case. For example, use DXGI_FORMAT_NV12 texture format instead of two textures with DXGI_FORMAT_R8_UNORM and DXGI_FORMAT_R8G8_UNORM.
This commit is contained in:
parent
9ee40679b5
commit
96f0f4b613
15 changed files with 178 additions and 177 deletions
|
@ -152,8 +152,8 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
|||
gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!priv->d3d11_params) {
|
||||
/* allocate memory with resource format by default */
|
||||
priv->d3d11_params = gst_d3d11_allocation_params_new (&info,
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, 0);
|
||||
priv->d3d11_params =
|
||||
gst_d3d11_allocation_params_new (priv->device, &info, 0, 0);
|
||||
}
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
{
|
||||
|
@ -265,9 +265,7 @@ gst_d3d11_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
|
||||
buf = gst_buffer_new ();
|
||||
|
||||
if ((d3d11_params->flags & GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT) ==
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT) {
|
||||
|
||||
if (d3d11_params->d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) {
|
||||
for (n_texture = 0; n_texture < GST_VIDEO_INFO_N_PLANES (info); n_texture++) {
|
||||
d3d11_params->plane = n_texture;
|
||||
mem = gst_d3d11_allocator_alloc (priv->allocator, d3d11_params);
|
||||
|
|
|
@ -340,8 +340,7 @@ gst_d3d11_color_convert_propose_allocation (GstBaseTransform * trans,
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&info,
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
|
||||
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &info, 0,
|
||||
D3D11_BIND_SHADER_RESOURCE);
|
||||
} else {
|
||||
/* Set bind flag */
|
||||
|
@ -421,8 +420,7 @@ gst_d3d11_color_convert_decide_allocation (GstBaseTransform * trans,
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&info,
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
|
||||
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &info, 0,
|
||||
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
|
||||
} else {
|
||||
/* Set bind flag */
|
||||
|
@ -690,14 +688,16 @@ gst_d3d11_color_convert_set_info (GstD3D11BaseFilter * filter,
|
|||
return TRUE;
|
||||
|
||||
self->in_d3d11_format =
|
||||
gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (in_info));
|
||||
gst_d3d11_device_format_from_gst (filter->device,
|
||||
GST_VIDEO_INFO_FORMAT (in_info));
|
||||
if (!self->in_d3d11_format) {
|
||||
unknown_info = in_info;
|
||||
goto format_unknown;
|
||||
}
|
||||
|
||||
self->out_d3d11_format =
|
||||
gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (out_info));
|
||||
gst_d3d11_device_format_from_gst (filter->device,
|
||||
GST_VIDEO_INFO_FORMAT (out_info));
|
||||
if (!self->out_d3d11_format) {
|
||||
unknown_info = out_info;
|
||||
goto format_unknown;
|
||||
|
|
|
@ -1090,14 +1090,17 @@ gst_d3d11_color_converter_new (GstD3D11Device * device,
|
|||
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (in_info)),
|
||||
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (out_info)));
|
||||
|
||||
in_d3d11_format = gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (in_info));
|
||||
in_d3d11_format =
|
||||
gst_d3d11_device_format_from_gst (device,
|
||||
GST_VIDEO_INFO_FORMAT (in_info));
|
||||
if (!in_d3d11_format) {
|
||||
unknown_info = in_info;
|
||||
goto format_unknown;
|
||||
}
|
||||
|
||||
out_d3d11_format =
|
||||
gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (out_info));
|
||||
gst_d3d11_device_format_from_gst (device,
|
||||
GST_VIDEO_INFO_FORMAT (out_info));
|
||||
if (!out_d3d11_format) {
|
||||
unknown_info = out_info;
|
||||
goto format_unknown;
|
||||
|
|
|
@ -393,7 +393,7 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self,
|
|||
|
||||
gst_clear_object (&priv->internal_pool);
|
||||
|
||||
alloc_params = gst_d3d11_allocation_params_new (info,
|
||||
alloc_params = gst_d3d11_allocation_params_new (priv->device, info,
|
||||
GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY, D3D11_BIND_DECODER);
|
||||
|
||||
if (!alloc_params) {
|
||||
|
@ -483,7 +483,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
priv = decoder->priv;
|
||||
decoder->opened = FALSE;
|
||||
|
||||
d3d11_format = gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (info));
|
||||
d3d11_format = gst_d3d11_device_format_from_gst (priv->device,
|
||||
GST_VIDEO_INFO_FORMAT (info));
|
||||
if (!d3d11_format || d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) {
|
||||
GST_ERROR_OBJECT (decoder, "Could not determine dxgi format from %s",
|
||||
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (info)));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "gstd3d11device.h"
|
||||
#include "gstd3d11utils.h"
|
||||
#include "gstd3d11format.h"
|
||||
#include "gmodule.h"
|
||||
|
||||
#if HAVE_D3D11SDKLAYERS_H
|
||||
|
@ -80,6 +81,7 @@ struct _GstD3D11DevicePrivate
|
|||
IDXGIFactory1 *factory;
|
||||
GstD3D11DXGIFactoryVersion factory_ver;
|
||||
D3D_FEATURE_LEVEL feature_level;
|
||||
GstD3D11Format format_table[GST_D3D11_N_FORMATS];
|
||||
|
||||
GRecMutex extern_lock;
|
||||
|
||||
|
@ -358,6 +360,103 @@ gst_d3d11_device_init (GstD3D11Device * self)
|
|||
self->priv = priv;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
can_support_format (GstD3D11Device * self, DXGI_FORMAT format)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv = self->priv;
|
||||
ID3D11Device *handle = priv->device;
|
||||
HRESULT hr;
|
||||
UINT supported;
|
||||
D3D11_FORMAT_SUPPORT flags =
|
||||
(D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_RENDER_TARGET |
|
||||
D3D11_FORMAT_SUPPORT_SHADER_SAMPLE);
|
||||
|
||||
if (!gst_d3d11_is_windows_8_or_greater ())
|
||||
return FALSE;
|
||||
|
||||
hr = ID3D11Device_CheckFormatSupport (handle, format, &supported);
|
||||
if (!gst_d3d11_result (hr, NULL))
|
||||
return FALSE;
|
||||
|
||||
return (supported & flags) == flags;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_d3d11_device_setup_format_table (GstD3D11Device * self)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv = self->priv;
|
||||
guint n_formats = 0;
|
||||
|
||||
/* RGB formats */
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_BGRA;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
n_formats++;
|
||||
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_RGBA;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
n_formats++;
|
||||
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_RGB10A2_LE;
|
||||
priv->format_table[n_formats].resource_format[0] =
|
||||
DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
n_formats++;
|
||||
|
||||
/* YUV packed */
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_VUYA;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
if (can_support_format (self, DXGI_FORMAT_AYUV))
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_AYUV;
|
||||
else
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
n_formats++;
|
||||
|
||||
/* YUV semi-planar */
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_NV12;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8_UNORM;
|
||||
priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R8G8_UNORM;
|
||||
if (can_support_format (self, DXGI_FORMAT_NV12))
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_NV12;
|
||||
else
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
n_formats++;
|
||||
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_P010_10LE;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM;
|
||||
priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16G16_UNORM;
|
||||
if (can_support_format (self, DXGI_FORMAT_P010))
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_P010;
|
||||
else
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
n_formats++;
|
||||
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_P016_LE;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM;
|
||||
priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16G16_UNORM;
|
||||
if (can_support_format (self, DXGI_FORMAT_P016))
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_P016;
|
||||
else
|
||||
priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_UNKNOWN;
|
||||
n_formats++;
|
||||
|
||||
/* YUV plannar */
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_I420;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8_UNORM;
|
||||
priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R8_UNORM;
|
||||
priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R8_UNORM;
|
||||
n_formats++;
|
||||
|
||||
priv->format_table[n_formats].format = GST_VIDEO_FORMAT_I420_10LE;
|
||||
priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM;
|
||||
priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM;
|
||||
priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM;
|
||||
n_formats++;
|
||||
|
||||
g_assert (n_formats == GST_D3D11_N_FORMATS);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_d3d11_device_constructed (GObject * object)
|
||||
{
|
||||
|
@ -537,6 +636,7 @@ gst_d3d11_device_constructed (GObject * object)
|
|||
#endif
|
||||
|
||||
IDXGIAdapter1_Release (adapter);
|
||||
gst_d3d11_device_setup_format_table (self);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
|
@ -1007,3 +1107,22 @@ gst_d3d11_device_unlock (GstD3D11Device * device)
|
|||
g_rec_mutex_unlock (&priv->extern_lock);
|
||||
GST_TRACE_OBJECT (device, "device unlocked");
|
||||
}
|
||||
|
||||
const GstD3D11Format *
|
||||
gst_d3d11_device_format_from_gst (GstD3D11Device * device,
|
||||
GstVideoFormat format)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
priv = device->priv;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (priv->format_table); i++) {
|
||||
if (priv->format_table[i].format == format)
|
||||
return &priv->format_table[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,10 @@ void gst_d3d11_device_dxgi_debug (GstD3D11Device * device,
|
|||
const gchar * file,
|
||||
const gchar * function,
|
||||
gint line);
|
||||
|
||||
const GstD3D11Format * gst_d3d11_device_format_from_gst (GstD3D11Device * device,
|
||||
GstVideoFormat format);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_D3D11_DEVICE_H__ */
|
||||
|
|
|
@ -29,112 +29,6 @@
|
|||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_format_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_format_debug
|
||||
|
||||
/* Following formats were introduced since Windows 8
|
||||
* DXGI_FORMAT_AYUV
|
||||
* DXGI_FORMAT_NV12
|
||||
* DXGI_FORMAT_P010
|
||||
* DXGI_FORMAT_P016
|
||||
* ...
|
||||
*/
|
||||
static const GstD3D11Format legacy_d3d11_formats[] = {
|
||||
/* RGB formats */
|
||||
{GST_VIDEO_FORMAT_BGRA, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
{DXGI_FORMAT_B8G8R8A8_UNORM,}},
|
||||
{GST_VIDEO_FORMAT_RGBA, DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
{DXGI_FORMAT_R8G8B8A8_UNORM,}},
|
||||
{GST_VIDEO_FORMAT_RGB10A2_LE, DXGI_FORMAT_R10G10B10A2_UNORM,
|
||||
{DXGI_FORMAT_R10G10B10A2_UNORM,}},
|
||||
|
||||
/* YUV packed */
|
||||
{GST_VIDEO_FORMAT_VUYA, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R8G8B8A8_UNORM,}},
|
||||
|
||||
/* YUV semi-planner */
|
||||
{GST_VIDEO_FORMAT_NV12, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM}},
|
||||
{GST_VIDEO_FORMAT_P010_10LE, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM}},
|
||||
{GST_VIDEO_FORMAT_P016_LE, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM}},
|
||||
|
||||
/* YUV planner */
|
||||
{GST_VIDEO_FORMAT_I420, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM}},
|
||||
{GST_VIDEO_FORMAT_I420_10LE, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16_UNORM}},
|
||||
|
||||
/* LAST */
|
||||
{GST_VIDEO_FORMAT_UNKNOWN,},
|
||||
};
|
||||
|
||||
static const GstD3D11Format d3d11_formats[] = {
|
||||
/* RGB formats */
|
||||
{GST_VIDEO_FORMAT_BGRA, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
{DXGI_FORMAT_B8G8R8A8_UNORM,}},
|
||||
{GST_VIDEO_FORMAT_RGBA, DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
{DXGI_FORMAT_R8G8B8A8_UNORM,}},
|
||||
{GST_VIDEO_FORMAT_RGB10A2_LE, DXGI_FORMAT_R10G10B10A2_UNORM,
|
||||
{DXGI_FORMAT_R10G10B10A2_UNORM,}},
|
||||
|
||||
/* YUV packed */
|
||||
{GST_VIDEO_FORMAT_VUYA, DXGI_FORMAT_AYUV,
|
||||
{DXGI_FORMAT_R8G8B8A8_UNORM,}},
|
||||
|
||||
/* YUV semi-planner */
|
||||
{GST_VIDEO_FORMAT_NV12, DXGI_FORMAT_NV12,
|
||||
{DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM}},
|
||||
{GST_VIDEO_FORMAT_P010_10LE, DXGI_FORMAT_P010,
|
||||
{DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM}},
|
||||
{GST_VIDEO_FORMAT_P016_LE, DXGI_FORMAT_P016,
|
||||
{DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM}},
|
||||
|
||||
/* YUV planner */
|
||||
{GST_VIDEO_FORMAT_I420, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM}},
|
||||
{GST_VIDEO_FORMAT_I420_10LE, DXGI_FORMAT_UNKNOWN,
|
||||
{DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16_UNORM}},
|
||||
|
||||
/* LAST */
|
||||
{GST_VIDEO_FORMAT_UNKNOWN,},
|
||||
};
|
||||
|
||||
static GstD3D11Format *
|
||||
get_supported_d3d11_formats (void)
|
||||
{
|
||||
static gsize format_once = 0;
|
||||
static GstD3D11Format *supported_d3d11_formats = NULL;
|
||||
|
||||
if (g_once_init_enter (&format_once)) {
|
||||
if (gst_d3d11_is_windows_8_or_greater ())
|
||||
supported_d3d11_formats = (GstD3D11Format *) d3d11_formats;
|
||||
else
|
||||
supported_d3d11_formats = (GstD3D11Format *) legacy_d3d11_formats;
|
||||
|
||||
g_once_init_leave (&format_once, 1);
|
||||
}
|
||||
|
||||
return supported_d3d11_formats;
|
||||
}
|
||||
|
||||
GstVideoFormat
|
||||
gst_d3d11_dxgi_format_to_gst (DXGI_FORMAT format)
|
||||
{
|
||||
gint i;
|
||||
GstD3D11Format *format_list;
|
||||
|
||||
if (format == DXGI_FORMAT_UNKNOWN)
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
|
||||
format_list = get_supported_d3d11_formats ();
|
||||
|
||||
for (i = 0; format_list[i].format != GST_VIDEO_FORMAT_UNKNOWN; i++) {
|
||||
if (format_list[i].dxgi_format == format)
|
||||
return format_list[i].format;
|
||||
}
|
||||
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
guint
|
||||
gst_d3d11_dxgi_format_n_planes (DXGI_FORMAT format)
|
||||
{
|
||||
|
@ -199,22 +93,6 @@ gst_d3d11_dxgi_format_get_size (DXGI_FORMAT format, guint width, guint height,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const GstD3D11Format *
|
||||
gst_d3d11_format_from_gst (GstVideoFormat format)
|
||||
{
|
||||
gint i;
|
||||
GstD3D11Format *format_list;
|
||||
|
||||
format_list = get_supported_d3d11_formats ();
|
||||
|
||||
for (i = 0; format_list[i].format != GST_VIDEO_FORMAT_UNKNOWN; i++) {
|
||||
if (format_list[i].format == format)
|
||||
return &format_list[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_d3d11_device_get_supported_caps:
|
||||
* @device: a #GstD3DDevice
|
||||
|
@ -233,25 +111,35 @@ gst_d3d11_device_get_supported_caps (GstD3D11Device * device,
|
|||
gint i;
|
||||
GValue v_list = G_VALUE_INIT;
|
||||
GstCaps *supported_caps;
|
||||
GstD3D11Format *format_list;
|
||||
static const GstVideoFormat format_list[] = {
|
||||
GST_VIDEO_FORMAT_BGRA,
|
||||
GST_VIDEO_FORMAT_RGBA,
|
||||
GST_VIDEO_FORMAT_RGB10A2_LE,
|
||||
GST_VIDEO_FORMAT_VUYA,
|
||||
GST_VIDEO_FORMAT_NV12,
|
||||
GST_VIDEO_FORMAT_P010_10LE,
|
||||
GST_VIDEO_FORMAT_P016_LE,
|
||||
GST_VIDEO_FORMAT_I420,
|
||||
GST_VIDEO_FORMAT_I420_10LE,
|
||||
};
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
d3d11_device = gst_d3d11_device_get_device_handle (device);
|
||||
g_value_init (&v_list, GST_TYPE_LIST);
|
||||
|
||||
format_list = get_supported_d3d11_formats ();
|
||||
|
||||
for (i = 0; format_list[i].format != GST_VIDEO_FORMAT_UNKNOWN; i++) {
|
||||
for (i = 0; i < G_N_ELEMENTS (format_list); i++) {
|
||||
UINT format_support = 0;
|
||||
GstVideoFormat format;
|
||||
const GstD3D11Format *d3d11_format;
|
||||
|
||||
if (format_list[i].dxgi_format == DXGI_FORMAT_UNKNOWN)
|
||||
d3d11_format = gst_d3d11_device_format_from_gst (device, format_list[i]);
|
||||
if (!d3d11_format || d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN)
|
||||
continue;
|
||||
|
||||
format = format_list[i].format;
|
||||
format = d3d11_format->format;
|
||||
hr = ID3D11Device_CheckFormatSupport (d3d11_device,
|
||||
format_list[i].dxgi_format, &format_support);
|
||||
d3d11_format->dxgi_format, &format_support);
|
||||
|
||||
if (SUCCEEDED (hr) && ((format_support & flags) == flags)) {
|
||||
GValue v_str = G_VALUE_INIT;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#define GST_D3D11_FORMATS \
|
||||
"{ BGRA, RGBA, RGB10A2_LE, VUYA, NV12, P010_10LE, P016_LE, I420, I420_10LE }"
|
||||
#define GST_D3D11_N_FORMATS 9
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -41,8 +42,6 @@ struct _GstD3D11Format
|
|||
DXGI_FORMAT resource_format[GST_VIDEO_MAX_COMPONENTS];
|
||||
};
|
||||
|
||||
GstVideoFormat gst_d3d11_dxgi_format_to_gst (DXGI_FORMAT format);
|
||||
|
||||
guint gst_d3d11_dxgi_format_n_planes (DXGI_FORMAT format);
|
||||
|
||||
gboolean gst_d3d11_dxgi_format_get_size (DXGI_FORMAT format,
|
||||
|
@ -53,8 +52,6 @@ gboolean gst_d3d11_dxgi_format_get_size (DXGI_FORMAT format,
|
|||
gint stride[GST_VIDEO_MAX_PLANES],
|
||||
gsize *size);
|
||||
|
||||
const GstD3D11Format * gst_d3d11_format_from_gst (GstVideoFormat format);
|
||||
|
||||
GstCaps * gst_d3d11_device_get_supported_caps (GstD3D11Device * device,
|
||||
D3D11_FORMAT_SUPPORT flags);
|
||||
|
||||
|
|
|
@ -446,7 +446,8 @@ gst_d3d11_h264_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
if (self->use_d3d11_output) {
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params)
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0, 0);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device,
|
||||
&vinfo, 0, 0);
|
||||
|
||||
/* dxva2 decoder uses non-resource format
|
||||
* (e.g., use NV12 instead of R8 + R8G8 */
|
||||
|
@ -454,8 +455,6 @@ gst_d3d11_h264_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
d3d11_params->desc[0].Height = GST_VIDEO_INFO_HEIGHT (&vinfo);
|
||||
d3d11_params->desc[0].Format = d3d11_params->d3d11_format->dxgi_format;
|
||||
|
||||
d3d11_params->flags &= ~GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT;
|
||||
|
||||
gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);
|
||||
gst_d3d11_allocation_params_free (d3d11_params);
|
||||
}
|
||||
|
|
|
@ -410,7 +410,8 @@ gst_d3d11_h265_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
if (self->use_d3d11_output) {
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params)
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0, 0);
|
||||
d3d11_params =
|
||||
gst_d3d11_allocation_params_new (self->device, &vinfo, 0, 0);
|
||||
|
||||
/* dxva2 decoder uses non-resource format
|
||||
* (e.g., use NV12 instead of R8 + R8G8 */
|
||||
|
@ -418,8 +419,6 @@ gst_d3d11_h265_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
d3d11_params->desc[0].Height = GST_VIDEO_INFO_HEIGHT (&vinfo);
|
||||
d3d11_params->desc[0].Format = d3d11_params->d3d11_format->dxgi_format;
|
||||
|
||||
d3d11_params->flags &= ~GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT;
|
||||
|
||||
gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);
|
||||
gst_d3d11_allocation_params_free (d3d11_params);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_d3d11_allocator_debug);
|
|||
#define GST_CAT_DEFAULT gst_d3d11_allocator_debug
|
||||
|
||||
GstD3D11AllocationParams *
|
||||
gst_d3d11_allocation_params_new (GstVideoInfo * info,
|
||||
gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info,
|
||||
GstD3D11AllocationFlags flags, gint bind_flags)
|
||||
{
|
||||
GstD3D11AllocationParams *ret;
|
||||
|
@ -39,7 +39,8 @@ gst_d3d11_allocation_params_new (GstVideoInfo * info,
|
|||
|
||||
g_return_val_if_fail (info != NULL, NULL);
|
||||
|
||||
d3d11_format = gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (info));
|
||||
d3d11_format = gst_d3d11_device_format_from_gst (device,
|
||||
GST_VIDEO_INFO_FORMAT (info));
|
||||
if (!d3d11_format) {
|
||||
GST_WARNING ("Couldn't get d3d11 format");
|
||||
return NULL;
|
||||
|
@ -64,11 +65,7 @@ gst_d3d11_allocation_params_new (GstVideoInfo * info,
|
|||
*/
|
||||
|
||||
/* If corresponding dxgi format is undefined, use resource format instead */
|
||||
if (d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN ||
|
||||
(flags & GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT) ==
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT) {
|
||||
flags |= GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT;
|
||||
|
||||
if (d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) {
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
|
||||
g_assert (d3d11_format->resource_format[i] != DXGI_FORMAT_UNKNOWN);
|
||||
|
||||
|
@ -83,8 +80,6 @@ gst_d3d11_allocation_params_new (GstVideoInfo * info,
|
|||
ret->desc[i].BindFlags = bind_flags;
|
||||
}
|
||||
} else {
|
||||
g_assert (d3d11_format->dxgi_format != DXGI_FORMAT_UNKNOWN);
|
||||
|
||||
ret->desc[0].Width = GST_VIDEO_INFO_WIDTH (info);
|
||||
ret->desc[0].Height = GST_VIDEO_INFO_HEIGHT (info);
|
||||
ret->desc[0].MipLevels = 1;
|
||||
|
@ -488,6 +483,7 @@ create_shader_resource_views (GstD3D11Memory * mem)
|
|||
formats[1] = DXGI_FORMAT_R8G8_UNORM;
|
||||
break;
|
||||
case DXGI_FORMAT_P010:
|
||||
case DXGI_FORMAT_P016:
|
||||
num_views = 2;
|
||||
formats[0] = DXGI_FORMAT_R16_UNORM;
|
||||
formats[1] = DXGI_FORMAT_R16G16_UNORM;
|
||||
|
@ -563,6 +559,7 @@ create_render_target_views (GstD3D11Memory * mem)
|
|||
formats[1] = DXGI_FORMAT_R8G8_UNORM;
|
||||
break;
|
||||
case DXGI_FORMAT_P010:
|
||||
case DXGI_FORMAT_P016:
|
||||
num_views = 2;
|
||||
formats[0] = DXGI_FORMAT_R16_UNORM;
|
||||
formats[1] = DXGI_FORMAT_R16G16_UNORM;
|
||||
|
|
|
@ -55,14 +55,11 @@ G_BEGIN_DECLS
|
|||
|
||||
/**
|
||||
* GstD3D11AllocationFlags:
|
||||
* GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT: Allocate texture with resource format
|
||||
* per planes instead of the direct use of DXGI format
|
||||
* GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY: Indicates each allocated texture should be array type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT = (1 << 0),
|
||||
GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY = (1 << 1),
|
||||
GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY = (1 << 0),
|
||||
} GstD3D11AllocationFlags;
|
||||
|
||||
/**
|
||||
|
@ -161,7 +158,8 @@ struct _GstD3D11AllocatorClass
|
|||
|
||||
GType gst_d3d11_allocation_params_get_type (void);
|
||||
|
||||
GstD3D11AllocationParams * gst_d3d11_allocation_params_new (GstVideoInfo * info,
|
||||
GstD3D11AllocationParams * gst_d3d11_allocation_params_new (GstD3D11Device * device,
|
||||
GstVideoInfo * info,
|
||||
GstD3D11AllocationFlags flags,
|
||||
gint bind_flags);
|
||||
|
||||
|
|
|
@ -415,9 +415,8 @@ gst_d3d11_video_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&self->info,
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
|
||||
D3D11_BIND_SHADER_RESOURCE);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device,
|
||||
&self->info, 0, D3D11_BIND_SHADER_RESOURCE);
|
||||
} else {
|
||||
/* Set bind flag */
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&self->info); i++) {
|
||||
|
@ -622,8 +621,7 @@ gst_d3d11_video_sink_propose_allocation (GstBaseSink * sink, GstQuery * query)
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&info,
|
||||
GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info, 0,
|
||||
D3D11_BIND_SHADER_RESOURCE);
|
||||
} else {
|
||||
/* Set bind flag */
|
||||
|
|
|
@ -415,7 +415,8 @@ gst_d3d11_vp9_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
if (self->use_d3d11_output) {
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params)
|
||||
d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0, 0);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device,
|
||||
&vinfo, 0, 0);
|
||||
|
||||
/* dxva2 decoder uses non-resource format
|
||||
* (e.g., use NV12 instead of R8 + R8G8 */
|
||||
|
@ -423,8 +424,6 @@ gst_d3d11_vp9_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
d3d11_params->desc[0].Height = GST_VIDEO_INFO_HEIGHT (&vinfo);
|
||||
d3d11_params->desc[0].Format = d3d11_params->d3d11_format->dxgi_format;
|
||||
|
||||
d3d11_params->flags &= ~GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT;
|
||||
|
||||
gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);
|
||||
gst_d3d11_allocation_params_free (d3d11_params);
|
||||
}
|
||||
|
|
|
@ -607,7 +607,8 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
|
|||
gst_clear_caps (&render_caps);
|
||||
|
||||
window->render_format =
|
||||
gst_d3d11_format_from_gst (GST_VIDEO_INFO_FORMAT (&window->render_info));
|
||||
gst_d3d11_device_format_from_gst (window->device,
|
||||
GST_VIDEO_INFO_FORMAT (&window->render_info));
|
||||
if (!window->render_format ||
|
||||
window->render_format->dxgi_format == DXGI_FORMAT_UNKNOWN) {
|
||||
GST_ERROR_OBJECT (window, "Unknown dxgi render format");
|
||||
|
|
Loading…
Reference in a new issue