vulkan: Try loading libvulkan.so.1 first
Change-Id: I876899fbfc126136f2842e9361e21ac10af8f14b Pick-to: 6.3 Fixes: QTBUG-101592 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
dfe5f99120
commit
888b75aa12
@ -81,19 +81,45 @@ QBasicPlatformVulkanInstance::~QBasicPlatformVulkanInstance()
|
||||
m_vkDestroyInstance(m_vkInst, nullptr);
|
||||
}
|
||||
|
||||
void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName)
|
||||
void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion)
|
||||
{
|
||||
if (qEnvironmentVariableIsSet("QT_VULKAN_LIB"))
|
||||
m_vulkanLib.setFileName(QString::fromUtf8(qgetenv("QT_VULKAN_LIB")));
|
||||
else
|
||||
m_vulkanLib.setFileName(defaultLibraryName);
|
||||
QVarLengthArray<std::pair<QString, int>, 3> loadList;
|
||||
|
||||
if (!m_vulkanLib.load()) {
|
||||
qWarning("Failed to load %s: %s", qPrintable(m_vulkanLib.fileName()), qPrintable(m_vulkanLib.errorString()));
|
||||
// First in the list of libraries to try is the manual override, relevant on
|
||||
// embedded systems without a Vulkan loader and possibly with custom vendor
|
||||
// library names.
|
||||
if (qEnvironmentVariableIsSet("QT_VULKAN_LIB"))
|
||||
loadList.append({ QString::fromUtf8(qgetenv("QT_VULKAN_LIB")), -1 });
|
||||
|
||||
// Then what the platform specified. On Linux the version is likely 1, thus
|
||||
// preferring libvulkan.so.1 over libvulkan.so.
|
||||
loadList.append({ defaultLibraryName, defaultLibraryVersion });
|
||||
|
||||
// If there was a version given, we must still try without it if the first
|
||||
// attempt fails, so that libvulkan.so is picked up if the .so.1 is not
|
||||
// present on the system (so loaderless embedded systems still work).
|
||||
if (defaultLibraryVersion >= 0)
|
||||
loadList.append({ defaultLibraryName, -1 });
|
||||
|
||||
bool ok = false;
|
||||
for (const auto &lib : loadList) {
|
||||
m_vulkanLib.reset(new QLibrary);
|
||||
if (lib.second >= 0)
|
||||
m_vulkanLib->setFileNameAndVersion(lib.first, lib.second);
|
||||
else
|
||||
m_vulkanLib->setFileName(lib.first);
|
||||
if (m_vulkanLib->load()) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
qWarning("Failed to load %s: %s", qPrintable(m_vulkanLib->fileName()), qPrintable(m_vulkanLib->errorString()));
|
||||
return;
|
||||
}
|
||||
|
||||
init(&m_vulkanLib);
|
||||
init(m_vulkanLib.get());
|
||||
}
|
||||
|
||||
void QBasicPlatformVulkanInstance::init(QLibrary *lib)
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
const QList<QVulkanInstance::DebugFilter> *debugFilters() const { return &m_debugFilters; }
|
||||
|
||||
protected:
|
||||
void loadVulkanLibrary(const QString &defaultLibraryName);
|
||||
void loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion = -1);
|
||||
void init(QLibrary *lib);
|
||||
void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts);
|
||||
|
||||
@ -93,7 +93,7 @@ protected:
|
||||
private:
|
||||
void setupDebugOutput();
|
||||
|
||||
QLibrary m_vulkanLib;
|
||||
std::unique_ptr<QLibrary> m_vulkanLib;
|
||||
|
||||
bool m_ownsVkInst;
|
||||
VkResult m_errorCode;
|
||||
|
@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
|
||||
QVkKhrDisplayVulkanInstance::QVkKhrDisplayVulkanInstance(QVulkanInstance *instance)
|
||||
: m_instance(instance)
|
||||
{
|
||||
loadVulkanLibrary(QStringLiteral("vulkan"));
|
||||
loadVulkanLibrary(QStringLiteral("vulkan"), 1);
|
||||
}
|
||||
|
||||
void QVkKhrDisplayVulkanInstance::createOrAdoptInstance()
|
||||
|
@ -48,7 +48,7 @@ QXcbVulkanInstance::QXcbVulkanInstance(QVulkanInstance *instance)
|
||||
m_getPhysDevPresSupport(nullptr),
|
||||
m_createSurface(nullptr)
|
||||
{
|
||||
loadVulkanLibrary(QStringLiteral("vulkan"));
|
||||
loadVulkanLibrary(QStringLiteral("vulkan"), 1);
|
||||
}
|
||||
|
||||
QXcbVulkanInstance::~QXcbVulkanInstance()
|
||||
|
Loading…
Reference in New Issue
Block a user