From 6395c6b95cf0cd435c4d84c9b4a5471aefc12c97 Mon Sep 17 00:00:00 2001 From: pupbrained Date: Mon, 30 Sep 2024 21:21:38 -0400 Subject: [PATCH] more vk stuff --- src/main.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 22d44f7..3f02874 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,9 @@ #include #include +#ifdef __APPLE__ +#define VK_ENABLE_BETA_EXTENSIONS +#endif #define VULKAN_HPP_NO_CONSTRUCTORS #include @@ -85,20 +88,22 @@ class VulkanApp { fn createInstance() -> void { if (enableValidationLayers && !checkValidationLayerSupport()) - throw std::runtime_error("validation layers requested, but not available!"); + throw std::runtime_error("Validation layers requested, but not available!"); vk::ApplicationInfo appInfo { .pApplicationName = "Hello Triangle", .applicationVersion = 1, .pEngineName = "No Engine", .engineVersion = 1, - .apiVersion = VK_API_VERSION_1_0 }; + .apiVersion = vk::ApiVersion10 }; // Retrieve extensions using custom function std::vector extensions = getRequiredExtensions(); // Enable the portability extension and set flags - extensions.push_back("VK_KHR_portability_enumeration"); - extensions.push_back("VK_KHR_get_physical_device_properties2"); + extensions.push_back(vk::KHRPortabilityEnumerationExtensionName); +#if VK_HEADER_VERSION < 110 + extensions.push_back(vk::KHRGetPhysicalDeviceProperties2ExtensionName); +#endif vk::InstanceCreateInfo createInfo { .flags = vk::InstanceCreateFlagBits::eEnumeratePortabilityKHR, @@ -187,13 +192,10 @@ class VulkanApp { vk::PhysicalDeviceFeatures deviceFeatures; #ifdef __APPLE__ - // Add the portability subset extension - std::vector deviceExtensions = { "VK_KHR_portability_subset" }; - vk::DeviceCreateInfo createInfo { .queueCreateInfoCount = static_cast(queueCreateInfos.size()), .pQueueCreateInfos = queueCreateInfos.data(), - .enabledExtensionCount = static_cast(deviceExtensions.size()), - .ppEnabledExtensionNames = deviceExtensions.data(), + .enabledExtensionCount = 1, + .ppEnabledExtensionNames = { vk::KHRPortabilitySubsetExtensionName }, .pEnabledFeatures = &deviceFeatures }; #else vk::DeviceCreateInfo createInfo { .queueCreateInfoCount = static_cast(queueCreateInfos.size()),