From ad6670ba811c33ee7030cb43bbecaae9625e42d4 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 2 Apr 2024 22:09:57 +0900 Subject: [PATCH] d3d12decoder: Always output sharable texture Because shared heap's additional costs is not significant, use D3D12_HEAP_FLAG_SHARED for resource can be shared over process boundary. And enables render target for d3d11 interop in the process. Part-of: --- .../gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp index 4eae1c4428..644e2ca074 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp @@ -722,7 +722,8 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder, D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; session->reference_only = true; } else { - resource_flags = D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS; + resource_flags = D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS | + D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; session->reference_only = false; } @@ -734,9 +735,12 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder, align.padding_right = session->aligned_width - info->width; align.padding_bottom = session->aligned_height - info->height; + D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED; + if (!session->reference_only) + heap_flags |= D3D12_HEAP_FLAG_SHARED; + auto params = gst_d3d12_allocation_params_new (decoder->device, info, - GST_D3D12_ALLOCATION_FLAG_DEFAULT, resource_flags, - D3D12_HEAP_FLAG_CREATE_NOT_ZEROED); + GST_D3D12_ALLOCATION_FLAG_DEFAULT, resource_flags, heap_flags); gst_d3d12_allocation_params_alignment (params, &align); if (!session->array_of_textures) gst_d3d12_allocation_params_set_array_size (params, session->dpb_size); @@ -767,8 +771,9 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder, params = gst_d3d12_allocation_params_new (decoder->device, info, GST_D3D12_ALLOCATION_FLAG_DEFAULT, - D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS, - D3D12_HEAP_FLAG_CREATE_NOT_ZEROED); + D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS | + D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, + D3D12_HEAP_FLAG_CREATE_NOT_ZEROED | D3D12_HEAP_FLAG_SHARED); gst_d3d12_allocation_params_alignment (params, &align); gst_buffer_pool_config_set_d3d12_allocation_params (config, params); gst_d3d12_allocation_params_free (params);