From e0b1c39bed0a70445529ec249688ff1ac5f3a199 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 9 Oct 2018 10:22:25 +0200 Subject: Drop cached shaders when arch is different According to reports Intel on Windows gets confused when feeding program binaries retrieved from x86 and x64 builds into each other. Task-number: QTBUG-64697 Change-Id: Ia7748f532ad06942a92c6fbfc4c9d1ad16bc785a Reviewed-by: Andy Shaw Reviewed-by: Friedemann Kleint Reviewed-by: Andy Nichols --- src/gui/opengl/qopenglprogrambinarycache.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gui/opengl/qopenglprogrambinarycache.cpp') diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp index 0f03101329..c96021a969 100644 --- a/src/gui/opengl/qopenglprogrambinarycache.cpp +++ b/src/gui/opengl/qopenglprogrambinarycache.cpp @@ -63,7 +63,7 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_SHADER_CACHE) #endif const quint32 BINSHADER_MAGIC = 0x5174; -const quint32 BINSHADER_VERSION = 0x2; +const quint32 BINSHADER_VERSION = 0x3; const quint32 BINSHADER_QTVERSION = QT_VERSION; namespace { @@ -120,7 +120,7 @@ QString QOpenGLProgramBinaryCache::cacheFileName(const QByteArray &cacheKey) con return m_cacheDir + QString::fromUtf8(cacheKey); } -#define BASE_HEADER_SIZE (int(3 * sizeof(quint32))) +#define BASE_HEADER_SIZE (int(4 * sizeof(quint32))) #define FULL_HEADER_SIZE(stringsSize) (BASE_HEADER_SIZE + 12 + stringsSize + 8) #define PADDING_SIZE(fullHeaderSize) (((fullHeaderSize + 3) & ~3) - fullHeaderSize) @@ -159,6 +159,10 @@ bool QOpenGLProgramBinaryCache::verifyHeader(const QByteArray &buf) const qCDebug(DBG_SHADER_CACHE, "Qt version does not match"); return false; } + if (readUInt(&p) != sizeof(quintptr)) { + qCDebug(DBG_SHADER_CACHE, "Architecture does not match"); + return false; + } return true; } @@ -371,6 +375,7 @@ void QOpenGLProgramBinaryCache::save(const QByteArray &cacheKey, uint programId) writeUInt(&p, BINSHADER_MAGIC); writeUInt(&p, BINSHADER_VERSION); writeUInt(&p, BINSHADER_QTVERSION); + writeUInt(&p, sizeof(quintptr)); writeStr(&p, info.glvendor); writeStr(&p, info.glrenderer); -- cgit v1.2.3