mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
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:
parent
dc1a326090
commit
b32ca4b550
2 changed files with 34 additions and 41 deletions
|
@ -159,10 +159,10 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
|
||||||
uint32_t device_extension_count = 0;
|
uint32_t device_extension_count = 0;
|
||||||
VkExtensionProperties *device_extensions = NULL;
|
VkExtensionProperties *device_extensions = NULL;
|
||||||
uint32_t enabled_layer_count = 0;
|
uint32_t enabled_layer_count = 0;
|
||||||
|
gchar **enabled_layers;
|
||||||
uint32_t device_layer_count = 0;
|
uint32_t device_layer_count = 0;
|
||||||
VkLayerProperties *device_layers;
|
VkLayerProperties *device_layers;
|
||||||
gboolean have_swapchain_ext;
|
gboolean have_swapchain_ext;
|
||||||
gboolean validation_found;
|
|
||||||
VkPhysicalDevice gpu;
|
VkPhysicalDevice gpu;
|
||||||
VkResult err;
|
VkResult err;
|
||||||
guint i;
|
guint i;
|
||||||
|
@ -197,26 +197,20 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
validation_found =
|
|
||||||
_check_for_all_layers (G_N_ELEMENTS (device_validation_layers),
|
_check_for_all_layers (G_N_ELEMENTS (device_validation_layers),
|
||||||
device_validation_layers, device_layer_count, device_layers);
|
device_validation_layers, device_layer_count, device_layers,
|
||||||
|
&enabled_layer_count, &enabled_layers);
|
||||||
g_free (device_layers);
|
g_free (device_layers);
|
||||||
device_layers = NULL;
|
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 =
|
err =
|
||||||
vkEnumerateDeviceExtensionProperties (gpu, NULL,
|
vkEnumerateDeviceExtensionProperties (gpu, NULL,
|
||||||
&device_extension_count, NULL);
|
&device_extension_count, NULL);
|
||||||
if (gst_vulkan_error_to_g_error (err, error,
|
if (gst_vulkan_error_to_g_error (err, error,
|
||||||
"vkEnumerateDeviceExtensionProperties") < 0)
|
"vkEnumerateDeviceExtensionProperties") < 0) {
|
||||||
|
g_strfreev (enabled_layers);
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
GST_DEBUG_OBJECT (device, "Found %u extensions", device_extension_count);
|
GST_DEBUG_OBJECT (device, "Found %u extensions", device_extension_count);
|
||||||
|
|
||||||
have_swapchain_ext = 0;
|
have_swapchain_ext = 0;
|
||||||
|
@ -227,6 +221,7 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
|
||||||
&device_extension_count, device_extensions);
|
&device_extension_count, device_extensions);
|
||||||
if (gst_vulkan_error_to_g_error (err, error,
|
if (gst_vulkan_error_to_g_error (err, error,
|
||||||
"vkEnumerateDeviceExtensionProperties") < 0) {
|
"vkEnumerateDeviceExtensionProperties") < 0) {
|
||||||
|
g_strfreev (enabled_layers);
|
||||||
g_free (device_extensions);
|
g_free (device_extensions);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -243,12 +238,12 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
|
||||||
g_assert (enabled_extension_count < 64);
|
g_assert (enabled_extension_count < 64);
|
||||||
}
|
}
|
||||||
if (!have_swapchain_ext) {
|
if (!have_swapchain_ext) {
|
||||||
g_error ("vkEnumerateDeviceExtensionProperties failed to find the \""
|
g_set_error_literal (error, GST_VULKAN_ERROR,
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
VK_ERROR_EXTENSION_NOT_PRESENT,
|
||||||
"\" extension.\n\nDo you have a compatible "
|
"Failed to find required extension, \"" VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
||||||
"Vulkan installable client driver (ICD) installed?\nPlease "
|
"\"");
|
||||||
"look at the Getting Started guide for additional "
|
g_strfreev (enabled_layers);
|
||||||
"information.\nvkCreateInstance Failure");
|
goto error;
|
||||||
}
|
}
|
||||||
g_free (device_extensions);
|
g_free (device_extensions);
|
||||||
|
|
||||||
|
@ -273,6 +268,7 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
|
||||||
if (i >= device->n_queue_families) {
|
if (i >= device->n_queue_families) {
|
||||||
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
|
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
|
||||||
"Failed to find a compatible queue family");
|
"Failed to find a compatible queue family");
|
||||||
|
g_strfreev (enabled_layers);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
device->queue_family_id = i;
|
device->queue_family_id = i;
|
||||||
|
@ -294,16 +290,19 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
|
||||||
device_info.queueCreateInfoCount = 1;
|
device_info.queueCreateInfoCount = 1;
|
||||||
device_info.pQueueCreateInfos = &queue_info;
|
device_info.pQueueCreateInfos = &queue_info;
|
||||||
device_info.enabledLayerCount = enabled_layer_count;
|
device_info.enabledLayerCount = enabled_layer_count;
|
||||||
device_info.ppEnabledLayerNames =
|
device_info.ppEnabledLayerNames = (const char *const *) enabled_layers;
|
||||||
(const char *const *) device_validation_layers;
|
|
||||||
device_info.enabledExtensionCount = enabled_extension_count;
|
device_info.enabledExtensionCount = enabled_extension_count;
|
||||||
device_info.ppEnabledExtensionNames = (const char *const *) extension_names;
|
device_info.ppEnabledExtensionNames = (const char *const *) extension_names;
|
||||||
device_info.pEnabledFeatures = NULL;
|
device_info.pEnabledFeatures = NULL;
|
||||||
|
|
||||||
err = vkCreateDevice (gpu, &device_info, NULL, &device->device);
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
g_strfreev (enabled_layers);
|
||||||
|
|
||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo cmd_pool_info = { 0, };
|
VkCommandPoolCreateInfo cmd_pool_info = { 0, };
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
||||||
uint32_t enabled_extension_count = 0;
|
uint32_t enabled_extension_count = 0;
|
||||||
uint32_t instance_layer_count = 0;
|
uint32_t instance_layer_count = 0;
|
||||||
uint32_t enabled_layer_count = 0;
|
uint32_t enabled_layer_count = 0;
|
||||||
gboolean validation_found;
|
gchar **enabled_layers;
|
||||||
VkResult err;
|
VkResult err;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (instance);
|
GST_OBJECT_LOCK (instance);
|
||||||
|
@ -200,23 +200,18 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: allow outside selection */
|
/* TODO: allow outside selection */
|
||||||
validation_found =
|
|
||||||
_check_for_all_layers (G_N_ELEMENTS (instance_validation_layers),
|
_check_for_all_layers (G_N_ELEMENTS (instance_validation_layers),
|
||||||
instance_validation_layers, instance_layer_count, instance_layers);
|
instance_validation_layers, instance_layer_count, instance_layers,
|
||||||
if (!validation_found) {
|
&enabled_layer_count, &enabled_layers);
|
||||||
g_error ("vkEnumerateInstanceLayerProperties failed to find"
|
|
||||||
" required validation layer.\n\n"
|
g_free (instance_layers);
|
||||||
"Please look at the Getting Started guide for additional "
|
|
||||||
"information.\nvkCreateInstance Failure");
|
|
||||||
}
|
|
||||||
enabled_layer_count = G_N_ELEMENTS (instance_validation_layers);
|
|
||||||
|
|
||||||
err =
|
err =
|
||||||
vkEnumerateInstanceExtensionProperties (NULL, &instance_extension_count,
|
vkEnumerateInstanceExtensionProperties (NULL, &instance_extension_count,
|
||||||
NULL);
|
NULL);
|
||||||
if (gst_vulkan_error_to_g_error (err, error,
|
if (gst_vulkan_error_to_g_error (err, error,
|
||||||
"vkEnumerateInstanceExtensionProperties") < 0) {
|
"vkEnumerateInstanceExtensionProperties") < 0) {
|
||||||
g_free (instance_layers);
|
g_strfreev (enabled_layers);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (instance, "Found %u extensions", instance_extension_count);
|
GST_DEBUG_OBJECT (instance, "Found %u extensions", instance_extension_count);
|
||||||
|
@ -229,7 +224,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
||||||
instance_extensions);
|
instance_extensions);
|
||||||
if (gst_vulkan_error_to_g_error (err, error,
|
if (gst_vulkan_error_to_g_error (err, error,
|
||||||
"vkEnumerateInstanceExtensionProperties") < 0) {
|
"vkEnumerateInstanceExtensionProperties") < 0) {
|
||||||
g_free (instance_layers);
|
g_strfreev (enabled_layers);
|
||||||
g_free (instance_extensions);
|
g_free (instance_extensions);
|
||||||
goto error;
|
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,
|
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
|
||||||
"vkEnumerateInstanceExtensionProperties failed to find the required "
|
"vkEnumerateInstanceExtensionProperties failed to find the required "
|
||||||
"\"" VK_KHR_SURFACE_EXTENSION_NAME "\" extension");
|
"\"" VK_KHR_SURFACE_EXTENSION_NAME "\" extension");
|
||||||
g_free (instance_layers);
|
g_strfreev (enabled_layers);
|
||||||
g_free (instance_extensions);
|
g_free (instance_extensions);
|
||||||
goto error;
|
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,
|
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
|
||||||
"vkEnumerateInstanceExtensionProperties failed to find the required "
|
"vkEnumerateInstanceExtensionProperties failed to find the required "
|
||||||
"\"%s\" window system extension", winsys_ext_name);
|
"\"%s\" window system extension", winsys_ext_name);
|
||||||
g_free (instance_layers);
|
g_strfreev (enabled_layers);
|
||||||
g_free (instance_extensions);
|
g_free (instance_extensions);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -305,21 +300,20 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
||||||
inst_info.pNext = NULL;
|
inst_info.pNext = NULL;
|
||||||
inst_info.pApplicationInfo = &app;
|
inst_info.pApplicationInfo = &app;
|
||||||
inst_info.enabledLayerCount = enabled_layer_count;
|
inst_info.enabledLayerCount = enabled_layer_count;
|
||||||
inst_info.ppEnabledLayerNames =
|
inst_info.ppEnabledLayerNames = (const char *const *) enabled_layers;
|
||||||
(const char *const *) instance_validation_layers;
|
|
||||||
inst_info.enabledExtensionCount = enabled_extension_count;
|
inst_info.enabledExtensionCount = enabled_extension_count;
|
||||||
inst_info.ppEnabledExtensionNames = (const char *const *) extension_names;
|
inst_info.ppEnabledExtensionNames = (const char *const *) extension_names;
|
||||||
|
|
||||||
err = vkCreateInstance (&inst_info, NULL, &instance->instance);
|
err = vkCreateInstance (&inst_info, NULL, &instance->instance);
|
||||||
if (gst_vulkan_error_to_g_error (err, error, "vkCreateInstance") < 0) {
|
if (gst_vulkan_error_to_g_error (err, error, "vkCreateInstance") < 0) {
|
||||||
g_free (instance_layers);
|
g_strfreev (enabled_layers);
|
||||||
g_free (instance_extensions);
|
g_free (instance_extensions);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (instance_layers);
|
|
||||||
g_free (instance_extensions);
|
g_free (instance_extensions);
|
||||||
|
g_strfreev (enabled_layers);
|
||||||
|
|
||||||
err =
|
err =
|
||||||
vkEnumeratePhysicalDevices (instance->instance,
|
vkEnumeratePhysicalDevices (instance->instance,
|
||||||
|
|
Loading…
Reference in a new issue