From cebeacfa5557b7db88906c5fd14826dfe32b1d2d Mon Sep 17 00:00:00 2001 From: askmeaboutloom Date: Tue, 6 Aug 2024 06:06:01 +0200 Subject: [PATCH] Add performance timing to GL canvas renderer To figure out potential slowness there. --- src/desktop/view/glcanvas.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/desktop/view/glcanvas.cpp b/src/desktop/view/glcanvas.cpp index 27094d57b6..7ca06fab81 100644 --- a/src/desktop/view/glcanvas.cpp +++ b/src/desktop/view/glcanvas.cpp @@ -4,11 +4,14 @@ #include "desktop/view/canvascontroller.h" #include "desktop/view/canvasscene.h" #include "libclient/canvas/tilecache.h" +#include "libclient/drawdance/perf.h" #include #include #include #include +#define DP_PERF_CONTEXT "glcanvas" + Q_LOGGING_CATEGORY(lcDpGlCanvas, "net.drawpile.view.canvas.gl", QtWarningMsg) namespace view { @@ -752,6 +755,7 @@ void main() void renderCanvasDirtyTextures(QOpenGLFunctions *f, canvas::TileCache &tileCache) { + DP_PERF_SCOPE("paint_gl:canvas_dirty:textures"); qCDebug(lcDpGlCanvas, "renderCanvasDirtyTexture"); setUpCanvasShader(f); updateCanvasTextureFilter(f); @@ -773,6 +777,7 @@ void main() void renderCanvasDirty(QOpenGLFunctions *f) { + DP_PERF_SCOPE("paint_gl:canvas_dirty"); // The loop is necessary because the canvas size may change // again while we're refreshing the tile cache visible area. while(true) { @@ -796,6 +801,7 @@ void main() void renderCanvasClean(QOpenGLFunctions *f) { + DP_PERF_SCOPE("paint_gl:canvas_clean"); setUpCanvasShader(f); updateCanvasTextureFilter(f); int textureCount = canvasTextures.size(); @@ -823,6 +829,7 @@ void main() void renderOutline(QOpenGLFunctions *f, qreal dpr) { + DP_PERF_SCOPE("paint_gl:outline"); // Called after renderCanvas, assumes vertex attribute 0 is enabled. f->glEnable(GL_BLEND); f->glBlendFuncSeparate(GL_ONE, GL_SRC_COLOR, GL_ONE, GL_ONE); @@ -862,6 +869,12 @@ void main() f->glBlendEquation(GL_FUNC_ADD); } + void renderScene(QPainter &painter) + { + DP_PERF_SCOPE("paint_gl:scene"); + controller->scene()->render(&painter); + } + CanvasController *controller; QSize viewSize; QColor checkerColor1; @@ -1122,6 +1135,7 @@ void GlCanvas::paintGL() { qCDebug(lcDpGlCanvas, "paintGL"); if(!d->viewSize.isEmpty()) { + DP_PERF_SCOPE("paint_gl"); QPainter painter(this); painter.beginNativePainting(); @@ -1144,7 +1158,8 @@ void GlCanvas::paintGL() } painter.endNativePainting(); - d->controller->scene()->render(&painter); + + d->renderScene(painter); } }