aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-12-07 09:41:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-29 20:10:07 +0100
commit3f8d5d0ad7eee1defe81543cf12142779e9e4bfc (patch)
tree3ff4936d9f6a94a9a0117bf96c30ca421f27f9f6 /src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
parent1bea30278d8e1355457af582969fc3ff9b2ed298 (diff)
Visualization modes for rendering.
There are two ways of setting this right now. One is to set it on startup using an environment varible. QSG_VISUALIZE= "batches" - Visualize batchtes in the renderer. Merged batches are drawn with solid color and Unmerged batches are drawn with a diagonal line pattern. Few unique colors means good batching. Unmerged batches are bad if they contain many individual nodes. "clip" - Visualize clipping as red areas on top of the scene. "overdraw" - Visualize all items in 3D to highlight overdraws. This mode can also be used to detect geometry outside the viewport to some extent. Opaque items are rendered with a green tint while translucent items are rendered with a red tint. The bounding box for the viewport is rendered in blue. Opaque content is easier for the scenegraph to process and it can also be faster to render on some hardware. "changes" - Changes in the scenegraph are visualized with a flashing overlay with a random color. Changes on a primitive is visualized with a solid color while changes in an ancestor, such as a matrix or opacity changes is visualized with a pattern. The second way to set the visualization mode is to set it at runtime through QString QQuickWindowPrivate::customRenderMode. This "API" is string based so it is not tied to the batch renderer and in theory can support other custom renderers. The visualized elements do not respect clipping and rendering order is arbitrary. Change-Id: I31efbe53fc905145bf48080ede3e36945cb60dcf Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h')
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 0aa84da185..d22ab4069e 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -368,7 +368,7 @@ public:
float lastOpacity;
};
- ShaderManager() : blitProgram(0) { }
+ ShaderManager() : blitProgram(0), visualizeProgram(0) { }
~ShaderManager() {
qDeleteAll(rewrittenShaders.values());
qDeleteAll(stockShaders.values());
@@ -385,6 +385,7 @@ public:
QHash<QSGMaterialType *, Shader *> stockShaders;
QOpenGLShaderProgram *blitProgram;
+ QOpenGLShaderProgram *visualizeProgram;
};
class Q_QUICK_PRIVATE_EXPORT Renderer : public QSGRenderer
@@ -393,6 +394,14 @@ public:
Renderer(QSGRenderContext *);
~Renderer();
+ enum VisualizeMode {
+ VisualizeNothing,
+ VisualizeBatches,
+ VisualizeClipping,
+ VisualizeChanges,
+ VisualizeOverdraw
+ };
+
protected:
void nodeChanged(QSGNode *node, QSGNode::DirtyState state);
void preprocess() Q_DECL_OVERRIDE;
@@ -448,6 +457,16 @@ private:
inline Batch *newBatch();
void invalidateAndRecycleBatch(Batch *b);
+ void visualize();
+ void visualizeBatch(Batch *b);
+ void visualizeClipping(QSGNode *node);
+ void visualizeChangesPrepare(Node *n, uint parentChanges = 0);
+ void visualizeChanges(Node *n);
+ void visualizeOverdraw();
+ void visualizeOverdraw_helper(Node *node);
+ void visualizeDrawGeometry(const QSGGeometry *g);
+ void setCustomRenderMode(const QByteArray &mode);
+
QSet<Node *> m_taggedRoots;
QDataBuffer<Element *> m_opaqueRenderList;
QDataBuffer<Element *> m_alphaRenderList;
@@ -484,6 +503,9 @@ private:
// For minimal OpenGL core profile support
QOpenGLVertexArrayObject *m_vao;
+
+ QHash<Node *, uint> m_visualizeChanceSet;
+ VisualizeMode m_visualizeMode;
};
Batch *Renderer::newBatch()