summaryrefslogtreecommitdiffstats
path: root/src/runtime
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-09-03 17:36:07 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-09-12 06:43:23 +0300
commit82574e7d6317898600958c356053cfdaa7321c32 (patch)
treed4d099d426094292a01e81cbb3f389a20a961cfc /src/runtime
parent0d6360909793aab11c66f4b8f7001f71cbacfee7 (diff)
Implement shader caching
Currently loaded shaders can now cached with an API call in either source code or binary format. It is necessary to do it that way as the shader cache can only be created in the target hardware. Task-number: QT3DS-3914 Change-Id: I094e8624943904c311ada2259a84b8c183f792f5 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/Qt3DSApplication.cpp12
-rw-r--r--src/runtime/Qt3DSApplication.h1
2 files changed, 6 insertions, 7 deletions
diff --git a/src/runtime/Qt3DSApplication.cpp b/src/runtime/Qt3DSApplication.cpp
index 63632f0..198bf3e 100644
--- a/src/runtime/Qt3DSApplication.cpp
+++ b/src/runtime/Qt3DSApplication.cpp
@@ -433,7 +433,6 @@ struct SApplicationSettings
{
Option<bool> m_LayerCacheEnabled;
Option<bool> m_LayerGpuProfilingEnabled;
- Option<bool> m_ShaderCachePersistenceEnabled;
SApplicationSettings() {}
@@ -452,8 +451,6 @@ struct SApplicationSettings
Choose(inCommandLine.m_LayerCacheEnabled, inUIAFileSettings.m_LayerCacheEnabled))
, m_LayerGpuProfilingEnabled(Choose(inCommandLine.m_LayerGpuProfilingEnabled,
inUIAFileSettings.m_LayerGpuProfilingEnabled))
- , m_ShaderCachePersistenceEnabled(Choose(inCommandLine.m_ShaderCachePersistenceEnabled,
- inUIAFileSettings.m_ShaderCachePersistenceEnabled))
{
}
@@ -511,7 +508,6 @@ struct SApplicationSettings
{
ParseBoolEnableDisableItem(inReader, LayerCacheName(), m_LayerCacheEnabled);
ParseBoolEnableDisableItem(inReader, LayerGpuProfilerName(), m_LayerGpuProfilingEnabled);
- ParseBoolEnableDisableItem(inReader, ShaderCacheName(), m_ShaderCachePersistenceEnabled);
}
void Parse(IDOMReader &inReader) { ParseItems(inReader); }
@@ -543,7 +539,6 @@ struct SApplicationSettings
{
outStream.Write(SOptionSerializer(m_LayerCacheEnabled));
outStream.Write(SOptionSerializer(m_LayerGpuProfilingEnabled));
- outStream.Write(SOptionSerializer(m_ShaderCachePersistenceEnabled));
}
void Load(IInStream &inStream)
@@ -553,8 +548,6 @@ struct SApplicationSettings
m_LayerCacheEnabled = s;
inStream.Read(s);
m_LayerGpuProfilingEnabled = s;
- inStream.Read(s);
- m_ShaderCachePersistenceEnabled = s;
}
};
@@ -1745,6 +1738,7 @@ struct SApp : public IApplication
IApplication &CreateApplication(Q3DStudio::CInputEngine &inInputEngine,
Q3DStudio::IAudioPlayer *inAudioPlayer,
Q3DStudio::IRuntimeFactory &inFactory,
+ const QByteArray &shaderCache,
bool initInRenderThread) override
{
{
@@ -1811,6 +1805,10 @@ struct SApp : public IApplication
*finalSettings.m_LayerCacheEnabled);
}
+
+ if (!shaderCache.isEmpty())
+ inFactory.GetQt3DSRenderContext().GetShaderCache().importShaderCache(shaderCache);
+
m_CoreFactory->GetPerfTimer().OutputTimerData();
m_AudioPlayer.SetPlayer(inAudioPlayer);
diff --git a/src/runtime/Qt3DSApplication.h b/src/runtime/Qt3DSApplication.h
index 13499f6..deaafe7 100644
--- a/src/runtime/Qt3DSApplication.h
+++ b/src/runtime/Qt3DSApplication.h
@@ -250,6 +250,7 @@ public:
virtual IApplication &CreateApplication(Q3DStudio::CInputEngine &inInputEngine,
Q3DStudio::IAudioPlayer *inAudioPlayer,
Q3DStudio::IRuntimeFactory &inFactory,
+ const QByteArray &shaderCache,
bool initInRenderThread) = 0;
// maintains reference to runtime factory core. AppDir is where the executable is located;