From f50f5bc9bcd5c411a2d22fe9275ebd474aa2b6f2 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 14 Mar 2023 13:01:34 +0100 Subject: [PATCH] [vulkan] Allow importing existing Vulkan dispatch tables --- src/vulkan/vulkan_loader.cpp | 9 ++++++++- src/vulkan/vulkan_loader.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vulkan/vulkan_loader.cpp b/src/vulkan/vulkan_loader.cpp index e5981e94..17e9b629 100644 --- a/src/vulkan/vulkan_loader.cpp +++ b/src/vulkan/vulkan_loader.cpp @@ -45,8 +45,13 @@ namespace dxvk::vk { std::tie(m_library, m_getInstanceProcAddr) = loadVulkanLibrary(); } + LibraryLoader::LibraryLoader(PFN_vkGetInstanceProcAddr loaderProc) { + m_getInstanceProcAddr = loaderProc; + } + LibraryLoader::~LibraryLoader() { - FreeLibrary(m_library); + if (m_library) + FreeLibrary(m_library); } PFN_vkVoidFunction LibraryLoader::sym(VkInstance instance, const char* name) const { @@ -84,6 +89,8 @@ namespace dxvk::vk { LibraryFn::LibraryFn() { } + LibraryFn::LibraryFn(PFN_vkGetInstanceProcAddr loaderProc) + : LibraryLoader(loaderProc) { } LibraryFn::~LibraryFn() { } diff --git a/src/vulkan/vulkan_loader.h b/src/vulkan/vulkan_loader.h index 89944e09..6939985f 100644 --- a/src/vulkan/vulkan_loader.h +++ b/src/vulkan/vulkan_loader.h @@ -20,6 +20,7 @@ namespace dxvk::vk { */ struct LibraryLoader : public RcObject { LibraryLoader(); + LibraryLoader(PFN_vkGetInstanceProcAddr loaderProc); ~LibraryLoader(); PFN_vkVoidFunction sym(VkInstance instance, const char* name) const; PFN_vkVoidFunction sym(const char* name) const; @@ -75,6 +76,7 @@ namespace dxvk::vk { */ struct LibraryFn : LibraryLoader { LibraryFn(); + LibraryFn(PFN_vkGetInstanceProcAddr loaderProc); ~LibraryFn(); VULKAN_FN(vkCreateInstance);