From 372cbff7909ecb0e9937373ce4266f77018ce075 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 11 May 2017 13:29:13 -0500 Subject: 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 --- customcontext/context.h | 4 ++++ customcontext/programbinary.cpp | 22 ++++++++++++++++++++-- 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; } -- cgit v1.2.3