summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/rhi
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-08-15 12:58:13 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-08-16 16:00:15 +0200
commit2de14b81a9c76ce95c96385262467f41892a2a1c (patch)
tree91ee1e7e9f82411756063f8379c5df457722177f /tests/auto/gui/rhi
parent73fe9a786c119a5763ae0ce9dd0575c088e0f29b (diff)
rhi: tst_qrhi: Check for OpenGL cap on the platform
Running tst_qrhi -platform eglfs will pass on RPi4 / Mesa 22. This does not test Vulkan of course since the platform plugin cannot create a Vulkan instance. Running tst_qrhi -platform vkkhrdisplay will enable Vulkan but will still try OpenGL since the autotest does not query the platform integration about OpenGL support. Make this nicer by skipping most of the GL test if the platform integration we have cannot handle OpenGL stuff anyway. For some tests the data-driven approach has to be removed since doing QFETCH without any rows will crash. These two OpenGL-specific tests now check OpenGL support directly and QSKIP if needed. While we are at it, fix up the Vulkan instance API version as well. Pick-to: 6.4 Change-Id: I2891c04540bc2dfd0ccf475629bd23542bff15f5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/auto/gui/rhi')
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp48
1 files changed, 11 insertions, 37 deletions
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 76527f83ed..d1252f8abf 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -17,6 +17,8 @@
# include <QOpenGLContext>
# include <QOpenGLFunctions>
# include <QtGui/private/qrhigles2_p.h>
+# include <QtGui/private/qguiapplication_p.h>
+# include <qpa/qplatformintegration.h>
# define TST_GL
#endif
@@ -49,7 +51,6 @@ private slots:
void cleanupTestCase();
void rhiTestData();
- void rhiTestDataOpenGL();
void create_data();
void create();
void stats_data();
@@ -123,9 +124,7 @@ private slots:
void pipelineCache_data();
void pipelineCache();
- void textureImportOpenGL_data();
void textureImportOpenGL();
- void renderbufferImportOpenGL_data();
void renderbufferImportOpenGL();
void threeDimTexture_data();
void threeDimTexture();
@@ -180,7 +179,7 @@ void tst_QRhi::initTestCase()
if (supportedVersion >= QVersionNumber(1, 2))
vulkanInstance.setApiVersion(QVersionNumber(1, 2));
else if (supportedVersion >= QVersionNumber(1, 1))
- vulkanInstance.setApiVersion(QVersionNumber(1, 2));
+ vulkanInstance.setApiVersion(QVersionNumber(1, 1));
vulkanInstance.setLayers({ "VK_LAYER_KHRONOS_validation" });
vulkanInstance.setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
vulkanInstance.create();
@@ -211,7 +210,8 @@ void tst_QRhi::rhiTestData()
QTest::newRow("Null") << QRhi::Null << static_cast<QRhiInitParams *>(&initParams.null);
#endif
#ifdef TST_GL
- QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
#endif
#ifdef TST_VK
if (vulkanInstance.isValid())
@@ -225,16 +225,6 @@ void tst_QRhi::rhiTestData()
#endif
}
-void tst_QRhi::rhiTestDataOpenGL()
-{
- QTest::addColumn<QRhi::Implementation>("impl");
- QTest::addColumn<QRhiInitParams *>("initParams");
-
-#ifdef TST_GL
- QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
-#endif
-}
-
void tst_QRhi::create_data()
{
rhiTestData();
@@ -4418,21 +4408,13 @@ void tst_QRhi::pipelineCache()
}
}
-void tst_QRhi::textureImportOpenGL_data()
-{
- rhiTestDataOpenGL();
-}
-
void tst_QRhi::textureImportOpenGL()
{
- QFETCH(QRhi::Implementation, impl);
- if (impl != QRhi::OpenGLES2)
- QSKIP("Skipping OpenGL-dependent test");
-
#ifdef TST_GL
- QFETCH(QRhiInitParams *, initParams);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QSKIP("Skipping OpenGL-dependent test");
- QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ QScopedPointer<QRhi> rhi(QRhi::create(QRhi::OpenGLES2, &initParams.gl, QRhi::Flags(), nullptr));
if (!rhi)
QSKIP("QRhi could not be created, skipping testing native texture");
@@ -4472,21 +4454,13 @@ void tst_QRhi::textureImportOpenGL()
#endif
}
-void tst_QRhi::renderbufferImportOpenGL_data()
-{
- rhiTestDataOpenGL();
-}
-
void tst_QRhi::renderbufferImportOpenGL()
{
- QFETCH(QRhi::Implementation, impl);
- if (impl != QRhi::OpenGLES2)
- QSKIP("Skipping OpenGL-dependent test");
-
#ifdef TST_GL
- QFETCH(QRhiInitParams *, initParams);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QSKIP("Skipping OpenGL-dependent test");
- QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ QScopedPointer<QRhi> rhi(QRhi::create(QRhi::OpenGLES2, &initParams.gl, QRhi::Flags(), nullptr));
if (!rhi)
QSKIP("QRhi could not be created, skipping testing native texture");