vkdevice: add gst_vulkan_device_queue_family_indices()

This method will return a GArray with all the queue family indices created by
the device when it's opened. This array will be used by VkImageCreateInfo to
allocate a new Vulkan image.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4351>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-03-28 15:31:19 +02:00 committed by GStreamer Marge Bot
parent ea2bd1882f
commit 7b62c26139
2 changed files with 54 additions and 0 deletions

View file

@ -60,6 +60,7 @@ struct _GstVulkanDevicePrivate
gboolean opened;
GArray *queues;
GArray *queue_family_indices;
GstVulkanFenceCache *fence_cache;
};
@ -214,6 +215,11 @@ gst_vulkan_device_dispose (GObject * object)
GstVulkanDevice *device = GST_VULKAN_DEVICE (object);
GstVulkanDevicePrivate *priv = GET_PRIV (device);
if (priv->queue_family_indices) {
g_array_unref (priv->queue_family_indices);
priv->queue_family_indices = NULL;
}
if (priv->queues) {
g_array_unref (priv->queues);
priv->queues = NULL;
@ -556,6 +562,51 @@ gst_vulkan_device_foreach_queue (GstVulkanDevice * device,
}
}
/**
* gst_vulkan_device_queue_family_indices:
* @device: a #GstVulkanDevice
*
* Returns: (element-type uint32_t) (transfer full): An array with the family
* indexes of the created queues in @device
*
* Since: 1.24
*/
GArray *
gst_vulkan_device_queue_family_indices (GstVulkanDevice * device)
{
GstVulkanDevicePrivate *priv = GET_PRIV (device);
guint i, j;
g_return_val_if_fail (GST_IS_VULKAN_DEVICE (device), NULL);
g_return_val_if_fail (priv->opened, NULL);
GST_OBJECT_LOCK (device);
if (priv->queue_family_indices)
goto beach;
priv->queue_family_indices =
g_array_sized_new (FALSE, FALSE, sizeof (uint32_t), priv->queues->len);
for (i = 0; i < priv->queues->len; i++) {
VkDeviceQueueCreateInfo *qi =
&g_array_index (priv->queues, VkDeviceQueueCreateInfo, i);
for (j = 0; j < priv->queue_family_indices->len; j++) {
uint32_t qfi = g_array_index (priv->queue_family_indices, uint32_t, j);
if (qfi == qi->queueFamilyIndex)
break;
}
if (j == priv->queue_family_indices->len)
g_array_append_val (priv->queue_family_indices, qi->queueFamilyIndex);
}
beach:
GST_OBJECT_UNLOCK (device);
return g_array_ref (priv->queue_family_indices);
}
/**
* gst_vulkan_device_get_proc_address:
* @device: a #GstVulkanDevice

View file

@ -123,6 +123,9 @@ GST_VULKAN_API
GstVulkanQueue * gst_vulkan_device_get_queue (GstVulkanDevice * device,
guint32 queue_family,
guint32 queue_i);
GST_VULKAN_API
GArray * gst_vulkan_device_queue_family_indices (GstVulkanDevice * device);
GST_VULKAN_API
VkPhysicalDevice gst_vulkan_device_get_physical_device (GstVulkanDevice * device);