d3d11: Update build-time dependency
authorSeungha Yang <seungha@centricular.com>
Thu, 10 Feb 2022 13:31:06 +0000 (22:31 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 11 Feb 2022 20:01:52 +0000 (20:01 +0000)
Remove all the d3d11 and dxgi header version dependent ifdef
and bump the minimum requirement to d3d11_4.h and dxgi1_6.h.
We are already failing support old Visual Studio (Windows SDK actually)
such as Visual Studio 2015. Note that our MinGW toolchain satisfies
the requirement.

From runtime point of view, this change should be fine since
we are checking OS version with IUnknown::QueryInterface()
everywhere in order to check API availability

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1684>

20 files changed:
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11_fwd.h
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11_private.h
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11bufferpool.cpp
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11config.h.meson
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.cpp
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11stagingbufferpool.cpp
subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.h
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11screencapturedevice.h
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videoprocessor.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videoprocessor.h
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_dummy.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp
subprojects/gst-plugins-bad/sys/d3d11/meson.build
subprojects/gst-plugins-bad/sys/d3d11/plugin.cpp
subprojects/gst-plugins-bad/sys/mediafoundation/plugin.cpp

index 4606688..cec4829 100644 (file)
 #include <initguid.h>
 #endif
 
-#if (GST_D3D11_HEADER_VERSION >= 4)
-#include <d3d11_4.h>
-#elif (GST_D3D11_HEADER_VERSION >= 3)
-#include <d3d11_3.h>
-#elif (GST_D3D11_HEADER_VERSION >= 2)
-#include <d3d11_2.h>
-#elif (GST_D3D11_HEADER_VERSION >= 1)
-#include <d3d11_1.h>
-#else
 #include <d3d11.h>
-#endif
-
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 6)
-#include <dxgi1_6.h>
-#elif (GST_D3D11_DXGI_HEADER_VERSION >= 5)
-#include <dxgi1_5.h>
-#elif (GST_D3D11_DXGI_HEADER_VERSION >= 4)
-#include <dxgi1_4.h>
-#elif (GST_D3D11_DXGI_HEADER_VERSION >= 3)
-#include <dxgi1_3.h>
-#elif (GST_D3D11_DXGI_HEADER_VERSION >= 2)
-#include <dxgi1_2.h>
-#else
 #include <dxgi.h>
-#endif
 
 G_BEGIN_DECLS
 
index cb0392b..0634f19 100644 (file)
@@ -23,6 +23,8 @@
 #include <gst/gst.h>
 #include <gst/video/video.h>
 #include <gst/d3d11/gstd3d11_fwd.h>
+#include <d3d11_4.h>
+#include <dxgi1_6.h>
 
 G_BEGIN_DECLS
 
index eb72f2f..7428f8b 100644 (file)
@@ -26,6 +26,7 @@
 #include "gstd3d11memory.h"
 #include "gstd3d11device.h"
 #include "gstd3d11utils.h"
+#include "gstd3d11_private.h"
 
 #include <string.h>
 
index ababe80..dff9166 100644 (file)
@@ -7,8 +7,6 @@
 
 G_BEGIN_DECLS
 
-#mesondefine GST_D3D11_DXGI_HEADER_VERSION
-#mesondefine GST_D3D11_HEADER_VERSION
 #mesondefine GST_D3D11_WINAPI_ONLY_APP
 #mesondefine GST_D3D11_WINAPI_APP
 
index d3b65bd..24e26a0 100644 (file)
@@ -277,7 +277,7 @@ gst_d3d11_device_enable_dxgi_debug (void)
           "DXGIGetDebugInterface", (gpointer *) & GstDXGIGetDebugInterface);
     if (GstDXGIGetDebugInterface)
       ret = TRUE;
-#elif (GST_D3D11_DXGI_HEADER_VERSION >= 3)
+#else
     ret = TRUE;
 #endif
     g_once_init_leave (&_init, 1);
@@ -292,12 +292,12 @@ gst_d3d11_device_dxgi_get_device_interface (REFIID riid, void **debug)
 #if (!GST_D3D11_WINAPI_ONLY_APP)
   if (GstDXGIGetDebugInterface) {
     return GstDXGIGetDebugInterface (riid, debug);
+  } else {
+    return E_NOINTERFACE;
   }
-#elif (GST_D3D11_DXGI_HEADER_VERSION >= 3)
+#else
   return DXGIGetDebugInterface1 (0, riid, debug);
 #endif
-
-  return E_NOINTERFACE;
 }
 
 static inline GstDebugLevel
index ab70c1a..ae2a19d 100644 (file)
@@ -25,6 +25,7 @@
 #include "gstd3d11utils.h"
 #include "gstd3d11device.h"
 #include "gstd3d11memory.h"
+#include "gstd3d11_private.h"
 
 #include <string.h>
 
index 1e75af1..19ae103 100644 (file)
@@ -7,23 +7,6 @@ d3d11_sources = [
   'gstd3d11utils.cpp',
 ]
 
-dxgi_headers = [
-  ['dxgi1_6.h', 6],
-  ['dxgi1_5.h', 5],
-  ['dxgi1_4.h', 4],
-  ['dxgi1_3.h', 3],
-  ['dxgi1_2.h', 2],
-  ['dxgi.h', 1]
-]
-
-d3d11_headers = [
-  ['d3d11_4.h', 4],
-  ['d3d11_3.h', 3],
-  ['d3d11_2.h', 2],
-  ['d3d11_1.h', 1],
-  ['d3d11.h', 0]
-]
-
 gstd3d11_dep = dependency('', required : false)
 
 d3d11_option = get_option('d3d11')
@@ -41,43 +24,17 @@ extra_comm_args = [
   '-DG_LOG_DOMAIN="GStreamer-D3D11"',
 ]
 
-have_dxgi_header = false
-have_d3d11_header = false
 have_d3d11sdk_h = false
 have_dxgidebug_h = false
-winapi_desktop = false
-winapi_app = false
+d3d11_winapi_app = false
 d3d11_conf = configuration_data()
-d3d11_conf_options = [
-  'GST_D3D11_DXGI_HEADER_VERSION',
-  'GST_D3D11_HEADER_VERSION',
-  'GST_D3D11_WINAPI_ONLY_APP',
-]
-
-foreach option : d3d11_conf_options
-  d3d11_conf.set10(option, false)
-endforeach
 
 d3d11_lib = cc.find_library('d3d11', required : d3d11_option)
 dxgi_lib = cc.find_library('dxgi', required : d3d11_option)
 d3dcompiler_lib = cc.find_library('d3dcompiler', required: d3d11_option)
 runtimeobject_lib = cc.find_library('runtimeobject', required : false)
 
-foreach dxgi_h: dxgi_headers
-  if not have_dxgi_header and cc.has_header(dxgi_h[0])
-    d3d11_conf.set('GST_D3D11_DXGI_HEADER_VERSION', dxgi_h[1])
-    have_dxgi_header = true
-  endif
-endforeach
-
-foreach d3d11_h: d3d11_headers
-  if not have_d3d11_header and cc.has_header(d3d11_h[0])
-    d3d11_conf.set('GST_D3D11_HEADER_VERSION', d3d11_h[1])
-    have_d3d11_header = true
-  endif
-endforeach
-
-have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and have_d3d11_header and have_dxgi_header
+have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and cc.has_header('d3d11_4.h') and cc.has_header('dxgi1_6.h')
 if not have_d3d11
   if d3d11_option.enabled()
     error('The d3d11 was enabled explicitly, but required dependencies were not found.')
@@ -97,8 +54,8 @@ if runtimeobject_lib.found() and d3dcompiler_lib.found()
       #include <windows.applicationmodel.core.h>
       #include <wrl.h>
       #include <wrl/wrappers/corewrappers.h>
-      #include <d3d11.h>
-      #include <dxgi1_2.h>
+      #include <d3d11_4.h>
+      #include <dxgi1_6.h>
       #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
       #error "not winrt"
       #endif
index 3ae4cd3..8dfe7da 100644 (file)
@@ -1810,7 +1810,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
     GST_ERROR_OBJECT (self, "couldn't set converter");
     return FALSE;
   }
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
+
   /* If both input and output formats are native DXGI format */
   if (self->in_d3d11_format->dxgi_format != DXGI_FORMAT_UNKNOWN &&
       self->out_d3d11_format->dxgi_format != DXGI_FORMAT_UNKNOWN) {
@@ -1863,7 +1863,6 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
     self->processor = processor;
     gst_d3d11_device_unlock (filter->device);
   }
-#endif
 
   GST_DEBUG_OBJECT (self, "from=%dx%d (par=%d/%d dar=%d/%d), size %"
       G_GSIZE_FORMAT " -> to=%dx%d (par=%d/%d dar=%d/%d borders=%d:%d), "
index 7a253d4..08c04e5 100644 (file)
@@ -133,7 +133,6 @@ gst_d3d11_get_device_vendor (GstD3D11Device * device)
   return vendor;
 }
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
 gboolean
 gst_d3d11_hdr_meta_data_to_dxgi (GstVideoMasteringDisplayInfo * minfo,
     GstVideoContentLightLevel * cll, DXGI_HDR_METADATA_HDR10 * dxgi_hdr10)
@@ -163,9 +162,7 @@ gst_d3d11_hdr_meta_data_to_dxgi (GstVideoMasteringDisplayInfo * minfo,
 
   return TRUE;
 }
-#endif
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
 typedef enum
 {
   GST_DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 = 0,
@@ -573,7 +570,6 @@ gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
 
   return colorspace;
 }
-#endif
 
 static void
 fill_staging_desc (const D3D11_TEXTURE2D_DESC * ref,
index b92eaca..0e3c4d3 100644 (file)
@@ -24,6 +24,8 @@
 #include <gst/gst.h>
 #include <gst/video/video.h>
 #include <gst/d3d11/gstd3d11.h>
+#include <d3d11_4.h>
+#include <dxgi1_6.h>
 
 G_BEGIN_DECLS
 
@@ -63,18 +65,14 @@ gboolean        gst_d3d11_is_windows_8_or_greater   (void);
 
 GstD3D11DeviceVendor gst_d3d11_get_device_vendor    (GstD3D11Device * device);
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
 gboolean        gst_d3d11_hdr_meta_data_to_dxgi     (GstVideoMasteringDisplayInfo * minfo,
                                                      GstVideoContentLightLevel * cll,
                                                      DXGI_HDR_METADATA_HDR10 * dxgi_hdr10);
-#endif
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
 const GstDxgiColorSpace * gst_d3d11_video_info_to_dxgi_color_space (GstVideoInfo * info);
 
 const GstDxgiColorSpace * gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
                                                                  IDXGISwapChain3 * swapchain);
-#endif
 
 GstBuffer *     gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer,
                                                        const GstVideoInfo * info,
index a907fab..2b6df26 100644 (file)
 #endif
 
 #include "gstd3d11videoprocessor.h"
-#include "gstd3d11pluginutils.h"
 
 #include <string.h>
 
 GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_video_processor_debug);
 #define GST_CAT_DEFAULT gst_d3d11_video_processor_debug
 
-#if (GST_D3D11_HEADER_VERSION >= 1 && GST_D3D11_DXGI_HEADER_VERSION >= 4)
-#define HAVE_VIDEO_CONTEXT_ONE
-#endif
-
-#if (GST_D3D11_HEADER_VERSION >= 4) && (GST_D3D11_DXGI_HEADER_VERSION >= 5)
-#define HAVE_VIDEO_CONTEXT_TWO
-#endif
-
 struct _GstD3D11VideoProcessor
 {
   GstD3D11Device *device;
 
   ID3D11VideoDevice *video_device;
   ID3D11VideoContext *video_context;
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   ID3D11VideoContext1 *video_context1;
-#endif
-#ifdef HAVE_VIDEO_CONTEXT_TWO
   ID3D11VideoContext2 *video_context2;
-#endif
   ID3D11VideoProcessor *processor;
   ID3D11VideoProcessorEnumerator *enumerator;
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   ID3D11VideoProcessorEnumerator1 *enumerator1;
-#endif
   D3D11_VIDEO_PROCESSOR_CAPS processor_caps;
 };
 
@@ -105,12 +90,11 @@ gst_d3d11_video_processor_new (GstD3D11Device * device, guint in_width,
       &self->enumerator);
   if (!gst_d3d11_result (hr, device))
     goto fail;
-#ifdef HAVE_VIDEO_CONTEXT_ONE
+
   hr = self->enumerator->QueryInterface (IID_PPV_ARGS (&self->enumerator1));
   if (gst_d3d11_result (hr, device)) {
     GST_DEBUG ("ID3D11VideoProcessorEnumerator1 interface available");
   }
-#endif
 
   hr = self->enumerator->GetVideoProcessorCaps (&self->processor_caps);
   if (!gst_d3d11_result (hr, device))
@@ -121,20 +105,17 @@ gst_d3d11_video_processor_new (GstD3D11Device * device, guint in_width,
   if (!gst_d3d11_result (hr, device))
     goto fail;
 
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   hr = self->video_context->
       QueryInterface (IID_PPV_ARGS (&self->video_context1));
   if (gst_d3d11_result (hr, device)) {
     GST_DEBUG ("ID3D11VideoContext1 interface available");
   }
-#endif
-#ifdef HAVE_VIDEO_CONTEXT_TWO
+
   hr = self->video_context->
       QueryInterface (IID_PPV_ARGS (&self->video_context2));
   if (gst_d3d11_result (hr, device)) {
     GST_DEBUG ("ID3D11VideoContext2 interface available");
   }
-#endif
 
   /* Setting up default options */
   gst_d3d11_device_lock (self->device);
@@ -158,17 +139,11 @@ gst_d3d11_video_processor_free (GstD3D11VideoProcessor * processor)
 
   GST_D3D11_CLEAR_COM (processor->video_device);
   GST_D3D11_CLEAR_COM (processor->video_context);
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   GST_D3D11_CLEAR_COM (processor->video_context1);
-#endif
-#ifdef HAVE_VIDEO_CONTEXT_TWO
   GST_D3D11_CLEAR_COM (processor->video_context2);
-#endif
   GST_D3D11_CLEAR_COM (processor->processor);
   GST_D3D11_CLEAR_COM (processor->enumerator);
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   GST_D3D11_CLEAR_COM (processor->enumerator1);
-#endif
 
   gst_clear_object (&processor->device);
   g_free (processor);
@@ -302,13 +277,11 @@ gst_d3d11_video_processor_set_output_color_space (GstD3D11VideoProcessor *
   return TRUE;
 }
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
 gboolean
 gst_d3d11_video_processor_check_format_conversion (GstD3D11VideoProcessor *
     processor, DXGI_FORMAT in_format, DXGI_COLOR_SPACE_TYPE in_color_space,
     DXGI_FORMAT out_format, DXGI_COLOR_SPACE_TYPE out_color_space)
 {
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   HRESULT hr;
   BOOL supported = TRUE;
 
@@ -325,9 +298,6 @@ gst_d3d11_video_processor_check_format_conversion (GstD3D11VideoProcessor *
   }
 
   return supported;
-#endif
-
-  return FALSE;
 }
 
 gboolean
@@ -336,13 +306,11 @@ gst_d3d11_video_processor_set_input_dxgi_color_space (GstD3D11VideoProcessor *
 {
   g_return_val_if_fail (processor != NULL, FALSE);
 
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   if (processor->video_context1) {
     processor->video_context1->VideoProcessorSetStreamColorSpace1
         (processor->processor, 0, color_space);
     return TRUE;
   }
-#endif
 
   return FALSE;
 }
@@ -353,19 +321,15 @@ gst_d3d11_video_processor_set_output_dxgi_color_space (GstD3D11VideoProcessor *
 {
   g_return_val_if_fail (processor != NULL, FALSE);
 
-#ifdef HAVE_VIDEO_CONTEXT_ONE
   if (processor->video_context1) {
     processor->video_context1->VideoProcessorSetOutputColorSpace1
         (processor->processor, color_space);
     return TRUE;
   }
-#endif
 
   return FALSE;
 }
-#endif
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
 /* D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_METADATA_HDR10
  * missing in mingw header */
 #define FEATURE_CAPS_METADATA_HDR10 (0x800)
@@ -376,7 +340,6 @@ gst_d3d11_video_processor_set_input_hdr10_metadata (GstD3D11VideoProcessor *
 {
   g_return_val_if_fail (processor != NULL, FALSE);
 
-#ifdef HAVE_VIDEO_CONTEXT_TWO
   if (processor->video_context2 && (processor->processor_caps.FeatureCaps &
           FEATURE_CAPS_METADATA_HDR10)) {
     if (hdr10_meta) {
@@ -391,7 +354,6 @@ gst_d3d11_video_processor_set_input_hdr10_metadata (GstD3D11VideoProcessor *
 
     return TRUE;
   }
-#endif
 
   return FALSE;
 }
@@ -402,7 +364,6 @@ gst_d3d11_video_processor_set_output_hdr10_metadata (GstD3D11VideoProcessor *
 {
   g_return_val_if_fail (processor != NULL, FALSE);
 
-#ifdef HAVE_VIDEO_CONTEXT_TWO
   if (processor->video_context2 && (processor->processor_caps.FeatureCaps &
           FEATURE_CAPS_METADATA_HDR10)) {
     if (hdr10_meta) {
@@ -416,11 +377,9 @@ gst_d3d11_video_processor_set_output_hdr10_metadata (GstD3D11VideoProcessor *
 
     return TRUE;
   }
-#endif
 
   return FALSE;
 }
-#endif
 
 gboolean
 gst_d3d11_video_processor_create_input_view (GstD3D11VideoProcessor * processor,
index 7949521..9094ed9 100644 (file)
@@ -23,6 +23,7 @@
 #include <gst/gst.h>
 #include <gst/video/video.h>
 #include <gst/d3d11/gstd3d11.h>
+#include "gstd3d11pluginutils.h"
 
 G_BEGIN_DECLS
 
@@ -51,7 +52,6 @@ gboolean  gst_d3d11_video_processor_set_input_color_space  (GstD3D11VideoProcess
 gboolean  gst_d3d11_video_processor_set_output_color_space (GstD3D11VideoProcessor * processor,
                                                             GstVideoColorimetry * color);
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
 gboolean  gst_d3d11_video_processor_check_format_conversion (GstD3D11VideoProcessor * processor,
                                                              DXGI_FORMAT in_format,
                                                              DXGI_COLOR_SPACE_TYPE in_color_space,
@@ -63,15 +63,12 @@ gboolean  gst_d3d11_video_processor_set_input_dxgi_color_space (GstD3D11VideoPro
 
 gboolean  gst_d3d11_video_processor_set_output_dxgi_color_space (GstD3D11VideoProcessor * processor,
                                                                 DXGI_COLOR_SPACE_TYPE color_space);
-#endif
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
 gboolean  gst_d3d11_video_processor_set_input_hdr10_metadata (GstD3D11VideoProcessor * processor,
                                                               DXGI_HDR_METADATA_HDR10 * hdr10_meta);
 
 gboolean  gst_d3d11_video_processor_set_output_hdr10_metadata (GstD3D11VideoProcessor * processor,
                                                               DXGI_HDR_METADATA_HDR10 * hdr10_meta);
-#endif
 
 gboolean  gst_d3d11_video_processor_create_input_view  (GstD3D11VideoProcessor * processor,
                                                         D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC * desc,
index 37928df..3f90dd7 100644 (file)
@@ -452,14 +452,10 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
   };
   const GstD3D11WindowDisplayFormat *chosen_format = NULL;
   const GstDxgiColorSpace *chosen_colorspace = NULL;
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
   gboolean have_hdr10 = FALSE;
   DXGI_COLOR_SPACE_TYPE native_colorspace_type =
       DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
-#endif
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
   DXGI_HDR_METADATA_HDR10 hdr10_metadata = { 0, };
-#endif
 
   /* Step 1: Clear old resources and objects */
   gst_clear_buffer (&window->cached_buffer);
@@ -534,7 +530,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
    * (or reuse old swapchain if the format is not changed) */
   window->allow_tearing = FALSE;
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
   {
     ComPtr < IDXGIFactory5 > factory5;
     IDXGIFactory1 *factory_handle;
@@ -550,7 +545,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
     if (SUCCEEDED (hr) && allow_tearing)
       window->allow_tearing = allow_tearing;
   }
-#endif
 
   if (window->allow_tearing) {
     GST_DEBUG_OBJECT (window, "device support tearning");
@@ -583,7 +577,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
   window->input_rect.bottom = GST_VIDEO_INFO_HEIGHT (&window->info);
 
   /* Step 4: Decide render color space and set it on converter/processor */
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
   {
     GstVideoMasteringDisplayInfo minfo;
     GstVideoContentLightLevel cll;
@@ -610,7 +603,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
       }
     }
   }
-#endif
 
   /* Step 5: Choose display color space */
   gst_video_info_set_format (&window->render_info,
@@ -625,7 +617,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
    * target display color space type */
   window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255;
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
   {
     ComPtr < IDXGISwapChain3 > swapchain3;
     HRESULT hr;
@@ -660,7 +651,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
       }
     }
   }
-#endif
 
   /* otherwise, use most common DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
    * color space */
@@ -670,7 +660,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
     window->render_info.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
     window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255;
   }
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
+
   if (chosen_colorspace) {
     const GstDxgiColorSpace *in_color_space =
         gst_d3d11_video_info_to_dxgi_color_space (&window->info);
@@ -712,7 +702,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
         gst_d3d11_video_processor_set_output_dxgi_color_space (processor,
             out_dxgi_color_space);
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
         if (have_hdr10) {
           GST_DEBUG_OBJECT (window, "Set HDR metadata on video processor");
           gst_d3d11_video_processor_set_input_hdr10_metadata (processor,
@@ -720,13 +709,12 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
           gst_d3d11_video_processor_set_output_hdr10_metadata (processor,
               &hdr10_metadata);
         }
-#endif
       }
 
       window->processor = processor;
     }
   }
-#endif
+
   *video_processor_available = !!window->processor;
 
   /* configure shader even if video processor is available for fallback */
@@ -976,11 +964,9 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer,
     gst_d3d11_overlay_compositor_upload (self->compositor, buffer);
     gst_d3d11_overlay_compositor_draw_unlocked (self->compositor, &rtv);
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
     if (self->allow_tearing && self->fullscreen) {
       present_flags |= DXGI_PRESENT_ALLOW_TEARING;
     }
-#endif
 
     if (klass->present)
       ret = klass->present (self, present_flags);
index f45ffbd..a4e1715 100644 (file)
@@ -114,7 +114,6 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
 
   gst_d3d11_device_lock (window->device);
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
   {
     const GstDxgiColorSpace *in_color_space =
         gst_d3d11_video_info_to_dxgi_color_space (&window->info);
@@ -167,7 +166,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
 
     window->processor = processor;
   }
-#endif
+
   *video_processor_available = !!window->processor;
 
   window->converter =
index cba1031..34a4052 100644 (file)
@@ -896,7 +896,6 @@ create_swap_chain (GstD3D11WindowWin32 * self, GstD3D11Device * device,
   return swap_chain;
 }
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 2)
 static IDXGISwapChain1 *
 create_swap_chain_for_hwnd (GstD3D11WindowWin32 * self, GstD3D11Device * device,
     HWND hwnd, DXGI_SWAP_CHAIN_DESC1 * desc,
@@ -927,7 +926,6 @@ create_swap_chain_for_hwnd (GstD3D11WindowWin32 * self, GstD3D11Device * device,
 
   return swap_chain;
 }
-#endif
 
 static gboolean
 gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
@@ -941,7 +939,6 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
 
   self->have_swapchain1 = FALSE;
 
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 2)
   {
     DXGI_SWAP_CHAIN_DESC1 desc1 = { 0, };
     desc1.Width = 0;
@@ -972,7 +969,6 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
       self->have_swapchain1 = TRUE;
     }
   }
-#endif
 
   if (!new_swapchain) {
     DXGI_SWAP_EFFECT swap_effect = DXGI_SWAP_EFFECT_DISCARD;
@@ -1070,7 +1066,7 @@ gst_d3d11_window_win32_present (GstD3D11Window * window, guint present_flags)
 
     return GST_D3D11_WINDOW_FLOW_CLOSED;
   }
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 2)
+
   if (self->have_swapchain1) {
     IDXGISwapChain1 *swap_chain1 = (IDXGISwapChain1 *) window->swap_chain;
     DXGI_PRESENT_PARAMETERS present_params = { 0, };
@@ -1082,9 +1078,7 @@ gst_d3d11_window_win32_present (GstD3D11Window * window, guint present_flags)
     }
 
     hr = swap_chain1->Present1 (0, present_flags, &present_params);
-  } else
-#endif
-  {
+  } else {
     hr = window->swap_chain->Present (0, present_flags);
   }
 
index b5dd2ae..11306f1 100644 (file)
@@ -1,31 +1,29 @@
 d3d11_sources = [
+  'gstd3d11av1dec.cpp',
   'gstd3d11basefilter.cpp',
-  'gstd3d11convert.cpp',
-  'gstd3d11converter.cpp',
   'gstd3d11compositor.cpp',
   'gstd3d11compositorbin.cpp',
+  'gstd3d11convert.cpp',
+  'gstd3d11converter.cpp',
+  'gstd3d11decoder.cpp',
+  'gstd3d11deinterlace.cpp',
   'gstd3d11download.cpp',
+  'gstd3d11h264dec.cpp',
+  'gstd3d11h265dec.cpp',
+  'gstd3d11mpeg2dec.cpp',
   'gstd3d11overlaycompositor.cpp',
   'gstd3d11pluginutils.cpp',
   'gstd3d11shader.cpp',
   'gstd3d11upload.cpp',
   'gstd3d11videoprocessor.cpp',
   'gstd3d11videosink.cpp',
+  'gstd3d11vp8dec.cpp',
+  'gstd3d11vp9dec.cpp',
   'gstd3d11window.cpp',
   'gstd3d11window_dummy.cpp',
   'plugin.cpp',
 ]
 
-d3d11_dec_sources = [
-  'gstd3d11av1dec.cpp',
-  'gstd3d11decoder.cpp',
-  'gstd3d11h264dec.cpp',
-  'gstd3d11vp9dec.cpp',
-  'gstd3d11h265dec.cpp',
-  'gstd3d11mpeg2dec.cpp',
-  'gstd3d11vp8dec.cpp',
-]
-
 extra_c_args = ['-DCOBJMACROS']
 extra_args = ['-DGST_USE_UNSTABLE_API']
 extra_dep = []
@@ -35,7 +33,7 @@ if host_system != 'windows' or d3d11_option.disabled()
   subdir_done()
 endif
 
-if not gstd3d11_dep.found()
+if not gstd3d11_dep.found() or not cc.has_header('dxva.h') or not cc.has_header('d3d9.h') or not cc.has_header('d3dcompiler.h')
   if d3d11_option.enabled()
     error('The d3d11 was enabled explicitly, but required dependencies were not found.')
   endif
@@ -45,23 +43,6 @@ endif
 d3dcompiler_lib = cc.find_library('d3dcompiler', required: d3d11_option)
 runtimeobject_lib = cc.find_library('runtimeobject', required : false)
 winmm_lib = cc.find_library('winmm', required: false)
-has_decoder = false
-
-have_d3d11 = cc.has_header('d3dcompiler.h')
-if not have_d3d11
-  if d3d11_option.enabled()
-    error('The d3d11 plugin was enabled explicitly, but required dependencies were not found.')
-  endif
-  subdir_done()
-endif
-
-# d3d11 video api uses dxva structure for decoding, and dxva.h needs d3d9 types
-if cc.has_header('dxva.h') and cc.has_header('d3d9.h')
-  d3d11_sources += d3d11_dec_sources
-  extra_args += ['-DHAVE_DXVA_H']
-  extra_dep += [gstcodecs_dep]
-  has_decoder = true
-endif
 
 if d3d11_winapi_only_app and (not d3dcompiler_lib.found() or not runtimeobject_lib.found())
   if d3d11_option.enabled()
@@ -80,28 +61,17 @@ endif
 
 if d3d11_winapi_desktop
   d3d11_sources += ['gstd3d11window_win32.cpp']
-  if d3d11_conf.get('GST_D3D11_DXGI_HEADER_VERSION') >= 6
-    # Desktop Duplication API is unavailable for UWP
-    # and MinGW is not supported due to some missing headers
-    extra_args += ['-DHAVE_DXGI_DESKTOP_DUP']
-    d3d11_sources += ['gstd3d11screencapture.cpp',
-                      'gstd3d11screencapturedevice.cpp',
-                      'gstd3d11screencapturesrc.cpp']
-    message('Enable D3D11 Desktop Duplication API')
-  endif
+  d3d11_sources += ['gstd3d11screencapture.cpp',
+                    'gstd3d11screencapturedevice.cpp',
+                    'gstd3d11screencapturesrc.cpp']
+
   # multimedia clock is desktop only API
-  if has_decoder and winmm_lib.found() and cc.has_header('timeapi.h')
+  if winmm_lib.found() and cc.has_header('timeapi.h')
     extra_args += ['-DHAVE_WINMM']
     extra_dep += [winmm_lib]
   endif
 endif
 
-# need dxgi1_5.h for HDR10 processing and d3d11_4.h for ID3D11VideoContext2 interface
-if d3d11_conf.get('GST_D3D11_DXGI_HEADER_VERSION') >= 5 and d3d11_conf.get('GST_D3D11_HEADER_VERSION') >= 4
-  d3d11_sources += ['gstd3d11deinterlace.cpp']
-  extra_args += ['-DHAVE_D3D11_VIDEO_PROC']
-endif
-
 # MinGW 32bits compiler seems to be complaining about redundant-decls
 # when ComPtr is in use. Let's just disable the warning
 if cc.get_id() != 'msvc'
@@ -117,7 +87,7 @@ gstd3d11 = library('gstd3d11',
   c_args : gst_plugins_bad_args + extra_c_args + extra_args,
   cpp_args: gst_plugins_bad_args + extra_args,
   include_directories : [configinc],
-  dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstcontroller_dep, gstd3d11_dep] + extra_dep,
+  dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstcontroller_dep, gstd3d11_dep, gstcodecs_dep] + extra_dep,
   install : true,
   install_dir : plugins_install_dir,
 )
index aaff1fe..eb58f3e 100644 (file)
 #include "gstd3d11shader.h"
 #include "gstd3d11compositor.h"
 #include "gstd3d11compositorbin.h"
-#ifdef HAVE_DXVA_H
 #include "gstd3d11h264dec.h"
 #include "gstd3d11h265dec.h"
 #include "gstd3d11vp9dec.h"
 #include "gstd3d11vp8dec.h"
 #include "gstd3d11mpeg2dec.h"
 #include "gstd3d11av1dec.h"
-#endif
-#ifdef HAVE_DXGI_DESKTOP_DUP
+#include "gstd3d11deinterlace.h"
+
+#if !GST_D3D11_WINAPI_ONLY_APP
 #include "gstd3d11screencapturesrc.h"
 #include "gstd3d11screencapturedevice.h"
 #endif
-#ifdef HAVE_D3D11_VIDEO_PROC
-#include "gstd3d11deinterlace.h"
-#endif
 
 GST_DEBUG_CATEGORY (gst_d3d11_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_shader_debug);
@@ -95,8 +92,6 @@ GST_DEBUG_CATEGORY (gst_d3d11_overlay_compositor_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_window_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_video_processor_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_compositor_debug);
-
-#ifdef HAVE_DXVA_H
 GST_DEBUG_CATEGORY (gst_d3d11_decoder_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_h264_dec_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_h265_dec_debug);
@@ -104,17 +99,13 @@ GST_DEBUG_CATEGORY (gst_d3d11_vp9_dec_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_vp8_dec_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_mpeg2_dec_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_av1_dec_debug);
-#endif
+GST_DEBUG_CATEGORY (gst_d3d11_deinterlace_debug);
 
-#ifdef HAVE_DXGI_DESKTOP_DUP
+#if !GST_D3D11_WINAPI_ONLY_APP
 GST_DEBUG_CATEGORY (gst_d3d11_screen_capture_debug);
 GST_DEBUG_CATEGORY (gst_d3d11_screen_capture_device_debug);
 #endif
 
-#ifdef HAVE_D3D11_VIDEO_PROC
-GST_DEBUG_CATEGORY (gst_d3d11_deinterlace_debug);
-#endif
-
 #define GST_CAT_DEFAULT gst_d3d11_debug
 
 static gboolean
@@ -144,7 +135,7 @@ plugin_init (GstPlugin * plugin)
     GST_WARNING ("Cannot initialize d3d11 shader");
     return TRUE;
   }
-#ifdef HAVE_DXVA_H
+
   /* DXVA2 API is availble since Windows 8 */
   if (gst_d3d11_is_windows_8_or_greater ()) {
     GST_DEBUG_CATEGORY_INIT (gst_d3d11_decoder_debug,
@@ -161,13 +152,9 @@ plugin_init (GstPlugin * plugin)
         "d3d11mpeg2dec", 0, "Direct3D11 MPEG2 Decoder");
     GST_DEBUG_CATEGORY_INIT (gst_d3d11_av1_dec_debug,
         "d3d11av1dec", 0, "Direct3D11 AV1 Decoder");
+    GST_DEBUG_CATEGORY_INIT (gst_d3d11_deinterlace_debug,
+        "d3d11deinterlace", 0, "Direct3D11 Deinterlacer");
   }
-#endif
-
-#ifdef HAVE_D3D11_VIDEO_PROC
-  GST_DEBUG_CATEGORY_INIT (gst_d3d11_deinterlace_debug,
-      "d3d11deinterlace", 0, "Direct3D11 Deinterlacer");
-#endif
 
   /* Enumerate devices to register decoders per device and to get the highest
    * feature level */
@@ -187,7 +174,6 @@ plugin_init (GstPlugin * plugin)
     if (feature_level > max_feature_level)
       max_feature_level = feature_level;
 
-#ifdef HAVE_DXVA_H
     /* DXVA2 API is availble since Windows 8 */
     if (gst_d3d11_is_windows_8_or_greater () &&
         gst_d3d11_device_get_video_device_handle (device)) {
@@ -203,19 +189,9 @@ plugin_init (GstPlugin * plugin)
         gst_d3d11_av1_dec_register (plugin, device, GST_RANK_PRIMARY);
         gst_d3d11_mpeg2_dec_register (plugin, device, GST_RANK_SECONDARY);
       }
-    }
-#endif
 
-#ifdef HAVE_D3D11_VIDEO_PROC
-    /* D3D11 video processor API is availble since Windows 8 */
-    if (gst_d3d11_is_windows_8_or_greater ()) {
-      gboolean hardware;
-
-      g_object_get (device, "hardware", &hardware, NULL);
-      if (hardware)
-        gst_d3d11_deinterlace_register (plugin, device, GST_RANK_MARGINAL);
+      gst_d3d11_deinterlace_register (plugin, device, GST_RANK_MARGINAL);
     }
-#endif
 
     gst_object_unref (device);
   }
@@ -252,7 +228,7 @@ plugin_init (GstPlugin * plugin)
   gst_element_register (plugin,
       "d3d11compositor", GST_RANK_SECONDARY, GST_TYPE_D3D11_COMPOSITOR_BIN);
 
-#ifdef HAVE_DXGI_DESKTOP_DUP
+#if !GST_D3D11_WINAPI_ONLY_APP
   if (gst_d3d11_is_windows_8_or_greater ()) {
     GST_DEBUG_CATEGORY_INIT (gst_d3d11_screen_capture_debug,
         "d3d11screencapturesrc", 0, "d3d11screencapturesrc");
index 70115a5..bb65508 100644 (file)
@@ -77,6 +77,8 @@
 
 #if GST_MF_HAVE_D3D11
 #include <gst/d3d11/gstd3d11.h>
+#include <d3d11_4.h>
+#include <dxgi1_6.h>
 #include <gstmfplatloader.h>
 #endif