Finally got thevalidation extension to seemingly work
This commit is contained in:
parent
46dc696668
commit
d6ae5a79d6
1 changed files with 36 additions and 17 deletions
47
src/main.c
47
src/main.c
|
|
@ -44,7 +44,7 @@ bool checkValidationLayerSupport() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool verifyGlfwExtensionSupport(uint32_t extensionCount,
|
bool verifyExtensionSupport(uint32_t extensionCount,
|
||||||
VkExtensionProperties *extentions,
|
VkExtensionProperties *extentions,
|
||||||
uint32_t glfwExtensionCount,
|
uint32_t glfwExtensionCount,
|
||||||
const char **glfwExtensions) {
|
const char **glfwExtensions) {
|
||||||
|
|
@ -57,6 +57,7 @@ bool verifyGlfwExtensionSupport(uint32_t extensionCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!layerFound) {
|
if (!layerFound) {
|
||||||
|
fprintf(stderr, "Missing %s vulkan extention\n", glfwExtensions[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +83,8 @@ void createInstance(Application *app) {
|
||||||
const char **glfwExtensions;
|
const char **glfwExtensions;
|
||||||
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
|
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
|
||||||
|
|
||||||
|
const char *glfwExtensionsDebug[glfwExtensionCount + 1];
|
||||||
|
|
||||||
VkInstanceCreateInfo createInfo = {
|
VkInstanceCreateInfo createInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
.pApplicationInfo = &appInfo,
|
.pApplicationInfo = &appInfo,
|
||||||
|
|
@ -89,25 +92,41 @@ void createInstance(Application *app) {
|
||||||
.ppEnabledExtensionNames = glfwExtensions,
|
.ppEnabledExtensionNames = glfwExtensions,
|
||||||
.enabledLayerCount = 0,
|
.enabledLayerCount = 0,
|
||||||
};
|
};
|
||||||
if (enableValidationLayers) {
|
|
||||||
createInfo.enabledLayerCount = validationLayerCount;
|
|
||||||
createInfo.ppEnabledLayerNames = validationLayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkResult result = vkCreateInstance(&createInfo, NULL, &app->instance);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
fprintf(stderr, "Failed to create vulkan instance\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t extensionCount = 0;
|
uint32_t extensionCount = 0;
|
||||||
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, NULL);
|
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, NULL);
|
||||||
VkExtensionProperties extensions[extensionCount];
|
VkExtensionProperties extensions[extensionCount];
|
||||||
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, extensions);
|
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, extensions);
|
||||||
|
|
||||||
if (!verifyGlfwExtensionSupport(extensionCount, extensions,
|
if (enableValidationLayers) {
|
||||||
glfwExtensionCount, glfwExtensions)) {
|
createInfo.enabledLayerCount = validationLayerCount;
|
||||||
fprintf(stderr, "Failed to find all required vulkan extentions for glfw\n");
|
createInfo.ppEnabledLayerNames = validationLayers;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < glfwExtensionCount; i++) {
|
||||||
|
glfwExtensionsDebug[i] = glfwExtensions[i];
|
||||||
|
}
|
||||||
|
glfwExtensionsDebug[glfwExtensionCount] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
|
||||||
|
createInfo.enabledExtensionCount = glfwExtensionCount + 1;
|
||||||
|
createInfo.ppEnabledExtensionNames = glfwExtensionsDebug;
|
||||||
|
if (!verifyExtensionSupport(extensionCount, extensions,
|
||||||
|
glfwExtensionCount + 1, glfwExtensionsDebug)) {
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"Failed to find all required vulkan extentions for glfw and debug\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!verifyExtensionSupport(extensionCount, extensions, glfwExtensionCount,
|
||||||
|
glfwExtensions)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Failed to find all required vulkan extentions for glfw\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult result = vkCreateInstance(&createInfo, NULL, &app->instance);
|
||||||
|
if (result != VK_SUCCESS) {
|
||||||
|
fprintf(stderr, "Failed to create vulkan instance\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue