From 647f318d1f88512ca6132626ab97eb7225850cf6 Mon Sep 17 00:00:00 2001 From: Mars Date: Thu, 26 Sep 2024 19:56:19 -0400 Subject: [PATCH] weh --- src/main.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c6649d4..ebadf7e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ constexpr u32 HEIGHT = 600; constexpr std::array validationLayers = { "VK_LAYER_KHRONOS_validation" }; -#if defined(NDEBUG) +#ifdef NDEBUG const bool enableValidationLayers = false; #else const bool enableValidationLayers = true; @@ -40,11 +40,6 @@ class Application { std::vector availableLayers(layerCount); vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data()); - fmt::println("Available layers:"); - - for (const auto& layerProperties : availableLayers) - fmt::println("\t{}", layerProperties.layerName); - for (const char* layerName : validationLayers) { bool layerFound = false; @@ -76,11 +71,6 @@ class Application { } fn createInstance() -> void { - fmt::println("Available extensions:"); - - for (const fn& extension : getAvailableExtensions()) - fmt::println("\t{}", extension.extensionName); - if (enableValidationLayers && !checkValidationLayerSupport()) throw std::runtime_error("Validation layers requested, but not available!"); @@ -100,7 +90,13 @@ class Application { createInfo.pApplicationInfo = &appInfo; createInfo.enabledExtensionCount = glfwExtensionCount; createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.enabledLayerCount = 0; + + if (enableValidationLayers) { + createInfo.enabledLayerCount = static_cast(validationLayers.size()); + createInfo.ppEnabledLayerNames = validationLayers.data(); + } else { + createInfo.enabledLayerCount = 0; + } std::vector requiredExtensions; @@ -111,9 +107,8 @@ class Application { createInfo.enabledExtensionCount = static_cast(requiredExtensions.size()); createInfo.ppEnabledExtensionNames = requiredExtensions.data(); - if (vkCreateInstance(&createInfo, nullptr, &mInstance) != VK_SUCCESS) { + if (vkCreateInstance(&createInfo, nullptr, &mInstance) != VK_SUCCESS) throw std::runtime_error("failed to create instance!"); - } } fn initWindow() -> void {