Include the scenegraph autotest in the testrun.
authorGunnar Sletta <gunnar.sletta@jollamobile.com>
Wed, 4 Jun 2014 18:32:07 +0000 (20:32 +0200)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Fri, 27 Mar 2015 08:20:25 +0000 (08:20 +0000)
The mipmap test has been updated to work on chips without npot, but
because it is failing in ci on some linux machines, we keep it enabled
for OSX and windows only.

The test also includes a dump of GPU capabilities to aid in debugging.

Change-Id: Ief3092b8e0502bea06aaf4a20c03b7edfa0b2403
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
tests/auto/quick/quick.pro
tests/auto/quick/scenegraph/data/mipmap_large.png
tests/auto/quick/scenegraph/data/mipmap_small.png
tests/auto/quick/scenegraph/data/render_Mipmap.qml
tests/auto/quick/scenegraph/tst_scenegraph.cpp

index c2b7a4cc8d5409ccd6bf1a491c98a4302f60f86a..e909b96cb76ae5d919d082191595d240eec04150 100644 (file)
@@ -74,7 +74,8 @@ QUICKTESTS =  \
     qquickview \
     qquickcanvasitem \
     qquickscreen \
-    touchmouse
+    touchmouse \
+    scenegraph
 
 
 SUBDIRS += $$PUBLICTESTS
index 9cb0fc7de16e2df8b8f9d69e8376160e653b7681..1b6d99c45c469c7682d87a7fa03693b660d8cde7 100644 (file)
Binary files a/tests/auto/quick/scenegraph/data/mipmap_large.png and b/tests/auto/quick/scenegraph/data/mipmap_large.png differ
index dc5216fb6cb5b4883671cc0e28aeaafd359ce7a8..2e53012ef5b6f36987cd4e1596a0d97d23475827 100644 (file)
Binary files a/tests/auto/quick/scenegraph/data/mipmap_small.png and b/tests/auto/quick/scenegraph/data/mipmap_small.png differ
index 6d9191c5ac2b308a5634666f271c94e20449045a..9bd585373aac371ce796c1f663b77f9ff922dbc5 100644 (file)
@@ -32,6 +32,7 @@
 ****************************************************************************/
 
 import QtQuick 2.3
+import QtQuick.Window 2.2
 
 /*
     The test verifies that scaled down mipmapped images contains
@@ -39,8 +40,8 @@ import QtQuick 2.3
 
     #samples: 2
                  PixelPos     R    G    B    Error-tolerance
-    #final:        0   0     0.33 0.33 0.33        0.1
-    #final:        1   0     0.33 0.33 0.33        0.1
+    #final:        0   0     0.25 0.25 0.25        0.1
+    #final:        1   0     0.25 0.25 0.25        0.1
 */
 
 RenderTestBase
@@ -52,7 +53,7 @@ RenderTestBase
         source: "mipmap_small.png"
         mipmap: true
         smooth: false
-        scale: 1 / width;
+        scale: 1 / (width * Screen.devicePixelRatio);
     }
 
     Image {
@@ -62,7 +63,7 @@ RenderTestBase
         source: "mipmap_large.png"
         mipmap: true
         smooth: false
-        scale: 1 / width;
+        scale: 1 / (width * Screen.devicePixelRatio);
     }
 
     onEnterFinalStage: finalStageComplete = true;
index d2d3643ca8609ad9162ecfb6a06c12f854699b99..f82163dcece33ef4ccc128d6e53af87c77c0f49d 100644 (file)
 
 #include <qtest.h>
 
+#include <QOffscreenSurface>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+
 #include <QtQuick>
+#include <QtQml>
 
 #include <private/qopenglcontext_p.h>
+#include <private/qsgcontext_p.h>
+#include <private/qsgrenderloop_p.h>
 
-#include <QtQml>
 
 class PerPixelRect : public QQuickItem
 {
@@ -107,6 +113,38 @@ public:
 void tst_SceneGraph::initTestCase()
 {
     qmlRegisterType<PerPixelRect>("SceneGraphTest", 1, 0, "PerPixelRect");
+
+    QSGRenderLoop *loop = QSGRenderLoop::instance();
+    qDebug() << "RenderLoop:        " << loop;
+
+    QOpenGLContext context;
+    context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat());
+    context.create();
+    QSurfaceFormat format = context.format();
+
+    QOffscreenSurface surface;
+    surface.setFormat(format);
+    surface.create();
+    if (!context.makeCurrent(&surface))
+        qFatal("Failed to create a GL context...");
+
+    QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
+    qDebug() << "R/G/B/A Buffers:   " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize();
+    qDebug() << "Depth Buffer:      " << format.depthBufferSize();
+    qDebug() << "Stencil Buffer:    " << format.stencilBufferSize();
+    qDebug() << "Samples:           " << format.samples();
+    int textureSize;
+    funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &textureSize);
+    qDebug() << "Max Texture Size:  " << textureSize;
+    qDebug() << "GL_VENDOR:         " << (const char *) funcs->glGetString(GL_VENDOR);
+    qDebug() << "GL_RENDERER:       " << (const char *) funcs->glGetString(GL_RENDERER);
+    qDebug() << "GL_VERSION:        " << (const char *) funcs->glGetString(GL_VERSION);
+    QSet<QByteArray> exts = context.extensions();
+    QByteArray all;
+    foreach (const QByteArray &e, exts) all += ' ' + e;
+    qDebug() << "GL_EXTENSIONS:    " << all.constData();
+
+    context.doneCurrent();
 }
 
 QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1)
@@ -210,7 +248,7 @@ void tst_SceneGraph::manyWindows_data()
 
 struct ShareContextResetter {
 public:
-    ~ShareContextResetter() { QOpenGLContextPrivate::setGlobalShareContext(0); }
+    ~ShareContextResetter() { qt_gl_set_global_share_context(0); }
 };
 
 void tst_SceneGraph::manyWindows()
@@ -223,7 +261,7 @@ void tst_SceneGraph::manyWindows()
     ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure.
     if (shared) {
         QVERIFY(sharedGLContext.create());
-        QOpenGLContextPrivate::setGlobalShareContext(&sharedGLContext);
+        qt_gl_set_global_share_context(&sharedGLContext);
     }
 
     QScopedPointer<QWindow> parent;
@@ -297,8 +335,8 @@ struct Sample {
                 .arg(color.redF()).arg(color.greenF()).arg(color.blueF());
     }
 
-    bool check(const QImage &image) {
-        QColor color(image.pixel(x, y));
+    bool check(const QImage &image, qreal scale) {
+        QColor color(image.pixel(x * scale, y * scale));
         return qAbs(color.redF() - r) <= tolerance
                 && qAbs(color.greenF() - g) <= tolerance
                 && qAbs(color.blueF() - b) <= tolerance;
@@ -368,10 +406,14 @@ void tst_SceneGraph::render_data()
           << "data/render_BreakOpacityBatch.qml"
           << "data/render_OutOfFloatRange.qml"
           << "data/render_StackingOrder.qml"
-          << "data/render_Mipmap.qml"
           << "data/render_ImageFiltering.qml"
           << "data/render_bug37422.qml"
           << "data/render_OpacityThroughBatchRoot.qml"
+#if defined(Q_OS_OSX) || defined(Q_OS_WIN)
+          // We've had some problems with this particular test in the CI, so
+          // we'll leave it out for now..
+          << "data/render_Mipmap.qml"
+#endif
         ;
 
     QRegExp sampleCount("#samples: *(\\d+)");
@@ -428,11 +470,18 @@ void tst_SceneGraph::render()
     view.show();
     QVERIFY(QTest::qWaitForWindowExposed(&view));
 
+    // We're checking actual pixels, so scale up the sample point to the top-left of the
+    // 2x2 pixel block and hope that this is good enough. Ideally, view and content
+    // would be in identical coordinate space, meaning pixels, but we're not in an
+    // ideal world.
+    // Just keep this in mind when writing tests.
+    qreal scale = view.devicePixelRatio();
+
     // Grab the window and check all our base stage samples
     QImage content = view.grabWindow();
     for (int i=0; i<baseStage.size(); ++i) {
         Sample sample = baseStage.at(i);
-        QVERIFY2(sample.check(content), qPrintable(sample.toString(content)));
+        QVERIFY2(sample.check(content, scale), qPrintable(sample.toString(content)));
     }
 
     // Put the qml file into the final stage and wait for it to
@@ -445,7 +494,7 @@ void tst_SceneGraph::render()
     content = view.grabWindow();
     for (int i=0; i<finalStage.size(); ++i) {
         Sample sample = finalStage.at(i);
-        QVERIFY2(sample.check(content), qPrintable(sample.toString(content)));
+        QVERIFY2(sample.check(content, scale), qPrintable(sample.toString(content)));
     }
 }