qsv: Check d3d shared resource tier using D3D11 API

We can check the tier using d3d11 API. Thus, don't need to
create d3d12 device

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7099>
This commit is contained in:
Seungha Yang 2024-06-25 20:08:54 +09:00 committed by GStreamer Marge Bot
parent 73480e60d0
commit 76fd732d42
4 changed files with 56 additions and 20 deletions

View file

@ -67,5 +67,8 @@ HRESULT gst_d3d11_device_get_rasterizer_msaa (GstD3D11Device * device,
GST_D3D11_API GST_D3D11_API
void gst_d3d11_device_check_device_removed (GstD3D11Device * device); void gst_d3d11_device_check_device_removed (GstD3D11Device * device);
GST_D3D11_API
gboolean gst_d3d11_device_d3d12_import_supported (GstD3D11Device * device);
G_END_DECLS G_END_DECLS

View file

@ -1962,3 +1962,34 @@ gst_d3d11_device_get_rasterizer_msaa (GstD3D11Device * device,
return S_OK; 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
}

View file

@ -227,6 +227,23 @@ if host_machine.cpu_family() != 'x86'
endif endif
endif endif
if cxx.compiles('''
#include <d3d11_4.h>
#include <d3d11.h>
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( configure_file(
input : 'gstd3d11config.h.meson', input : 'gstd3d11config.h.meson',
output : 'gstd3d11config.h', output : 'gstd3d11config.h',

View file

@ -57,12 +57,14 @@
#include <windows.h> #include <windows.h>
#include <versionhelpers.h> #include <versionhelpers.h>
#include <gst/d3d11/gstd3d11.h> #include <gst/d3d11/gstd3d11.h>
#include <gst/d3d11/gstd3d11device-private.h>
#else #else
#include <gst/va/gstva.h> #include <gst/va/gstva.h>
#endif #endif
#ifdef HAVE_GST_D3D12 #ifdef HAVE_GST_D3D12
#include <gst/d3d12/gstd3d12.h> #include <gst/d3d12/gstd3d12.h>
#include <d3d11_4.h>
#endif #endif
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
@ -274,26 +276,9 @@ plugin_init (GstPlugin * plugin)
goto next; goto next;
#ifdef HAVE_GST_D3D12 #ifdef HAVE_GST_D3D12
{ if (gst_d3d11_device_d3d12_import_supported (GST_D3D11_DEVICE (device))) {
gint64 luid; GST_INFO_OBJECT (device, "Device supports D3D12 resource share");
g_object_get (device, "adapter-luid", &luid, nullptr); d3d12_interop = TRUE;
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);
}
} }
#endif #endif