summaryrefslogtreecommitdiffstats
path: root/src/runtimerender/Qt3DSRenderShaderCache.cpp
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-02-07 14:12:42 +0200
committerAntti Määttä <antti.maatta@qt.io>2020-02-10 14:02:35 +0200
commitbff0bf78b328b730843abf0e79f58e8411908de5 (patch)
tree6fcf341f3d79dfc6d9af50d52b99f4c603fba287 /src/runtimerender/Qt3DSRenderShaderCache.cpp
parent90dd0bdcf1c9e3a1eddee8abcf4307c06e82e37b (diff)
Implement shader cache loading error handling
Task-number: QT3DS-4040 Change-Id: Ie5f8284ab76cd4aa5f3ff0701457f4ef84c3e215 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/runtimerender/Qt3DSRenderShaderCache.cpp')
-rw-r--r--src/runtimerender/Qt3DSRenderShaderCache.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/runtimerender/Qt3DSRenderShaderCache.cpp b/src/runtimerender/Qt3DSRenderShaderCache.cpp
index e26405c..3794a83 100644
--- a/src/runtimerender/Qt3DSRenderShaderCache.cpp
+++ b/src/runtimerender/Qt3DSRenderShaderCache.cpp
@@ -571,10 +571,11 @@ struct ShaderCache : public IShaderCache
return retval;
}
- void importShaderCache(const QByteArray &shaderCache) override
+ void importShaderCache(const QByteArray &shaderCache, QString &errors) override
{
#define BAILOUT(details) { \
- qWarning() << "importShaderCache failed to import shader cache:" << details; \
+ errors = "importShaderCache failed to import shader cache: " details; \
+ qWarning() << errors; \
return; \
}
@@ -634,9 +635,13 @@ struct ShaderCache : public IShaderCache
qCInfo(TRACE_INFO) << "Loading binary program from shader cache: '<" << key << ">'";
eastl::pair<TShaderMap::iterator, bool> theInserter = m_Shaders.insert(tempKey);
- theInserter.first->second
- = m_RenderContext.CompileBinary(theKey, format, binary).mShader;
- theShader = theInserter.first->second;
+ auto ret = m_RenderContext.CompileBinary(theKey, format, binary);
+ if (!ret.errors.isEmpty()) {
+ errors += ret.errors + "\n";
+ } else {
+ theInserter.first->second = ret.mShader;
+ theShader = ret.mShader;
+ }
} else {
QByteArray loadVertexData;
QByteArray loadFragmentData;
@@ -663,6 +668,10 @@ struct ShaderCache : public IShaderCache
qt3ds::foundation::toDataRef(
features.data(), static_cast<QT3DSU32>(features.size())),
error, false, true);
+ if (!error.isEmpty()) {
+ errors += error + "\n";
+ theShader = nullptr;
+ }
}
}
// If something doesn't save or load correctly, get the runtime to re-generate.