renderer: added generate job
For nodes that produce an image on the CPU before sending it to the GPU.
This commit is contained in:
@@ -468,6 +468,12 @@ void Node::ProcessSamples(NodeValueDatabase &, const SampleBufferPtr, SampleBuff
|
||||
{
|
||||
}
|
||||
|
||||
void Node::GenerateFrame(FramePtr frame, const GenerateJob &job) const
|
||||
{
|
||||
Q_UNUSED(frame)
|
||||
Q_UNUSED(job)
|
||||
}
|
||||
|
||||
NodeInput *Node::GetInputWithID(const QString &id) const
|
||||
{
|
||||
QList<NodeInput*> inputs = GetInputsIncludingArrays();
|
||||
|
||||
+11
-1
@@ -27,6 +27,7 @@
|
||||
#include <QPointF>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "codec/frame.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
#include "common/rational.h"
|
||||
#include "common/xmlutils.h"
|
||||
@@ -177,10 +178,19 @@ public:
|
||||
virtual ShaderCode GetShaderCode(const QString& shader_id) const;
|
||||
|
||||
/**
|
||||
* @brief If ProcessesSamples() is true, this is the function that will process them.
|
||||
* @brief If Value() pushes a ShaderJob, this is the function that will process them.
|
||||
*/
|
||||
virtual void ProcessSamples(NodeValueDatabase &values, const SampleBufferPtr input, SampleBufferPtr output, int index) const;
|
||||
|
||||
/**
|
||||
* @brief If Value() pushes a GenerateJob, override this function for the image to create
|
||||
*
|
||||
* @param frame
|
||||
*
|
||||
* The destination buffer. It will already be allocated and ready for writing to.
|
||||
*/
|
||||
virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the input with the specified ID (or nullptr if it doesn't exist)
|
||||
*/
|
||||
|
||||
@@ -214,6 +214,7 @@ QByteArray NodeParam::ValueToBytes(const NodeParam::DataType &type, const QVaria
|
||||
case kVector:
|
||||
case kShaderJob:
|
||||
case kSampleJob:
|
||||
case kGenerateJob:
|
||||
case kAny:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -196,6 +196,15 @@ public:
|
||||
*/
|
||||
kSampleJob = 0x20000,
|
||||
|
||||
/**
|
||||
* Job type
|
||||
*
|
||||
* An internal type used to indicate to the renderer that an accelerated sample job needs to
|
||||
* take place. This value will usually be taken from a table and a kSamples value will be
|
||||
* pushed to take its place.
|
||||
*/
|
||||
kGenerateJob = 0x40000,
|
||||
|
||||
/**
|
||||
****************************** BROAD IDENTIFIERS ******************************
|
||||
*/
|
||||
|
||||
+22
-1
@@ -140,6 +140,14 @@ QVariant NodeTraverser::ProcessSamples(const Node *node, const TimeRange &range,
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::ProcessFrameGeneration(const Node *node, const GenerateJob &job)
|
||||
{
|
||||
Q_UNUSED(node)
|
||||
Q_UNUSED(job)
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant NodeTraverser::GetCachedFrame(const Node *node, const rational &time)
|
||||
{
|
||||
Q_UNUSED(node)
|
||||
@@ -166,8 +174,9 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
|
||||
QList<NodeValue> audio_footage_to_retrieve;
|
||||
QList<NodeValue> shader_jobs_to_run;
|
||||
QList<NodeValue> sample_jobs_to_run;
|
||||
QList<NodeValue> generate_jobs_to_run;
|
||||
|
||||
for (int i=output_params.Count()-1; i>=0; i--) {
|
||||
for (int i=0; i<output_params.Count(); i++) {
|
||||
const NodeValue& v = output_params.at(i);
|
||||
QList<NodeValue>* take_this_value_list = nullptr;
|
||||
|
||||
@@ -186,10 +195,13 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
|
||||
take_this_value_list = &shader_jobs_to_run;
|
||||
} else if (v.type() == NodeParam::kSampleJob) {
|
||||
take_this_value_list = &sample_jobs_to_run;
|
||||
} else if (v.type() == NodeParam::kGenerateJob) {
|
||||
take_this_value_list = &generate_jobs_to_run;
|
||||
}
|
||||
|
||||
if (take_this_value_list) {
|
||||
take_this_value_list->append(output_params.TakeAt(i));
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +223,15 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
|
||||
output_params.Push(NodeParam::kTexture, value, node);
|
||||
}
|
||||
}
|
||||
|
||||
// Run generate jobs
|
||||
foreach (const NodeValue& v, generate_jobs_to_run) {
|
||||
QVariant value = ProcessFrameGeneration(node, v.data().value<GenerateJob>());
|
||||
|
||||
if (!value.isNull()) {
|
||||
output_params.Push(NodeParam::kTexture, value, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve audio samples
|
||||
|
||||
@@ -52,6 +52,8 @@ protected:
|
||||
|
||||
virtual QVariant ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job);
|
||||
|
||||
virtual QVariant ProcessFrameGeneration(const Node *node, const GenerateJob& job);
|
||||
|
||||
virtual QVariant GetCachedFrame(const Node *node, const rational &time);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user