static void _vk_display_context_query (GstElement * element, GstVulkanDisplay ** display_ptr) { gst_vulkan_global_context_query (element, GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR); }
gboolean gst_vulkan_ensure_element_data (gpointer element, GstVulkanDisplay ** display_ptr, GstVulkanInstance ** instance_ptr) { g_return_val_if_fail (element != NULL, FALSE); g_return_val_if_fail (display_ptr != NULL, FALSE); g_return_val_if_fail (instance_ptr != NULL, FALSE); /* 1) Check if the element already has a context of the specific * type. */ if (!*instance_ptr) { GError *error = NULL; gst_vulkan_global_context_query (element, GST_VULKAN_INSTANCE_CONTEXT_TYPE_STR); /* Neighbour found and it updated the display */ if (!*instance_ptr) { GstContext *context; /* If no neighboor, or application not interested, use system default */ *instance_ptr = gst_vulkan_instance_new (); context = gst_context_new (GST_VULKAN_INSTANCE_CONTEXT_TYPE_STR, TRUE); gst_context_set_vulkan_instance (context, *instance_ptr); _vk_context_propagate (element, context); } if (!gst_vulkan_instance_open (*instance_ptr, &error)) { GST_ELEMENT_ERROR (element, RESOURCE, NOT_FOUND, ("Failed to create vulkan instance"), ("%s", error->message)); g_clear_error (&error); return FALSE; } } if (!*display_ptr) { _vk_display_context_query (element, display_ptr); /* Neighbour found and it updated the display */ if (!*display_ptr) { GstContext *context; /* instance is required before the display */ g_return_val_if_fail (*instance_ptr != NULL, FALSE); /* If no neighboor, or application not interested, use system default */ *display_ptr = gst_vulkan_display_new (*instance_ptr); context = gst_context_new (GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR, TRUE); gst_context_set_vulkan_display (context, *display_ptr); _vk_context_propagate (element, context); } } return *display_ptr != NULL && *instance_ptr != NULL; }
gboolean gst_vulkan_instance_run_context_query (GstElement * element, GstVulkanInstance ** instance) { g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (instance != NULL, FALSE); if (*instance && GST_IS_VULKAN_INSTANCE (*instance)) return TRUE; gst_vulkan_global_context_query (element, GST_VULKAN_INSTANCE_CONTEXT_TYPE_STR); GST_DEBUG_OBJECT (element, "found instance %p", *instance); if (*instance) return TRUE; return FALSE; }