From: Gunnar Sletta Date: Mon, 30 Sep 2013 11:18:10 +0000 (+0200) Subject: Remove QSGContext's precompilation step. X-Git-Tag: upstream/5.2.1~294 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c20ce89e6e92c403e9b50462a0e000056a2eff73;p=platform%2Fupstream%2Fqtdeclarative.git Remove QSGContext's precompilation step. Materials are managed solely inside the renderer now, so these are just wasting time. Task-number: QTBUG-33456 Change-Id: Ie320df20b7971633c257b1bd3a218e7d70e52c3d Reviewed-by: Yoann Lopes --- diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index f1c13a9..caa0d03 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include @@ -78,11 +77,6 @@ DEFINE_BOOL_CONFIG_OPTION(qmlTranslucentMode, QML_TRANSLUCENT_MODE) DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) -#ifndef QSG_NO_RENDER_TIMING -static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty(); -static QElapsedTimer qsg_renderer_timer; -#endif - /* Comments about this class from Gunnar: @@ -129,7 +123,6 @@ public: QOpenGLContext *gl; - QHash materials; QMutex textureMutex; QHash textures; QSGDepthStencilBufferManager *depthStencilBufferManager; @@ -207,8 +200,6 @@ void QSGContext::invalidate() qDeleteAll(d->textures.values()); d->textures.clear(); d->textureMutex.unlock(); - qDeleteAll(d->materials.values()); - d->materials.clear(); delete d->depthStencilBufferManager; d->depthStencilBufferManager = 0; delete d->distanceFieldCacheManager; @@ -319,36 +310,9 @@ void QSGContext::initialize(QOpenGLContext *context) Q_ASSERT(!d->gl); d->gl = context; - precompileMaterials(); - emit initialized(); } -#define QSG_PRECOMPILE_MATERIAL(name) { name m; prepareMaterial(&m); } - -/* - * Some glsl compilers take their time compiling materials, and - * the way the scene graph is being processed, these materials - * get compiled when they are first taken into use. This can - * easily lead to skipped frames. By precompiling the most - * common materials, we potentially add a few milliseconds to the - * start up, and reduce the chance of avoiding skipped frames - * later on. - */ -void QSGContext::precompileMaterials() -{ - if (qEnvironmentVariableIsEmpty("QSG_NO_MATERIAL_PRELOADING")) { - QSG_PRECOMPILE_MATERIAL(QSGVertexColorMaterial); - QSG_PRECOMPILE_MATERIAL(QSGFlatColorMaterial); - QSG_PRECOMPILE_MATERIAL(QSGOpaqueTextureMaterial); - QSG_PRECOMPILE_MATERIAL(QSGTextureMaterial); - QSG_PRECOMPILE_MATERIAL(QSGSmoothTextureMaterial); - QSG_PRECOMPILE_MATERIAL(QSGSmoothColorMaterial); - QSG_PRECOMPILE_MATERIAL(QSGDistanceFieldTextMaterial); - } -} - - /*! Returns if the scene graph context is ready or not, meaning that it has a valid GL context. @@ -568,44 +532,6 @@ QSGDepthStencilBufferManager *QSGContext::depthStencilBufferManager() /*! - Returns a material shader for the given material. - */ - -QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material) -{ - Q_D(QSGContext); - QSGMaterialType *type = material->type(); - QSGMaterialShader *shader = d->materials.value(type); - if (shader) - return shader; - -#ifndef QSG_NO_RENDER_TIMING - if (qsg_render_timing || QQmlProfilerService::enabled) - qsg_renderer_timer.start(); -#endif - - shader = material->createShader(); - shader->compile(); - shader->initialize(); - d->materials[type] = shader; - -#ifndef QSG_NO_RENDER_TIMING - if (qsg_render_timing) - printf(" - compiling material: %dms\n", (int) qsg_renderer_timer.elapsed()); - - if (QQmlProfilerService::enabled) { - QQmlProfilerService::sceneGraphFrame( - QQmlProfilerService::SceneGraphContextFrame, - qsg_renderer_timer.nsecsElapsed()); - } -#endif - - return shader; -} - - - -/*! Sets whether the scene graph should render with flashing update rectangles or not */ diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 7727f07..2057c00 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -90,9 +90,6 @@ public: bool isReady() const; - virtual void precompileMaterials(); - QSGMaterialShader *prepareMaterial(QSGMaterial *material); - virtual void renderNextFrame(QSGRenderer *renderer, GLuint fboId); virtual QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font);