summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/rhi
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/rhi')
-rw-r--r--tests/auto/gui/rhi/CMakeLists.txt3
-rw-r--r--tests/auto/gui/rhi/qrhi/CMakeLists.txt5
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp49
-rw-r--r--tests/auto/gui/rhi/qshader/CMakeLists.txt5
-rw-r--r--tests/auto/gui/rhi/qshader/tst_qshader.cpp11
5 files changed, 66 insertions, 7 deletions
diff --git a/tests/auto/gui/rhi/CMakeLists.txt b/tests/auto/gui/rhi/CMakeLists.txt
index 786e121f00..2d7b2d651d 100644
--- a/tests/auto/gui/rhi/CMakeLists.txt
+++ b/tests/auto/gui/rhi/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
# Generated from rhi.pro.
add_subdirectory(qshader)
diff --git a/tests/auto/gui/rhi/qrhi/CMakeLists.txt b/tests/auto/gui/rhi/qrhi/CMakeLists.txt
index e0e97f6509..3ac91893bd 100644
--- a/tests/auto/gui/rhi/qrhi/CMakeLists.txt
+++ b/tests/auto/gui/rhi/qrhi/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
# Generated from qrhi.pro.
#####################################################################
@@ -13,7 +16,7 @@ file(GLOB_RECURSE qrhi_resource_files
qt_internal_add_test(tst_qrhi
SOURCES
tst_qrhi.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
TESTDATA ${qrhi_resource_files}
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 6409c43bc4..76527f83ed 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -52,6 +52,8 @@ private slots:
void rhiTestDataOpenGL();
void create_data();
void create();
+ void stats_data();
+ void stats();
void nativeHandles_data();
void nativeHandles();
void nativeHandlesImportVulkan();
@@ -163,6 +165,12 @@ private:
void tst_QRhi::initTestCase()
{
#ifdef TST_GL
+ QSurfaceFormat fmt;
+ fmt.setDepthBufferSize(24);
+ fmt.setStencilBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(fmt);
+
+ initParams.gl.format = QSurfaceFormat::defaultFormat();
fallbackSurface = QRhiGles2InitParams::newFallbackSurface();
initParams.gl.fallbackSurface = fallbackSurface;
#endif
@@ -255,6 +263,7 @@ void tst_QRhi::create()
QCOMPARE(rhi->backend(), impl);
QVERIFY(strcmp(rhi->backendName(), ""));
+ QVERIFY(!strcmp(rhi->backendName(), QRhi::backendName(rhi->backend())));
QVERIFY(!rhi->driverInfo().deviceName.isEmpty());
QCOMPARE(rhi->thread(), QThread::currentThread());
@@ -399,6 +408,38 @@ void tst_QRhi::create()
}
}
+void tst_QRhi::stats_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::stats()
+{
+ QFETCH(QRhi::Implementation, impl);
+ QFETCH(QRhiInitParams *, initParams);
+
+ QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ if (!rhi)
+ QSKIP("QRhi could not be created, skipping testing statistics getter");
+
+ QRhiStats stats = rhi->statistics();
+ qDebug() << stats;
+ QCOMPARE(stats.totalPipelineCreationTime, 0);
+
+ if (impl == QRhi::Vulkan) {
+ QScopedPointer<QRhiBuffer> buf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, 32768));
+ QVERIFY(buf->create());
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(1024, 1024)));
+ QVERIFY(tex->create());
+
+ stats = rhi->statistics();
+ qDebug() << stats;
+ QVERIFY(stats.allocCount > 0);
+ QVERIFY(stats.blockCount > 0);
+ QVERIFY(stats.usedBytes > 0);
+ }
+}
+
void tst_QRhi::nativeHandles_data()
{
rhiTestData();
@@ -675,7 +716,6 @@ void tst_QRhi::nativeHandlesImportOpenGL()
#ifdef TST_GL
QRhiGles2NativeHandles h;
QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
- ctx->setFormat(QRhiGles2InitParams::adjustedFormat());
if (!ctx->create())
QSKIP("No OpenGL context, skipping OpenGL-specific test");
h.context = ctx.data();
@@ -1016,7 +1056,7 @@ void tst_QRhi::resourceUpdateBatchRGBATextureUpload()
QRhiResourceUpdateBatch *batch = rhi->nextResourceUpdateBatch();
- QRhiTextureUploadEntry upload(0, 0, { image.constBits(), int(image.sizeInBytes()) });
+ QRhiTextureUploadEntry upload(0, 0, { image.constBits(), quint32(image.sizeInBytes()) });
QRhiTextureUploadDescription uploadDesc(upload);
batch->uploadTexture(texture.data(), uploadDesc);
@@ -1104,8 +1144,8 @@ void tst_QRhi::resourceUpdateBatchRGBATextureUpload()
// SourceTopLeft is not supported for non-QImage-based uploads.
const QImage im = image.copy(QRect(greenRectPos, copySize));
QRhiTextureSubresourceUploadDescription desc;
- desc.setData(QByteArray::fromRawData(reinterpret_cast<const char *>(im.constBits()),
- int(im.sizeInBytes())));
+ desc.setData(QByteArray::fromRawData(reinterpret_cast<const char *>(im.constBits()), im.sizeInBytes()));
+
desc.setSourceSize(copySize);
desc.setDestinationTopLeft(QPoint(gap, gap));
@@ -3234,7 +3274,6 @@ void tst_QRhi::setWindowType(QWindow *window, QRhi::Implementation impl)
switch (impl) {
#ifdef TST_GL
case QRhi::OpenGLES2:
- window->setFormat(QRhiGles2InitParams::adjustedFormat());
window->setSurfaceType(QSurface::OpenGLSurface);
break;
#endif
diff --git a/tests/auto/gui/rhi/qshader/CMakeLists.txt b/tests/auto/gui/rhi/qshader/CMakeLists.txt
index 9807b19e53..b710a8b4b7 100644
--- a/tests/auto/gui/rhi/qshader/CMakeLists.txt
+++ b/tests/auto/gui/rhi/qshader/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
# Generated from qshader.pro.
#####################################################################
@@ -13,7 +16,7 @@ file(GLOB_RECURSE qshader_resource_files
qt_internal_add_test(tst_qshader
SOURCES
tst_qshader.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
TESTDATA ${qshader_resource_files}
diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
index cd883b34d9..40aa9d9a87 100644
--- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp
+++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
@@ -18,6 +18,7 @@ private slots:
void genVariants();
void shaderDescImplicitSharing();
void bakedShaderImplicitSharing();
+ void sortedKeys();
void mslResourceMapping();
void serializeShaderDesc();
void comparison();
@@ -238,6 +239,16 @@ void tst_QShader::bakedShaderImplicitSharing()
}
}
+void tst_QShader::sortedKeys()
+{
+ QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb"));
+ QVERIFY(s.isValid());
+ QList<QShaderKey> availableShaders = s.availableShaders();
+ QCOMPARE(availableShaders.count(), 7);
+ std::sort(availableShaders.begin(), availableShaders.end());
+ QCOMPARE(availableShaders, s.availableShaders());
+}
+
void tst_QShader::mslResourceMapping()
{
QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb"));