aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPasi Petäjäjärvi <pasi.petajajarvi@qt.io>2023-09-15 11:53:22 +0300
committerPasi Petäjäjärvi <pasi.petajajarvi@qt.io>2023-10-11 07:24:28 +0000
commit0a46a640e317395abdc89d3910bdabf7b8017762 (patch)
tree218ce1cfbdccb203a70267062526ae0ddd7502c5
parent7acb7e2b4382745d7759ea1cc962b7eba73fc54f (diff)
Improve Vulkan backend support handling when requested by userHEADdev
Previous usage of defines fails as those are available on compile time when Vulkan SDK is installed and cause QT_QPA_PLATFORM=vkkhrdisplay to bet set for desktop also. Since dd3840a1a201318c8f089dc7d34ec38f64e05b4e we can get platform plugin name before creating actual QGuiApplication instance. For older Qt versions provide hint message for embedded for possible need to set env variable. Also check if Qt was build with Vulkan support and if not inform user and exit application. Change-Id: I781f7e4e048dd8417aba14ecc2cb919b1b9ae136 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--src/main.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7b43df0..cee21c2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -463,11 +463,18 @@ int main(int argc, char **argv)
useVulkan = true;
}
}
-
if (useVulkan) {
+#if QT_CONFIG(vulkan)
qputenv("QSG_RHI_BACKEND", QByteArray("vulkan"));
-#if !defined(VK_USE_PLATFORM_ANDROID_KHR) && !defined(VK_USE_PLATFORM_MACOS_MVK) && !defined(VK_USE_PLATFORM_WIN32_KHR) && !defined(VK_USE_PLATFORM_XCB_KHR)
- qputenv("QT_QPA_PLATFORM", QByteArray("vkkhrdisplay"));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 3)
+ if (QGuiApplication::platformName().contains("eglfs"))
+ qputenv("QT_QPA_PLATFORM", QByteArray("vkkhrdisplay"));
+#else
+ qInfo() << "Vulkan backend requested. If qmlbench fails to start, and executed on embedded, you need to define QT_QPA_PLATFORM=vkkhrdisplay";
+#endif
+#else
+ qWarning() << "Vulkan backend requested, but Qt was build without Vulkan support. Exiting.";
+ exit(0);
#endif
}