summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michaƫl Celerier <jean-michael.celerier@kdab.com>2019-12-27 09:17:54 +0100
committerPaul Lemire <paul.lemire@kdab.com>2020-01-15 07:02:44 +0100
commit5e9b597281aedeaa358f2d6a1586405ea59906f2 (patch)
tree2c934eadf2131e537d2e6bc095204ee1abd3a3a7
parente286e94caf83397a4c5942dc0b152f5dcd228516 (diff)
Add support for multiple surface types in Qt3DWindow
-rw-r--r--src/extras/defaults/qt3dwindow.cpp31
-rw-r--r--src/extras/defaults/qt3dwindow.h2
2 files changed, 30 insertions, 3 deletions
diff --git a/src/extras/defaults/qt3dwindow.cpp b/src/extras/defaults/qt3dwindow.cpp
index 04b8554f1..134026a9a 100644
--- a/src/extras/defaults/qt3dwindow.cpp
+++ b/src/extras/defaults/qt3dwindow.cpp
@@ -64,6 +64,7 @@
#include <private/qrendersettings_p.h>
#include <QEvent>
+#include <QVulkanInstance>
static void initResources()
{
@@ -91,7 +92,7 @@ Qt3DWindowPrivate::Qt3DWindowPrivate()
{
}
-Qt3DWindow::Qt3DWindow(QScreen *screen)
+Qt3DWindow::Qt3DWindow(QScreen *screen, QSurface::SurfaceType surfaceType)
: QWindow(*new Qt3DWindowPrivate(), nullptr)
{
Q_D(Qt3DWindow);
@@ -101,7 +102,33 @@ Qt3DWindow::Qt3DWindow(QScreen *screen)
if (!d->parentWindow)
d->connectToScreen(screen ? screen : d->topLevelScreen.data());
- setSurfaceType(QSurface::OpenGLSurface);
+ switch(surfaceType)
+ {
+ case QSurface::VulkanSurface:
+ {
+ static QVulkanInstance inst;
+#ifndef Q_OS_ANDROID
+ inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
+#else
+ inst.setLayers(QByteArrayList()
+ << "VK_LAYER_GOOGLE_threading"
+ << "VK_LAYER_LUNARG_parameter_validation"
+ << "VK_LAYER_LUNARG_object_tracker"
+ << "VK_LAYER_LUNARG_core_validation"
+ << "VK_LAYER_LUNARG_image"
+ << "VK_LAYER_LUNARG_swapchain"
+ << "VK_LAYER_GOOGLE_unique_objects");
+#endif
+ inst.setExtensions(QByteArrayList()
+ << "VK_KHR_get_physical_device_properties2");
+ Q_ASSERT (inst.create());
+ setVulkanInstance(&inst);
+ }
+ default:
+ break;
+ }
+
+ setSurfaceType(surfaceType);
resize(1024, 768);
diff --git a/src/extras/defaults/qt3dwindow.h b/src/extras/defaults/qt3dwindow.h
index bf4f44ff0..69b6daefe 100644
--- a/src/extras/defaults/qt3dwindow.h
+++ b/src/extras/defaults/qt3dwindow.h
@@ -90,7 +90,7 @@ class Q_3DEXTRASSHARED_EXPORT Qt3DWindow : public QWindow
{
Q_OBJECT
public:
- Qt3DWindow(QScreen *screen = nullptr);
+ Qt3DWindow(QScreen *screen = nullptr, QSurface::SurfaceType surfaceType = QSurface::OpenGLSurface);
~Qt3DWindow();
void registerAspect(Qt3DCore::QAbstractAspect *aspect);