Got the debug stuff in but we're not cleaning it up properly currently.
This commit is contained in:
parent
6d5854d5b1
commit
3deda81b1d
1 changed files with 13 additions and 12 deletions
25
src/main.c
25
src/main.c
|
|
@ -92,7 +92,6 @@ void populateDebugMessengerCreateInfo(
|
||||||
createInfo->pUserData = NULL; // Optional
|
createInfo->pUserData = NULL; // Optional
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createInstance(Application *app) {
|
void createInstance(Application *app) {
|
||||||
if (enableValidationLayers && !checkValidationLayerSupport()) {
|
if (enableValidationLayers && !checkValidationLayerSupport()) {
|
||||||
fprintf(stderr, "Validation layers requested, but not available!\n");
|
fprintf(stderr, "Validation layers requested, but not available!\n");
|
||||||
|
|
@ -191,30 +190,32 @@ VkResult CreateDebugUtilsMessengerEXT(
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupDebugMessenger(Application *app) {
|
void setupDebugMessenger(Application *app) {
|
||||||
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
|
if (enableValidationLayers && !checkValidationLayerSupport()) {
|
||||||
populateDebugMessengerCreateInfo(&createInfo);
|
fprintf(stderr, "Validation layers requested, but not available!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
|
||||||
|
populateDebugMessengerCreateInfo(&createInfo);
|
||||||
|
|
||||||
if (CreateDebugUtilsMessengerEXT(app->instance, &createInfo, NULL,
|
if (CreateDebugUtilsMessengerEXT(app->instance, &createInfo, NULL,
|
||||||
&app->debugMessenger) != VK_SUCCESS) {
|
&app->debugMessenger) != VK_SUCCESS) {
|
||||||
fprintf(stderr, "failed to set up debug messenger!");
|
fprintf(stderr, "failed to set up debug messenger!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance,
|
void DestroyDebugUtilsMessengerEXT(VkInstance instance,
|
||||||
VkDebugUtilsMessengerEXT debugMessenger,
|
VkDebugUtilsMessengerEXT *debugMessenger,
|
||||||
const VkAllocationCallbacks *pAllocator) {
|
const VkAllocationCallbacks *pAllocator) {
|
||||||
PFN_vkDestroyDebugUtilsMessengerEXT func =
|
PFN_vkDestroyDebugUtilsMessengerEXT func =
|
||||||
(PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(
|
(PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(
|
||||||
instance, "vkDestroyDebugUtilsMessengerEXT");
|
instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
func(instance, debugMessenger, pAllocator);
|
func(instance, *debugMessenger, pAllocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initVulkan(Application *app) {
|
void initVulkan(Application *app) {
|
||||||
if (enableValidationLayers) {
|
setupDebugMessenger(app);
|
||||||
setupDebugMessenger(app);
|
|
||||||
}
|
|
||||||
createInstance(app);
|
createInstance(app);
|
||||||
}
|
}
|
||||||
void mainLoop(Application *app) {
|
void mainLoop(Application *app) {
|
||||||
|
|
@ -224,7 +225,7 @@ void mainLoop(Application *app) {
|
||||||
}
|
}
|
||||||
void cleanup(Application *app) {
|
void cleanup(Application *app) {
|
||||||
if (enableValidationLayers) {
|
if (enableValidationLayers) {
|
||||||
DestroyDebugUtilsMessengerEXT(app->instance, app->debugMessenger, NULL);
|
DestroyDebugUtilsMessengerEXT(app->instance, &app->debugMessenger, NULL);
|
||||||
}
|
}
|
||||||
vkDestroyInstance(app->instance, NULL);
|
vkDestroyInstance(app->instance, NULL);
|
||||||
glfwDestroyWindow(app->window);
|
glfwDestroyWindow(app->window);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue