d3d12decoder: Use D3D12_HEAP_FLAG_CREATE_NOT_ZEROED flag

Since the first access to a texture is always write, zero initialization
is unnecessary

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5919>
This commit is contained in:
Seungha Yang 2024-01-14 19:32:43 +09:00 committed by GStreamer Marge Bot
parent b1ac114ca5
commit 077470913d
5 changed files with 22 additions and 2 deletions

View file

@ -190,7 +190,7 @@ gst_d3d12_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
auto alloc = (GstD3D12Allocator *)
gst_d3d12_pool_allocator_new (self->device,
&heap_props, D3D12_HEAP_FLAG_NONE, &desc[0],
&heap_props, params->heap_flags, &desc[0],
D3D12_RESOURCE_STATE_COMMON, nullptr);
auto num_planes = D3D12GetFormatPlaneCount (device,
params->d3d12_format.dxgi_format);
@ -218,7 +218,7 @@ gst_d3d12_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
auto alloc = (GstD3D12Allocator *)
gst_d3d12_pool_allocator_new (self->device,
&heap_props, D3D12_HEAP_FLAG_NONE, &desc[i],
&heap_props, params->heap_flags, &desc[i],
D3D12_RESOURCE_STATE_COMMON, nullptr);
UINT64 mem_size;

View file

@ -717,6 +717,8 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder,
auto params = gst_d3d12_allocation_params_new (decoder->device, info,
GST_D3D12_ALLOCATION_FLAG_DEFAULT, resource_flags);
gst_d3d12_allocation_params_alignment (params, &align);
gst_d3d12_allocation_params_set_heap_flags (params,
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED);
if (!session->array_of_textures)
gst_d3d12_allocation_params_set_array_size (params, session->dpb_size);
@ -748,6 +750,8 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder,
GST_D3D12_ALLOCATION_FLAG_DEFAULT,
D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS);
gst_d3d12_allocation_params_alignment (params, &align);
gst_d3d12_allocation_params_set_heap_flags (params,
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED);
gst_buffer_pool_config_set_d3d12_allocation_params (config, params);
gst_d3d12_allocation_params_free (params);
gst_buffer_pool_config_set_params (config, caps, info->size, 0, 0);

View file

@ -33,6 +33,7 @@ struct _GstD3D12AllocationParams
GstVideoInfo aligned_info;
GstD3D12Format d3d12_format;
GstD3D12AllocationFlags flags;
D3D12_HEAP_FLAGS heap_flags;
D3D12_RESOURCE_FLAGS resource_flags;
guint array_size;
};

View file

@ -97,6 +97,7 @@ gst_d3d12_allocation_params_new (GstD3D12Device * device,
ret->d3d12_format = d3d12_format;
ret->array_size = 1;
ret->flags = flags;
ret->heap_flags = D3D12_HEAP_FLAG_NONE;
ret->resource_flags = resource_flags;
return ret;
@ -172,6 +173,17 @@ gst_d3d12_allocation_params_unset_resource_flags (GstD3D12AllocationParams *
return TRUE;
}
gboolean
gst_d3d12_allocation_params_set_heap_flags (GstD3D12AllocationParams *
params, D3D12_HEAP_FLAGS heap_flags)
{
g_return_val_if_fail (params, FALSE);
params->heap_flags |= heap_flags;
return TRUE;
}
gboolean
gst_d3d12_allocation_params_set_array_size (GstD3D12AllocationParams * params,
guint size)

View file

@ -104,6 +104,9 @@ gboolean gst_d3d12_allocation_params_set_resource_flags (GstD3
gboolean gst_d3d12_allocation_params_unset_resource_flags (GstD3D12AllocationParams * params,
D3D12_RESOURCE_FLAGS resource_flags);
gboolean gst_d3d12_allocation_params_set_heap_flags (GstD3D12AllocationParams * params,
D3D12_HEAP_FLAGS heap_flags);
gboolean gst_d3d12_allocation_params_set_array_size (GstD3D12AllocationParams * params,
guint size);