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);
|
m_vkDestroyInstance(m_vkInst, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName)
|
void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion)
|
||||||
{
|
{
|
||||||
if (qEnvironmentVariableIsSet("QT_VULKAN_LIB"))
|
QVarLengthArray<std::pair<QString, int>, 3> loadList;
|
||||||
m_vulkanLib.setFileName(QString::fromUtf8(qgetenv("QT_VULKAN_LIB")));
|
|
||||||
else
|
|
||||||
m_vulkanLib.setFileName(defaultLibraryName);
|
|
||||||
|
|
||||||
if (!m_vulkanLib.load()) {
|
// First in the list of libraries to try is the manual override, relevant on
|
||||||
qWarning("Failed to load %s: %s", qPrintable(m_vulkanLib.fileName()), qPrintable(m_vulkanLib.errorString()));
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
init(&m_vulkanLib);
|
init(m_vulkanLib.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBasicPlatformVulkanInstance::init(QLibrary *lib)
|
void QBasicPlatformVulkanInstance::init(QLibrary *lib)
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
const QList<QVulkanInstance::DebugFilter> *debugFilters() const { return &m_debugFilters; }
|
const QList<QVulkanInstance::DebugFilter> *debugFilters() const { return &m_debugFilters; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void loadVulkanLibrary(const QString &defaultLibraryName);
|
void loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion = -1);
|
||||||
void init(QLibrary *lib);
|
void init(QLibrary *lib);
|
||||||
void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts);
|
void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts);
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void setupDebugOutput();
|
void setupDebugOutput();
|
||||||
|
|
||||||
QLibrary m_vulkanLib;
|
std::unique_ptr<QLibrary> m_vulkanLib;
|
||||||
|
|
||||||
bool m_ownsVkInst;
|
bool m_ownsVkInst;
|
||||||
VkResult m_errorCode;
|
VkResult m_errorCode;
|
||||||
|
@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
QVkKhrDisplayVulkanInstance::QVkKhrDisplayVulkanInstance(QVulkanInstance *instance)
|
QVkKhrDisplayVulkanInstance::QVkKhrDisplayVulkanInstance(QVulkanInstance *instance)
|
||||||
: m_instance(instance)
|
: m_instance(instance)
|
||||||
{
|
{
|
||||||
loadVulkanLibrary(QStringLiteral("vulkan"));
|
loadVulkanLibrary(QStringLiteral("vulkan"), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QVkKhrDisplayVulkanInstance::createOrAdoptInstance()
|
void QVkKhrDisplayVulkanInstance::createOrAdoptInstance()
|
||||||
|
@ -48,7 +48,7 @@ QXcbVulkanInstance::QXcbVulkanInstance(QVulkanInstance *instance)
|
|||||||
m_getPhysDevPresSupport(nullptr),
|
m_getPhysDevPresSupport(nullptr),
|
||||||
m_createSurface(nullptr)
|
m_createSurface(nullptr)
|
||||||
{
|
{
|
||||||
loadVulkanLibrary(QStringLiteral("vulkan"));
|
loadVulkanLibrary(QStringLiteral("vulkan"), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QXcbVulkanInstance::~QXcbVulkanInstance()
|
QXcbVulkanInstance::~QXcbVulkanInstance()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user