vulkan: remove unused layer enablement
authorMatthew Waters <matthew@centricular.com>
Thu, 4 Apr 2019 06:33:34 +0000 (17:33 +1100)
committerMatthew Waters <matthew@centricular.com>
Tue, 4 Jun 2019 09:03:44 +0000 (09:03 +0000)
This is possible now via the vulkan loader

ext/vulkan/vkdevice.c
ext/vulkan/vkinstance.c
ext/vulkan/vkutils.c
ext/vulkan/vkutils_private.h

index c76321c..c997b89 100644 (file)
 
 #include <string.h>
 
-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, };
index 9fdc90c..b06c6ae 100644 (file)
 
 #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,
index aaa6bba..e677bf9 100644 (file)
 
 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)
 {
index c1debbe..d861d29 100644 (file)
 
 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_ */