Properly collect polish timings from all render loops
authorUlf Hermann <ulf.hermann@digia.com>
Mon, 30 Jun 2014 12:01:38 +0000 (14:01 +0200)
committerUlf Hermann <ulf.hermann@digia.com>
Wed, 2 Jul 2014 08:41:14 +0000 (10:41 +0200)
Previously the polish timings were collected incorrectly from the
windows render loop and not at all from the basic render loop. By
collecting the polish times at the right places we can get rid of
the 2-argument profile macro as well.

Task-number: QTBUG-39876
Change-Id: I0b4aaf87162c652b8dcea6cd4f54db053f8312fe
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
src/qml/debugger/qqmlprofilerdefinitions_p.h
src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
src/quick/scenegraph/coreapi/qsgrenderer.cpp
src/quick/scenegraph/qsgadaptationlayer.cpp
src/quick/scenegraph/qsgrenderloop.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp
src/quick/scenegraph/qsgwindowsrenderloop.cpp
src/quick/scenegraph/util/qsgatlastexture.cpp
src/quick/scenegraph/util/qsgtexture.cpp
src/quick/util/qquickprofiler.cpp
src/quick/util/qquickprofiler_p.h

index 177b1ae..689a06a 100644 (file)
@@ -123,7 +123,7 @@ struct QQmlProfilerDefinitions {
         SceneGraphPolishAndSync,
         SceneGraphWindowsRenderShow,
         SceneGraphWindowsAnimations,
-        SceneGraphWindowsPolishFrame,
+        SceneGraphPolishFrame,
 
         MaximumSceneGraphFrameType
     };
index c064023..3770461 100644 (file)
@@ -162,7 +162,7 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material)
 
     qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms", (int) qsg_renderer_timer.elapsed());
 
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphContextFrame, (
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphContextFrame, (
             qsg_renderer_timer.nsecsElapsed()));
 
     rewrittenShaders[type] = shader;
@@ -193,7 +193,7 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate
 
     qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms (no rewrite)", (int) qsg_renderer_timer.elapsed());
 
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphContextFrame, (
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphContextFrame, (
             qsg_renderer_timer.nsecsElapsed()));
     return shader;
 }
index d64bd4e..2980cea 100644 (file)
@@ -276,7 +276,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
             int((bindTime - updatePassTime) / 1000000),
             int((renderTime - bindTime) / 1000000));
 
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphRendererFrame, (
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRendererFrame, (
             preprocessTime,
             updatePassTime - preprocessTime,
             bindTime - updatePassTime,
index 0ac5f23..9826fa8 100644 (file)
@@ -190,7 +190,7 @@ void QSGDistanceFieldGlyphCache::update()
                 int(renderTime / 1000000),
                 int((now - (renderTime / 1000000))));
     }
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphAdaptationLayerFrame, (
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphAdaptationLayerFrame, (
             count,
             renderTime,
             qsg_render_timer.nsecsElapsed() - renderTime));
index fba2114..b4b4a6e 100644 (file)
@@ -367,8 +367,10 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
 
     cd->polishItems();
 
-    if (profileFrames)
+    if (profileFrames) {
         polishTime = renderTimer.nsecsElapsed();
+        Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphPolishFrame, (polishTime));
+    }
 
     emit window->afterAnimating();
 
@@ -409,8 +411,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
         lastFrameTime = QTime::currentTime();
     }
 
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphRenderLoopFrame, (
-            syncTime,
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRenderLoopFrame, (
+            syncTime - polishTime,
             renderTime - syncTime,
             swapTime));
 
index 106819e..584098c 100644 (file)
@@ -605,7 +605,7 @@ void QSGRenderThread::syncAndRender()
             int(threadTimer.elapsed() - renderTime / 1000000));
 
 
-        Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphRenderLoopFrame, (
+        Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRenderLoopFrame, (
                 syncTime,
                 renderTime - syncTime,
                 threadTimer.nsecsElapsed() - renderTime));
@@ -1141,7 +1141,7 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose)
             << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000
             << " - (on Gui thread) " << window;
 
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphPolishAndSync, (
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphPolishAndSync, (
             polishTime,
             waitTime - polishTime,
             syncTime - waitTime,
index 5961c96..70f8068 100644 (file)
@@ -376,7 +376,7 @@ void QSGWindowsRenderLoop::render()
                 "animations ticked in %dms",
                 int((qsg_render_timer.nsecsElapsed() - time_start)/1000000));
 
-        Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphWindowsAnimations, (
+        Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphWindowsAnimations, (
                 qsg_render_timer.nsecsElapsed() - time_start));
 
         // It is not given that animations triggered another maybeUpdate()
@@ -418,6 +418,8 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
     d->polishItems();
     QSG_RENDER_TIMING_SAMPLE(time_polished);
 
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphPolishFrame, (time_polished - time_start));
+
     emit window->afterAnimating();
 
     RLDEBUG(" - syncing");
@@ -443,12 +445,10 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
             << ", swap=" << (time_swapped - time_rendered) / 1000000
             << " - " << window;
 
-        Q_QUICK_SG_PROFILE2(QQuickProfiler::SceneGraphWindowsPolishFrame,
-                            QQuickProfiler::SceneGraphRenderLoopFrame, (
+        Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRenderLoopFrame, (
                 time_synced - time_polished,
                 time_rendered - time_synced,
-                time_swapped - time_rendered,
-                time_polished - time_start));
+                time_swapped - time_rendered));
 }
 
 QT_END_NAMESPACE
index fcd10ee..f7cf979 100644 (file)
@@ -399,7 +399,7 @@ void Atlas::bind(QSGTexture::Filtering filtering)
                                            << "ms (" << m_pending_uploads.at(i)->image().width() << "x"
                                            << m_pending_uploads.at(i)->image().height() << ")";
 
-        Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphTexturePrepare, (
+        Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTexturePrepare, (
                 0,  // bind (not relevant)
                 0,  // convert (not relevant)
                 0,  // swizzle (not relevant)
index 995bfc1..120a3eb 100644 (file)
@@ -625,7 +625,7 @@ void QSGPlainTexture::bind()
                     (int) qsg_renderer_timer.elapsed(),
                     m_texture_size.width(),
                     m_texture_size.height());
-            Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphTextureDeletion, (
+            Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTextureDeletion, (
                     qsg_renderer_timer.nsecsElapsed()));
         }
         m_texture_id = 0;
@@ -726,7 +726,7 @@ void QSGPlainTexture::bind()
                 int((mipmapTime - uploadTime)/1000000));
     }
 
-    Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphTexturePrepare, (
+    Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTexturePrepare, (
             bindTime,
             convertTime - bindTime,
             swizzleTime - convertTime,
index 3e2a078..3fd9b15 100644 (file)
@@ -103,8 +103,8 @@ void QQuickProfilerData::toByteArrays(QList<QByteArray> &messages) const
                     case QQuickProfiler::SceneGraphWindowsRenderShow: ds << subtime_1 << subtime_2 << subtime_3; break;
                     // WindowsAnimations: update time
                     case QQuickProfiler::SceneGraphWindowsAnimations: ds << subtime_1; break;
-                    // WindowsRenderWindow: polish time; always comes packed after a RenderLoop
-                    case QQuickProfiler::SceneGraphWindowsPolishFrame: ds << subtime_4; break;
+                    // non-threaded rendering: polish time
+                    case QQuickProfiler::SceneGraphPolishFrame: ds << subtime_1; break;
                     default:break;
                 }
                 break;
index 03cef95..d5927a1 100644 (file)
@@ -71,10 +71,8 @@ QT_BEGIN_NAMESPACE
 #define Q_QUICK_PROFILE(Method)\
     Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::Method)
 
-#define Q_QUICK_SG_PROFILE2(Type1, Type2, Params)\
-    Q_QUICK_PROFILE_IF_ENABLED((QQuickProfiler::sceneGraphFrame<Type1, Type2> Params))
-
-#define Q_QUICK_SG_PROFILE1(Type, Params) Q_QUICK_SG_PROFILE2(Type, Type, Params)
+#define Q_QUICK_SG_PROFILE(Type, Params)\
+    Q_QUICK_PROFILE_IF_ENABLED((QQuickProfiler::sceneGraphFrame<Type> Params))
 
 
 // This struct is somewhat dangerous to use:
@@ -170,12 +168,12 @@ public:
         }
     }
 
-    template<SceneGraphFrameType FrameType1, SceneGraphFrameType FrameType2>
+    template<SceneGraphFrameType FrameType>
     static void sceneGraphFrame(qint64 value1, qint64 value2 = -1, qint64 value3 = -1,
                                 qint64 value4 = -1, qint64 value5 = -1)
     {
         s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(), 1 << SceneGraphFrame,
-                1 << FrameType1 | 1 << FrameType2, value1, value2, value3, value4, value5));
+                1 << FrameType, value1, value2, value3, value4, value5));
     }
 
     template<PixmapEventType PixmapState>