nodes: revert shader ID to string
Much easier to manage this way and fixes a compile issue on several platforms.
This commit is contained in:
@@ -80,7 +80,7 @@ void BlurFilterNode::Retranslate()
|
||||
repeat_edge_pixels_input_->set_name(tr("Repeat Edge Pixels"));
|
||||
}
|
||||
|
||||
ShaderCode BlurFilterNode::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode BlurFilterNode::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
return ShaderCode(ReadFileAsString(":/shaders/blur.frag"), QString());
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const QByteArray &shader_id) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -106,7 +106,7 @@ NodeValueTable StrokeFilterNode::Value(NodeValueDatabase &value) const
|
||||
return table;
|
||||
}
|
||||
|
||||
ShaderCode StrokeFilterNode::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode StrokeFilterNode::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
virtual ShaderCode GetShaderCode(const QByteArray &shader_id) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
|
||||
private:
|
||||
NodeInput* tex_input_;
|
||||
|
||||
@@ -85,7 +85,7 @@ void PolygonGenerator::Retranslate()
|
||||
color_input_->set_name(tr("Color"));
|
||||
}
|
||||
|
||||
ShaderCode PolygonGenerator::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode PolygonGenerator::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const QByteArray& shader_id) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString& shader_id) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
|
||||
virtual bool HasGizmos() const override;
|
||||
|
||||
@@ -73,7 +73,7 @@ NodeValueTable SolidGenerator::Value(NodeValueDatabase &value) const
|
||||
return table;
|
||||
}
|
||||
|
||||
ShaderCode SolidGenerator::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode SolidGenerator::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
virtual ShaderCode GetShaderCode(const QByteArray &shader_id) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
|
||||
private:
|
||||
NodeInput* color_input_;
|
||||
|
||||
+12
-19
@@ -89,21 +89,18 @@ void MathNode::Retranslate()
|
||||
method_in_->set_combobox_strings(operations);
|
||||
}
|
||||
|
||||
ShaderCode MathNode::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode MathNode::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
QDataStream data(shader_id);
|
||||
QStringList code_id = shader_id.split('.');
|
||||
|
||||
Pairing pairing;
|
||||
NodeParam::DataType type_a;
|
||||
NodeParam::DataType type_b;
|
||||
|
||||
data >> pairing;
|
||||
data >> type_a;
|
||||
data >> type_b;
|
||||
Operation op = static_cast<Operation>(code_id.at(0).toInt());
|
||||
Pairing pairing = static_cast<Pairing>(code_id.at(1).toInt());
|
||||
NodeParam::DataType type_a = static_cast<NodeParam::DataType>(code_id.at(2).toInt());
|
||||
NodeParam::DataType type_b = static_cast<NodeParam::DataType>(code_id.at(3).toInt());
|
||||
|
||||
QString operation, frag, vert;
|
||||
|
||||
if (pairing == kPairTextureMatrix && GetOperation() == kOpMultiply) {
|
||||
if (pairing == kPairTextureMatrix && op == kOpMultiply) {
|
||||
|
||||
// Override the operation for this operation since we multiply texture COORDS by the matrix rather than
|
||||
NodeParam* tex_in = (type_a == NodeParam::kTexture) ? param_a_in_ : param_b_in_;
|
||||
@@ -117,7 +114,7 @@ ShaderCode MathNode::GetShaderCode(const QByteArray &shader_id) const
|
||||
vert = ReadFileAsString(":/shaders/matrix.vert").arg(mat_in->id(), tex_in->id());
|
||||
|
||||
} else {
|
||||
switch (GetOperation()) {
|
||||
switch (op) {
|
||||
case kOpAdd:
|
||||
operation = QStringLiteral("%1 + %2");
|
||||
break;
|
||||
@@ -294,14 +291,10 @@ NodeValueTable MathNode::Value(NodeValueDatabase &value) const
|
||||
case kPairTextureMatrix:
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
QByteArray shader_id;
|
||||
QDataStream shader_id_stream(&shader_id, QIODevice::WriteOnly);
|
||||
shader_id_stream << calc.GetMostLikelyPairing();
|
||||
shader_id_stream << val_a.type();
|
||||
shader_id_stream << val_b.type();
|
||||
|
||||
job.SetShaderID(shader_id);
|
||||
job.SetShaderID(QStringLiteral("%1.%2.%3.%4").arg(QString::number(GetOperation()),
|
||||
QString::number(calc.GetMostLikelyPairing()),
|
||||
QString::number(val_a.type()),
|
||||
QString::number(val_b.type())));
|
||||
|
||||
job.InsertValue(param_a_in_, val_a);
|
||||
job.InsertValue(param_b_in_, val_b);
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const QByteArray &shader_id) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
|
||||
virtual void ProcessSamples(NodeValueDatabase &values, const SampleBufferPtr input, SampleBufferPtr output, int index) const override;
|
||||
|
||||
@@ -62,7 +62,7 @@ void MergeNode::Retranslate()
|
||||
blend_in_->set_name(tr("Blend"));
|
||||
}
|
||||
|
||||
ShaderCode MergeNode::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode MergeNode::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const QByteArray &shader_id) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
|
||||
NodeInput* base_in() const;
|
||||
|
||||
+1
-1
@@ -457,7 +457,7 @@ QList<Node *> Node::GetImmediateDependencies() const
|
||||
return GetDependenciesInternal(false, false);
|
||||
}
|
||||
|
||||
ShaderCode Node::GetShaderCode(const QByteArray &shader_id) const
|
||||
ShaderCode Node::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ public:
|
||||
/**
|
||||
* @brief Generate hardware accelerated code for this Node
|
||||
*/
|
||||
virtual ShaderCode GetShaderCode(const QByteArray& shader_id) const;
|
||||
virtual ShaderCode GetShaderCode(const QString& shader_id) const;
|
||||
|
||||
/**
|
||||
* @brief If ProcessesSamples() is true, this is the function that will process them.
|
||||
|
||||
@@ -64,7 +64,7 @@ void Sequence::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const
|
||||
}
|
||||
|
||||
if (reader->name() == QStringLiteral("video")) {
|
||||
int video_width = 0, video_height = 0, preview_div = 0;
|
||||
int video_width = 0, video_height = 0, preview_div = 1;
|
||||
rational video_timebase;
|
||||
PixelFormat::Format preview_format = PixelFormat::PIX_FMT_INVALID;
|
||||
|
||||
|
||||
@@ -182,12 +182,11 @@ QVariant OpenGLProxy::PreCachedFrameToValue(FramePtr frame)
|
||||
return QVariant::fromValue(texture_cache_.Get(ctx_, frame));
|
||||
}
|
||||
|
||||
OpenGLShaderPtr OpenGLProxy::ResolveShaderFromCache(const Node *node, const QByteArray &shader_id)
|
||||
OpenGLShaderPtr OpenGLProxy::ResolveShaderFromCache(const Node *node, const QString &shader_id)
|
||||
{
|
||||
// Make a composite of the node ID and the shader ID (if applicable)
|
||||
QByteArray id = node->id().toUtf8();
|
||||
id.append(shader_id);
|
||||
OpenGLShaderPtr shader = shader_cache_.value(id);
|
||||
QString full_shader_id = QStringLiteral("%1:%2").arg(node->id(), shader_id);
|
||||
OpenGLShaderPtr shader = shader_cache_.value(full_shader_id);
|
||||
|
||||
if (!shader) {
|
||||
// Since we have shader code, compile it now
|
||||
@@ -213,7 +212,7 @@ OpenGLShaderPtr OpenGLProxy::ResolveShaderFromCache(const Node *node, const QByt
|
||||
&& shader->addShaderFromSourceCode(QOpenGLShader::Fragment, frag_code)
|
||||
&& shader->addShaderFromSourceCode(QOpenGLShader::Vertex, vert_code)
|
||||
&& shader->link()) {
|
||||
shader_cache_.insert(shader_id, shader);
|
||||
shader_cache_.insert(full_shader_id, shader);
|
||||
} else {
|
||||
qWarning() << "Failed to compile shader for" << node->id();
|
||||
shader = nullptr;
|
||||
|
||||
@@ -84,7 +84,7 @@ public slots:
|
||||
QVariant PreCachedFrameToValue(OLIVE_NAMESPACE::FramePtr frame);
|
||||
|
||||
private:
|
||||
OpenGLShaderPtr ResolveShaderFromCache(const Node* node, const QByteArray& shader_id);
|
||||
OpenGLShaderPtr ResolveShaderFromCache(const Node* node, const QString &shader_id);
|
||||
|
||||
QOpenGLContext* ctx_;
|
||||
QOffscreenSurface surface_;
|
||||
@@ -97,7 +97,7 @@ private:
|
||||
|
||||
OpenGLShaderPtr copy_pipeline_;
|
||||
|
||||
QHash<QByteArray, OpenGLShaderPtr> shader_cache_;
|
||||
QHash<QString, OpenGLShaderPtr> shader_cache_;
|
||||
|
||||
OpenGLTextureCache texture_cache_;
|
||||
|
||||
|
||||
@@ -93,12 +93,12 @@ public:
|
||||
alpha_channel_required_ = false;
|
||||
}
|
||||
|
||||
const QByteArray& GetShaderID() const
|
||||
const QString& GetShaderID() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
void SetShaderID(const QByteArray& id)
|
||||
void SetShaderID(const QString& id)
|
||||
{
|
||||
id_ = id;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QByteArray id_;
|
||||
QString id_;
|
||||
|
||||
int iterations_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user