d3d11: Update gst_d3d11_allocation_params_new() interface

Define GST_D3D11_ALLOCATION_FLAG_DEFAULT (0) value instead of
casting enum type everywhere. And pass D3D11_RESOURCE_MISC_FLAG value

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2646>
This commit is contained in:
Seungha Yang 2022-06-24 01:21:48 +09:00 committed by GStreamer Marge Bot
parent c4a9a96a15
commit aca71fd692
16 changed files with 48 additions and 39 deletions

View file

@ -177,7 +177,7 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
/* allocate memory with resource format by default */
priv->d3d11_params =
gst_d3d11_allocation_params_new (self->device,
&info, (GstD3D11AllocationFlags) 0, 0);
&info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, 0);
}
desc = priv->d3d11_params->desc;

View file

@ -46,7 +46,8 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (GstD3D11AllocationParams,
* @device: a #GstD3D11Device
* @info: a #GstVideoInfo
* @flags: a #GstD3D11AllocationFlags
* @bind_flags: D3D11_BIND_FLAG value used for creating Direct3D11 texture
* @bind_flags: D3D11_BIND_FLAG value used for creating texture
* @misc_flags: D3D11_RESOURCE_MISC_FLAG value used for creating texture
*
* Create #GstD3D11AllocationParams object which is used by #GstD3D11BufferPool
* and #GstD3D11Allocator in order to allocate new ID3D11Texture2D
@ -58,7 +59,7 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (GstD3D11AllocationParams,
*/
GstD3D11AllocationParams *
gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info,
GstD3D11AllocationFlags flags, guint bind_flags)
GstD3D11AllocationFlags flags, guint bind_flags, guint misc_flags)
{
GstD3D11AllocationParams *ret;
GstD3D11Format d3d11_format;
@ -105,6 +106,7 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info,
ret->desc[i].SampleDesc.Quality = 0;
ret->desc[i].Usage = D3D11_USAGE_DEFAULT;
ret->desc[i].BindFlags = bind_flags;
ret->desc[i].MiscFlags = misc_flags;
}
} else {
ret->desc[0].Width = GST_VIDEO_INFO_WIDTH (info);
@ -116,6 +118,7 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info,
ret->desc[0].SampleDesc.Quality = 0;
ret->desc[0].Usage = D3D11_USAGE_DEFAULT;
ret->desc[0].BindFlags = bind_flags;
ret->desc[0].MiscFlags = misc_flags;
}
ret->flags = flags;

View file

@ -78,6 +78,7 @@ G_BEGIN_DECLS
/**
* GstD3D11AllocationFlags:
* @GST_D3D11_ALLOCATION_FLAG_DEFAULT: Default allocation behavior
* @GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY: Indicates each allocated texture
* should be array type. This type of
* is used for D3D11/DXVA decoders
@ -87,6 +88,7 @@ G_BEGIN_DECLS
*/
typedef enum
{
GST_D3D11_ALLOCATION_FLAG_DEFAULT = 0,
GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY = (1 << 0),
} GstD3D11AllocationFlags;
@ -142,7 +144,8 @@ GST_D3D11_API
GstD3D11AllocationParams * gst_d3d11_allocation_params_new (GstD3D11Device * device,
GstVideoInfo * info,
GstD3D11AllocationFlags flags,
guint bind_flags);
guint bind_flags,
guint misc_flags);
GST_D3D11_API
GstD3D11AllocationParams * gst_d3d11_allocation_params_copy (GstD3D11AllocationParams * src);

View file

@ -464,7 +464,7 @@ gst_amf_encoder_prepare_internal_pool (GstAmfEncoder * self)
GST_VIDEO_INFO_SIZE (info), 0, 0);
params = gst_d3d11_allocation_params_new (priv->device, info,
(GstD3D11AllocationFlags) 0, 0);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, 0);
params->desc[0].MiscFlags = D3D11_RESOURCE_MISC_SHARED;
gst_buffer_pool_config_set_d3d11_allocation_params (config, params);

View file

@ -726,7 +726,7 @@ gst_d3d11_compositor_pad_ensure_fallback_buffer (GstD3D11Compositor * self,
}
d3d11_params = gst_d3d11_allocation_params_new (self->device,
info, (GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0);
pool = gst_d3d11_buffer_pool_new_with_options (self->device,
caps, d3d11_params, 0, 0);
@ -1743,8 +1743,8 @@ gst_d3d11_compositor_negotiated_src_caps (GstAggregator * agg, GstCaps * caps)
GstFlowReturn flow_ret;
d3d11_params = gst_d3d11_allocation_params_new (self->device,
&info, (GstD3D11AllocationFlags) 0,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
&info, GST_D3D11_ALLOCATION_FLAG_DEFAULT,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, 0);
pool = gst_d3d11_buffer_pool_new_with_options (self->device,
caps, d3d11_params, 0, 0);
@ -1825,7 +1825,8 @@ gst_d3d11_compositor_propose_allocation (GstAggregator * agg,
d3d11_params =
gst_d3d11_allocation_params_new (self->device,
&info, (GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
&info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_SHADER_RESOURCE,
0);
gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);
gst_d3d11_allocation_params_free (d3d11_params);
@ -1925,7 +1926,8 @@ gst_d3d11_compositor_decide_allocation (GstAggregator * agg, GstQuery * query)
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params) {
d3d11_params = gst_d3d11_allocation_params_new (self->device,
&info, (GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
&info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_RENDER_TARGET,
0);
} else {
guint i;

View file

@ -1236,7 +1236,7 @@ gst_d3d11_base_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 (filter->device, &info,
(GstD3D11AllocationFlags) 0, bind_flags);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, 0);
} else {
/* Set bind flag */
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++) {
@ -1354,7 +1354,7 @@ gst_d3d11_base_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 (filter->device, &info,
(GstD3D11AllocationFlags) 0, bind_flags);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, 0);
} else {
/* Set bind flag */
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++) {

View file

@ -444,7 +444,7 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self)
GstBufferPool *pool = NULL;
GstCaps *caps = NULL;
GstVideoAlignment align;
GstD3D11AllocationFlags alloc_flags = (GstD3D11AllocationFlags) 0;
GstD3D11AllocationFlags alloc_flags = GST_D3D11_ALLOCATION_FLAG_DEFAULT;
gint bind_flags = D3D11_BIND_DECODER;
GstVideoInfo *info = &self->info;
guint pool_size;
@ -464,7 +464,7 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self)
}
alloc_params = gst_d3d11_allocation_params_new (self->device, info,
alloc_flags, bind_flags);
alloc_flags, bind_flags, 0);
if (!alloc_params) {
GST_ERROR_OBJECT (self, "Failed to create allocation param");
@ -1792,7 +1792,7 @@ gst_d3d11_decoder_decide_allocation (GstD3D11Decoder * decoder,
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params)
d3d11_params = gst_d3d11_allocation_params_new (decoder->device, &vinfo,
(GstD3D11AllocationFlags) 0, 0);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, 0);
width = GST_VIDEO_INFO_WIDTH (&vinfo);
height = GST_VIDEO_INFO_HEIGHT (&vinfo);

View file

@ -891,7 +891,7 @@ gst_d3d11_deinterlace_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 (self->device, &info,
(GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_RENDER_TARGET, 0);
} else {
d3d11_params->desc[0].BindFlags |= D3D11_BIND_RENDER_TARGET;
}
@ -996,7 +996,7 @@ gst_d3d11_deinterlace_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 (self->device, &info,
(GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_RENDER_TARGET, 0);
} else {
d3d11_params->desc[0].BindFlags |= D3D11_BIND_RENDER_TARGET;
}
@ -1052,7 +1052,7 @@ gst_d3d11_deinterlace_prepare_fallback_pool (GstD3D11Deinterlace * self,
/* Empty bind flag is allowed for video processor input */
d3d11_params = gst_d3d11_allocation_params_new (self->device, in_info,
(GstD3D11AllocationFlags) 0, 0);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, 0);
self->fallback_in_pool = gst_d3d11_buffer_pool_new_with_options (self->device,
in_caps, d3d11_params, 0, 0);
gst_d3d11_allocation_params_free (d3d11_params);
@ -1064,7 +1064,7 @@ gst_d3d11_deinterlace_prepare_fallback_pool (GstD3D11Deinterlace * self,
/* For processor output, render target bind flag is required */
d3d11_params = gst_d3d11_allocation_params_new (self->device, out_info,
(GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_RENDER_TARGET, 0);
self->fallback_out_pool =
gst_d3d11_buffer_pool_new_with_options (self->device,
out_caps, d3d11_params, 0, 0);

View file

@ -527,8 +527,8 @@ gst_d3d11_screen_capture_src_decide_allocation (GstBaseSrc * bsrc,
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params) {
d3d11_params = gst_d3d11_allocation_params_new (self->device, &vinfo,
(GstD3D11AllocationFlags) 0,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, 0);
} else {
d3d11_params->desc[0].BindFlags |= D3D11_BIND_RENDER_TARGET;
}
@ -560,7 +560,7 @@ gst_d3d11_screen_capture_src_decide_allocation (GstBaseSrc * bsrc,
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params) {
d3d11_params = gst_d3d11_allocation_params_new (self->device, &vinfo,
(GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_RENDER_TARGET, 0);
} else {
d3d11_params->desc[0].BindFlags |= D3D11_BIND_RENDER_TARGET;
}

View file

@ -1306,8 +1306,8 @@ gst_d3d11_test_src_setup_resource (GstD3D11TestSrc * self, GstCaps * caps)
draw_caps = gst_video_info_to_caps (&draw_info);
params = gst_d3d11_allocation_params_new (self->device, &draw_info,
(GstD3D11AllocationFlags) 0,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, 0);
self->render_pool = gst_d3d11_buffer_pool_new_with_options (self->device,
draw_caps, params, 0, 0);
@ -1321,7 +1321,7 @@ gst_d3d11_test_src_setup_resource (GstD3D11TestSrc * self, GstCaps * caps)
}
params = gst_d3d11_allocation_params_new (self->device, &self->info,
(GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_RENDER_TARGET, 0);
self->convert_pool = gst_d3d11_buffer_pool_new_with_options (self->device,
caps, params, 0, 0);
gst_d3d11_allocation_params_free (params);
@ -1479,8 +1479,8 @@ gst_d3d11_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params) {
d3d11_params = gst_d3d11_allocation_params_new (self->device, &vinfo,
(GstD3D11AllocationFlags) 0,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
GST_D3D11_ALLOCATION_FLAG_DEFAULT,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, 0);
} else {
d3d11_params->desc[0].BindFlags |= D3D11_BIND_RENDER_TARGET;
}

View file

@ -378,7 +378,7 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query)
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params) {
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &vinfo,
(GstD3D11AllocationFlags) 0, bind_flags);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, 0);
} else {
/* Set bind flag */
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&vinfo); i++) {

View file

@ -635,7 +635,7 @@ gst_d3d11_video_sink_update_window (GstD3D11VideoSink * self, GstCaps * caps)
}
d3d11_params = gst_d3d11_allocation_params_new (self->device,
&self->info, (GstD3D11AllocationFlags) 0, bind_flags);
&self->info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, 0);
self->fallback_pool = gst_d3d11_buffer_pool_new_with_options (self->device,
caps, d3d11_params, 2, 0);
@ -908,7 +908,8 @@ gst_d3d11_video_sink_propose_allocation (GstBaseSink * sink, GstQuery * query)
d3d11_params =
gst_d3d11_allocation_params_new (self->device,
&info, (GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
&info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, D3D11_BIND_SHADER_RESOURCE,
0);
gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);
gst_d3d11_allocation_params_free (d3d11_params);

View file

@ -1000,8 +1000,7 @@ gst_nv_encoder_create_d3d11_pool (GstNvEncoder * self,
GstD3D11AllocationParams *params;
params = gst_d3d11_allocation_params_new (priv->device, &state->info,
(GstD3D11AllocationFlags) 0, 0);
params->desc[0].MiscFlags = D3D11_RESOURCE_MISC_SHARED;
GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, D3D11_RESOURCE_MISC_SHARED);
pool = gst_d3d11_buffer_pool_new (priv->device);

View file

@ -222,7 +222,7 @@ gst_qsv_d3d11_allocator_alloc (GstQsvAllocator * allocator,
pool = gst_d3d11_buffer_pool_new (self->device);
params = gst_d3d11_allocation_params_new (self->device, &info,
(GstD3D11AllocationFlags) 0, bind_flags);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, 0);
gst_d3d11_allocation_params_alignment (params, &align);

View file

@ -880,8 +880,8 @@ gst_qsv_decoder_prepare_d3d11_pool (GstQsvDecoder * self,
/* Bind to shader resource as well for this texture can be used
* in generic pixel shader */
params = gst_d3d11_allocation_params_new (device, info,
(GstD3D11AllocationFlags) 0,
D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE);
GST_D3D11_ALLOCATION_FLAG_DEFAULT,
D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE, 0);
gst_d3d11_allocation_params_alignment (params, align);
gst_buffer_pool_config_set_d3d11_allocation_params (config, params);
gst_d3d11_allocation_params_free (params);
@ -1232,9 +1232,10 @@ gst_qsv_decoder_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
* copying in case of reverse playback */
if (use_d3d11_pool) {
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!d3d11_params)
if (!d3d11_params) {
d3d11_params = gst_d3d11_allocation_params_new (device, &vinfo,
(GstD3D11AllocationFlags) 0, 0);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, 0);
}
/* Use both render target (for videoprocessor) and shader resource
* for (pixel shader) bind flags for downstream to be able to use consistent
* conversion path even when we copy textures */

View file

@ -915,7 +915,7 @@ gst_qsv_encoder_prepare_d3d11_pool (GstQsvEncoder * self,
priv->internal_pool = gst_d3d11_buffer_pool_new (device);
config = gst_buffer_pool_get_config (priv->internal_pool);
params = gst_d3d11_allocation_params_new (device, aligned_info,
(GstD3D11AllocationFlags) 0, bind_flags);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, 0);
gst_buffer_pool_config_set_d3d11_allocation_params (config, params);
gst_d3d11_allocation_params_free (params);
@ -1487,7 +1487,7 @@ gst_qsv_encoder_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
GST_VIDEO_INFO_HEIGHT (&info);
d3d11_params = gst_d3d11_allocation_params_new (device, &info,
(GstD3D11AllocationFlags) 0, 0);
GST_D3D11_ALLOCATION_FLAG_DEFAULT, 0, 0);
gst_d3d11_allocation_params_alignment (d3d11_params, &align);
gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);