mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
mediafoundation: mfvideoenc: Use DXGI adapter LUID
Make use of new DXGI adapter LUID based device context sharing. Note that we were using DXGI adapter LUID to open MFT already. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1098>
This commit is contained in:
parent
5707e487cf
commit
0d96e43c91
5 changed files with 38 additions and 35 deletions
|
@ -163,7 +163,7 @@ enum
|
|||
PROP_QP_B,
|
||||
PROP_REF,
|
||||
PROP_D3D11_AWARE,
|
||||
PROP_ADAPTER,
|
||||
PROP_ADAPTER_LUID,
|
||||
};
|
||||
|
||||
#define DEFAULT_BITRATE (2 * 1024)
|
||||
|
@ -476,10 +476,10 @@ gst_mf_h264_enc_class_init (GstMFH264EncClass * klass, gpointer data)
|
|||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
if (device_caps->d3d11_aware) {
|
||||
g_object_class_install_property (gobject_class, PROP_ADAPTER,
|
||||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, device_caps->adapter,
|
||||
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",
|
||||
G_MININT64, G_MAXINT64, device_caps->adapter_luid,
|
||||
(GParamFlags) (GST_PARAM_CONDITIONALLY_AVAILABLE |
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
}
|
||||
|
@ -629,8 +629,8 @@ gst_mf_h264_enc_get_property (GObject * object, guint prop_id,
|
|||
case PROP_D3D11_AWARE:
|
||||
g_value_set_boolean (value, klass->device_caps.d3d11_aware);
|
||||
break;
|
||||
case PROP_ADAPTER:
|
||||
g_value_set_uint (value, klass->device_caps.adapter);
|
||||
case PROP_ADAPTER_LUID:
|
||||
g_value_set_int64 (value, klass->device_caps.adapter_luid);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
|
@ -118,7 +118,7 @@ enum
|
|||
PROP_QP_B,
|
||||
PROP_REF,
|
||||
PROP_D3D11_AWARE,
|
||||
PROP_ADAPTER,
|
||||
PROP_ADAPTER_LUID,
|
||||
};
|
||||
|
||||
#define DEFAULT_BITRATE (2 * 1024)
|
||||
|
@ -364,10 +364,10 @@ gst_mf_h265_enc_class_init (GstMFH265EncClass * klass, gpointer data)
|
|||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
if (device_caps->d3d11_aware) {
|
||||
g_object_class_install_property (gobject_class, PROP_ADAPTER,
|
||||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, device_caps->adapter,
|
||||
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",
|
||||
G_MININT64, G_MAXINT64, device_caps->adapter_luid,
|
||||
(GParamFlags) (GST_PARAM_CONDITIONALLY_AVAILABLE |
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
}
|
||||
|
@ -487,8 +487,8 @@ gst_mf_h265_enc_get_property (GObject * object, guint prop_id,
|
|||
case PROP_D3D11_AWARE:
|
||||
g_value_set_boolean (value, klass->device_caps.d3d11_aware);
|
||||
break;
|
||||
case PROP_ADAPTER:
|
||||
g_value_set_uint (value, klass->device_caps.adapter);
|
||||
case PROP_ADAPTER_LUID:
|
||||
g_value_set_int64 (value, klass->device_caps.adapter_luid);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
|
@ -120,8 +120,13 @@ gst_mf_video_enc_set_context (GstElement * element, GstContext * context)
|
|||
{
|
||||
#if GST_MF_HAVE_D3D11
|
||||
GstMFVideoEnc *self = GST_MF_VIDEO_ENC (element);
|
||||
GstMFVideoEncClass *klass = GST_MF_VIDEO_ENC_GET_CLASS (self);
|
||||
GstMFVideoEncDeviceCaps *device_caps = &klass->device_caps;
|
||||
|
||||
gst_d3d11_handle_set_context (element, context, 0, &self->other_d3d11_device);
|
||||
if (device_caps->d3d11_aware) {
|
||||
gst_d3d11_handle_set_context_for_adapter_luid (element, context,
|
||||
device_caps->adapter_luid, &self->other_d3d11_device);
|
||||
}
|
||||
#endif
|
||||
|
||||
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
|
||||
|
@ -134,7 +139,6 @@ gst_mf_video_enc_open (GstVideoEncoder * enc)
|
|||
GstMFVideoEncClass *klass = GST_MF_VIDEO_ENC_GET_CLASS (enc);
|
||||
GstMFVideoEncDeviceCaps *device_caps = &klass->device_caps;
|
||||
GstMFTransformEnumParams enum_params = { 0, };
|
||||
gint64 adapter_luid = 0;
|
||||
MFT_REGISTER_TYPE_INFO output_type;
|
||||
gboolean ret;
|
||||
|
||||
|
@ -145,14 +149,15 @@ gst_mf_video_enc_open (GstVideoEncoder * enc)
|
|||
ComPtr < ID3D10Multithread > multi_thread;
|
||||
GstD3D11Device *device;
|
||||
|
||||
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self),
|
||||
device_caps->adapter, &self->other_d3d11_device)) {
|
||||
if (!gst_d3d11_ensure_element_data_for_adapter_luid (GST_ELEMENT (self),
|
||||
device_caps->adapter_luid, &self->other_d3d11_device)) {
|
||||
GST_ERROR_OBJECT (self, "Other d3d11 device is unavailable");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create our own device with D3D11_CREATE_DEVICE_VIDEO_SUPPORT */
|
||||
self->d3d11_device = gst_d3d11_device_new (device_caps->adapter,
|
||||
self->d3d11_device =
|
||||
gst_d3d11_device_new_for_adapter_luid (device_caps->adapter_luid,
|
||||
D3D11_CREATE_DEVICE_VIDEO_SUPPORT);
|
||||
if (!self->d3d11_device) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't create internal d3d11 device");
|
||||
|
@ -191,8 +196,6 @@ gst_mf_video_enc_open (GstVideoEncoder * enc)
|
|||
gst_clear_object (&self->d3d11_device);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_get (self->d3d11_device, "adapter-luid", &adapter_luid, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -205,12 +208,12 @@ gst_mf_video_enc_open (GstVideoEncoder * enc)
|
|||
enum_params.device_index = klass->device_index;
|
||||
|
||||
if (device_caps->d3d11_aware)
|
||||
enum_params.adapter_luid = adapter_luid;
|
||||
enum_params.adapter_luid = device_caps->adapter_luid;
|
||||
|
||||
GST_DEBUG_OBJECT (self,
|
||||
"Create MFT with enum flags: 0x%x, device index: %d, d3d11 aware: %d, "
|
||||
"adapter-luid %" G_GINT64_FORMAT, klass->enum_flags, klass->device_index,
|
||||
device_caps->d3d11_aware, adapter_luid);
|
||||
device_caps->d3d11_aware, device_caps->adapter_luid);
|
||||
|
||||
self->transform = gst_mf_transform_new (&enum_params);
|
||||
ret = !!self->transform;
|
||||
|
@ -1692,10 +1695,10 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
|
|||
}
|
||||
|
||||
if (d3d11_device && (have_NV12 || have_P010) && d3d11_aware) {
|
||||
guint adapter = 0;
|
||||
gint64 adapter_luid = 0;
|
||||
GValue d3d11_formats = G_VALUE_INIT;
|
||||
|
||||
g_object_get (d3d11_device, "adapter", &adapter, NULL);
|
||||
g_object_get (d3d11_device, "adapter-luid", &adapter_luid, NULL);
|
||||
|
||||
d3d11_caps = gst_caps_copy (sink_caps);
|
||||
|
||||
|
@ -1719,7 +1722,7 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
|
|||
gst_caps_set_features_simple (d3d11_caps,
|
||||
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY));
|
||||
device_caps->d3d11_aware = TRUE;
|
||||
device_caps->adapter = adapter;
|
||||
device_caps->adapter_luid = adapter_luid;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ struct _GstMFVideoEncDeviceCaps
|
|||
|
||||
/* TRUE if MFT support d3d11 and also we can use d3d11 interop */
|
||||
gboolean d3d11_aware;
|
||||
/* DXGI adapter index to use, ignored if d3d11-unaware */
|
||||
guint adapter;
|
||||
/* DXGI adapter LUID, valid only when d3d11_aware == TRUE */
|
||||
gint64 adapter_luid;
|
||||
};
|
||||
|
||||
struct _GstMFVideoEncClassData
|
||||
|
|
|
@ -108,7 +108,7 @@ enum
|
|||
PROP_CONTENT_TYPE,
|
||||
PROP_LOW_LATENCY,
|
||||
PROP_D3D11_AWARE,
|
||||
PROP_ADAPTER,
|
||||
PROP_ADAPTER_LUID,
|
||||
};
|
||||
|
||||
#define DEFAULT_BITRATE (2 * 1024)
|
||||
|
@ -261,10 +261,10 @@ gst_mf_vp9_enc_class_init (GstMFVP9EncClass * klass, gpointer data)
|
|||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
if (device_caps->d3d11_aware) {
|
||||
g_object_class_install_property (gobject_class, PROP_ADAPTER,
|
||||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, device_caps->adapter,
|
||||
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",
|
||||
G_MININT64, G_MAXINT64, device_caps->adapter_luid,
|
||||
(GParamFlags) (GST_PARAM_CONDITIONALLY_AVAILABLE |
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
}
|
||||
|
@ -349,8 +349,8 @@ gst_mf_vp9_enc_get_property (GObject * object, guint prop_id,
|
|||
case PROP_D3D11_AWARE:
|
||||
g_value_set_boolean (value, klass->device_caps.d3d11_aware);
|
||||
break;
|
||||
case PROP_ADAPTER:
|
||||
g_value_set_uint (value, klass->device_caps.adapter);
|
||||
case PROP_ADAPTER_LUID:
|
||||
g_value_set_int64 (value, klass->device_caps.adapter_luid);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
Loading…
Reference in a new issue