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
@@ -51,17 +51,17 @@ ShaderCode GeneratorWithMerge::GetShaderCode(const ShaderRequest &request) const
return ShaderCode();
}
void GeneratorWithMerge::PushMergableJob(const NodeValueRow &value, const QVariant &job, NodeValueTable *table) const
void GeneratorWithMerge::PushMergableJob(const NodeValueRow &value, TexturePtr job, NodeValueTable *table) const
{
if (value[kBaseInput].toTexture()) {
if (TexturePtr base = value[kBaseInput].toTexture()) {
// Push as merge node
ShaderJob merge;
merge.SetShaderID(QStringLiteral("mrg"));
merge.Insert(MergeNode::kBaseIn, value[kBaseInput]);
merge.Insert(MergeNode::kBlendIn, NodeValue(NodeValue::kTexture, job, this));
merge.Insert(MergeNode::kBlendIn, NodeValue(NodeValue::kTexture, base->toJob(*job->job()), this));
table->Push(NodeValue::kTexture, QVariant::fromValue(merge), this);
table->Push(NodeValue::kTexture, base->toJob(merge), this);
} else {
// Just push generate job
table->Push(NodeValue::kTexture, job, this);
@@ -38,7 +38,7 @@ public:
static const QString kBaseInput;
protected:
void PushMergableJob(const NodeValueRow &value, const QVariant &job, NodeValueTable *table) const;
void PushMergableJob(const NodeValueRow &value, TexturePtr job, NodeValueTable *table) const;
};
+5 -4
View File
@@ -77,13 +77,14 @@ ShaderCode ShapeNode::GetShaderCode(const ShaderRequest &request) const
void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
ShaderJob job;
TexturePtr base = value[kBaseInput].toTexture();
job.Insert(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
ShaderJob job(value);
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, base ? base->virtual_resolution() : globals.square_resolution(), this));
job.SetShaderID(QStringLiteral("shape"));
PushMergableJob(value, QVariant::fromValue(job), table);
PushMergableJob(value, Texture::Job(base ? base->params() : globals.vparams(), job), table);
}
void ShapeNode::InputValueChangedEvent(const QString &input, int element)
+2 -2
View File
@@ -77,7 +77,7 @@ void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlob
{
// Use offsets to make the appearance of values that start in the top left, even though we
// really anchor around the center
QVector2D center_pt = globals.resolution() * 0.5;
QVector2D center_pt = globals.square_resolution() * 0.5;
SetInputProperty(kPositionInput, QStringLiteral("offset"), center_pt);
QVector2D pos = row[kPositionInput].toVec2();
@@ -137,7 +137,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, const Qt::KeyboardModifier
QVector2D gizmo_sz_start(w_drag.GetStartValue().toDouble(), h_drag.GetStartValue().toDouble());
QVector2D gizmo_pos_start(x_drag.GetStartValue().toDouble(), y_drag.GetStartValue().toDouble());
QVector2D gizmo_half_res = gizmo->GetGlobals().resolution()/2;
QVector2D gizmo_half_res = gizmo->GetGlobals().square_resolution()/2;
QVector2D adjusted_pt(x, y);
QVector2D new_size;
QVector2D new_pos;