From 70c837fba2f8fb0fe19474ef5ba44fdf3cf9e41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Wed, 13 Mar 2019 15:33:33 +0100 Subject: [PATCH] Add DispatchLoaderDynamic constructor for use with linked vulkan library. (#300) --- VulkanHppGenerator.cpp | 14 ++++++++++++++ vulkan/vulkan.hpp | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 58bac3d..3902232 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -2444,11 +2444,25 @@ void VulkanHppGenerator::writeDispatchLoaderDynamic(std::ostream &os) public: DispatchLoaderDynamic() = default; + // This interface is designed to be used for per-device function pointers in combination with a linked vulkan library. + DispatchLoaderDynamic(vk::Instance const& instance, vk::Device const& device = {}) + { + init(instance, device); + } + + // This interface is designed to be used for per-device function pointers in combination with a linked vulkan library. + void init(vk::Instance const& instance, vk::Device const& device = {}) + { + init(instance, ::vkGetInstanceProcAddr, device, device ? ::vkGetDeviceProcAddr : nullptr); + } + + // This interface does not require a linked vulkan library. DispatchLoaderDynamic( VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device = VK_NULL_HANDLE, PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr ) { init( instance, getInstanceProcAddr, device, getDeviceProcAddr ); } + // This interface does not require a linked vulkan library. void init( VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device = VK_NULL_HANDLE, PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr ) { assert(instance && getInstanceProcAddr); diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 17b0a25..1ca3e04 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -54998,11 +54998,25 @@ namespace VULKAN_HPP_NAMESPACE public: DispatchLoaderDynamic() = default; + // This interface is designed to be used for per-device function pointers in combination with a linked vulkan library. + DispatchLoaderDynamic(vk::Instance const& instance, vk::Device const& device = {}) + { + init(instance, device); + } + + // This interface is designed to be used for per-device function pointers in combination with a linked vulkan library. + void init(vk::Instance const& instance, vk::Device const& device = {}) + { + init(instance, ::vkGetInstanceProcAddr, device, device ? ::vkGetDeviceProcAddr : nullptr); + } + + // This interface does not require a linked vulkan library. DispatchLoaderDynamic( VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device = VK_NULL_HANDLE, PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr ) { init( instance, getInstanceProcAddr, device, getDeviceProcAddr ); } + // This interface does not require a linked vulkan library. void init( VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device = VK_NULL_HANDLE, PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr ) { assert(instance && getInstanceProcAddr);