From b9ebe979ee026e279ab51af89d1ad18c689dce44 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 2 Apr 2024 22:56:00 +0900 Subject: [PATCH] qsvencoder: Handle d3d12 context GstD3D12Device objetct's internal resources are singletons per adapter already though, the object itself is not a singleton. Due to the singleton design (unlike other APIs such as d3d11), d3d12 device context sharing is not a strict requirement for zero-copy, but handles context ones to make things less noisy. Part-of: --- .../gst-plugins-bad/sys/qsv/gstqsvencoder.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvencoder.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvencoder.cpp index 0020911e28..e659878be7 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvencoder.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvencoder.cpp @@ -362,6 +362,10 @@ gst_qsv_encoder_set_context (GstElement * element, GstContext * context) #ifdef G_OS_WIN32 gst_d3d11_handle_set_context_for_adapter_luid (element, context, klass->adapter_luid, (GstD3D11Device **) & priv->device); +#ifdef HAVE_GST_D3D12 + gst_d3d12_handle_set_context_for_adapter_luid (element, + context, klass->adapter_luid, (GstD3D12Device **) & priv->device12); +#endif #else gst_va_handle_set_context (element, context, klass->display_path, (GstVaDisplay **) & priv->device); @@ -1429,13 +1433,20 @@ gst_qsv_encoder_flush (GstVideoEncoder * encoder) static gboolean gst_qsv_encoder_handle_context_query (GstQsvEncoder * self, GstQuery * query) { - GstQsvEncoderPrivate *priv = self->priv; + auto priv = self->priv; + auto elem = GST_ELEMENT_CAST (self); #ifdef G_OS_WIN32 - return gst_d3d11_handle_context_query (GST_ELEMENT (self), query, +#ifdef HAVE_GST_D3D12 + if (gst_d3d12_handle_context_query (elem, query, + (GstD3D12Device *) priv->device12)) { + return TRUE; + } +#endif + return gst_d3d11_handle_context_query (elem, query, (GstD3D11Device *) priv->device); #else - return gst_va_handle_context_query (GST_ELEMENT (self), query, + return gst_va_handle_context_query (elem, query, (GstVaDisplay *) priv->device); #endif }