diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h index 19f3b173bb..27ddc0c7d0 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h @@ -67,5 +67,8 @@ HRESULT gst_d3d11_device_get_rasterizer_msaa (GstD3D11Device * device, GST_D3D11_API void gst_d3d11_device_check_device_removed (GstD3D11Device * device); +GST_D3D11_API +gboolean gst_d3d11_device_d3d12_import_supported (GstD3D11Device * device); + G_END_DECLS diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp index 43d5d23e78..67b9220dbd 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp @@ -1962,3 +1962,34 @@ gst_d3d11_device_get_rasterizer_msaa (GstD3D11Device * device, return S_OK; } + +gboolean +gst_d3d11_device_d3d12_import_supported (GstD3D11Device * device) +{ +#ifdef HAVE_D3D11_FEATURE_DATA_D3D11_OPTIONS5 + auto priv = device->priv; + auto dev = priv->device; + + D3D11_FEATURE_DATA_D3D11_OPTIONS options = { }; + D3D11_FEATURE_DATA_D3D11_OPTIONS4 options4 = { }; + D3D11_FEATURE_DATA_D3D11_OPTIONS5 options5 = { }; + auto hr = dev->CheckFeatureSupport (D3D11_FEATURE_D3D11_OPTIONS5, + &options5, sizeof (options5)); + if (FAILED (hr) || options5.SharedResourceTier < D3D11_SHARED_RESOURCE_TIER_2) + return FALSE; + + hr = dev->CheckFeatureSupport (D3D11_FEATURE_D3D11_OPTIONS, + &options, sizeof (options)); + if (FAILED (hr) || !options.ExtendedResourceSharing) + return FALSE; + + hr = dev->CheckFeatureSupport (D3D11_FEATURE_D3D11_OPTIONS4, + &options4, sizeof (options4)); + if (FAILED (hr) || !options4.ExtendedNV12SharedTextureSupported) + return FALSE; + + return TRUE; +#else + return FALSE; +#endif +} diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build index f2f3ab5f68..fc24571e6e 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build @@ -227,6 +227,23 @@ if host_machine.cpu_family() != 'x86' endif endif +if cxx.compiles(''' + #include + #include + int main(int argc, char ** argv) { + D3D11_FEATURE_DATA_D3D11_OPTIONS options; + D3D11_FEATURE_DATA_D3D11_OPTIONS4 options4; + D3D11_FEATURE_DATA_D3D11_OPTIONS5 options5; + D3D11_FEATURE fo = D3D11_FEATURE_D3D11_OPTIONS; + D3D11_FEATURE fo4 = D3D11_FEATURE_D3D11_OPTIONS4; + D3D11_FEATURE fo5 = D3D11_FEATURE_D3D11_OPTIONS5; + return 0; + } + ''', + name: 'D3D11_FEATURE_DATA_* symbols in d3d11 header') + extra_comm_args += ['-DHAVE_D3D11_FEATURE_DATA_D3D11_OPTIONS5'] +endif + configure_file( input : 'gstd3d11config.h.meson', output : 'gstd3d11config.h', diff --git a/subprojects/gst-plugins-bad/sys/qsv/plugin.cpp b/subprojects/gst-plugins-bad/sys/qsv/plugin.cpp index eed9654412..b01f4bf98d 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/plugin.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/plugin.cpp @@ -57,12 +57,14 @@ #include #include #include +#include #else #include #endif #ifdef HAVE_GST_D3D12 #include +#include #endif #include @@ -274,26 +276,9 @@ plugin_init (GstPlugin * plugin) goto next; #ifdef HAVE_GST_D3D12 - { - gint64 luid; - g_object_get (device, "adapter-luid", &luid, nullptr); - auto device12 = gst_d3d12_device_new_for_adapter_luid (luid); - if (device12) { - auto handle12 = gst_d3d12_device_get_device_handle (device12); - D3D12_FEATURE_DATA_D3D12_OPTIONS4 feature_data = { }; - auto hr = handle12->CheckFeatureSupport (D3D12_FEATURE_D3D12_OPTIONS4, - &feature_data, sizeof (feature_data)); - if (SUCCEEDED (hr) && feature_data.SharedResourceCompatibilityTier >= - D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_2) { - GST_INFO_OBJECT (device, "Device supports D3D12 resource share"); - d3d12_interop = TRUE; - } else { - GST_INFO_OBJECT (device, - "Device does not support D3D12 resource share"); - } - - gst_object_unref (device12); - } + if (gst_d3d11_device_d3d12_import_supported (GST_D3D11_DEVICE (device))) { + GST_INFO_OBJECT (device, "Device supports D3D12 resource share"); + d3d12_interop = TRUE; } #endif