From 484d510558092859554d8f841ff10b5866d8553a Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 24 Oct 2020 02:33:29 +0900 Subject: [PATCH] d3d11memory: Store ID3D11VideoProcessorOutputView object Part-of: --- sys/d3d11/gstd3d11memory.c | 49 ++++++++++++++++++++++++++++++++++++++ sys/d3d11/gstd3d11memory.h | 6 ++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/sys/d3d11/gstd3d11memory.c b/sys/d3d11/gstd3d11memory.c index 49072d2902..fb2b7352ea 100644 --- a/sys/d3d11/gstd3d11memory.c +++ b/sys/d3d11/gstd3d11memory.c @@ -465,6 +465,9 @@ gst_d3d11_allocator_free (GstAllocator * allocator, GstMemory * mem) if (dmem->processor_input_view) ID3D11VideoProcessorInputView_Release (dmem->processor_input_view); + if (dmem->processor_output_view) + ID3D11VideoProcessorOutputView_Release (dmem->processor_output_view); + if (dmem->texture) ID3D11Texture2D_Release (dmem->texture); @@ -1171,3 +1174,49 @@ gst_d3d11_memory_ensure_processor_input_view (GstD3D11Memory * mem, return TRUE; } + +gboolean +gst_d3d11_memory_ensure_processor_output_view (GstD3D11Memory * mem, + ID3D11VideoDevice * video_device, + ID3D11VideoProcessorEnumerator * enumerator) +{ + GstD3D11Allocator *allocator; + D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC desc = { 0, }; + HRESULT hr; + + g_return_val_if_fail (gst_is_d3d11_memory (GST_MEMORY_CAST (mem)), FALSE); + g_return_val_if_fail (video_device != NULL, FALSE); + g_return_val_if_fail (enumerator != NULL, FALSE); + + allocator = GST_D3D11_ALLOCATOR (GST_MEMORY_CAST (mem)->allocator); + + if (mem->processor_output_view) + return TRUE; + + if (!(mem->desc.BindFlags & D3D11_BIND_RENDER_TARGET)) { + GST_WARNING_OBJECT (allocator, + "Need BindFlags, current flag 0x%x", mem->desc.BindFlags); + return FALSE; + } + + /* FIXME: texture array should be supported at some point */ + if (mem->subresource_index != 0) { + GST_FIXME_OBJECT (allocator, + "Texture array is not suppoted for processor output view"); + return FALSE; + } + + desc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D; + desc.Texture2D.MipSlice = 0; + + hr = ID3D11VideoDevice_CreateVideoProcessorOutputView (video_device, + (ID3D11Resource *) mem->texture, enumerator, &desc, + &mem->processor_output_view); + if (!gst_d3d11_result (hr, mem->device)) { + GST_ERROR_OBJECT (allocator, + "Could not create processor input view, hr: 0x%x", (guint) hr); + return FALSE; + } + + return TRUE; +} diff --git a/sys/d3d11/gstd3d11memory.h b/sys/d3d11/gstd3d11memory.h index 923ad9c433..46d8ffad12 100644 --- a/sys/d3d11/gstd3d11memory.h +++ b/sys/d3d11/gstd3d11memory.h @@ -114,8 +114,8 @@ struct _GstD3D11Memory guint num_render_target_views; ID3D11VideoDecoderOutputView *decoder_output_view; - ID3D11VideoProcessorInputView *processor_input_view; + ID3D11VideoProcessorOutputView *processor_output_view; GstD3D11MemoryType type; @@ -195,6 +195,10 @@ gboolean gst_d3d11_memory_ensure_processor_input_view (GstD3D11Memory ID3D11VideoDevice * video_device, ID3D11VideoProcessorEnumerator * enumerator); +gboolean gst_d3d11_memory_ensure_processor_output_view (GstD3D11Memory * mem, + ID3D11VideoDevice * video_device, + ID3D11VideoProcessorEnumerator * enumerator); + G_END_DECLS #endif /* __GST_D3D11_MEMORY_H__ */