d3d11: Remove unnecessary helper methods

We can query selected D3D_FEATURE_LEVEL and factory version
by using native D3D11 API

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1906>
This commit is contained in:
Seungha Yang 2020-12-23 21:21:55 +09:00
parent 2ca298d459
commit 1138c798ff
4 changed files with 5 additions and 43 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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)

View file

@ -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;
}