Old code assumes that a NodeParam's parent will always be a Node. The function has been separated off and tweaked in the event that this is not the case.
35 lines
778 B
C++
35 lines
778 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->parentNode()->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));
|
|
}
|
|
|
|
bool OpenGLShaderCache::HasShader(NodeOutput *output)
|
|
{
|
|
return compiled_nodes_.contains(GenerateShaderID(output));
|
|
}
|