mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-11 06:11:27 +00:00
d3d11device: Add an optional flags argument for creating device
Extend gst_d3d11_device_new() method so that caller can specify D3D11_CREATE_DEVICE_FLAG value to use. See https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ne-d3d11-d3d11_create_device_flag for more detail about D3D11_CREATE_DEVICE_FLAG Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1901>
This commit is contained in:
parent
7e7e54d089
commit
4337031430
4 changed files with 31 additions and 7 deletions
|
@ -62,9 +62,11 @@ enum
|
||||||
PROP_HARDWARE,
|
PROP_HARDWARE,
|
||||||
PROP_DESCRIPTION,
|
PROP_DESCRIPTION,
|
||||||
PROP_ALLOW_TEARING,
|
PROP_ALLOW_TEARING,
|
||||||
|
PROP_CREATE_FLAGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_ADAPTER 0
|
#define DEFAULT_ADAPTER 0
|
||||||
|
#define DEFAULT_CREATE_FLAGS 0
|
||||||
|
|
||||||
struct _GstD3D11DevicePrivate
|
struct _GstD3D11DevicePrivate
|
||||||
{
|
{
|
||||||
|
@ -74,6 +76,7 @@ struct _GstD3D11DevicePrivate
|
||||||
gboolean hardware;
|
gboolean hardware;
|
||||||
gchar *description;
|
gchar *description;
|
||||||
gboolean allow_tearing;
|
gboolean allow_tearing;
|
||||||
|
guint create_flags;
|
||||||
|
|
||||||
ID3D11Device *device;
|
ID3D11Device *device;
|
||||||
ID3D11DeviceContext *device_context;
|
ID3D11DeviceContext *device_context;
|
||||||
|
@ -345,6 +348,12 @@ gst_d3d11_device_class_init (GstD3D11DeviceClass * klass)
|
||||||
g_param_spec_boolean ("allow-tearing", "Allow tearing",
|
g_param_spec_boolean ("allow-tearing", "Allow tearing",
|
||||||
"Whether dxgi device supports allow-tearing feature or not", FALSE,
|
"Whether dxgi device supports allow-tearing feature or not", FALSE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_CREATE_FLAGS,
|
||||||
|
g_param_spec_uint ("create-flags", "Create flags",
|
||||||
|
"D3D11_CREATE_DEVICE_FLAG flags used for D3D11CreateDevice",
|
||||||
|
0, G_MAXUINT32, DEFAULT_CREATE_FLAGS,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -539,7 +548,7 @@ gst_d3d11_device_constructed (GObject * object)
|
||||||
IDXGIAdapter1 *adapter = NULL;
|
IDXGIAdapter1 *adapter = NULL;
|
||||||
IDXGIFactory1 *factory = NULL;
|
IDXGIFactory1 *factory = NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
UINT d3d11_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
UINT d3d11_flags = priv->create_flags;
|
||||||
|
|
||||||
static const D3D_FEATURE_LEVEL feature_levels[] = {
|
static const D3D_FEATURE_LEVEL feature_levels[] = {
|
||||||
D3D_FEATURE_LEVEL_11_1,
|
D3D_FEATURE_LEVEL_11_1,
|
||||||
|
@ -733,6 +742,10 @@ gst_d3d11_device_constructed (GObject * object)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Update final create flags here, since D3D11_CREATE_DEVICE_DEBUG
|
||||||
|
* might be added by us */
|
||||||
|
priv->create_flags = d3d11_flags;
|
||||||
|
|
||||||
IDXGIAdapter1_Release (adapter);
|
IDXGIAdapter1_Release (adapter);
|
||||||
gst_d3d11_device_setup_format_table (self);
|
gst_d3d11_device_setup_format_table (self);
|
||||||
|
|
||||||
|
@ -763,6 +776,9 @@ gst_d3d11_device_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_ADAPTER:
|
case PROP_ADAPTER:
|
||||||
priv->adapter = g_value_get_uint (value);
|
priv->adapter = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CREATE_FLAGS:
|
||||||
|
priv->create_flags = g_value_get_uint (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -795,6 +811,9 @@ gst_d3d11_device_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_ALLOW_TEARING:
|
case PROP_ALLOW_TEARING:
|
||||||
g_value_set_boolean (value, priv->allow_tearing);
|
g_value_set_boolean (value, priv->allow_tearing);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CREATE_FLAGS:
|
||||||
|
g_value_set_uint (value, priv->create_flags);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -875,17 +894,19 @@ gst_d3d11_device_finalize (GObject * object)
|
||||||
/**
|
/**
|
||||||
* gst_d3d11_device_new:
|
* gst_d3d11_device_new:
|
||||||
* @adapter: the index of adapter for creating d3d11 device
|
* @adapter: the index of adapter for creating d3d11 device
|
||||||
|
* @flags: a D3D11_CREATE_DEVICE_FLAG value used for creating d3d11 device
|
||||||
*
|
*
|
||||||
* Returns: (transfer full) (nullable): a new #GstD3D11Device for @adapter or %NULL
|
* Returns: (transfer full) (nullable): a new #GstD3D11Device for @adapter or %NULL
|
||||||
* when failed to create D3D11 device with given adapter index.
|
* when failed to create D3D11 device with given adapter index.
|
||||||
*/
|
*/
|
||||||
GstD3D11Device *
|
GstD3D11Device *
|
||||||
gst_d3d11_device_new (guint adapter)
|
gst_d3d11_device_new (guint adapter, guint flags)
|
||||||
{
|
{
|
||||||
GstD3D11Device *device = NULL;
|
GstD3D11Device *device = NULL;
|
||||||
GstD3D11DevicePrivate *priv;
|
GstD3D11DevicePrivate *priv;
|
||||||
|
|
||||||
device = g_object_new (GST_TYPE_D3D11_DEVICE, "adapter", adapter, NULL);
|
device = g_object_new (GST_TYPE_D3D11_DEVICE, "adapter", adapter,
|
||||||
|
"create-flags", flags, NULL);
|
||||||
|
|
||||||
priv = device->priv;
|
priv = device->priv;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,8 @@ struct _GstD3D11DeviceClass
|
||||||
|
|
||||||
GType gst_d3d11_device_get_type (void);
|
GType gst_d3d11_device_get_type (void);
|
||||||
|
|
||||||
GstD3D11Device * gst_d3d11_device_new (guint adapter);
|
GstD3D11Device * gst_d3d11_device_new (guint adapter,
|
||||||
|
guint flags);
|
||||||
|
|
||||||
ID3D11Device * gst_d3d11_device_get_device_handle (GstD3D11Device * device);
|
ID3D11Device * gst_d3d11_device_get_device_handle (GstD3D11Device * device);
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,9 @@ gst_d3d11_ensure_element_data (GstElement * element, gint adapter,
|
||||||
if (adapter > 0)
|
if (adapter > 0)
|
||||||
target_adapter = adapter;
|
target_adapter = adapter;
|
||||||
|
|
||||||
*device = gst_d3d11_device_new (target_adapter);
|
/* Needs D3D11_CREATE_DEVICE_BGRA_SUPPORT flag for Direct2D interop */
|
||||||
|
*device = gst_d3d11_device_new (target_adapter,
|
||||||
|
D3D11_CREATE_DEVICE_BGRA_SUPPORT);
|
||||||
|
|
||||||
if (*device == NULL) {
|
if (*device == NULL) {
|
||||||
GST_ERROR_OBJECT (element,
|
GST_ERROR_OBJECT (element,
|
||||||
|
|
|
@ -120,7 +120,7 @@ plugin_init (GstPlugin * plugin)
|
||||||
gst_element_register (plugin,
|
gst_element_register (plugin,
|
||||||
"d3d11videosinkelement", GST_RANK_NONE, GST_TYPE_D3D11_VIDEO_SINK);
|
"d3d11videosinkelement", GST_RANK_NONE, GST_TYPE_D3D11_VIDEO_SINK);
|
||||||
|
|
||||||
device = gst_d3d11_device_new (0);
|
device = gst_d3d11_device_new (0, D3D11_CREATE_DEVICE_BGRA_SUPPORT);
|
||||||
|
|
||||||
/* FIXME: Our shader code is not compatible with D3D_FEATURE_LEVEL_9_3
|
/* FIXME: Our shader code is not compatible with D3D_FEATURE_LEVEL_9_3
|
||||||
* or lower. So HLSL compiler cannot understand our shader code and
|
* or lower. So HLSL compiler cannot understand our shader code and
|
||||||
|
@ -167,7 +167,7 @@ plugin_init (GstPlugin * plugin)
|
||||||
gboolean hardware;
|
gboolean hardware;
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
device = gst_d3d11_device_new (i);
|
device = gst_d3d11_device_new (i, D3D11_CREATE_DEVICE_BGRA_SUPPORT);
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue