summaryrefslogtreecommitdiffstats
path: root/tests/manual/rhi/offscreen/offscreen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/rhi/offscreen/offscreen.cpp')
-rw-r--r--tests/manual/rhi/offscreen/offscreen.cpp44
1 files changed, 15 insertions, 29 deletions
diff --git a/tests/manual/rhi/offscreen/offscreen.cpp b/tests/manual/rhi/offscreen/offscreen.cpp
index b36c3b3667..86bf5ad5a9 100644
--- a/tests/manual/rhi/offscreen/offscreen.cpp
+++ b/tests/manual/rhi/offscreen/offscreen.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
#include <QImage>
@@ -7,28 +7,10 @@
#include <QFile>
#include <QLoggingCategory>
#include <QCommandLineParser>
-#include <QtGui/private/qshader_p.h>
-
-#include <QtGui/private/qrhinull_p.h>
-
-#ifndef QT_NO_OPENGL
-#include <QtGui/private/qrhigles2_p.h>
-#include <QOffscreenSurface>
-#endif
-
-#if QT_CONFIG(vulkan)
#include <QLoggingCategory>
-#include <QtGui/private/qrhivulkan_p.h>
-#endif
-
-#ifdef Q_OS_WIN
-#include <QtGui/private/qrhid3d11_p.h>
-#include <QtGui/private/qrhid3d12_p.h>
-#endif
+#include <QOffscreenSurface>
-#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
-#include <QtGui/private/qrhimetal_p.h>
-#endif
+#include <rhi/qrhi.h>
//#define TEST_FINISH
@@ -86,7 +68,7 @@ int main(int argc, char **argv)
#if defined(Q_OS_WIN)
graphicsApi = D3D11;
-#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS)
+#elif QT_CONFIG(metal)
graphicsApi = Metal;
#elif QT_CONFIG(vulkan)
graphicsApi = Vulkan;
@@ -126,10 +108,11 @@ int main(int argc, char **argv)
qDebug("This is a multi-api example, use command line arguments to override:\n%s", qPrintable(cmdLineParser.helpText()));
QRhi *r = nullptr;
+ QRhi::Flags rhiFlags = QRhi::EnableTimestamps;
if (graphicsApi == Null) {
QRhiNullInitParams params;
- r = QRhi::create(QRhi::Null, &params);
+ r = QRhi::create(QRhi::Null, &params, rhiFlags);
}
#if QT_CONFIG(vulkan)
@@ -137,10 +120,11 @@ int main(int argc, char **argv)
if (graphicsApi == Vulkan) {
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
+ inst.setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
if (inst.create()) {
QRhiVulkanInitParams params;
params.inst = &inst;
- r = QRhi::create(QRhi::Vulkan, &params);
+ r = QRhi::create(QRhi::Vulkan, &params, rhiFlags);
} else {
qWarning("Failed to create Vulkan instance, switching to OpenGL");
graphicsApi = OpenGL;
@@ -154,7 +138,7 @@ int main(int argc, char **argv)
offscreenSurface.reset(QRhiGles2InitParams::newFallbackSurface());
QRhiGles2InitParams params;
params.fallbackSurface = offscreenSurface.data();
- r = QRhi::create(QRhi::OpenGLES2, &params);
+ r = QRhi::create(QRhi::OpenGLES2, &params, rhiFlags);
}
#endif
@@ -162,18 +146,18 @@ int main(int argc, char **argv)
if (graphicsApi == D3D11) {
QRhiD3D11InitParams params;
params.enableDebugLayer = true;
- r = QRhi::create(QRhi::D3D11, &params);
+ r = QRhi::create(QRhi::D3D11, &params, rhiFlags);
} else if (graphicsApi == D3D12) {
QRhiD3D12InitParams params;
params.enableDebugLayer = true;
- r = QRhi::create(QRhi::D3D12, &params);
+ r = QRhi::create(QRhi::D3D12, &params, rhiFlags);
}
#endif
-#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
+#if QT_CONFIG(metal)
if (graphicsApi == Metal) {
QRhiMetalInitParams params;
- r = QRhi::create(QRhi::Metal, &params);
+ r = QRhi::create(QRhi::Metal, &params, rhiFlags);
}
#endif
@@ -300,6 +284,8 @@ int main(int argc, char **argv)
#ifdef TEST_FINISH
r->endOffscreenFrame();
#endif
+ if (r->isFeatureSupported(QRhi::Timestamps))
+ qDebug() << "GPU time:" << cb->lastCompletedGpuTime() << "seconds (may refer to a previous frame)";
}
delete ps;