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 {