Files
oak-editor/app/render/backend/opengl/openglshadercache.cpp
T
itsmattkc 092d76f41a disambiguated whether NodeParam::parent() would return a Node* or a QObject*
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.
2019-11-30 23:58:56 +11:00

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));
}