Got the debug stuff in but we're not cleaning it up properly currently.

This commit is contained in:
Warwick New 2024-10-12 22:41:11 +01:00
parent 6d5854d5b1
commit 3deda81b1d

View file

@ -92,7 +92,6 @@ void populateDebugMessengerCreateInfo(
createInfo->pUserData = NULL; // Optional
}
void createInstance(Application *app) {
if (enableValidationLayers && !checkValidationLayerSupport()) {
fprintf(stderr, "Validation layers requested, but not available!\n");
@ -191,30 +190,32 @@ VkResult CreateDebugUtilsMessengerEXT(
}
void setupDebugMessenger(Application *app) {
if (enableValidationLayers && !checkValidationLayerSupport()) {
fprintf(stderr, "Validation layers requested, but not available!\n");
exit(EXIT_FAILURE);
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
populateDebugMessengerCreateInfo(&createInfo);
if (CreateDebugUtilsMessengerEXT(app->instance, &createInfo, NULL,
&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,
VkDebugUtilsMessengerEXT debugMessenger,
VkDebugUtilsMessengerEXT *debugMessenger,
const VkAllocationCallbacks *pAllocator) {
PFN_vkDestroyDebugUtilsMessengerEXT func =
(PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(
instance, "vkDestroyDebugUtilsMessengerEXT");
if (func != NULL) {
func(instance, debugMessenger, pAllocator);
func(instance, *debugMessenger, pAllocator);
}
}
void initVulkan(Application *app) {
if (enableValidationLayers) {
setupDebugMessenger(app);
}
createInstance(app);
}
void mainLoop(Application *app) {
@ -224,7 +225,7 @@ void mainLoop(Application *app) {
}
void cleanup(Application *app) {
if (enableValidationLayers) {
DestroyDebugUtilsMessengerEXT(app->instance, app->debugMessenger, NULL);
DestroyDebugUtilsMessengerEXT(app->instance, &app->debugMessenger, NULL);
}
vkDestroyInstance(app->instance, NULL);
glfwDestroyWindow(app->window);