From 873add374ad2da0ff0b0f2847f9bcebf716114b4 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 4 Apr 2019 17:33:34 +1100 Subject: [PATCH] vulkan: remove unused layer enablement This is possible now via the vulkan loader --- ext/vulkan/vkdevice.c | 27 --------------------------- ext/vulkan/vkinstance.c | 29 ----------------------------- ext/vulkan/vkutils.c | 35 ----------------------------------- ext/vulkan/vkutils_private.h | 4 ---- 4 files changed, 95 deletions(-) diff --git a/ext/vulkan/vkdevice.c b/ext/vulkan/vkdevice.c index c76321c526..c997b8960f 100644 --- a/ext/vulkan/vkdevice.c +++ b/ext/vulkan/vkdevice.c @@ -27,17 +27,6 @@ #include -static const char *device_validation_layers[] = { - "VK_LAYER_GOOGLE_threading", - "VK_LAYER_LUNARG_mem_tracker", - "VK_LAYER_LUNARG_object_tracker", - "VK_LAYER_LUNARG_draw_state", - "VK_LAYER_LUNARG_param_checker", - "VK_LAYER_LUNARG_swapchain", - "VK_LAYER_LUNARG_device_limits", - "VK_LAYER_LUNARG_image", -}; - #define GST_CAT_DEFAULT gst_vulkan_device_debug GST_DEBUG_CATEGORY (GST_CAT_DEFAULT); GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT); @@ -162,8 +151,6 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error) uint32_t enabled_extension_count = 0; 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; @@ -201,9 +188,6 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error) goto error; } - _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; @@ -212,7 +196,6 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error) &device_extension_count, NULL); if (gst_vulkan_error_to_g_error (err, error, "vkEnumerateDeviceExtensionProperties") < 0) { - g_strfreev (enabled_layers); goto error; } GST_DEBUG_OBJECT (device, "Found %u extensions", device_extension_count); @@ -225,7 +208,6 @@ 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; } @@ -246,7 +228,6 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** 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); @@ -272,7 +253,6 @@ 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; @@ -293,24 +273,17 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error) device_info.pNext = NULL; device_info.queueCreateInfoCount = 1; device_info.pQueueCreateInfos = &queue_info; -#if 0 - device_info.enabledLayerCount = enabled_layer_count; - device_info.ppEnabledLayerNames = (const char *const *) enabled_layers; -#else device_info.enabledLayerCount = 0; device_info.ppEnabledLayerNames = NULL; -#endif 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) { - g_strfreev (enabled_layers); goto error; } } - g_strfreev (enabled_layers); { VkCommandPoolCreateInfo cmd_pool_info = { 0, }; diff --git a/ext/vulkan/vkinstance.c b/ext/vulkan/vkinstance.c index 9fdc90c7bf..b06c6aeb25 100644 --- a/ext/vulkan/vkinstance.c +++ b/ext/vulkan/vkinstance.c @@ -29,17 +29,6 @@ #define APP_SHORT_NAME "GStreamer" -static const char *instance_validation_layers[] = { - "VK_LAYER_GOOGLE_threading", - "VK_LAYER_LUNARG_mem_tracker", - "VK_LAYER_LUNARG_object_tracker", - "VK_LAYER_LUNARG_draw_state", - "VK_LAYER_LUNARG_param_checker", - "VK_LAYER_LUNARG_swapchain", - "VK_LAYER_LUNARG_device_limits", - "VK_LAYER_LUNARG_image", -}; - #define GST_CAT_DEFAULT gst_vulkan_instance_debug GST_DEBUG_CATEGORY (GST_CAT_DEFAULT); GST_DEBUG_CATEGORY (GST_VULKAN_DEBUG_CAT); @@ -176,8 +165,6 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error) uint32_t instance_extension_count = 0; uint32_t enabled_extension_count = 0; uint32_t instance_layer_count = 0; - uint32_t enabled_layer_count = 0; - gchar **enabled_layers; gboolean have_debug_extension = FALSE; VkResult err; @@ -205,11 +192,6 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error) goto error; } - /* TODO: allow outside selection */ - _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 = @@ -217,7 +199,6 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error) NULL); if (gst_vulkan_error_to_g_error (err, error, "vkEnumerateInstanceExtensionProperties") < 0) { - g_strfreev (enabled_layers); goto error; } GST_DEBUG_OBJECT (instance, "Found %u extensions", instance_extension_count); @@ -230,7 +211,6 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error) instance_extensions); if (gst_vulkan_error_to_g_error (err, error, "vkEnumerateInstanceExtensionProperties") < 0) { - g_strfreev (enabled_layers); g_free (instance_extensions); goto error; } @@ -278,7 +258,6 @@ 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_strfreev (enabled_layers); g_free (instance_extensions); goto error; } @@ -286,7 +265,6 @@ 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_strfreev (enabled_layers); g_free (instance_extensions); goto error; } @@ -307,26 +285,19 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error) inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; inst_info.pNext = NULL; inst_info.pApplicationInfo = &app; -#if 0 - inst_info.enabledLayerCount = enabled_layer_count; - inst_info.ppEnabledLayerNames = (const char *const *) enabled_layers; -#else inst_info.enabledLayerCount = 0; inst_info.ppEnabledLayerNames = NULL; -#endif 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_strfreev (enabled_layers); g_free (instance_extensions); goto error; } } g_free (instance_extensions); - g_strfreev (enabled_layers); err = vkEnumeratePhysicalDevices (instance->instance, diff --git a/ext/vulkan/vkutils.c b/ext/vulkan/vkutils.c index aaa6bba230..e677bf923a 100644 --- a/ext/vulkan/vkutils.c +++ b/ext/vulkan/vkutils.c @@ -27,41 +27,6 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT); -gboolean -_check_for_all_layers (uint32_t check_count, const char **check_names, - uint32_t layer_count, VkLayerProperties * layers, - guint32 * supported_layers_count, gchar *** supported_layers) -{ - uint32_t i, j, k; - - if (check_count <= 0 || layer_count <= 0) { - GST_WARNING ("no layers requested or supported"); - *supported_layers = NULL; - return FALSE; - } - - *supported_layers = g_new0 (gchar *, check_count + 1); - k = 0; - - for (i = 0; i < check_count; i++) { - gboolean found = FALSE; - for (j = 0; j < layer_count; j++) { - if (g_strcmp0 (check_names[i], layers[j].layerName) == 0) { - GST_TRACE ("found layer: %s", check_names[i]); - found = TRUE; - (*supported_layers)[k++] = g_strdup (check_names[i]); - } - } - if (!found) - GST_WARNING ("Cannot find layer: %s", check_names[i]); - } - - (*supported_layers)[k] = NULL; - *supported_layers_count = g_strv_length (*supported_layers); - - return TRUE; -} - static void _init_context_debug (void) { diff --git a/ext/vulkan/vkutils_private.h b/ext/vulkan/vkutils_private.h index c1debbe806..d861d29e91 100644 --- a/ext/vulkan/vkutils_private.h +++ b/ext/vulkan/vkutils_private.h @@ -25,10 +25,6 @@ G_BEGIN_DECLS -gboolean _check_for_all_layers (uint32_t check_count, const char ** check_names, - uint32_t layer_count, VkLayerProperties * layers, guint32 * enabled_layer_count, - gchar *** enabled_layers); - G_END_DECLS #endif /*_VK_UTILS_H_ */