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>
bb10
Laszlo Agocs 2022-08-15 12:58:13 +02:00
parent 73fe9a786c
commit 2de14b81a9
1 changed files with 11 additions and 37 deletions

View File

@ -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)
#ifdef TST_GL
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
QSKIP("Skipping OpenGL-dependent test");
#ifdef TST_GL
QFETCH(QRhiInitParams *, initParams);
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)
#ifdef TST_GL
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
QSKIP("Skipping OpenGL-dependent test");
#ifdef TST_GL
QFETCH(QRhiInitParams *, initParams);
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");