#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);
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;
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;
&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);
&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;
}
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);
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;
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, };
#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);
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;
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 =
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);
instance_extensions);
if (gst_vulkan_error_to_g_error (err, error,
"vkEnumerateInstanceExtensionProperties") < 0) {
- g_strfreev (enabled_layers);
g_free (instance_extensions);
goto 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;
}
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;
}
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,
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)
{
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_ */