mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
d3d11device: Add property for getting adapter LUID
LUID (Locally Unique Identifier) can used for identifying GPU and that's required for some Windows APIs (e.g., MFTEnum2()) to setup device. See also https://docs.microsoft.com/en-us/windows/win32/api/mfapi/nf-mfapi-mftenum2 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1910>
This commit is contained in:
parent
4b522dd355
commit
7eab7ae8cc
2 changed files with 19 additions and 3 deletions
|
@ -63,6 +63,7 @@ enum
|
||||||
PROP_DESCRIPTION,
|
PROP_DESCRIPTION,
|
||||||
PROP_ALLOW_TEARING,
|
PROP_ALLOW_TEARING,
|
||||||
PROP_CREATE_FLAGS,
|
PROP_CREATE_FLAGS,
|
||||||
|
PROP_ADAPTER_LUID,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_ADAPTER 0
|
#define DEFAULT_ADAPTER 0
|
||||||
|
@ -77,6 +78,7 @@ struct _GstD3D11DevicePrivate
|
||||||
gchar *description;
|
gchar *description;
|
||||||
gboolean allow_tearing;
|
gboolean allow_tearing;
|
||||||
guint create_flags;
|
guint create_flags;
|
||||||
|
gint64 adapter_luid;
|
||||||
|
|
||||||
ID3D11Device *device;
|
ID3D11Device *device;
|
||||||
ID3D11DeviceContext *device_context;
|
ID3D11DeviceContext *device_context;
|
||||||
|
@ -352,6 +354,11 @@ gst_d3d11_device_class_init (GstD3D11DeviceClass * klass)
|
||||||
"D3D11_CREATE_DEVICE_FLAG flags used for D3D11CreateDevice",
|
"D3D11_CREATE_DEVICE_FLAG flags used for D3D11CreateDevice",
|
||||||
0, G_MAXUINT32, DEFAULT_CREATE_FLAGS,
|
0, G_MAXUINT32, DEFAULT_CREATE_FLAGS,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_ADAPTER_LUID,
|
||||||
|
g_param_spec_int64 ("adapter-luid", "Adapter LUID",
|
||||||
|
"DXGI Adapter LUID (Locally Unique Identifier) of created device",
|
||||||
|
0, G_MAXINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -632,22 +639,26 @@ gst_d3d11_device_constructed (GObject * object)
|
||||||
if (SUCCEEDED (hr)) {
|
if (SUCCEEDED (hr)) {
|
||||||
gchar *description = NULL;
|
gchar *description = NULL;
|
||||||
gboolean is_hardware = FALSE;
|
gboolean is_hardware = FALSE;
|
||||||
|
gint64 adapter_luid;
|
||||||
|
|
||||||
/* DXGI_ADAPTER_FLAG_SOFTWARE is missing in dxgi.h of mingw */
|
/* DXGI_ADAPTER_FLAG_SOFTWARE is missing in dxgi.h of mingw */
|
||||||
if ((desc.Flags & 0x2) != 0x2) {
|
if ((desc.Flags & 0x2) != 0x2) {
|
||||||
is_hardware = TRUE;
|
is_hardware = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adapter_luid = (((gint64) desc.AdapterLuid.HighPart) << 32) |
|
||||||
|
((gint64) desc.AdapterLuid.LowPart);
|
||||||
description = g_utf16_to_utf8 (desc.Description, -1, NULL, NULL, NULL);
|
description = g_utf16_to_utf8 (desc.Description, -1, NULL, NULL, NULL);
|
||||||
GST_DEBUG_OBJECT (self,
|
GST_DEBUG_OBJECT (self,
|
||||||
"adapter index %d: D3D11 device vendor-id: 0x%04x, device-id: 0x%04x, "
|
"adapter index %d: D3D11 device vendor-id: 0x%04x, device-id: 0x%04x, "
|
||||||
"Flags: 0x%x, %s",
|
"Flags: 0x%x, adapter-luid: " G_GINT64_FORMAT ", %s",
|
||||||
priv->adapter, desc.VendorId, desc.DeviceId, desc.Flags, description);
|
priv->adapter, desc.VendorId, desc.DeviceId, desc.Flags, description);
|
||||||
|
|
||||||
priv->vendor_id = desc.VendorId;
|
priv->vendor_id = desc.VendorId;
|
||||||
priv->device_id = desc.DeviceId;
|
priv->device_id = desc.DeviceId;
|
||||||
priv->hardware = is_hardware;
|
priv->hardware = is_hardware;
|
||||||
priv->description = description;
|
priv->description = description;
|
||||||
|
priv->adapter_luid = adapter_luid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,6 +816,9 @@ gst_d3d11_device_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_CREATE_FLAGS:
|
case PROP_CREATE_FLAGS:
|
||||||
g_value_set_uint (value, priv->create_flags);
|
g_value_set_uint (value, priv->create_flags);
|
||||||
break;
|
break;
|
||||||
|
case PROP_ADAPTER_LUID:
|
||||||
|
g_value_set_int64 (value, priv->adapter_luid);
|
||||||
|
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;
|
||||||
|
|
|
@ -108,12 +108,13 @@ context_set_d3d11_device (GstContext * context, GstD3D11Device * device)
|
||||||
guint vendor_id = 0;
|
guint vendor_id = 0;
|
||||||
gboolean hardware = FALSE;
|
gboolean hardware = FALSE;
|
||||||
gchar *desc = NULL;
|
gchar *desc = NULL;
|
||||||
|
gint64 adapter_luid = 0;
|
||||||
|
|
||||||
g_return_if_fail (context != NULL);
|
g_return_if_fail (context != NULL);
|
||||||
|
|
||||||
g_object_get (G_OBJECT (device), "adapter", &adapter, "device-id", &device_id,
|
g_object_get (G_OBJECT (device), "adapter", &adapter, "device-id", &device_id,
|
||||||
"vendor_id", &vendor_id, "hardware", &hardware, "description", &desc,
|
"vendor-id", &vendor_id, "hardware", &hardware, "description", &desc,
|
||||||
NULL);
|
"adapter-luid", &adapter_luid, NULL);
|
||||||
|
|
||||||
GST_CAT_LOG (GST_CAT_CONTEXT,
|
GST_CAT_LOG (GST_CAT_CONTEXT,
|
||||||
"setting GstD3D11Device(%" GST_PTR_FORMAT
|
"setting GstD3D11Device(%" GST_PTR_FORMAT
|
||||||
|
@ -123,6 +124,7 @@ context_set_d3d11_device (GstContext * context, GstD3D11Device * device)
|
||||||
s = gst_context_writable_structure (context);
|
s = gst_context_writable_structure (context);
|
||||||
gst_structure_set (s, "device", GST_TYPE_D3D11_DEVICE, device,
|
gst_structure_set (s, "device", GST_TYPE_D3D11_DEVICE, device,
|
||||||
"adapter", G_TYPE_UINT, adapter,
|
"adapter", G_TYPE_UINT, adapter,
|
||||||
|
"adapter-luid", G_TYPE_INT64, adapter_luid,
|
||||||
"device-id", G_TYPE_UINT, device_id,
|
"device-id", G_TYPE_UINT, device_id,
|
||||||
"vendor-id", G_TYPE_UINT, vendor_id,
|
"vendor-id", G_TYPE_UINT, vendor_id,
|
||||||
"hardware", G_TYPE_BOOLEAN, hardware,
|
"hardware", G_TYPE_BOOLEAN, hardware,
|
||||||
|
|
Loading…
Reference in a new issue