From 3804dfb28d971ffca58d45ccfc2f7033a6af2628 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 26 Apr 2020 22:37:12 +0900 Subject: [PATCH] d3d11device: Add fallback for device creation D3D11_CREATE_DEVICE_DEBUG flag will be used while creating d3d11 device to activate debug layer. However, if system doesn't support the debug layer for some reason, we should try to create d3d11 device without the flag. Debug layer should be optional for device creation. Part-of: --- sys/d3d11/gstd3d11device.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/d3d11/gstd3d11device.c b/sys/d3d11/gstd3d11device.c index 4265e63512..c8df4a8aa1 100644 --- a/sys/d3d11/gstd3d11device.c +++ b/sys/d3d11/gstd3d11device.c @@ -602,6 +602,30 @@ gst_d3d11_device_constructed (GObject * object) priv->feature_level = selected_level; } + /* if D3D11_CREATE_DEVICE_DEBUG was enabled but couldn't create device, + * try it without the flag again */ + if (FAILED (hr) && (d3d11_flags & D3D11_CREATE_DEVICE_DEBUG) == + D3D11_CREATE_DEVICE_DEBUG) { + GST_WARNING_OBJECT (self, "Couldn't create d3d11 device with debug flag"); + + d3d11_flags &= ~D3D11_CREATE_DEVICE_DEBUG; + + hr = D3D11CreateDevice ((IDXGIAdapter *) adapter, D3D_DRIVER_TYPE_UNKNOWN, + NULL, d3d11_flags, feature_levels, G_N_ELEMENTS (feature_levels), + D3D11_SDK_VERSION, &priv->device, &selected_level, + &priv->device_context); + priv->feature_level = selected_level; + + if (!gst_d3d11_result (hr, NULL)) { + /* Retry if the system could not recognize D3D_FEATURE_LEVEL_11_1 */ + hr = D3D11CreateDevice ((IDXGIAdapter *) adapter, D3D_DRIVER_TYPE_UNKNOWN, + NULL, d3d11_flags, &feature_levels[1], + G_N_ELEMENTS (feature_levels) - 1, D3D11_SDK_VERSION, &priv->device, + &selected_level, &priv->device_context); + priv->feature_level = selected_level; + } + } + if (gst_d3d11_result (hr, NULL)) { GST_DEBUG_OBJECT (self, "Selected feature level 0x%x", selected_level); } else {