From 1138c798ffa6d9b500393cc537db60b805b36e59 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 23 Dec 2020 21:21:55 +0900 Subject: [PATCH] d3d11: Remove unnecessary helper methods We can query selected D3D_FEATURE_LEVEL and factory version by using native D3D11 API Part-of: --- sys/d3d11/gstd3d11device.c | 26 -------------------------- sys/d3d11/gstd3d11device.h | 15 --------------- sys/d3d11/gstd3d11shader.c | 4 +++- sys/d3d11/plugin.c | 3 ++- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/sys/d3d11/gstd3d11device.c b/sys/d3d11/gstd3d11device.c index e519e7d5c0..be66187822 100644 --- a/sys/d3d11/gstd3d11device.c +++ b/sys/d3d11/gstd3d11device.c @@ -82,8 +82,6 @@ struct _GstD3D11DevicePrivate ID3D11DeviceContext *device_context; IDXGIFactory1 *factory; - GstD3D11DXGIFactoryVersion factory_ver; - D3D_FEATURE_LEVEL feature_level; GstD3D11Format format_table[GST_D3D11_N_FORMATS]; GRecMutex extern_lock; @@ -612,12 +610,9 @@ gst_d3d11_device_constructed (GObject * object) hr = S_OK; } - - priv->factory_ver = GST_D3D11_DXGI_FACTORY_5; #endif if (!factory) { - priv->factory_ver = GST_D3D11_DXGI_FACTORY_1; hr = CreateDXGIFactory1 (&IID_IDXGIFactory1, (void **) &factory); } @@ -674,7 +669,6 @@ gst_d3d11_device_constructed (GObject * object) 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 */ @@ -682,7 +676,6 @@ gst_d3d11_device_constructed (GObject * object) 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 D3D11_CREATE_DEVICE_DEBUG was enabled but couldn't create device, @@ -697,7 +690,6 @@ gst_d3d11_device_constructed (GObject * object) 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 */ @@ -705,7 +697,6 @@ gst_d3d11_device_constructed (GObject * object) 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; } } @@ -962,23 +953,6 @@ gst_d3d11_device_get_dxgi_factory_handle (GstD3D11Device * device) return device->priv->factory; } -GstD3D11DXGIFactoryVersion -gst_d3d11_device_get_chosen_dxgi_factory_version (GstD3D11Device * device) -{ - g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), - GST_D3D11_DXGI_FACTORY_UNKNOWN); - - return device->priv->factory_ver; -} - -D3D_FEATURE_LEVEL -gst_d3d11_device_get_chosen_feature_level (GstD3D11Device * device) -{ - g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), 0); - - return device->priv->feature_level; -} - void gst_d3d11_device_lock (GstD3D11Device * device) { diff --git a/sys/d3d11/gstd3d11device.h b/sys/d3d11/gstd3d11device.h index 61c508bce0..b3b7dd0942 100644 --- a/sys/d3d11/gstd3d11device.h +++ b/sys/d3d11/gstd3d11device.h @@ -37,17 +37,6 @@ G_BEGIN_DECLS #define GST_D3D11_DEVICE_HANDLE_CONTEXT_TYPE "gst.d3d11.device.handle" -typedef enum -{ - GST_D3D11_DXGI_FACTORY_UNKNOWN = 0, - GST_D3D11_DXGI_FACTORY_1, - GST_D3D11_DXGI_FACTORY_2, - GST_D3D11_DXGI_FACTORY_3, - GST_D3D11_DXGI_FACTORY_4, - GST_D3D11_DXGI_FACTORY_5, -} GstD3D11DXGIFactoryVersion; - - struct _GstD3D11Device { GstObject parent; @@ -77,10 +66,6 @@ ID3D11DeviceContext * gst_d3d11_device_get_device_context_handle (GstD3D11Device IDXGIFactory1 * gst_d3d11_device_get_dxgi_factory_handle (GstD3D11Device * device); -GstD3D11DXGIFactoryVersion gst_d3d11_device_get_chosen_dxgi_factory_version (GstD3D11Device * device); - -D3D_FEATURE_LEVEL gst_d3d11_device_get_chosen_feature_level (GstD3D11Device * device); - void gst_d3d11_device_lock (GstD3D11Device * device); void gst_d3d11_device_unlock (GstD3D11Device * device); diff --git a/sys/d3d11/gstd3d11shader.c b/sys/d3d11/gstd3d11shader.c index 24dea2a417..905ea87840 100644 --- a/sys/d3d11/gstd3d11shader.c +++ b/sys/d3d11/gstd3d11shader.c @@ -88,13 +88,15 @@ compile_shader (GstD3D11Device * device, const gchar * shader_source, const gchar *shader_target; D3D_FEATURE_LEVEL feature_level; HRESULT hr; + ID3D11Device *device_handle; if (!gst_d3d11_shader_init ()) { GST_ERROR ("D3DCompiler is unavailable"); return NULL; } - feature_level = gst_d3d11_device_get_chosen_feature_level (device); + device_handle = gst_d3d11_device_get_device_handle (device); + feature_level = ID3D11Device_GetFeatureLevel (device_handle); if (is_pixel_shader) { if (feature_level >= D3D_FEATURE_LEVEL_10_0) diff --git a/sys/d3d11/plugin.c b/sys/d3d11/plugin.c index 8105f7bd7a..6dffb32bf6 100644 --- a/sys/d3d11/plugin.c +++ b/sys/d3d11/plugin.c @@ -140,8 +140,9 @@ plugin_init (GstPlugin * plugin) */ if (device) { D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_10_0; + ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device); - feature_level = gst_d3d11_device_get_chosen_feature_level (device); + feature_level = ID3D11Device_GetFeatureLevel (device_handle); if (feature_level >= D3D_FEATURE_LEVEL_10_0) video_sink_rank = GST_RANK_PRIMARY; }