finished conforming renderers to new node structure
Stateless node system is done! Functionality is about equal to the functionality in master meaning this is ready for merging.
This commit is contained in:
@@ -71,63 +71,51 @@ bool OpenGLBackend::CompileInternal()
|
||||
}
|
||||
|
||||
// Traverse node graph compiling where necessary
|
||||
return TraverseCompiling(viewer_node());
|
||||
}
|
||||
|
||||
void OpenGLBackend::DecompileInternal()
|
||||
{
|
||||
shader_cache_.Clear();
|
||||
}
|
||||
QList<Node*> nodes = viewer_node()->GetDependencies();
|
||||
|
||||
bool OpenGLBackend::TraverseCompiling(Node *n)
|
||||
{
|
||||
foreach (NodeParam* param, n->parameters()) {
|
||||
if (param->type() == NodeParam::kInput && param->IsConnected()) {
|
||||
Node* connected_output = static_cast<NodeInput*>(param)->get_connected_node();
|
||||
foreach (Node* n, nodes) {
|
||||
// Check if we have a shader or not
|
||||
if (!shader_cache_.HasShader(n)) {
|
||||
// Since we don't have a shader, compile one now
|
||||
QString node_code = n->Code();
|
||||
|
||||
// Check if we have a shader or not
|
||||
if (shader_cache_.GetShader(connected_output) == nullptr) {
|
||||
// Since we don't have a shader, compile one now
|
||||
QString node_code = connected_output->Code();
|
||||
// If the node has no code, it mustn't be GPU accelerated
|
||||
if (node_code.isEmpty()) {
|
||||
// We enter a null shader so we don't try to compile this again
|
||||
shader_cache_.AddShader(n, nullptr);
|
||||
} else {
|
||||
// Since we have shader code, compile it now
|
||||
OpenGLShaderPtr program;
|
||||
|
||||
// If the node has no code, it mustn't be GPU accelerated
|
||||
if (!node_code.isEmpty()) {
|
||||
// Since we have shader code, compile it now
|
||||
OpenGLShaderPtr program;
|
||||
|
||||
if (!(program = std::make_shared<OpenGLShader>())) {
|
||||
SetError(QStringLiteral("Failed to create OpenGL shader object"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->create()) {
|
||||
SetError(QStringLiteral("Failed to create OpenGL shader on device"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->addShaderFromSourceCode(QOpenGLShader::Fragment, node_code)) {
|
||||
SetError(QStringLiteral("Failed to add OpenGL fragment shader code"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->addShaderFromSourceCode(QOpenGLShader::Vertex, OpenGLShader::CodeDefaultVertex())) {
|
||||
SetError(QStringLiteral("Failed to add OpenGL vertex shader code"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->link()) {
|
||||
SetError(QStringLiteral("Failed to compile OpenGL shader: %1").arg(program->log()));
|
||||
return false;
|
||||
}
|
||||
|
||||
shader_cache_.AddShader(connected_output, program);
|
||||
|
||||
//qDebug() << "Compiled" << connected_output->parent()->id() << "->" << connected_output->id();
|
||||
if (!(program = std::make_shared<OpenGLShader>())) {
|
||||
SetError(QStringLiteral("Failed to create OpenGL shader object"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!TraverseCompiling(connected_output)) {
|
||||
return false;
|
||||
if (!program->create()) {
|
||||
SetError(QStringLiteral("Failed to create OpenGL shader on device"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->addShaderFromSourceCode(QOpenGLShader::Fragment, node_code)) {
|
||||
SetError(QStringLiteral("Failed to add OpenGL fragment shader code"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->addShaderFromSourceCode(QOpenGLShader::Vertex, OpenGLShader::CodeDefaultVertex())) {
|
||||
SetError(QStringLiteral("Failed to add OpenGL vertex shader code"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!program->link()) {
|
||||
SetError(QStringLiteral("Failed to compile OpenGL shader: %1").arg(program->log()));
|
||||
return false;
|
||||
}
|
||||
|
||||
shader_cache_.AddShader(n, program);
|
||||
|
||||
//qDebug() << "Compiled" << connected_output->parent()->id() << "->" << connected_output->id();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,6 +123,11 @@ bool OpenGLBackend::TraverseCompiling(Node *n)
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLBackend::DecompileInternal()
|
||||
{
|
||||
shader_cache_.Clear();
|
||||
}
|
||||
|
||||
bool OpenGLBackend::TimeIsCached(const TimeRange &time)
|
||||
{
|
||||
return cache_queue_.contains(time);
|
||||
|
||||
@@ -28,15 +28,10 @@ protected:
|
||||
virtual void DecompileInternal() override;
|
||||
|
||||
private:
|
||||
bool TraverseCompiling(Node* n);
|
||||
|
||||
bool TimeIsCached(const TimeRange &time);
|
||||
|
||||
OpenGLTexturePtr master_texture_;
|
||||
|
||||
/*OpenGLFramebuffer copy_buffer_;
|
||||
OpenGLShaderPtr copy_pipeline_;*/
|
||||
|
||||
OpenGLShaderCache shader_cache_;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -82,7 +82,7 @@ void OpenGLWorker::RunNodeAccelerated(Node *node, const NodeValueDatabase *input
|
||||
{
|
||||
OpenGLShaderPtr shader = shader_cache_->GetShader(node);
|
||||
|
||||
if (shader == nullptr) {
|
||||
if (!shader) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,8 +111,15 @@ void OpenGLWorker::RunNodeAccelerated(Node *node, const NodeValueDatabase *input
|
||||
// Get value from database at this input
|
||||
const NodeValueTable& input_data = (*input_params)[input];
|
||||
|
||||
NodeParam::DataType find_data_type = input->data_type();
|
||||
|
||||
// Exception for Footage types (try to get a Texture instead)
|
||||
if (find_data_type == NodeParam::kFootage) {
|
||||
find_data_type = NodeParam::kTexture;
|
||||
}
|
||||
|
||||
// Try to get a value from it
|
||||
QVariant value = input_data.Get(input->data_type());
|
||||
QVariant value = input_data.Get(find_data_type);
|
||||
|
||||
switch (input->data_type()) {
|
||||
case NodeInput::kInt:
|
||||
@@ -139,17 +146,17 @@ void OpenGLWorker::RunNodeAccelerated(Node *node, const NodeValueDatabase *input
|
||||
case NodeInput::kBoolean:
|
||||
shader->setUniformValue(variable_location, value.toBool());
|
||||
break;
|
||||
case NodeInput::kTexture:
|
||||
case NodeInput::kFootage:
|
||||
case NodeInput::kTexture:
|
||||
{
|
||||
OpenGLTexturePtr texture = value.value<OpenGLTexturePtr>();
|
||||
|
||||
functions_->glActiveTexture(GL_TEXTURE0 + input_texture_count);
|
||||
|
||||
if (texture == nullptr) {
|
||||
functions_->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
} else {
|
||||
if (texture) {
|
||||
functions_->glBindTexture(GL_TEXTURE_2D, texture->texture());
|
||||
} else {
|
||||
functions_->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
// Set value to bound texture
|
||||
|
||||
@@ -207,6 +207,8 @@ void RenderBackend::CacheNext()
|
||||
|
||||
TimeRange cache_frame = cache_queue_.takeFirst();
|
||||
|
||||
//qDebug() << "Caching" << cache_frame.in();
|
||||
|
||||
caching_ = GenerateData(cache_frame);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ NodeValueTable RenderWorker::RenderAsSibling(NodeDependency dep)
|
||||
QList<NodeInput*> connected_inputs;
|
||||
NodeValueTable value;
|
||||
|
||||
//qDebug() << "Processing" << node->id();
|
||||
|
||||
// Set working state
|
||||
working_++;
|
||||
|
||||
@@ -121,8 +123,6 @@ NodeValueTable RenderWorker::ProcessNodeNormally(const NodeDependency& dep)
|
||||
{
|
||||
Node* node = dep.node();
|
||||
|
||||
//qDebug() << "Processing" << node->id();
|
||||
|
||||
// FIXME: Cache certain values here if we've already processed them before
|
||||
|
||||
NodeValueDatabase database;
|
||||
|
||||
@@ -47,10 +47,10 @@ void VideoRenderBackend::InvalidateCache(const rational &start_range, const rati
|
||||
rational start_range_adj = qMax(rational(0), start_range);
|
||||
rational end_range_adj = qMin(SequenceLength(), end_range);
|
||||
|
||||
/*qDebug() << "Cache invalidated between"
|
||||
qDebug() << "Cache invalidated between"
|
||||
<< start_range_adj.toDouble()
|
||||
<< "and"
|
||||
<< end_range_adj.toDouble();*/
|
||||
<< end_range_adj.toDouble();
|
||||
|
||||
// Snap start_range to timebase
|
||||
double start_range_dbl = start_range_adj.toDouble();
|
||||
|
||||
Reference in New Issue
Block a user