aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-04-23 09:40:59 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-07-04 10:44:26 +0200
commit341ab7708049b1a3f559b76f16393e688951a938 (patch)
tree0203da53d1adf5025fa85ecc38e0e37bce35c46f /tests/auto
parent1f01b44d20471a7f4a5029a4c0049e8296749fef (diff)
Add the graphics api independent scenegraph port
Opt in via environment variables: QSG_RHI=1 -> enable using QRhi instead of GL QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default (the default is d3d11 on Windows, metal on Mac, gl elsewhere) Or force a given rhi backend via the existing QQuickWindow::setSceneGraphBackend(). Otherwise the default behavior is the same as before, the rhi code path is never active by default. -no-opengl builds are supported in the sense that they work and default to the software backend. However, the rhi code path cannot currently be used in such builds, even though QRhi from qtbase is fully functional with Vulkan, D3D, or Metal even when qtbase was configured with -no-opengl. This cannot be utilized by Quick atm due to OpenGL usage being all over the place in the sources corresponding to the default backend, and those host the rhi code path as well. This will be cleaned up hopefully in Qt 6, with the removal all direct OpenGL usage. Other env.vars.: QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer (assuming the system is set up for this) QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too) QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both merged/unmerged, convert when needed - with some rhi backends this is implicit) QSG_RENDER_LOOP -> to override the render loop as usual. The default with RHI is threaded for Metal, threaded for Vulkan on Windows, basic for Vulkan on Linux and Android (to be checked later), while the existing rules apply for OpenGL. Not supported when running with QRhi: - particles - compressed atlases (though this is transparent to the apps) - QSGRenderNode - QQuickRenderControl - QQuickFramebufferObject - certain QQuickWindow functionality that depends directly on OpenGL - anisotropic filtering for textures - native text may lack some gamma correction - QSGEngine applicability unclear - some QML profiler logs may be incorrect or irrelevant Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/drawingmodes/tst_drawingmodes.cpp25
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp7
-rw-r--r--tests/auto/quick/nokeywords/tst_nokeywords.cpp9
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp27
-rw-r--r--tests/auto/quick/scenegraph/data/render_bug37422.frag9
-rw-r--r--tests/auto/quick/scenegraph/data/render_bug37422.frag.qsbbin0 -> 864 bytes
-rw-r--r--tests/auto/quick/scenegraph/data/render_bug37422.qml6
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp71
8 files changed, 124 insertions, 30 deletions
diff --git a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp
index afc66948b0..f3825b350f 100644
--- a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp
+++ b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp
@@ -69,6 +69,9 @@ private slots:
void triangles();
void triangleStrip();
void triangleFan();
+
+private:
+ bool isRunningOnRhi() const;
};
class DrawingModeItem : public QQuickItem
@@ -260,6 +263,9 @@ void tst_drawingmodes::lineLoop()
|| (QGuiApplication::platformName() == QLatin1String("minimal")))
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
+ if (isRunningOnRhi())
+ QSKIP("Line loops are not supported by some modern graphics APIs - skipping test");
+
QImage fb = runTest("DrawingModes.qml");
QCOMPARE(fb.width(), 200);
@@ -350,6 +356,9 @@ void tst_drawingmodes::triangleFan()
|| (QGuiApplication::platformName() == QLatin1String("minimal")))
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
+ if (isRunningOnRhi())
+ QSKIP("Triangle fans are not supported by some modern graphics APIs - skipping test");
+
QImage fb = runTest("DrawingModes.qml");
QCOMPARE(fb.width(), 200);
@@ -368,6 +377,22 @@ void tst_drawingmodes::triangleFan()
QVERIFY(!hasPixelAround(fb, 37, 100));
}
+bool tst_drawingmodes::isRunningOnRhi() const
+{
+ static bool retval = false;
+ static bool decided = false;
+ if (!decided) {
+ decided = true;
+ QQuickView dummy;
+ dummy.show();
+ QTest::qWaitForWindowExposed(&dummy);
+ QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
+ retval = QSGRendererInterface::isApiRhiBased(api);
+ dummy.hide();
+ }
+ return retval;
+}
+
QTEST_MAIN(tst_drawingmodes)
diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp
index 79a9e5f757..bd5e6c6383 100644
--- a/tests/auto/quick/nodes/tst_nodestest.cpp
+++ b/tests/auto/quick/nodes/tst_nodestest.cpp
@@ -39,7 +39,7 @@
#include <QtQuick/qsgsimplerectnode.h>
#include <QtQuick/qsgsimpletexturenode.h>
-#include <QtQuick/private/qsgtexture_p.h>
+#include <QtQuick/private/qsgplaintexture_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
@@ -99,7 +99,10 @@ void NodesTest::initTestCase()
auto rc = renderLoop->createRenderContext(renderLoop->sceneGraphContext());
renderContext = static_cast<QSGDefaultRenderContext *>(rc);
QVERIFY(renderContext);
- renderContext->initialize(context);
+ QSGDefaultRenderContext::InitParams rcParams;
+ rcParams.openGLContext = context;
+ rcParams.initialSurfacePixelSize = QSize(512, 512); // dummy, make up something
+ renderContext->initialize(&rcParams);
QVERIFY(renderContext->isValid());
}
diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
index e6655589a3..c0b66f1c3f 100644
--- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp
+++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
@@ -49,7 +49,7 @@
#include <QtQuick/private/qsgcontext_p.h>
#include <QtQuick/private/qsgcontextplugin_p.h>
#if QT_CONFIG(opengl)
-#include <QtQuick/private/qsgdefaultdistancefieldglyphcache_p.h>
+#include <QtQuick/private/qsgopengldistancefieldglyphcache_p.h>
#include <QtQuick/private/qsgdefaultglyphnode_p.h>
#include <QtQuick/private/qsgdefaultinternalimagenode_p.h>
#include <QtQuick/private/qsgdefaultinternalrectanglenode_p.h>
@@ -65,9 +65,16 @@
#include <QtQuick/private/qsgrendernode_p.h>
#include <QtQuick/private/qsgtexturematerial_p.h>
#include <QtQuick/private/qsgtexture_p.h>
+#include <QtQuick/private/qsgplaintexture_p.h>
#include <QtQuick/private/qsgthreadedrenderloop_p.h>
#include <QtQuick/private/qsgwindowsrenderloop_p.h>
+#include <QtQuick/private/qsgrhiatlastexture_p.h>
+#include <QtQuick/private/qsgrhidistancefieldglyphcache_p.h>
+#include <QtQuick/private/qsgrhilayer_p.h>
+#include <QtQuick/private/qsgrhishadereffectnode_p.h>
+#include <QtQuick/private/qsgrhitextureglyphcache_p.h>
+
#undef signals
#undef slots
#undef emit
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
index 0e06ee6f50..d862e51dfa 100644
--- a/tests/auto/quick/rendernode/tst_rendernode.cpp
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -61,6 +61,9 @@ private slots:
void renderOrder();
void messUpState();
void matrix();
+
+private:
+ bool isRunningOnRhi() const;
};
class ClearNode : public QSGRenderNode
@@ -218,6 +221,9 @@ void tst_rendernode::renderOrder()
|| (QGuiApplication::platformName() == QLatin1String("minimal")))
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
+ if (isRunningOnRhi())
+ QSKIP("Render nodes not yet supported with QRhi");
+
QImage fb = runTest("RenderOrder.qml");
const qreal scaleFactor = QGuiApplication::primaryScreen()->devicePixelRatio();
@@ -247,6 +253,9 @@ void tst_rendernode::messUpState()
|| (QGuiApplication::platformName() == QLatin1String("minimal")))
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
+ if (isRunningOnRhi())
+ QSKIP("Render nodes not yet supported with QRhi");
+
QImage fb = runTest("MessUpState.qml");
int x1 = 0;
int x2 = fb.width() / 2;
@@ -304,6 +313,9 @@ void tst_rendernode::matrix()
|| (QGuiApplication::platformName() == QLatin1String("minimal")))
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
+ if (isRunningOnRhi())
+ QSKIP("Render nodes not yet supported with QRhi");
+
qmlRegisterType<StateRecordingRenderNodeItem>("RenderNode", 1, 0, "StateRecorder");
StateRecordingRenderNode::matrices.clear();
runTest("matrix.qml");
@@ -351,6 +363,21 @@ void tst_rendernode::matrix()
}
}
+bool tst_rendernode::isRunningOnRhi() const
+{
+ static bool retval = false;
+ static bool decided = false;
+ if (!decided) {
+ decided = true;
+ QQuickView dummy;
+ dummy.show();
+ QTest::qWaitForWindowExposed(&dummy);
+ QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
+ retval = QSGRendererInterface::isApiRhiBased(api);
+ dummy.hide();
+ }
+ return retval;
+}
QTEST_MAIN(tst_rendernode)
diff --git a/tests/auto/quick/scenegraph/data/render_bug37422.frag b/tests/auto/quick/scenegraph/data/render_bug37422.frag
new file mode 100644
index 0000000000..da157232ac
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/render_bug37422.frag
@@ -0,0 +1,9 @@
+#version 440
+
+layout(location = 0) in vec2 qt_TexCoord0;
+layout(location = 0) out vec4 fragColor;
+
+void main()
+{
+ fragColor = vec4(1, 0, 0, 1);
+}
diff --git a/tests/auto/quick/scenegraph/data/render_bug37422.frag.qsb b/tests/auto/quick/scenegraph/data/render_bug37422.frag.qsb
new file mode 100644
index 0000000000..1233ccfbca
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/render_bug37422.frag.qsb
Binary files differ
diff --git a/tests/auto/quick/scenegraph/data/render_bug37422.qml b/tests/auto/quick/scenegraph/data/render_bug37422.qml
index c1b47eddb8..09661d8ccb 100644
--- a/tests/auto/quick/scenegraph/data/render_bug37422.qml
+++ b/tests/auto/quick/scenegraph/data/render_bug37422.qml
@@ -26,7 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.2
+import QtQuick 2.12
/*
The test verifies that batching does not interfere with overlapping
@@ -71,7 +71,9 @@ RenderTestBase
width: 100
height: 9
y: 10
- fragmentShader: "varying highp vec2 qt_TexCoord0; void main() { gl_FragColor = vec4(1, 0, 0, 1); }"
+ fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL
+ ? "varying highp vec2 qt_TexCoord0; void main() { gl_FragColor = vec4(1, 0, 0, 1); }"
+ : "file:data/render_bug37422.frag.qsb"
Rectangle {
width: 5
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index b4abdd6fe2..c15f1e941e 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -70,16 +70,17 @@ public:
QColor color() const { return m_color; }
- QSGNode *updatePaintNode(QSGNode *old, UpdatePaintNodeData *)
+ QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
{
- if (old)
- delete old;
-
- QSGNode *node = new QSGNode();
-
- for (int y=0; y<height(); ++y) {
- for (int x=0; x<width(); ++x) {
- QSGSimpleRectNode *rn = new QSGSimpleRectNode();
+ delete node;
+ node = new QSGNode;
+
+ const int w = width();
+ const int h = height();
+ QQuickWindow *win = window();
+ for (int y = 0; y < h; ++y) {
+ for (int x = 0; x < w; ++x) {
+ QSGRectangleNode *rn = win->createRectangleNode();
rn->setRect(x, y, 1, 1);
rn->setColor(m_color);
node->appendChildNode(rn);
@@ -90,7 +91,7 @@ public:
}
Q_SIGNALS:
- void colorChanged(const QColor &c );
+ void colorChanged(const QColor &c);
private:
QColor m_color;
@@ -117,7 +118,8 @@ private slots:
private:
bool m_brokenMipmapSupport;
QQuickView *createView(const QString &file, QWindow *parent = nullptr, int x = -1, int y = -1, int w = -1, int h = -1);
- bool isRunningOnOpenGL();
+ bool isRunningOnOpenGLDirectly();
+ bool isRunningOnRhi();
};
template <typename T> class ScopedList : public QList<T> {
@@ -402,7 +404,7 @@ void tst_SceneGraph::render_data()
<< "render_bug37422.qml"
<< "render_OpacityThroughBatchRoot.qml";
if (!m_brokenMipmapSupport)
- files << "render_Mipmap.qml";
+ files << "render_Mipmap.qml";
QRegExp sampleCount("#samples: *(\\d+)");
// X:int Y:int R:float G:float B:float Error:float
@@ -444,8 +446,8 @@ void tst_SceneGraph::render_data()
void tst_SceneGraph::render()
{
- if (!isRunningOnOpenGL())
- QSKIP("Skipping complex rendering tests due to not running with OpenGL");
+ if (!isRunningOnOpenGLDirectly() && !isRunningOnRhi())
+ QSKIP("Skipping complex rendering tests due to not running with OpenGL or QRhi");
QFETCH(QString, file);
QFETCH(QList<Sample>, baseStage);
@@ -495,7 +497,7 @@ void tst_SceneGraph::render()
// current on the other window.
void tst_SceneGraph::hideWithOtherContext()
{
- if (!isRunningOnOpenGL())
+ if (!isRunningOnOpenGLDirectly())
QSKIP("Skipping OpenGL context test due to not running with OpenGL");
QWindow window;
@@ -559,18 +561,37 @@ void tst_SceneGraph::createTextureFromImage()
QCOMPARE(texture->hasAlphaChannel(), expectedAlpha);
}
-bool tst_SceneGraph::isRunningOnOpenGL()
+bool tst_SceneGraph::isRunningOnOpenGLDirectly()
+{
+ static bool retval = false;
+ static bool decided = false;
+ if (!decided) {
+ decided = true;
+ QQuickView dummy;
+ dummy.show();
+ QTest::qWaitForWindowExposed(&dummy);
+ retval = dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL;
+ dummy.hide();
+ }
+ return retval;
+}
+
+bool tst_SceneGraph::isRunningOnRhi()
{
- bool retval = false;
- QQuickView dummy;
- dummy.show();
- if (!QTest::qWaitForWindowExposed(&dummy)) {
- [](){ QFAIL("Could not show a QQuickView"); }();
- return false;
+ static bool retval = false;
+ static bool decided = false;
+ if (!decided) {
+ decided = true;
+ QQuickView dummy;
+ dummy.show();
+ if (!QTest::qWaitForWindowExposed(&dummy)) {
+ [](){ QFAIL("Could not show a QQuickView"); }();
+ return false;
+ }
+ QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
+ retval = QSGRendererInterface::isApiRhiBased(api);
+ dummy.hide();
}
- if (dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL)
- retval = true;
- dummy.hide();
return retval;
}