Remove QSGContext's precompilation step.
authorGunnar Sletta <gunnar.sletta@digia.com>
Mon, 30 Sep 2013 11:18:10 +0000 (13:18 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 3 Oct 2013 14:18:44 +0000 (16:18 +0200)
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 <yoann.lopes@digia.com>
src/quick/scenegraph/qsgcontext.cpp
src/quick/scenegraph/qsgcontext_p.h

index f1c13a9..caa0d03 100644 (file)
@@ -49,7 +49,6 @@
 #include <QtQuick/private/qsgdistancefieldglyphnode_p.h>
 #include <QtQuick/private/qsgdistancefieldglyphnode_p_p.h>
 #include <QtQuick/private/qsgshareddistancefieldglyphcache_p.h>
-#include <QtQuick/QSGFlatColorMaterial>
 #include <QtQuick/private/qsgatlastexture_p.h>
 
 #include <QtQuick/private/qsgtexture_p.h>
@@ -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<QSGMaterialType *, QSGMaterialShader *> materials;
     QMutex textureMutex;
     QHash<QQuickTextureFactory *, QSGTexture *> 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
   */
 
index 7727f07..2057c00 100644 (file)
@@ -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);