renderer: minor code improvements

This commit is contained in:
itsmattkc
2020-02-03 12:41:20 +11:00
parent 0c46b0c471
commit 776cfd87c8
6 changed files with 16 additions and 40 deletions
-1
View File
@@ -22,7 +22,6 @@
#define NODE_H
#include <QCryptographicHash>
#include <QMutex>
#include <QObject>
#include <QPointF>
#include <QXmlStreamWriter>
-1
View File
@@ -21,7 +21,6 @@
#ifndef NODEPARAM_H
#define NODEPARAM_H
#include <QMutex>
#include <QObject>
#include <QVariant>
#include <QVector>
@@ -22,6 +22,7 @@
#define OPENGLFUNCTIONS_H
#include <QMatrix4x4>
#include <QMutex>
#include <QOpenGLFunctions>
#include "openglshader.h"
@@ -48,6 +49,7 @@ public:
static void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
static void PrepareToDraw(QOpenGLFunctions* f);
};
#endif // OPENGLFUNCTIONS_H
@@ -230,13 +230,3 @@ QString OpenGLShader::CodeAlphaAssociate(const QString &function_name)
" return vec4(col.rgb * col.a, col.a);\n"
"}\n").arg(function_name);
}
void OpenGLShader::Lock()
{
lock_.lock();
}
void OpenGLShader::Unlock()
{
lock_.unlock();
}
-6
View File
@@ -2,7 +2,6 @@
#define OPENGLSHADER_H
#include <memory>
#include <QMutex>
#include <QOpenGLShaderProgram>
#include <OpenColorIO/OpenColorIO.h>
@@ -33,11 +32,6 @@ public:
static QString CodeAlphaReassociate(const QString& function_name);
static QString CodeAlphaAssociate(const QString& function_name);
void Lock();
void Unlock();
private:
QMutex lock_;
};
#endif // OPENGLSHADER_H
+14 -22
View File
@@ -180,7 +180,6 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
}
// Lock the shader so no other thread interferes as we set parameters and draw (and we don't interfere with any others)
shader->Lock();
shader->bind();
unsigned int input_texture_count = 0;
@@ -292,35 +291,32 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
static_cast<GLfloat>(video_params().width()),
static_cast<GLfloat>(video_params().height()));
if (node->IsBlock()) {
const Block* block_node = static_cast<const Block*>(node);
if (node->IsBlock() && static_cast<const Block*>(node)->type() == Block::kTransition) {
const TransitionBlock* transition_node = static_cast<const TransitionBlock*>(node);
if (block_node->type() == Block::kTransition) {
const TransitionBlock* transition_node = static_cast<const TransitionBlock*>(node);
// Provides total transition progress from 0.0 (start) - 1.0 (end)
shader->setUniformValue("ove_tprog_all", static_cast<GLfloat>(transition_node->GetTotalProgress(range.in())));
// Provides total transition progress from 0.0 (start) - 1.0 (end)
shader->setUniformValue("ove_tprog_all", static_cast<GLfloat>(transition_node->GetTotalProgress(range.in())));
// Provides progress of out section from 1.0 (start) - 0.0 (end)
shader->setUniformValue("ove_tprog_out", static_cast<GLfloat>(transition_node->GetOutProgress(range.in())));
// Provides progress of out section from 1.0 (start) - 0.0 (end)
shader->setUniformValue("ove_tprog_out", static_cast<GLfloat>(transition_node->GetOutProgress(range.in())));
// Provides progress of in section from 0.0 (start) - 1.0 (end)
shader->setUniformValue("ove_tprog_in", static_cast<GLfloat>(transition_node->GetInProgress(range.in())));
}
// Provides progress of in section from 0.0 (start) - 1.0 (end)
shader->setUniformValue("ove_tprog_in", static_cast<GLfloat>(transition_node->GetInProgress(range.in())));
}
// Some nodes use multiple iterations for optimization
OpenGLTextureCache::ReferencePtr output_tex;
for (int iteration=0;iteration<node->AcceleratedCodeIterations();iteration++) {
// If this is not the first iteration, set the parameter that will receive the last iteration's texture
OpenGLTextureCache::ReferencePtr source_tex = dst_refs.at((iteration+1)%dst_refs.size());
OpenGLTextureCache::ReferencePtr destination_tex = dst_refs.at(iteration%dst_refs.size());
// Set iteration number
shader->bind();
shader->setUniformValue("ove_iteration", iteration);
shader->release();
// If this is not the first iteration, set the parameter that will receive the last iteration's texture
OpenGLTextureCache::ReferencePtr source_tex = dst_refs.at((iteration+1)%dst_refs.size());
OpenGLTextureCache::ReferencePtr destination_tex = dst_refs.at(iteration%dst_refs.size());
if (iteration > 0) {
functions_->glActiveTexture(GL_TEXTURE0 + iterative_input);
functions_->glBindTexture(GL_TEXTURE_2D, source_tex->texture()->texture());
@@ -339,10 +335,6 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
output_tex = destination_tex;
}
// Make sure all OpenGL functions are complete by this point before unlocking the shader (or another thread may
// change its parameters before our drawing in this thread is done)
shader->Unlock();
// Release any textures we bound before
while (input_texture_count > 0) {
input_texture_count--;
@@ -371,8 +363,8 @@ void OpenGLWorker::TextureToBuffer(const QVariant &tex_in, QByteArray &buffer)
f->glReadPixels(0,
0,
texture->texture()->width(),
texture->texture()->height(),
video_params().effective_width(),
video_params().effective_height(),
format_info.pixel_format,
format_info.gl_pixel_type,
buffer.data());