mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
test: look for proper queue among multiple physical device
There might be multiple GPUs in a system and only one might provided vulkan video extensions. Now, in order to run the tests, the proper GPU is looked. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4850>
This commit is contained in:
parent
221811119a
commit
23a144dcec
1 changed files with 32 additions and 32 deletions
|
@ -30,17 +30,27 @@ static GstVulkanInstance *instance;
|
||||||
static GstVulkanDevice *device;
|
static GstVulkanDevice *device;
|
||||||
static GstVulkanQueue *queue = NULL;
|
static GstVulkanQueue *queue = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup (void)
|
||||||
|
{
|
||||||
|
instance = gst_vulkan_instance_new ();
|
||||||
|
fail_unless (gst_vulkan_instance_open (instance, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
teardown (void)
|
||||||
|
{
|
||||||
|
gst_clear_object (&queue);
|
||||||
|
gst_clear_object (&device);
|
||||||
|
gst_object_unref (instance);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_choose_queue (GstVulkanDevice * device, GstVulkanQueue * _queue, gpointer data)
|
_choose_queue (GstVulkanDevice * device, GstVulkanQueue * _queue, gpointer data)
|
||||||
{
|
{
|
||||||
guint flags =
|
guint flags =
|
||||||
device->physical_device->queue_family_props[_queue->family].queueFlags;
|
device->physical_device->queue_family_props[_queue->family].queueFlags;
|
||||||
guint expected_flags = VK_QUEUE_COMPUTE_BIT;
|
guint expected_flags = GPOINTER_TO_UINT (data);
|
||||||
|
|
||||||
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
|
|
||||||
if (data)
|
|
||||||
expected_flags = VK_QUEUE_VIDEO_DECODE_BIT_KHR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((flags & expected_flags) != 0) {
|
if ((flags & expected_flags) != 0) {
|
||||||
gst_object_replace ((GstObject **) & queue, GST_OBJECT_CAST (_queue));
|
gst_object_replace ((GstObject **) & queue, GST_OBJECT_CAST (_queue));
|
||||||
|
@ -51,23 +61,23 @@ _choose_queue (GstVulkanDevice * device, GstVulkanQueue * _queue, gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup (void)
|
setup_queue (guint expected_flags)
|
||||||
{
|
{
|
||||||
instance = gst_vulkan_instance_new ();
|
int i;
|
||||||
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));
|
|
||||||
|
|
||||||
gst_vulkan_device_foreach_queue (device, _choose_queue, NULL);
|
|
||||||
fail_unless (GST_IS_VULKAN_QUEUE (queue));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
teardown (void)
|
|
||||||
{
|
|
||||||
gst_clear_object (&queue);
|
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);
|
gst_object_unref (device);
|
||||||
gst_object_unref (instance);
|
}
|
||||||
|
|
||||||
|
fail_unless (GST_IS_VULKAN_QUEUE (queue));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBufferPool *
|
static GstBufferPool *
|
||||||
|
@ -108,6 +118,7 @@ GST_START_TEST (test_image)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstBuffer *buffer = NULL;
|
GstBuffer *buffer = NULL;
|
||||||
|
|
||||||
|
setup_queue (VK_QUEUE_COMPUTE_BIT);
|
||||||
pool = create_buffer_pool ("NV12", 0, NULL);
|
pool = create_buffer_pool ("NV12", 0, NULL);
|
||||||
|
|
||||||
ret = gst_buffer_pool_acquire_buffer (pool, &buffer, NULL);
|
ret = gst_buffer_pool_acquire_buffer (pool, &buffer, NULL);
|
||||||
|
@ -182,18 +193,7 @@ GST_START_TEST (test_decoding_image)
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
/* force to use a queue with decoding support */
|
/* force to use a queue with decoding support */
|
||||||
if (queue && (device->physical_device->queue_family_ops[queue->family].video
|
setup_queue (VK_QUEUE_VIDEO_DECODE_BIT_KHR);
|
||||||
& VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) == 0)
|
|
||||||
gst_clear_object (&queue);
|
|
||||||
|
|
||||||
if (!queue) {
|
|
||||||
gst_vulkan_device_foreach_queue (device, _choose_queue,
|
|
||||||
GUINT_TO_POINTER (1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!queue)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((device->physical_device->queue_family_ops[queue->family].video
|
if ((device->physical_device->queue_family_ops[queue->family].video
|
||||||
& VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) == 0)
|
& VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue