vkinstance: Don't abort in case that system has no available vulkan device
authorSeungha Yang <seungha@centricular.com>
Thu, 3 Jun 2021 16:44:47 +0000 (01:44 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 4 Jun 2021 07:44:36 +0000 (07:44 +0000)
Specification doesn't have restriction that returned
pPhysicalDeviceCount value must be non-zero

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2304>

gst-libs/gst/vulkan/gstvkinstance.c

index 14db329..46f9148 100644 (file)
@@ -975,7 +975,15 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
   if (gst_vulkan_error_to_g_error (err, error,
           "vkEnumeratePhysicalDevices") < 0)
     goto error;
-  g_assert (instance->n_physical_devices > 0);
+
+  if (instance->n_physical_devices == 0) {
+    GST_WARNING_OBJECT (instance, "No available physical device");
+    g_set_error_literal (error,
+        GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
+        "No available physical device");
+    goto error;
+  }
+
   instance->physical_devices =
       g_new0 (VkPhysicalDevice, instance->n_physical_devices);
   err =