diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c b/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c index 4a2fa8cf5f..eca04fc5ef 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c @@ -544,37 +544,6 @@ struct choose_data GstVulkanQueue *queue; }; -static gboolean -_choose_queue (GstVulkanDevice * device, GstVulkanQueue * queue, - struct choose_data *data) -{ - guint flags = - device->physical_device->queue_family_props[queue->family].queueFlags; - - if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { - if (data->queue) - gst_object_unref (data->queue); - data->queue = gst_object_ref (queue); - return FALSE; - } - - return TRUE; -} - -static GstVulkanQueue * -_find_graphics_queue (GstVulkanDownload * download) -{ - struct choose_data data; - - data.download = download; - data.queue = NULL; - - gst_vulkan_device_foreach_queue (download->device, - (GstVulkanDeviceForEachQueueFunc) _choose_queue, &data); - - return data.queue; -} - static GstStateChangeReturn gst_vulkan_download_change_state (GstElement * element, GstStateChange transition) @@ -615,7 +584,9 @@ gst_vulkan_download_change_state (GstElement * element, if (!gst_vulkan_queue_run_context_query (GST_ELEMENT (vk_download), &vk_download->queue)) { GST_DEBUG_OBJECT (vk_download, "No queue retrieved from peer elements"); - vk_download->queue = _find_graphics_queue (vk_download); + vk_download->queue = + gst_vulkan_device_select_queue (vk_download->device, + VK_QUEUE_GRAPHICS_BIT); } if (!vk_download->queue) { GST_ELEMENT_ERROR (vk_download, RESOURCE, NOT_FOUND, diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c b/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c index 79c632745d..c89ead4e51 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c @@ -1221,43 +1221,6 @@ gst_vulkan_upload_set_context (GstElement * element, GstContext * context) GST_ELEMENT_CLASS (parent_class)->set_context (element, context); } -struct choose_data -{ - GstVulkanUpload *upload; - GstVulkanQueue *queue; -}; - -static gboolean -_choose_queue (GstVulkanDevice * device, GstVulkanQueue * queue, - struct choose_data *data) -{ - guint flags = - device->physical_device->queue_family_props[queue->family].queueFlags; - - if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { - if (data->queue) - gst_object_unref (data->queue); - data->queue = gst_object_ref (queue); - return FALSE; - } - - return TRUE; -} - -static GstVulkanQueue * -_find_graphics_queue (GstVulkanUpload * upload) -{ - struct choose_data data; - - data.upload = upload; - data.queue = NULL; - - gst_vulkan_device_foreach_queue (upload->device, - (GstVulkanDeviceForEachQueueFunc) _choose_queue, &data); - - return data.queue; -} - static GstStateChangeReturn gst_vulkan_upload_change_state (GstElement * element, GstStateChange transition) { @@ -1295,7 +1258,9 @@ gst_vulkan_upload_change_state (GstElement * element, GstStateChange transition) if (!gst_vulkan_queue_run_context_query (GST_ELEMENT (vk_upload), &vk_upload->queue)) { GST_DEBUG_OBJECT (vk_upload, "No queue retrieved from peer elements"); - vk_upload->queue = _find_graphics_queue (vk_upload); + vk_upload->queue = + gst_vulkan_device_select_queue (vk_upload->device, + VK_QUEUE_GRAPHICS_BIT); } if (!vk_upload->queue) { GST_ELEMENT_ERROR (vk_upload, RESOURCE, NOT_FOUND, diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c index eb5070db32..d8ae14a585 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c @@ -318,24 +318,6 @@ image_failed: } } -#if defined(VK_KHR_synchronization2) -static gboolean -_choose_queue (GstVulkanDevice * device, GstVulkanQueue * _queue, - gpointer user_data) -{ - GstVulkanQueue **queue = user_data; - guint flags = - device->physical_device->queue_family_props[_queue->family].queueFlags; - - if ((flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT)) != 0) { - *queue = gst_object_ref (_queue); - return FALSE; - } - - return TRUE; -} -#endif - static gboolean prepare_buffer (GstVulkanImageBufferPool * vk_pool, GstBuffer * buffer) { @@ -350,7 +332,9 @@ prepare_buffer (GstVulkanImageBufferPool * vk_pool, GstBuffer * buffer) GstVulkanCommandPool *cmd_pool; GstVulkanQueue *queue = NULL; - gst_vulkan_device_foreach_queue (vk_pool->device, _choose_queue, &queue); + queue = + gst_vulkan_device_select_queue (vk_pool->device, + VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT); if (!queue) return FALSE; cmd_pool = gst_vulkan_queue_create_command_pool (queue, &error); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideofilter.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideofilter.c index 079e9a2b5a..1e28436597 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideofilter.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideofilter.c @@ -165,37 +165,6 @@ struct choose_data GstVulkanQueue *queue; }; -static gboolean -_choose_queue (GstVulkanDevice * device, GstVulkanQueue * queue, - struct choose_data *data) -{ - guint flags = - device->physical_device->queue_family_props[queue->family].queueFlags; - - if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { - if (data->queue) - gst_object_unref (data->queue); - data->queue = gst_object_ref (queue); - return FALSE; - } - - return TRUE; -} - -static GstVulkanQueue * -_find_graphics_queue (GstVulkanVideoFilter * filter) -{ - struct choose_data data; - - data.filter = filter; - data.queue = NULL; - - gst_vulkan_device_foreach_queue (filter->device, - (GstVulkanDeviceForEachQueueFunc) _choose_queue, &data); - - return data.queue; -} - static GstCaps * gst_vulkan_video_filter_transform_caps (GstBaseTransform * bt, GstPadDirection direction, GstCaps * caps, GstCaps * filter) @@ -318,7 +287,8 @@ gst_vulkan_video_filter_start (GstBaseTransform * bt) if (!gst_vulkan_queue_run_context_query (GST_ELEMENT (render), &render->queue)) { GST_DEBUG_OBJECT (render, "No queue retrieved from peer elements"); - render->queue = _find_graphics_queue (render); + render->queue = + gst_vulkan_device_select_queue (render->device, VK_QUEUE_GRAPHICS_BIT); } if (!render->queue) return FALSE; diff --git a/subprojects/gst-plugins-bad/tests/check/libs/vkimagebufferpool.c b/subprojects/gst-plugins-bad/tests/check/libs/vkimagebufferpool.c index 374b963f2a..8bd5cc5b1a 100644 --- a/subprojects/gst-plugins-bad/tests/check/libs/vkimagebufferpool.c +++ b/subprojects/gst-plugins-bad/tests/check/libs/vkimagebufferpool.c @@ -35,6 +35,11 @@ setup (void) { instance = gst_vulkan_instance_new (); fail_unless (gst_vulkan_instance_open (instance, NULL)); + + device = gst_vulkan_device_new_with_index (instance, 0); + fail_unless (gst_vulkan_device_open (device, NULL)); + + queue = gst_vulkan_device_select_queue (device, VK_QUEUE_COMPUTE_BIT); } static void @@ -45,37 +50,10 @@ teardown (void) gst_object_unref (instance); } -static gboolean -_choose_queue (GstVulkanDevice * device, GstVulkanQueue * _queue, gpointer data) -{ - guint flags = - device->physical_device->queue_family_props[_queue->family].queueFlags; - guint expected_flags = GPOINTER_TO_UINT (data); - - if ((flags & expected_flags) != 0) { - gst_object_replace ((GstObject **) & queue, GST_OBJECT_CAST (_queue)); - return FALSE; - } - - return TRUE; -} - static void setup_queue (guint expected_flags) { - int i; - - gst_clear_object (&queue); - - for (i = 0; i < instance->n_physical_devices; i++) { - device = gst_vulkan_device_new_with_index (instance, i); - fail_unless (gst_vulkan_device_open (device, NULL)); - gst_vulkan_device_foreach_queue (device, _choose_queue, - GUINT_TO_POINTER (expected_flags)); - if (queue && GST_IS_VULKAN_QUEUE (queue)) - break; - gst_object_unref (device); - } + queue = gst_vulkan_device_select_queue (device, VK_QUEUE_COMPUTE_BIT); fail_unless (GST_IS_VULKAN_QUEUE (queue)); } @@ -193,7 +171,18 @@ GST_START_TEST (test_decoding_image) /* *INDENT-ON* */ /* force to use a queue with decoding support */ - setup_queue (VK_QUEUE_VIDEO_DECODE_BIT_KHR); + if (queue && (device->physical_device->queue_family_ops[queue->family].video + & VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) == 0) + gst_clear_object (&queue); + + if (!queue) { + queue = + gst_vulkan_device_select_queue (device, VK_QUEUE_VIDEO_DECODE_BIT_KHR); + } + + if (!queue) + return; + if ((device->physical_device->queue_family_ops[queue->family].video & VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) == 0) return;