renderer: added generate job
For nodes that produce an image on the CPU before sending it to the GPU.
This commit is contained in:
@@ -364,6 +364,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
|
||||
case NodeInput::kVector:
|
||||
case NodeInput::kShaderJob:
|
||||
case NodeInput::kSampleJob:
|
||||
case NodeInput::kGenerateJob:
|
||||
case NodeInput::kFootage:
|
||||
case NodeInput::kBuffer:
|
||||
case NodeInput::kNone:
|
||||
|
||||
@@ -211,6 +211,29 @@ QVariant RenderWorker::ProcessSamples(const Node *node, const TimeRange &range,
|
||||
return QVariant::fromValue(output_buffer);
|
||||
}
|
||||
|
||||
QVariant RenderWorker::ProcessFrameGeneration(const Node* node, const GenerateJob &job)
|
||||
{
|
||||
FramePtr frame = Frame::Create();
|
||||
|
||||
PixelFormat::Format output_fmt;
|
||||
if (job.GetAlphaChannelRequired()) {
|
||||
output_fmt = PixelFormat::GetFormatWithAlphaChannel(video_params_.format());
|
||||
} else {
|
||||
output_fmt = PixelFormat::GetFormatWithoutAlphaChannel(video_params_.format());
|
||||
}
|
||||
|
||||
frame->set_video_params(VideoParams(video_params_.width(),
|
||||
video_params_.height(),
|
||||
video_params_.time_base(),
|
||||
output_fmt,
|
||||
video_params_.divider()));
|
||||
frame->allocate();
|
||||
|
||||
node->GenerateFrame(frame, job);
|
||||
|
||||
return CachedFrameToTexture(frame);
|
||||
}
|
||||
|
||||
QVariant RenderWorker::GetCachedFrame(const Node* node, const rational& time)
|
||||
{
|
||||
if (node->id() == QStringLiteral("org.olivevideoeditor.Olive.videoinput")) {
|
||||
|
||||
@@ -126,6 +126,8 @@ protected:
|
||||
|
||||
virtual QVariant ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job) override;
|
||||
|
||||
virtual QVariant ProcessFrameGeneration(const Node *node, const GenerateJob& job) override;
|
||||
|
||||
virtual QVariant GetCachedFrame(const Node *node, const rational &time) override;
|
||||
|
||||
virtual bool TextureHasAlpha(const QVariant& v) const = 0;
|
||||
|
||||
+24
-14
@@ -84,13 +84,34 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class ShaderJob : public AcceleratedJob {
|
||||
class GenerateJob : public AcceleratedJob {
|
||||
public:
|
||||
GenerateJob()
|
||||
{
|
||||
alpha_channel_required_ = false;
|
||||
}
|
||||
|
||||
bool GetAlphaChannelRequired() const
|
||||
{
|
||||
return alpha_channel_required_;
|
||||
}
|
||||
|
||||
void SetAlphaChannelRequired(bool e)
|
||||
{
|
||||
alpha_channel_required_ = e;
|
||||
}
|
||||
|
||||
private:
|
||||
bool alpha_channel_required_;
|
||||
|
||||
};
|
||||
|
||||
class ShaderJob : public GenerateJob {
|
||||
public:
|
||||
ShaderJob()
|
||||
{
|
||||
iterations_ = 1;
|
||||
iterative_input_ = nullptr;
|
||||
alpha_channel_required_ = false;
|
||||
}
|
||||
|
||||
const QString& GetShaderID() const
|
||||
@@ -119,16 +140,6 @@ public:
|
||||
return iterative_input_;
|
||||
}
|
||||
|
||||
bool GetAlphaChannelRequired() const
|
||||
{
|
||||
return alpha_channel_required_;
|
||||
}
|
||||
|
||||
void SetAlphaChannelRequired(bool e)
|
||||
{
|
||||
alpha_channel_required_ = e;
|
||||
}
|
||||
|
||||
private:
|
||||
QString id_;
|
||||
|
||||
@@ -136,8 +147,6 @@ private:
|
||||
|
||||
NodeInput* iterative_input_;
|
||||
|
||||
bool alpha_channel_required_;
|
||||
|
||||
};
|
||||
|
||||
class ShaderCode {
|
||||
@@ -169,5 +178,6 @@ OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::ShaderJob)
|
||||
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::SampleJob)
|
||||
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::GenerateJob)
|
||||
|
||||
#endif // SHADERINFO_H
|
||||
|
||||
Reference in New Issue
Block a user