novelrt / NovelRT

A cross-platform 2D game engine accompanied by a strong toolset for visual novels.
MIT License
183 stars 43 forks source link

Vendored MoltenVK fails to find ICD without workaround #479

Closed capnkenny closed 1 year ago

capnkenny commented 2 years ago

At this time, if a NovelRT user vendors MoltenVK for macOS builds, they will need to apply the following workaround for their applications to run:

#if NOVELRT_MOLTENVK_VENDORED

auto icdPath = NovelRT::Utilities::Misc::getExecutablePath() / "MoltenVK_icd.json"; setenv("VK_ICD_FILENAMES", icdPath.c_str(), 0); logger.logInfo("macOS detected - setting VK_ICD_FILENAMES to path: {}", icdPath.c_str());

#endif

This is pretty unsightly, but it works to allow MoltenVK to search the proper path and find the ICD file. However, it needs to be done for every sample or other application using NovelRT as a library lest we make macOS throw exceptions due to not initialising Vulkan.

We should find an alternative solution to this that would be more portable and cleaner if we can.

capnkenny commented 2 years ago

To be specific - this is not an issue with how the Engine is using Vulkan/MoltenVK, but rather how MoltenVK is searching for MoltenVK_icd.json