From 0d77992e6731e285b417326cf21bf5f540facbbf Mon Sep 17 00:00:00 2001 From: Mars Date: Sun, 6 Oct 2024 12:26:44 -0400 Subject: [PATCH] what --- src/main.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8d8dc9e..5c78056 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,20 +3,19 @@ #include #include +#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 #define VK_ENABLE_BETA_EXTENSIONS #define VULKAN_HPP_NO_CONSTRUCTORS #define VULKAN_HPP_NO_EXCEPTIONS #include +VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE + #include "util/types.h" #define VKFW_NO_STD_FUNCTION_CALLBACKS #include "vkfw.hpp" -namespace vk { - using DebugUtilsMessengerUnique = vk::UniqueHandle; -} - constexpr i32 WIDTH = 800; constexpr i32 HEIGHT = 600; @@ -51,9 +50,8 @@ class VulkanApp { vk::UniqueInstance mInstance; - vk::DebugUtilsMessengerUnique mDebugMessenger; - vk::DispatchLoaderDynamic mLoader; - vk::UniqueSurfaceKHR mSurface; + vk::UniqueDebugUtilsMessengerEXT mDebugMessenger; + vk::UniqueSurfaceKHR mSurface; vk::PhysicalDevice mPhysicalDevice; vk::UniqueDevice mDevice; @@ -160,14 +158,10 @@ class VulkanApp { } fn cleanupSwapChain() -> void { - for (vk::UniqueHandle& mSwapChainFramebuffer : - mSwapChainFramebuffers) { + for (vk::UniqueFramebuffer& mSwapChainFramebuffer : mSwapChainFramebuffers) { mSwapChainFramebuffer.reset(); } - for (vk::UniqueHandle& mSwapChainImageView : - mSwapChainImageViews) { - mSwapChainImageView.reset(); - } + for (vk::UniqueImageView& mSwapChainImageView : mSwapChainImageViews) { mSwapChainImageView.reset(); } mSwapChain.reset(); } @@ -201,7 +195,7 @@ class VulkanApp { .applicationVersion = 1, .pEngineName = "No Engine", .engineVersion = 1, - .apiVersion = vk::ApiVersion10 }; + .apiVersion = vk::ApiVersion12 }; // Retrieve extensions using custom function std::vector extensions = getRequiredExtensions(); @@ -233,7 +227,7 @@ class VulkanApp { #endif mInstance = vk::createInstanceUnique(createInfo).value; - mLoader = vk::DispatchLoaderDynamic(mInstance.get(), vkGetInstanceProcAddr); + VULKAN_HPP_DEFAULT_DISPATCHER.init(mInstance.get()); } fn setupDebugMessenger() -> void { @@ -251,7 +245,9 @@ class VulkanApp { }; mDebugMessenger = - mInstance->createDebugUtilsMessengerEXTUnique(messengerCreateInfo, nullptr, mLoader).value; + mInstance + ->createDebugUtilsMessengerEXTUnique(messengerCreateInfo, nullptr, VULKAN_HPP_DEFAULT_DISPATCHER) + .value; } fn createSurface() -> void { mSurface = vkfw::createWindowSurfaceUnique(mInstance.get(), mWindow.get()); } @@ -817,6 +813,11 @@ class VulkanApp { }; fn main() -> i32 { + vk::DynamicLoader dynamicLoader; + auto vkGetInstanceProcAddr = + dynamicLoader.getProcAddress("vkGetInstanceProcAddr"); + VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); + VulkanApp app; try {