vulkan: don't g_error when failing to find validation layers

Aborting the application is never a good thing to do for recoverable errors.

Just warn and error out instead.

https://bugzilla.gnome.org/show_bug.cgi?id=764545
This commit is contained in:
Matthew Waters 2016-04-08 17:41:07 +10:00
parent dc1a326090
commit b32ca4b550
2 changed files with 34 additions and 41 deletions

View file

@ -159,10 +159,10 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
uint32_t device_extension_count = 0;
VkExtensionProperties *device_extensions = NULL;
uint32_t enabled_layer_count = 0;
gchar **enabled_layers;
uint32_t device_layer_count = 0;
VkLayerProperties *device_layers;
gboolean have_swapchain_ext;
gboolean validation_found;
VkPhysicalDevice gpu;
VkResult err;
guint i;
@ -197,26 +197,20 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
goto error;
}
validation_found =
_check_for_all_layers (G_N_ELEMENTS (device_validation_layers),
device_validation_layers, device_layer_count, device_layers);
_check_for_all_layers (G_N_ELEMENTS (device_validation_layers),
device_validation_layers, device_layer_count, device_layers,
&enabled_layer_count, &enabled_layers);
g_free (device_layers);
device_layers = NULL;
if (!validation_found) {
g_error ("vkEnumerateDeviceLayerProperties failed to find"
"a required validation layer.\n\n"
"Please look at the Getting Started guide for additional "
"information.\nvkCreateDevice Failure");
goto error;
}
enabled_layer_count = G_N_ELEMENTS (device_validation_layers);
err =
vkEnumerateDeviceExtensionProperties (gpu, NULL,
&device_extension_count, NULL);
if (gst_vulkan_error_to_g_error (err, error,
"vkEnumerateDeviceExtensionProperties") < 0)
"vkEnumerateDeviceExtensionProperties") < 0) {
g_strfreev (enabled_layers);
goto error;
}
GST_DEBUG_OBJECT (device, "Found %u extensions", device_extension_count);
have_swapchain_ext = 0;
@ -227,6 +221,7 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
&device_extension_count, device_extensions);
if (gst_vulkan_error_to_g_error (err, error,
"vkEnumerateDeviceExtensionProperties") < 0) {
g_strfreev (enabled_layers);
g_free (device_extensions);
goto error;
}
@ -243,12 +238,12 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
g_assert (enabled_extension_count < 64);
}
if (!have_swapchain_ext) {
g_error ("vkEnumerateDeviceExtensionProperties failed to find the \""
VK_KHR_SWAPCHAIN_EXTENSION_NAME
"\" extension.\n\nDo you have a compatible "
"Vulkan installable client driver (ICD) installed?\nPlease "
"look at the Getting Started guide for additional "
"information.\nvkCreateInstance Failure");
g_set_error_literal (error, GST_VULKAN_ERROR,
VK_ERROR_EXTENSION_NOT_PRESENT,
"Failed to find required extension, \"" VK_KHR_SWAPCHAIN_EXTENSION_NAME
"\"");
g_strfreev (enabled_layers);
goto error;
}
g_free (device_extensions);
@ -273,6 +268,7 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
if (i >= device->n_queue_families) {
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"Failed to find a compatible queue family");
g_strfreev (enabled_layers);
goto error;
}
device->queue_family_id = i;
@ -294,16 +290,19 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
device_info.queueCreateInfoCount = 1;
device_info.pQueueCreateInfos = &queue_info;
device_info.enabledLayerCount = enabled_layer_count;
device_info.ppEnabledLayerNames =
(const char *const *) device_validation_layers;
device_info.ppEnabledLayerNames = (const char *const *) enabled_layers;
device_info.enabledExtensionCount = enabled_extension_count;
device_info.ppEnabledExtensionNames = (const char *const *) extension_names;
device_info.pEnabledFeatures = NULL;
err = vkCreateDevice (gpu, &device_info, NULL, &device->device);
if (gst_vulkan_error_to_g_error (err, error, "vkCreateDevice") < 0)
if (gst_vulkan_error_to_g_error (err, error, "vkCreateDevice") < 0) {
g_strfreev (enabled_layers);
goto error;
}
}
g_strfreev (enabled_layers);
{
VkCommandPoolCreateInfo cmd_pool_info = { 0, };

View file

@ -174,7 +174,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
uint32_t enabled_extension_count = 0;
uint32_t instance_layer_count = 0;
uint32_t enabled_layer_count = 0;
gboolean validation_found;
gchar **enabled_layers;
VkResult err;
GST_OBJECT_LOCK (instance);
@ -200,23 +200,18 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
}
/* TODO: allow outside selection */
validation_found =
_check_for_all_layers (G_N_ELEMENTS (instance_validation_layers),
instance_validation_layers, instance_layer_count, instance_layers);
if (!validation_found) {
g_error ("vkEnumerateInstanceLayerProperties failed to find"
" required validation layer.\n\n"
"Please look at the Getting Started guide for additional "
"information.\nvkCreateInstance Failure");
}
enabled_layer_count = G_N_ELEMENTS (instance_validation_layers);
_check_for_all_layers (G_N_ELEMENTS (instance_validation_layers),
instance_validation_layers, instance_layer_count, instance_layers,
&enabled_layer_count, &enabled_layers);
g_free (instance_layers);
err =
vkEnumerateInstanceExtensionProperties (NULL, &instance_extension_count,
NULL);
if (gst_vulkan_error_to_g_error (err, error,
"vkEnumerateInstanceExtensionProperties") < 0) {
g_free (instance_layers);
g_strfreev (enabled_layers);
goto error;
}
GST_DEBUG_OBJECT (instance, "Found %u extensions", instance_extension_count);
@ -229,7 +224,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
instance_extensions);
if (gst_vulkan_error_to_g_error (err, error,
"vkEnumerateInstanceExtensionProperties") < 0) {
g_free (instance_layers);
g_strfreev (enabled_layers);
g_free (instance_extensions);
goto error;
}
@ -275,7 +270,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"vkEnumerateInstanceExtensionProperties failed to find the required "
"\"" VK_KHR_SURFACE_EXTENSION_NAME "\" extension");
g_free (instance_layers);
g_strfreev (enabled_layers);
g_free (instance_extensions);
goto error;
}
@ -283,7 +278,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
"vkEnumerateInstanceExtensionProperties failed to find the required "
"\"%s\" window system extension", winsys_ext_name);
g_free (instance_layers);
g_strfreev (enabled_layers);
g_free (instance_extensions);
goto error;
}
@ -305,21 +300,20 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
inst_info.pNext = NULL;
inst_info.pApplicationInfo = &app;
inst_info.enabledLayerCount = enabled_layer_count;
inst_info.ppEnabledLayerNames =
(const char *const *) instance_validation_layers;
inst_info.ppEnabledLayerNames = (const char *const *) enabled_layers;
inst_info.enabledExtensionCount = enabled_extension_count;
inst_info.ppEnabledExtensionNames = (const char *const *) extension_names;
err = vkCreateInstance (&inst_info, NULL, &instance->instance);
if (gst_vulkan_error_to_g_error (err, error, "vkCreateInstance") < 0) {
g_free (instance_layers);
g_strfreev (enabled_layers);
g_free (instance_extensions);
goto error;
}
}
g_free (instance_layers);
g_free (instance_extensions);
g_strfreev (enabled_layers);
err =
vkEnumeratePhysicalDevices (instance->instance,