Skip to content

Commit

Permalink
Vulkan: Make sure that Qt will load the Vulkan library
Browse files Browse the repository at this point in the history
  • Loading branch information
zaps166 committed Jun 18, 2024
1 parent 935a51e commit 74ee99c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/qmplay2/vulkan/VulkanInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,32 @@ void Instance::prepareDestroy()

void Instance::init(bool doObtainPhysicalDevice)
{
#ifdef Q_OS_UNIX
static bool envVarInitialized = [] {
if (qEnvironmentVariableIsSet("QT_VULKAN_LIB"))
return true;

QLibrary lib;

lib.setFileName("libvulkan.so");
if (lib.load())
{
qputenv("QT_VULKAN_LIB", "libvulkan.so");
return true;
}

lib.setFileName("libvulkan.so.1");
if (lib.load())
{
qputenv("QT_VULKAN_LIB", "libvulkan.so.1");
return true;
}

return true;
}();
Q_UNUSED(envVarInitialized);
#endif

static const auto getInstanceProcAddr = AbstractInstance::loadVulkanLibrary(
qEnvironmentVariable("QT_VULKAN_LIB").toStdString()
);
Expand Down

0 comments on commit 74ee99c

Please sign in to comment.