made vast improvements to rendering engine and node structure

This was many changes that were largely fundamentally related. They included:
- More const modifiers to enforce read only node graphs
- Support for fragment and vertex shaders from the nodes
- Support for node code loaded externally (embedded into the binary)
- Fixed issue preventing two textures from being used in a shader
- Removed several unused functions and cleaned up code
- Fixed video media node misreading its matrix input
This commit is contained in:
itsmattkc
2019-12-09 23:50:52 +11:00
parent daafcbfc95
commit 26b3993b9d
31 changed files with 287 additions and 233 deletions
+46 -28
View File
@@ -9,9 +9,9 @@ RenderBackend::RenderBackend(QObject *parent) :
started_(false),
viewer_node_(nullptr),
copied_viewer_node_(nullptr),
value_update_queued_(false),
recompile_queued_(false),
input_update_queued_(false)
input_update_queued_(false),
blocking_(false)
{
}
@@ -51,6 +51,8 @@ void RenderBackend::Close()
started_ = false;
Decompile();
CloseInternal();
for (int i=0;i<processors_.size();i++) {
@@ -127,12 +129,14 @@ bool RenderBackend::Compile()
foreach (Node* n, source_node_list_) {
Node* copy = n->copy();
// Copy values (but not connections yet)
Node::CopyInputs(n, copy, false);
copied_graph_.AddNode(copy);
}
// We just copied the inputs, so if an input update is queued, it's unnecessary
input_update_queued_ = false;
// We know that the first node will be the viewer node since we appended that first in the copy
copied_viewer_node_ = static_cast<ViewerOutput*>(copied_graph_.nodes().first());
@@ -183,7 +187,7 @@ void RenderBackend::RegenerateCacheID()
CacheIDChangedEvent(cache_id_);
}
rational RenderBackend::SequenceLength()
rational RenderBackend::GetSequenceLength()
{
if (viewer_node_ == nullptr) {
return 0;
@@ -216,16 +220,24 @@ void RenderBackend::CacheNext()
}
if ((input_update_queued_ || recompile_queued_) && !AllProcessorsAreAvailable()) {
qDebug() << "Blocking render while we wait for all workers to finish...";
if (input_update_queued_ && recompile_queued_) {
qDebug() << "Input update and recompile queued, blocking while processors are busy...";
} else if (input_update_queued_) {
qDebug() << "Input update queued, blocking while processors are busy...";
} else {
qDebug() << "Recompile queued, blocking while processors are busy...";
}
blocking_ = true;
return;
}
if (input_update_queued_) {
UpdateNodeInputs();
input_update_queued_ = false;
if (blocking_) {
qDebug() << "Processors are free now";
blocking_ = false;
}
if (recompile_queued_) {
qDebug() << "Recompile requested, decompiling now...";
Decompile();
recompile_queued_ = false;
}
@@ -235,6 +247,25 @@ void RenderBackend::CacheNext()
return;
}
if (input_update_queued_) {
qDebug() << "Copied inputs from UI graph";
for (int i=0;i<source_node_list_.size();i++) {
Node* src = source_node_list_.at(i);
Node* dst = copied_graph_.nodes().at(i);
Node::CopyInputs(src, dst, false);
}
input_update_queued_ = false;
}
Node* node_connected_to_viewer = GetDependentInput()->get_connected_node();
if (!node_connected_to_viewer) {
return;
}
foreach (RenderWorker* worker, processors_) {
if (cache_queue_.isEmpty()) {
break;
@@ -243,14 +274,16 @@ void RenderBackend::CacheNext()
if (!WorkerIsBusy(worker)) {
TimeRange cache_frame = cache_queue_.takeFirst();
NodeDependency dep = NodeDependency(GetDependentInput()->get_connected_node(), cache_frame.in(), cache_frame.out());
//qDebug() << "Rendering" << cache_frame.in().toDouble() << "-" << cache_frame.out().toDouble();
NodeDependency dep = NodeDependency(node_connected_to_viewer, cache_frame.in(), cache_frame.out());
SetWorkerBusyState(worker, true);
QMetaObject::invokeMethod(worker,
"Render",
Qt::QueuedConnection,
Q_ARG(NodeDependency, dep));
SetWorkerBusyState(worker, true);
}
}
}
@@ -270,24 +303,9 @@ const QString &RenderBackend::cache_id() const
return cache_id_;
}
void RenderBackend::QueueValueUpdate(const TimeRange &range)
void RenderBackend::QueueValueUpdate()
{
value_update_queued_ = true;
value_update_range_ = range;
}
void RenderBackend::UpdateNodeInputs()
{
if (value_update_queued_) {
for (int i=0;i<source_node_list_.size();i++) {
Node* src = source_node_list_.at(i);
Node* dst = copied_graph_.nodes().at(i);
Node::CopyInputs(src, dst, false);
}
value_update_queued_ = false;
}
input_update_queued_ = true;
}
bool RenderBackend::WorkerIsBusy(RenderWorker *worker) const