Add fallback logic for locating MoltenVK & loader on macOS

This commit is contained in:
baldurk
2018-09-04 15:55:17 +01:00
parent bec9c56300
commit d20624b32f
7 changed files with 44 additions and 7 deletions
+4 -1
View File
@@ -81,7 +81,10 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h
h = ANativeWindow_getHeight(outw.wnd);
}
const char *VulkanLibraryName = "libvulkan.so";
void *LoadVulkanLibrary()
{
return Process::LoadModule("libvulkan.so");
}
bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, std::vector<std::string> &myJSONs,
std::vector<std::string> &otherJSONs)
+29 -1
View File
@@ -22,6 +22,7 @@
* THE SOFTWARE.
******************************************************************************/
#include "strings/string_utils.h"
#include "vk_core.h"
#include "vk_replay.h"
@@ -86,7 +87,7 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h
h = getCALayerHeight(outw.wnd);
}
const char *VulkanLibraryName = "libvulkan.1.dylib";
static const char *VulkanLibraryName = "libvulkan.1.dylib";
string GetThisLibPath()
{
@@ -97,4 +98,31 @@ string GetThisLibPath()
return info.dli_fname;
}
return "";
}
void *LoadVulkanLibrary()
{
// first try to load the module globally. If so we assume the user has a global (or at least
// user-wide) configuration that we should use.
void *ret = Process::LoadModule(VulkanLibraryName);
if(ret)
{
RDCLOG("Loaded global libvulkan.1.dylib, using default MoltenVK environment");
return ret;
}
// if not, we fall back to our embedded libvulkan and also force use of our embedded ICD.
std::string libpath = GetThisLibPath();
libpath = dirname(libpath) + "/../MoltenVK/";
RDCLOG("Couldn't load global libvulkan.1.dylib, falling back to bundled MoltenVK in %s",
libpath.c_str());
Process::RegisterEnvironmentModification(EnvironmentModification(
EnvMod::Set, EnvSep::NoSep, "VK_ICD_FILENAMES", (libpath + "MoltenVK_icd.json").c_str()));
Process::ApplyEnvironmentModification();
return Process::LoadModule((libpath + VulkanLibraryName).c_str());
}
+1 -1
View File
@@ -176,7 +176,7 @@ struct GPUBuffer
};
// in vk_<platform>.cpp
extern const char *VulkanLibraryName;
extern void *LoadVulkanLibrary();
class VkDriverInfo
{
+4 -1
View File
@@ -235,7 +235,10 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h
RDCERR("Unrecognised/unsupported window system %d", outw.m_WindowSystem);
}
const char *VulkanLibraryName = "libvulkan.so.1";
void *LoadVulkanLibrary()
{
return Process::LoadModule("libvulkan.so.1");
}
string GetThisLibPath()
{
+1 -1
View File
@@ -3405,7 +3405,7 @@ ReplayStatus Vulkan_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver)
Process::ApplyEnvironmentModification();
void *module = Process::LoadModule(VulkanLibraryName);
void *module = LoadVulkanLibrary();
if(module == NULL)
{
+4 -1
View File
@@ -156,7 +156,10 @@ VkBool32 WrappedVulkan::vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysica
->GetPhysicalDeviceWin32PresentationSupportKHR(Unwrap(physicalDevice), queueFamilyIndex);
}
const char *VulkanLibraryName = "vulkan-1.dll";
void *LoadVulkanLibrary()
{
return Process::LoadModule("vulkan-1.dll");
}
std::wstring GetJSONPath(bool wow6432)
{
@@ -430,7 +430,7 @@ VkResult WrappedVulkan::vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo
std::vector<VkExtensionProperties> supportedExts;
// enumerate what instance extensions are available
void *module = Process::LoadModule(VulkanLibraryName);
void *module = LoadVulkanLibrary();
if(module)
{
PFN_vkEnumerateInstanceExtensionProperties enumInstExts =