From c93e18399d888051547709a7fc77b603993cad48 Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Wed, 31 Dec 2025 11:10:32 +0100 Subject: [PATCH] feat(frame-pacing): update functions struct [will not compile] --- .../include/lsfg-vk-common/vulkan/vulkan.hpp | 5 +++-- lsfg-vk-common/src/vulkan/vulkan.cpp | 21 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lsfg-vk-common/include/lsfg-vk-common/vulkan/vulkan.hpp b/lsfg-vk-common/include/lsfg-vk-common/vulkan/vulkan.hpp index 18fe083..bb4dcf5 100644 --- a/lsfg-vk-common/include/lsfg-vk-common/vulkan/vulkan.hpp +++ b/lsfg-vk-common/include/lsfg-vk-common/vulkan/vulkan.hpp @@ -51,6 +51,7 @@ namespace vk { /// vulkan device function pointers struct VulkanDeviceFuncs { PFN_vkGetDeviceQueue GetDeviceQueue; + PFN_vkQueueWaitIdle QueueWaitIdle; PFN_vkDeviceWaitIdle DeviceWaitIdle; PFN_vkCreateCommandPool CreateCommandPool; PFN_vkDestroyCommandPool DestroyCommandPool; @@ -119,11 +120,11 @@ namespace vk { }; /// initialize vulkan device function pointers - /// @param fi instance function pointers + /// @param f function to get device proc addresses /// @param device logical device handle /// @param graphical whether the device is graphical (rather than compute) /// @return initialized function pointers - VulkanDeviceFuncs initVulkanDeviceFuncs(const VulkanInstanceFuncs& fi, VkDevice device, + VulkanDeviceFuncs initVulkanDeviceFuncs(PFN_vkGetDeviceProcAddr f, VkDevice device, bool graphical); /// vulkan version wrapper diff --git a/lsfg-vk-common/src/vulkan/vulkan.cpp b/lsfg-vk-common/src/vulkan/vulkan.cpp index b6a2c7a..9d1bfec 100644 --- a/lsfg-vk-common/src/vulkan/vulkan.cpp +++ b/lsfg-vk-common/src/vulkan/vulkan.cpp @@ -51,9 +51,8 @@ namespace { namespace { template - T ipa(PFN_vkGetInstanceProcAddr mpa, VkInstance instance, const char* name) { - T func = reinterpret_cast( - mpa(instance, name)); + T ipa(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, VkInstance instance, const char* name) { + T func = reinterpret_cast(vkGetInstanceProcAddr(instance, name)); if (!func) throw ls::vulkan_error("failed to get instance proc addr for " + std::string(name)); return func; @@ -86,8 +85,7 @@ namespace { if (res != VK_SUCCESS) throw ls::vulkan_error(res, "vkCreateInstance() failed"); - auto defunc = - ipa(get_mpa(), handle, "vkDestroyInstance"); + auto defunc = ipa(get_mpa(), handle, "vkDestroyInstance"); if (!defunc) throw ls::vulkan_error("failed to get vkDestroyInstance symbol"); return ls::owned_ptr( @@ -150,9 +148,8 @@ namespace { } template - T dpa(const VulkanInstanceFuncs& funcs, VkDevice device, const char* name) { - T func = reinterpret_cast( - funcs.GetDeviceProcAddr(device, name)); + T dpa(PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr, VkDevice device, const char* name) { + T func = reinterpret_cast(vkGetDeviceProcAddr(device, name)); if (!func) throw ls::vulkan_error("failed to get device proc addr for " + std::string(name)); return func; @@ -192,8 +189,7 @@ namespace { if (res != VK_SUCCESS) throw ls::vulkan_error(res, "vkCreateDevice() failed"); - auto defunc = - dpa(fi, handle, "vkDestroyDevice"); + auto defunc = dpa(fi.GetDeviceProcAddr, handle, "vkDestroyDevice"); if (!defunc) throw ls::vulkan_error("failed to get vkDestroyDevice symbol"); return ls::owned_ptr( @@ -312,10 +308,11 @@ VulkanInstanceFuncs vk::initVulkanInstanceFuncs(VkInstance i, PFN_vkGetInstanceP } /// initialize vulkan device function pointers -VulkanDeviceFuncs vk::initVulkanDeviceFuncs(const VulkanInstanceFuncs& f, VkDevice d, +VulkanDeviceFuncs vk::initVulkanDeviceFuncs(PFN_vkGetDeviceProcAddr f, VkDevice d, bool graphical) { return { .GetDeviceQueue = dpa(f, d, "vkGetDeviceQueue"), + .QueueWaitIdle = dpa(f, d, "vkQueueWaitIdle"), .DeviceWaitIdle = dpa(f, d, "vkDeviceWaitIdle"), .CreateCommandPool = dpa(f, d, "vkCreateCommandPool"), .DestroyCommandPool = dpa(f, d, "vkDestroyCommandPool"), @@ -420,7 +417,7 @@ Vulkan::Vulkan(const std::string& appName, version appVersion, )), setLoaderData(setLoaderData), device_funcs(initVulkanDeviceFuncs( - this->instance_funcs, + this->instance_funcs.GetDeviceProcAddr, *this->device, false )), computeQueue(getQueue(this->device_funcs, *this->device,