mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
vkinstance: add signal for overriding device creation
This commit is contained in:
parent
300f4e03b2
commit
0bcb3cdd29
3 changed files with 53 additions and 5 deletions
|
@ -45,6 +45,15 @@ GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
||||||
GST_DEBUG_CATEGORY (GST_VULKAN_DEBUG_CAT);
|
GST_DEBUG_CATEGORY (GST_VULKAN_DEBUG_CAT);
|
||||||
GST_DEBUG_CATEGORY (GST_CAT_CONTEXT);
|
GST_DEBUG_CATEGORY (GST_CAT_CONTEXT);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SIGNAL_0,
|
||||||
|
SIGNAL_CREATE_DEVICE,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint gst_vulkan_instance_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
#define gst_vulkan_instance_parent_class parent_class
|
#define gst_vulkan_instance_parent_class parent_class
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanInstance, gst_vulkan_instance,
|
G_DEFINE_TYPE_WITH_CODE (GstVulkanInstance, gst_vulkan_instance,
|
||||||
GST_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
|
GST_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
|
||||||
|
@ -74,15 +83,29 @@ gst_vulkan_instance_init (GstVulkanInstance * instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vulkan_instance_class_init (GstVulkanInstanceClass * instance_class)
|
gst_vulkan_instance_class_init (GstVulkanInstanceClass * klass)
|
||||||
{
|
{
|
||||||
gst_vulkan_memory_init_once ();
|
gst_vulkan_memory_init_once ();
|
||||||
gst_vulkan_image_memory_init_once ();
|
gst_vulkan_image_memory_init_once ();
|
||||||
gst_vulkan_buffer_memory_init_once ();
|
gst_vulkan_buffer_memory_init_once ();
|
||||||
|
|
||||||
g_type_class_add_private (instance_class, sizeof (GstVulkanInstancePrivate));
|
g_type_class_add_private (klass, sizeof (GstVulkanInstancePrivate));
|
||||||
|
|
||||||
G_OBJECT_CLASS (instance_class)->finalize = gst_vulkan_instance_finalize;
|
/**
|
||||||
|
* GstVulkanInstance::create-device:
|
||||||
|
* @object: the #GstVulkanDisplay
|
||||||
|
*
|
||||||
|
* Overrides the #GstVulkanDevice creation mechanism.
|
||||||
|
* It can be called from any thread.
|
||||||
|
*
|
||||||
|
* Returns: the newly created #GstVulkanDevice.
|
||||||
|
*/
|
||||||
|
gst_vulkan_instance_signals[SIGNAL_CREATE_DEVICE] =
|
||||||
|
g_signal_new ("create-device", G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
||||||
|
GST_TYPE_VULKAN_DEVICE, 0);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (klass)->finalize = gst_vulkan_instance_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -383,6 +406,28 @@ gst_vulkan_instance_get_proc_address (GstVulkanInstance * instance,
|
||||||
return vkGetInstanceProcAddr (instance->instance, name);
|
return vkGetInstanceProcAddr (instance->instance, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstVulkanDevice *
|
||||||
|
gst_vulkan_instance_create_device (GstVulkanInstance * instance,
|
||||||
|
GError ** error)
|
||||||
|
{
|
||||||
|
GstVulkanDevice *device;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_VULKAN_INSTANCE (instance), NULL);
|
||||||
|
|
||||||
|
g_signal_emit (instance, gst_vulkan_instance_signals[SIGNAL_CREATE_DEVICE], 0,
|
||||||
|
&device);
|
||||||
|
|
||||||
|
if (!device)
|
||||||
|
device = gst_vulkan_device_new (instance);
|
||||||
|
|
||||||
|
if (!gst_vulkan_device_open (device, error)) {
|
||||||
|
gst_object_unref (device);
|
||||||
|
device = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_context_set_vulkan_instance:
|
* gst_context_set_vulkan_instance:
|
||||||
* @context: a #GstContext
|
* @context: a #GstContext
|
||||||
|
|
|
@ -63,6 +63,9 @@ gboolean gst_vulkan_instance_open (GstVulkanInstance *
|
||||||
gpointer gst_vulkan_instance_get_proc_address (GstVulkanInstance * instance,
|
gpointer gst_vulkan_instance_get_proc_address (GstVulkanInstance * instance,
|
||||||
const gchar * name);
|
const gchar * name);
|
||||||
|
|
||||||
|
GstVulkanDevice * gst_vulkan_instance_create_device (GstVulkanInstance * instance,
|
||||||
|
GError ** error);
|
||||||
|
|
||||||
void gst_context_set_vulkan_instance (GstContext * context,
|
void gst_context_set_vulkan_instance (GstContext * context,
|
||||||
GstVulkanInstance * instance);
|
GstVulkanInstance * instance);
|
||||||
gboolean gst_context_get_vulkan_instance (GstContext * context,
|
gboolean gst_context_get_vulkan_instance (GstContext * context,
|
||||||
|
|
|
@ -258,8 +258,8 @@ gst_vulkan_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk_sink->device = gst_vulkan_device_new (vk_sink->instance);
|
if (!(vk_sink->device =
|
||||||
if (!gst_vulkan_device_open (vk_sink->device, &error)) {
|
gst_vulkan_instance_create_device (vk_sink->instance, &error))) {
|
||||||
GST_ELEMENT_ERROR (vk_sink, RESOURCE, NOT_FOUND,
|
GST_ELEMENT_ERROR (vk_sink, RESOURCE, NOT_FOUND,
|
||||||
("Failed to create vulkan device"), ("%s", error->message));
|
("Failed to create vulkan device"), ("%s", error->message));
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
|
Loading…
Reference in a new issue