nodes: rework so that jobs can be completely deferred

Big optimization requiring a lot of refactoring.
This commit is contained in:
itsmattkc
2022-09-24 18:44:59 -07:00
parent 658fe9da7e
commit c0d8ff403f
57 changed files with 593 additions and 588 deletions
+4 -1
View File
@@ -26,10 +26,13 @@
namespace olive {
class AcceleratedJob {
class AcceleratedJob
{
public:
AcceleratedJob() = default;
virtual ~AcceleratedJob(){}
NodeValue Get(const QString& input) const
{
return value_map_.value(input);
+8 -7
View File
@@ -24,13 +24,16 @@
#include <QString>
#include <QVariant>
#include "node/value.h"
#include "render/job/acceleratedjob.h"
namespace olive {
class CacheJob
class CacheJob : public AcceleratedJob
{
public:
CacheJob() = default;
CacheJob(const QString &filename, const QVariant &fallback = QVariant())
CacheJob(const QString &filename, const NodeValue &fallback = NodeValue())
{
filename_ = filename;
}
@@ -38,18 +41,16 @@ public:
const QString &GetFilename() const { return filename_; }
void SetFilename(const QString &s) { filename_ = s; }
const QVariant &GetFallback() const { return fallback_; }
void SetFallback(const QVariant &val) { fallback_ = val; }
const NodeValue &GetFallback() const { return fallback_; }
void SetFallback(const NodeValue &val) { fallback_ = val; }
private:
QString filename_;
QVariant fallback_;
NodeValue fallback_;
};
}
Q_DECLARE_METATYPE(olive::CacheJob)
#endif // CACHEJOB_H
+16 -8
View File
@@ -24,7 +24,7 @@
#include <QMatrix4x4>
#include <QString>
#include "render/job/generatejob.h"
#include "acceleratedjob.h"
#include "render/alphaassoc.h"
#include "render/colorprocessor.h"
#include "render/texture.h"
@@ -33,18 +33,23 @@ namespace olive {
class Node;
class ColorTransformJob : public GenerateJob
class ColorTransformJob : public AcceleratedJob
{
public:
ColorTransformJob()
{
processor_ = nullptr;
input_texture_ = nullptr;
custom_shader_src_ = nullptr;
input_alpha_association_ = kAlphaNone;
clear_destination_ = true;
}
ColorTransformJob(const NodeValueRow &row) :
ColorTransformJob()
{
Insert(row);
}
QString id() const
{
if (id_.isEmpty()) {
@@ -56,8 +61,13 @@ public:
void SetOverrideID(const QString &id) { id_ = id; }
TexturePtr GetInputTexture() const { return input_texture_; }
void SetInputTexture(TexturePtr tex) { input_texture_ = tex; }
const NodeValue &GetInputTexture() const { return input_texture_; }
void SetInputTexture(const NodeValue &tex) { input_texture_ = tex; }
void SetInputTexture(TexturePtr tex)
{
Q_ASSERT(!tex->IsDummy());
input_texture_ = NodeValue(NodeValue::kTexture, tex);
}
ColorProcessorPtr GetColorProcessor() const { return processor_; }
void SetColorProcessor(ColorProcessorPtr p) { processor_ = p; }
@@ -89,7 +99,7 @@ private:
ColorProcessorPtr processor_;
QString id_;
TexturePtr input_texture_;
NodeValue input_texture_;
const Node *custom_shader_src_;
QString custom_shader_id_;
@@ -108,6 +118,4 @@ private:
}
Q_DECLARE_METATYPE(olive::ColorTransformJob)
#endif // COLORTRANSFORMJOB_H
+1 -1
View File
@@ -25,7 +25,7 @@
namespace olive {
class FootageJob
class FootageJob : public AcceleratedJob
{
public:
FootageJob() :
+7 -18
View File
@@ -22,33 +22,22 @@
#define GENERATEJOB_H
#include "acceleratedjob.h"
#include "render/videoparams.h"
#include "codec/frame.h"
namespace olive {
class GenerateJob : public AcceleratedJob {
class GenerateJob : public AcceleratedJob
{
public:
GenerateJob()
GenerateJob() = default;
GenerateJob(const NodeValueRow &row) :
GenerateJob()
{
requested_format_ = VideoParams::kFormatInvalid;
Insert(row);
}
VideoParams::Format GetRequestedFormat() const { return requested_format_; }
void SetRequestedFormat(VideoParams::Format f) { requested_format_ = f; }
const QString &GetColorspace() const { return colorspace_; }
void SetColorspace(const QString &s) { colorspace_ = s; }
private:
VideoParams::Format requested_format_;
QString colorspace_;
};
}
Q_DECLARE_METATYPE(olive::GenerateJob)
#endif // GENERATEJOB_H
+2 -1
View File
@@ -27,7 +27,8 @@
namespace olive {
class SampleJob : public AcceleratedJob {
class SampleJob : public AcceleratedJob
{
public:
SampleJob()
{
+9 -11
View File
@@ -24,19 +24,24 @@
#include <QMatrix4x4>
#include <QVector>
#include "generatejob.h"
#include "render/colorprocessor.h"
#include "acceleratedjob.h"
#include "render/texture.h"
namespace olive {
class ShaderJob : public GenerateJob {
class ShaderJob : public AcceleratedJob
{
public:
ShaderJob()
{
iterations_ = 1;
iterative_input_ = nullptr;
will_change_image_size_ = true;
}
ShaderJob(const NodeValueRow &row) :
ShaderJob()
{
Insert(row);
}
const QString& GetShaderID() const
@@ -100,9 +105,6 @@ public:
return vertex_overrides_;
}
bool GetWillChangeImageSize() const { return will_change_image_size_; }
void SetWillChangeImageSize(bool e) { will_change_image_size_ = e; }
private:
QString shader_id_;
@@ -114,12 +116,8 @@ private:
QVector<float> vertex_overrides_;
bool will_change_image_size_;
};
}
Q_DECLARE_METATYPE(olive::ShaderJob)
#endif // SHADERJOB_H