Get OCIO node groundwork working

This commit is contained in:
Thomas Wilshaw
2022-03-08 14:40:03 +00:00
parent 4d5ca96b68
commit 979095d2e0
14 changed files with 61 additions and 121 deletions
-1
View File
@@ -16,7 +16,6 @@
add_subdirectory(colormanager)
add_subdirectory(displaytransform)
add_subdirectory(ociobase)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
@@ -107,8 +107,11 @@ void DisplayTransformNode::Value(const NodeValueRow &value, const NodeGlobals &g
{
ShaderJob job;
job.InsertValue(value);
job.SetUseOCIO(true);
job.SetShaderDesc(shader_desc_);
job.SetColorProcessor(reference_to_display_);
renderer()->ShaderJobInsertTextures(reference_to_display_, &job, shader_desc_);
//renderer()->ShaderJobInsertTextures(reference_to_display_, &job, shader_desc_);
// If there's no texture, no need to run an operation
if (!job.GetValue(kTextureInput).data().isNull()) {
@@ -16,10 +16,11 @@
#ifndef DISPLAYTRANSFORMNODE_H
#define DISPLAYTRANSFORMNODE_H
#include "node/color/ociobase/ociobase.h"
#include "node/node.h"
#include "render/colorprocessor.h"
namespace olive {
class DisplayTransformNode : public OCIONodeBase {
class DisplayTransformNode : public Node {
Q_OBJECT
public:
DisplayTransformNode();
@@ -41,6 +42,9 @@ class DisplayTransformNode : public OCIONodeBase {
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
ColorProcessorPtr GetColorProcessor() { return reference_to_display_; };
OCIO::GpuShaderDescRcPtr GetGPUShaderDesc() { return shader_desc_; };
static const QString kTextureInput;
static const QString kDirectionInput;
-22
View File
@@ -1,22 +0,0 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2021 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/color/ociobase/ociobase.cpp
node/color/ociobase/ociobase.h
PARENT_SCOPE
)
-37
View File
@@ -1,37 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "ociobase.h"
#include "render/opengl/openglrenderer.h"
namespace olive {
OCIONodeBase::OCIONodeBase()
{
if (true){//RenderManager::instance()->backend() == RenderManager::kOpenGL) {
// Create OpenGL renderer
attached_renderer_ = new OpenGLRenderer(this);
attached_renderer_->Init();
attached_renderer_->PostInit();
}
}
}
-51
View File
@@ -1,51 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef OCIOBASE_H
#define OCIOBASE_H
#include "node/node.h"
#include "render/rendermanager.h"
namespace olive {
class OCIONodeBase : public Node
{
public:
OCIONodeBase();
NODE_DEFAULT_DESTRUCTOR(OCIONodeBase);
protected:
Renderer* renderer() const
{
return attached_renderer_;
}
/**
* @brief Renderer abstraction
*/
Renderer* attached_renderer_;
};
} // olive
#endif // OCIOBASE_H
+1 -1
View File
@@ -86,7 +86,7 @@ SampleBufferPtr HashTraverser::ProcessAudioFootage(const FootageJob &stream, con
return buf;
}
TexturePtr HashTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
TexturePtr HashTraverser::ProcessShader(const Node *node, const TimeRange &range, ShaderJob &job)
{
HashGenerateJob(node, &job);
+1 -1
View File
@@ -37,7 +37,7 @@ protected:
virtual SampleBufferPtr ProcessAudioFootage(const FootageJob &stream, const TimeRange &input_time) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, ShaderJob& job) override;
virtual SampleBufferPtr ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job) override;
+1 -1
View File
@@ -292,7 +292,7 @@ SampleBufferPtr NodeTraverser::ProcessAudioFootage(const FootageJob& stream, con
return SampleBuffer::Create();
}
TexturePtr NodeTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
TexturePtr NodeTraverser::ProcessShader(const Node *node, const TimeRange &range, ShaderJob &job)
{
Q_UNUSED(node)
Q_UNUSED(range)
+1 -1
View File
@@ -76,7 +76,7 @@ protected:
virtual SampleBufferPtr ProcessAudioFootage(const FootageJob &stream, const TimeRange &input_time);
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job);
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, ShaderJob& job);
virtual SampleBufferPtr ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job);
+39
View File
@@ -24,6 +24,7 @@
#include <QMatrix4x4>
#include "generatejob.h"
#include "render/colorprocessor.h"
#include "render/texture.h"
namespace olive {
@@ -34,6 +35,7 @@ public:
{
iterations_ = 1;
iterative_input_ = nullptr;
use_ocio_ = false;
}
const QString& GetShaderID() const
@@ -87,6 +89,38 @@ public:
interpolation_.insert(id, interp);
}
bool UseOCIO() const
{
return use_ocio_;
}
void SetUseOCIO(bool use_ocio)
{
use_ocio_ = use_ocio;
}
ColorProcessorPtr ColorProcessor()
{
return color_processor_;
}
void SetColorProcessor(ColorProcessorPtr processor)
{
color_processor_ = processor;
}
OCIO::GpuShaderDescRcPtr ShaderDesc()
{
return shader_desc_;
}
void SetShaderDesc(OCIO::GpuShaderDescRcPtr shader_desc)
{
shader_desc_ = shader_desc;
}
private:
QString shader_id_;
@@ -96,6 +130,11 @@ private:
QHash<QString, Texture::Interpolation> interpolation_;
bool use_ocio_;
ColorProcessorPtr color_processor_;
OCIO::GpuShaderDescRcPtr shader_desc_;
};
}
+6 -1
View File
@@ -27,6 +27,7 @@
#include "node/block/clip/clip.h"
#include "node/block/transition/transition.h"
#include "node/color/displaytransform/displaytransform.h"
#include "node/project/project.h"
#include "rendermanager.h"
@@ -464,7 +465,7 @@ SampleBufferPtr RenderProcessor::ProcessAudioFootage(const FootageJob &stream, c
return super::ProcessAudioFootage(stream, input_time);
}
TexturePtr RenderProcessor::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
TexturePtr RenderProcessor::ProcessShader(const Node *node, const TimeRange &range, ShaderJob &job)
{
Q_UNUSED(range)
@@ -475,6 +476,10 @@ TexturePtr RenderProcessor::ProcessShader(const Node *node, const TimeRange &ran
QVariant shader = shader_cache_->value(full_shader_id);
if (shader.isNull()) {
if (job.UseOCIO()) {
render_ctx_->ShaderJobInsertTextures(job.ColorProcessor(), &job, job.ShaderDesc());
}
// Since we have shader code, compile it now
shader = render_ctx_->CreateNativeShader(node->GetShaderCode(job.GetShaderID()));
+1 -1
View File
@@ -48,7 +48,7 @@ protected:
virtual SampleBufferPtr ProcessAudioFootage(const FootageJob &stream, const TimeRange &input_time) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, ShaderJob& job) override;
virtual SampleBufferPtr ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job) override;
+1 -1
View File
@@ -9,5 +9,5 @@ void main() {
col = DisplayTransform(col);
gl_FragColor - col;
gl_FragColor = col;
}