various changes to rendering flow and structure

This commit is contained in:
itsmattkc
2019-10-23 00:42:52 +11:00
parent 5f86b9b9c7
commit 7dec79ceaa
42 changed files with 663 additions and 888 deletions
+12 -51
View File
@@ -23,13 +23,8 @@
#include "audiorenderer.h"
AudioRendererProcessThread::AudioRendererProcessThread(AudioRendererProcessor* parent,
QOpenGLContext *share_ctx,
const int &width,
const int &height,
const int &divider,
const olive::PixelFormat &format,
const olive::RenderMode &mode) :
AudioRendererThreadBase(share_ctx, width, height, divider, format, mode),
const AudioRenderingParams &params) :
AudioRendererThreadBase(params),
parent_(parent),
cancelled_(false)
{
@@ -93,49 +88,20 @@ void AudioRendererProcessThread::ProcessLoop()
NodeOutput* output_to_process = path_.node();
Node* node_to_process = output_to_process->parent();
texture_ = nullptr;
QList<Node*> all_deps;
bool has_hash = false;
bool can_cache = true;
if (!sibling_) {
node_to_process->Lock();
QList<NodeDependency> deps = node_to_process->RunDependencies(output_to_process, path_.in());
all_deps = node_to_process->GetDependencies();
foreach (Node* dep, all_deps) {
dep->Lock();
}
// Check hash
QCryptographicHash hasher(QCryptographicHash::Sha1);
node_to_process->Hash(&hasher, output_to_process, path_.time());
hash_ = hasher.result();
has_hash = parent_->HasHash(hash_);
can_cache = false;
}
if (!has_hash){
if ((can_cache = parent_->TryCache(hash_))) {
QList<NodeDependency> deps = node_to_process->RunDependencies(output_to_process, path_.time());
// Ask for other threads to run these deps while we're here
if (!deps.isEmpty()) {
for (int i=1;i<deps.size();i++) {
emit RequestSibling(deps.at(i));
}
}
// Get the requested value
texture_ = output_to_process->get_value(path_.time(), path_.time()).value<RenderTexturePtr>();
render_instance()->context()->functions()->glFinish();
// Ask for other threads to run these deps while we're here
if (!deps.isEmpty()) {
for (int i=1;i<deps.size();i++) {
emit RequestSibling(deps.at(i));
}
}
// Get the requested value
QByteArray samples = output_to_process->get_value(path_.in(), path_.out()).toByteArray();
if (!sibling_) {
foreach (Node* dep, all_deps) {
dep->Unlock();
@@ -144,12 +110,7 @@ void AudioRendererProcessThread::ProcessLoop()
node_to_process->Unlock();
}
if (can_cache) {
// We cached this frame, signal that it will need to be downloaded to disk
emit CachedFrame(texture_, path_.time(), hash_);
} else {
// This hash already exists, no need to cache, just map it
emit FrameSkipped(path_.time(), hash_);
}
// Signal that we cached some samples
emit CachedSamples(samples, path_.in(), path_.out());
}
}