Once again, conceptually this system should work, however it does not seem to be the most efficient and it wouldn't surprise me if the multithreading was eventually upgraded to an even more coherent system one day. However for "core principles" this should be fairly decent.
30 lines
654 B
C++
30 lines
654 B
C++
#include "openglshadercache.h"
|
|
|
|
#include "node/node.h"
|
|
|
|
OpenGLShaderCache::OpenGLShaderCache()
|
|
{
|
|
|
|
}
|
|
|
|
QString OpenGLShaderCache::GenerateShaderID(NodeOutput *output)
|
|
{
|
|
// Creates a unique identifier for this specific node and this specific output
|
|
return QString("%1:%2").arg(output->parent()->id(), output->id());
|
|
}
|
|
|
|
void OpenGLShaderCache::Clear()
|
|
{
|
|
compiled_nodes_.clear();
|
|
}
|
|
|
|
void OpenGLShaderCache::AddShader(NodeOutput *output, OpenGLShaderPtr shader)
|
|
{
|
|
compiled_nodes_.insert(GenerateShaderID(output), shader);
|
|
}
|
|
|
|
OpenGLShaderPtr OpenGLShaderCache::GetShader(NodeOutput *output)
|
|
{
|
|
return compiled_nodes_.value(GenerateShaderID(output));
|
|
}
|