From 613779568291aee01dd3656dfe2bcfb12f64b9fd Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 7 Jul 2019 16:48:53 +0900 Subject: [PATCH] Use deep binding for the vulkan loader This fixes the problem with using vkGetInstanceProcAddr to find global vulkan functions. --- libs/video/renderer/vulkan/vulkan_vid_common.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libs/video/renderer/vulkan/vulkan_vid_common.c b/libs/video/renderer/vulkan/vulkan_vid_common.c index 42b751de0..9366799cb 100644 --- a/libs/video/renderer/vulkan/vulkan_vid_common.c +++ b/libs/video/renderer/vulkan/vulkan_vid_common.c @@ -64,7 +64,8 @@ static VulkanDevice_t *vulkan_device; static void load_vulkan_library (void) { - vulkan_library = dlopen (vulkan_library_name->string, RTLD_NOW); + vulkan_library = dlopen (vulkan_library_name->string, + RTLD_DEEPBIND | RTLD_NOW); if (!vulkan_library) { Sys_Error ("Couldn't load vulkan library %s: %s", vulkan_library_name->name, dlerror ()); @@ -76,13 +77,8 @@ load_vulkan_library (void) Sys_Error ("Couldn't find exported vulkan function %s", #name); \ } - // Can't use vkGetInstanceProcAddr (0, ...) here because it grabs from - // the whole exe and thus sees the function pointers instead of the actual - // functions. Sure, could rename all the function pointers, but while that - // worked for gl and glsl, it also made it a real pain to work with the - // spec (or man pages, etc). Of course, namespaces would help, too. #define GLOBAL_LEVEL_VULKAN_FUNCTION(name) \ - name = (PFN_##name) dlsym (vulkan_library, #name); \ + name = (PFN_##name) vkGetInstanceProcAddr (0, #name); \ if (!name) { \ Sys_Error ("Couldn't find global-level function %s", #name); \ }