From 9736b9e7b71f04e9cceab40590d6f622fb25e88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 21 Dec 2023 09:32:25 +0100 Subject: [PATCH] vulkan{up,down}load: check for a graphics family queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vulkan queue retrieved from peer elements should be a graphics family one. Otherwise, get a compatible queue from the given device. Co-Authored-By: Víctor Jáquez Part-of: --- .../gst-plugins-bad/ext/vulkan/vkdownload.c | 19 +++++++++++++--- .../gst-plugins-bad/ext/vulkan/vkupload.c | 22 +++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c b/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c index 37fbf39755..eec8497c87 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkdownload.c @@ -585,16 +585,29 @@ gst_vulkan_download_change_state (GstElement * element, } } - if (!gst_vulkan_queue_run_context_query (GST_ELEMENT (vk_download), + 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"); + guint32 flags, idx; + + GST_DEBUG_OBJECT (vk_download, "Queue retrieved from peer elements"); + idx = vk_download->queue->family; + flags = vk_download->device->physical_device->queue_family_props[idx] + .queueFlags; + if ((flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) == 0) { + GST_DEBUG_OBJECT (vk_download, + "Queue does not support VK_QUEUE_GRAPHICS_BIT with VK_QUEUE_TRANSFER_BIT"); + gst_clear_object (&vk_download->queue); + } + } + + if (!vk_download->queue) { 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, - ("Failed to create/retrieve vulkan queue"), (NULL)); + ("Failed to create/retrieve a valid vulkan queue"), (NULL)); return GST_STATE_CHANGE_FAILURE; } break; diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c b/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c index 27eaecadfb..d14e870744 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkupload.c @@ -1165,17 +1165,31 @@ gst_vulkan_upload_change_state (GstElement * element, GstStateChange transition) return GST_STATE_CHANGE_FAILURE; } } - - if (!gst_vulkan_queue_run_context_query (GST_ELEMENT (vk_upload), + // Issue with NVIDIA driver where the output gets artifacts if I select another + // queue seen the codec one does not support VK_QUEUE_GRAPHICS_BIT but VK_QUEUE_TRANSFER_BIT. + 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"); + guint32 flags, idx; + + GST_DEBUG_OBJECT (vk_upload, "Queue retrieved from peer elements"); + idx = vk_upload->queue->family; + flags = vk_upload->device->physical_device->queue_family_props[idx] + .queueFlags; + if ((flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) == 0) { + GST_DEBUG_OBJECT (vk_upload, + "Queue does not support VK_QUEUE_GRAPHICS_BIT with VK_QUEUE_TRANSFER_BIT"); + gst_clear_object (&vk_upload->queue); + } + } + + if (!vk_upload->queue) { 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, - ("Failed to create/retrieve vulkan queue"), (NULL)); + ("Failed to create/retrieve a valid vulkan queue"), (NULL)); return GST_STATE_CHANGE_FAILURE; } break;