From 2a1fc76f4ed1680e78b740c47fa736768aed82e9 Mon Sep 17 00:00:00 2001
From: Gunnar Sletta <gunnar.sletta@digia.com>
Date: Thu, 31 Oct 2013 09:45:57 +0100
Subject: [PATCH] Added QSG_INFO=1 environment variable to spit out graphics
 info

Change-Id: I12bc0bc475b3e99185aefcd58eef5a0fb5e9852e
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
---
 src/quick/scenegraph/qsgcontext.cpp           | 10 ++++++++++
 src/quick/scenegraph/qsgrenderloop.cpp        | 10 +++++++++-
 src/quick/scenegraph/util/qsgatlastexture.cpp |  3 +++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index c6dbf350b6..4ccbaca08e 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -206,6 +206,16 @@ void QSGContext::renderContextInitialized(QSGRenderContext *renderContext)
                 d->antialiasingMethod = VertexAntialiasing;
         }
     }
+
+    static bool dumped = false;
+    if (!dumped && qEnvironmentVariableIsSet("QSG_INFO")) {
+        dumped = true;
+        qDebug() << "GL_VENDOR:     " << (const char *) glGetString(GL_VENDOR);
+        qDebug() << "GL_RENDERER:   " << (const char *) glGetString(GL_RENDERER);
+        qDebug() << "GL_VERSION:    " << (const char *) glGetString(GL_VERSION);
+        qDebug() << "GL_EXTENSIONS:\n   " << QByteArray((const char *) glGetString(GL_EXTENSIONS)).replace(" ", "\n    ").constData();
+    }
+
     d->mutex.unlock();
 }
 
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index f294cb4a2d..0cc2a15c51 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -144,8 +144,13 @@ QSGRenderLoop *QSGRenderLoop::instance()
     if (!s_instance) {
         s_instance = QSGContext::createWindowManager();
 
-        if (useConsistentTiming())
+        bool info = qEnvironmentVariableIsSet("QSG_INFO");
+
+        if (useConsistentTiming()) {
             QUnifiedTimer::instance(true)->setConsistentTiming(true);
+            if (info)
+                qDebug() << "QSG: using fixed animation steps";
+        }
 
         if (!s_instance) {
 
@@ -178,12 +183,15 @@ QSGRenderLoop *QSGRenderLoop::instance()
 
             switch (loopType) {
             case ThreadedRenderLoop:
+                if (info) qDebug() << "QSG: threaded render loop";
                 s_instance = new QSGThreadedRenderLoop();
                 break;
             case WindowsRenderLoop:
+                if (info) qDebug() << "QSG: windows render loop";
                 s_instance = new QSGWindowsRenderLoop();
                 break;
             default:
+                if (info) qDebug() << "QSG: basic render loop";
                 s_instance = new QSGGuiThreadRenderLoop();
                 break;
             }
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index b180bc43bd..2bc106a025 100644
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
@@ -104,6 +104,9 @@ Manager::Manager()
 
     m_atlas_size_limit = qsg_envInt("QSG_ATLAS_SIZE_LIMIT", qMax(w, h) / 2);
     m_atlas_size = QSize(w, h);
+
+    if (qEnvironmentVariableIsSet("QSG_INFO"))
+        qDebug() << "QSG: texture atlas dimensions:" << w << "x" << h;
 }
 
 
-- 
GitLab