From 7f8a0d35d9e76f3831f03208fe6ba70dd78a67d1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 2 Sep 2018 12:52:41 +0100 Subject: [PATCH] Handle not being able to load vulkan library at runtime * We try to call vkEnumerateInstanceExtensionProperties to figure out instance extensions we might want to add, and we can only do this at the moment by loading the vulkan dynamic library and calling into it. --- .../vulkan/wrappers/vk_device_funcs.cpp | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 867c3bef5..86cff7fa3 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -428,17 +428,30 @@ VkResult WrappedVulkan::vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo hasDebugReport = true; } + std::vector supportedExts; + // enumerate what instance extensions are available void *module = Process::LoadModule(VulkanLibraryName); - PFN_vkEnumerateInstanceExtensionProperties enumInstExts = - (PFN_vkEnumerateInstanceExtensionProperties)Process::GetFunctionAddress( - module, "vkEnumerateInstanceExtensionProperties"); + if(module) + { + PFN_vkEnumerateInstanceExtensionProperties enumInstExts = + (PFN_vkEnumerateInstanceExtensionProperties)Process::GetFunctionAddress( + module, "vkEnumerateInstanceExtensionProperties"); - uint32_t numSupportedExts = 0; - enumInstExts(NULL, &numSupportedExts, NULL); + if(enumInstExts) + { + uint32_t numSupportedExts = 0; + enumInstExts(NULL, &numSupportedExts, NULL); - std::vector supportedExts(numSupportedExts); - enumInstExts(NULL, &numSupportedExts, &supportedExts[0]); + supportedExts.resize(numSupportedExts); + enumInstExts(NULL, &numSupportedExts, &supportedExts[0]); + } + } + + if(supportedExts.empty()) + RDCWARN( + "Couldn't load vkEnumerateInstanceExtensionProperties in vkCreateInstance to enumerate " + "instance extensions"); // always enable debug report, if it's available if(!hasDebugReport)