forked from pupbrained/vulkan-test
weh
This commit is contained in:
parent
b19910cb24
commit
647f318d1f
23
src/main.cpp
23
src/main.cpp
|
@ -14,7 +14,7 @@ constexpr u32 HEIGHT = 600;
|
||||||
|
|
||||||
constexpr std::array<const char*, 1> validationLayers = { "VK_LAYER_KHRONOS_validation" };
|
constexpr std::array<const char*, 1> validationLayers = { "VK_LAYER_KHRONOS_validation" };
|
||||||
|
|
||||||
#if defined(NDEBUG)
|
#ifdef NDEBUG
|
||||||
const bool enableValidationLayers = false;
|
const bool enableValidationLayers = false;
|
||||||
#else
|
#else
|
||||||
const bool enableValidationLayers = true;
|
const bool enableValidationLayers = true;
|
||||||
|
@ -40,11 +40,6 @@ class Application {
|
||||||
std::vector<VkLayerProperties> availableLayers(layerCount);
|
std::vector<VkLayerProperties> availableLayers(layerCount);
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
||||||
|
|
||||||
fmt::println("Available layers:");
|
|
||||||
|
|
||||||
for (const auto& layerProperties : availableLayers)
|
|
||||||
fmt::println("\t{}", layerProperties.layerName);
|
|
||||||
|
|
||||||
for (const char* layerName : validationLayers) {
|
for (const char* layerName : validationLayers) {
|
||||||
bool layerFound = false;
|
bool layerFound = false;
|
||||||
|
|
||||||
|
@ -76,11 +71,6 @@ class Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createInstance() -> void {
|
fn createInstance() -> void {
|
||||||
fmt::println("Available extensions:");
|
|
||||||
|
|
||||||
for (const fn& extension : getAvailableExtensions())
|
|
||||||
fmt::println("\t{}", extension.extensionName);
|
|
||||||
|
|
||||||
if (enableValidationLayers && !checkValidationLayerSupport())
|
if (enableValidationLayers && !checkValidationLayerSupport())
|
||||||
throw std::runtime_error("Validation layers requested, but not available!");
|
throw std::runtime_error("Validation layers requested, but not available!");
|
||||||
|
|
||||||
|
@ -100,7 +90,13 @@ class Application {
|
||||||
createInfo.pApplicationInfo = &appInfo;
|
createInfo.pApplicationInfo = &appInfo;
|
||||||
createInfo.enabledExtensionCount = glfwExtensionCount;
|
createInfo.enabledExtensionCount = glfwExtensionCount;
|
||||||
createInfo.ppEnabledExtensionNames = glfwExtensions;
|
createInfo.ppEnabledExtensionNames = glfwExtensions;
|
||||||
createInfo.enabledLayerCount = 0;
|
|
||||||
|
if (enableValidationLayers) {
|
||||||
|
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
|
||||||
|
createInfo.ppEnabledLayerNames = validationLayers.data();
|
||||||
|
} else {
|
||||||
|
createInfo.enabledLayerCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<const char*> requiredExtensions;
|
std::vector<const char*> requiredExtensions;
|
||||||
|
|
||||||
|
@ -111,9 +107,8 @@ class Application {
|
||||||
createInfo.enabledExtensionCount = static_cast<u32>(requiredExtensions.size());
|
createInfo.enabledExtensionCount = static_cast<u32>(requiredExtensions.size());
|
||||||
createInfo.ppEnabledExtensionNames = requiredExtensions.data();
|
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!");
|
throw std::runtime_error("failed to create instance!");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initWindow() -> void {
|
fn initWindow() -> void {
|
||||||
|
|
Loading…
Reference in a new issue