aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgcontext.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-05-18 08:20:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-23 11:22:56 +0200
commit0e9cd8b4098661bf611fa73a787c58c85e7d7338 (patch)
tree2be51fc45238e147531c5ba87b090bd83ffecf72 /src/quick/scenegraph/qsgcontext.cpp
parentc23dfece55e12c18a19a72ccf8ea617eaea50ba6 (diff)
Cut performance cost in QSGContext::prepareMaterial()
The hash-lookup in this function is costing us a lot, and since we're looking up the same materials again and again, and the material has a place holder for it, we can store it directly in the material at no extra cost. This was a 10% gain in this particular benchmark. Change-Id: I46b67791ce39f453fa86d1ee82f6f5c7785b46a1 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 14f0fabbdd..d3710c7bd5 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -478,10 +478,16 @@ QSGDepthStencilBufferManager *QSGContext::depthStencilBufferManager()
QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
{
Q_D(QSGContext);
+
+ if (material->m_reserved)
+ return reinterpret_cast<QSGMaterialShader *>(material->m_reserved);
+
QSGMaterialType *type = material->type();
QSGMaterialShader *shader = d->materials.value(type);
- if (shader)
+ if (shader) {
+ material->m_reserved = shader;
return shader;
+ }
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing || QQmlProfilerService::enabled)
@@ -489,6 +495,7 @@ QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
#endif
shader = material->createShader();
+ material->m_reserved = shader;
shader->compile();
shader->initialize();
d->materials[type] = shader;