summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-10-30 11:38:00 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-10-30 13:03:25 (GMT)
commit90567274b900b22ab6b1c016ee66b7915aa994c8 (patch)
tree1c8df6469520c99f054e4b6b2c8ec4e1fea847d4 /src/opengl/gl2paintengineex/qglengineshadermanager_p.h
parenta8d1c0a7137b2d1f7ca74a24321cea41428ce0bd (diff)
downloadQt-90567274b900b22ab6b1c016ee66b7915aa994c8.zip
Qt-90567274b900b22ab6b1c016ee66b7915aa994c8.tar.gz
Qt-90567274b900b22ab6b1c016ee66b7915aa994c8.tar.bz2
Implement a simple caching algorithm for shader programs.
When the number of programs held in the cache exceeds a threshold, the least frequantly used programs get deleted. This also covers programs with custom snippets of code. As a conequence, when a QGLCustomShaderStage gets deleted, any programs using that code will (eventually) be freed. Reviewed-By: Samuel Rødal
Diffstat (limited to 'src/opengl/gl2paintengineex/qglengineshadermanager_p.h')
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index fd73b44..59e50d0 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -366,13 +366,22 @@ private:
QGLSharedResourceGuard ctxGuard;
QGLShaderProgram *blitShaderProg;
QGLShaderProgram *simpleShaderProg;
- QList<QGLEngineShaderProg> cachedPrograms;
+ QList<QGLEngineShaderProg*> cachedPrograms;
static const char* qShaderSnippets[TotalSnippetCount];
};
-struct QGLEngineShaderProg
+
+class QGLEngineShaderProg
{
+public:
+ QGLEngineShaderProg() : program(0) {}
+
+ ~QGLEngineShaderProg() {
+ if (program)
+ delete program;
+ }
+
QGLEngineSharedShaders::SnippetName mainVertexShader;
QGLEngineSharedShaders::SnippetName positionVertexShader;
QGLEngineSharedShaders::SnippetName mainFragShader;