This commit is contained in:
Mars 2024-09-26 19:56:19 -04:00
parent b19910cb24
commit 647f318d1f
Signed by untrusted user: pupbrained
GPG key ID: 874E22DF2F9DFCB5

View file

@ -14,7 +14,7 @@ constexpr u32 HEIGHT = 600;
constexpr std::array<const char*, 1> 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<VkLayerProperties> 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;
if (enableValidationLayers) {
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
createInfo.ppEnabledLayerNames = validationLayers.data();
} else {
createInfo.enabledLayerCount = 0;
}
std::vector<const char*> requiredExtensions;
@ -111,10 +107,9 @@ class Application {
createInfo.enabledExtensionCount = static_cast<u32>(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 {
// Initialize GLFW