summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2017-05-11 13:29:13 -0500
committerMichael Brasser <michael.brasser@live.com>2017-05-12 13:56:20 +0000
commit372cbff7909ecb0e9937373ce4266f77018ce075 (patch)
tree4fc8c0db9ac22d1baf9cc31a86815e7e096d3fee
parent16a5ff5ffb00b2be7046a2350717e0cf7370a9a3 (diff)
Enable shader cache for 5.8
This is still useful for 5.8, since a built-in solution isn't available until 5.9. Change-Id: I63df1012a05ecf798bbd8d3aa47fd2a290ababf5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--customcontext/context.h4
-rw-r--r--customcontext/programbinary.cpp22
2 files changed, 24 insertions, 2 deletions
diff --git a/customcontext/context.h b/customcontext/context.h
index 53b26e0..b7fec10 100644
--- a/customcontext/context.h
+++ b/customcontext/context.h
@@ -95,8 +95,12 @@ public:
QSGRenderer *createRenderer();
#ifdef PROGRAM_BINARY
+#if QT_VERSION >= 0x050800
+ void compileShader(QSGMaterialShader *shader, QSGMaterial *material, const char *vertex = 0, const char *fragment = 0);
+#else
void compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertex = 0, const char *fragment = 0);
#endif
+#endif
#ifdef CUSTOMCONTEXT_DITHER
bool m_dither;
diff --git a/customcontext/programbinary.cpp b/customcontext/programbinary.cpp
index ea9e63c..0aa64af 100644
--- a/customcontext/programbinary.cpp
+++ b/customcontext/programbinary.cpp
@@ -155,8 +155,11 @@ public:
void purge(const QByteArray &key);
void sanityCheck();
-
+#if QT_VERSION >= 0x050800
+ void compileAndInsert(QSGDefaultRenderContext *rc, const QByteArray &key, QSGMaterialShader *s, QSGMaterial *m, const char *v, const char *f);
+#else
void compileAndInsert(QSGRenderContext *rc, const QByteArray &key, QSGMaterialShader *s, QSGMaterial *m, const char *v, const char *f);
+#endif
private:
QCryptographicHash m_hash;
@@ -231,11 +234,18 @@ void ProgramBinaryStore::purge(const QByteArray &key)
if (file.exists())
file.remove();
}
-
+#if QT_VERSION >= 0x050800
+void ProgramBinaryStore::compileAndInsert(QSGDefaultRenderContext *rc, const QByteArray &key, QSGMaterialShader *s, QSGMaterial *m, const char *v, const char *f)
+#else
void ProgramBinaryStore::compileAndInsert(QSGRenderContext *rc, const QByteArray &key, QSGMaterialShader *s, QSGMaterial *m, const char *v, const char *f)
+#endif
{
// Use the baseclass impl to do the actual compilation
+#if QT_VERSION >= 0x050800
+ rc->QSGDefaultRenderContext::compileShader(s, m, v, f);
+#else
rc->QSGRenderContext::compile(s, m, v, f);
+#endif
QOpenGLShaderProgram *p = s->program();
if (p->isLinked()) {
ProgramBinary *b = new ProgramBinary;
@@ -257,13 +267,21 @@ void ProgramBinaryStore::compileAndInsert(QSGRenderContext *rc, const QByteArray
}
}
+#if QT_VERSION >= 0x050800
+void RenderContext::compileShader(QSGMaterialShader *shader, QSGMaterial *material, const char *vertex, const char *fragment)
+#else
void RenderContext::compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertex, const char *fragment)
+#endif
{
Q_ASSERT(QOpenGLContext::currentContext()->extensions().contains("GL_OES_get_program_binary"));
// We cannot cache shaders which have custom compilation
if (material->flags() & QSGMaterial::CustomCompileStep) {
+#if QT_VERSION >= 0x050800
+ QSGDefaultRenderContext::compileShader(shader, material, vertex, fragment);
+#else
QSGRenderContext::compile(shader, material, vertex, fragment);
+#endif
return;
}