minor render pipeline improvements
Simple flow improvements of the rendering pipeline for efficiency and reliability.
This commit is contained in:
@@ -249,25 +249,8 @@ bool VideoRenderBackend::CanRender()
|
||||
|
||||
void VideoRenderBackend::ThreadCompletedFrame(NodeDependency path, qint64 job_time, QByteArray hash, QVariant value)
|
||||
{
|
||||
// Here, we received a frame resident in memory that can be forwarded along to a viewer or exporter if necessary.
|
||||
|
||||
QList<rational> times_with_this_hash;
|
||||
|
||||
// If the viewer last requested this time, presumably it hasn't moved from there and should know this frame has now
|
||||
// changed
|
||||
if (last_time_requested_ == path.in()
|
||||
&& JobIsCurrent(path, job_time)) {
|
||||
times_with_this_hash.append(path.in());
|
||||
}
|
||||
|
||||
// Send all deferred frames to the exporter
|
||||
/*if (export_mode_) {
|
||||
times_with_this_hash.append(frame_cache()->DeferredMapsWithHash(hash));
|
||||
}*/
|
||||
|
||||
// If we have frames to forward along to a viewer/exporter, forward them here
|
||||
if (!times_with_this_hash.isEmpty()) {
|
||||
EmitCachedFrameReady(times_with_this_hash, value);
|
||||
if (last_time_requested_ == path.in() || frame_cache_.TimeToHash(last_time_requested_) == hash) {
|
||||
EmitCachedFrameReady({last_time_requested_}, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +268,11 @@ void VideoRenderBackend::ThreadSkippedFrame(NodeDependency dep, qint64 job_time,
|
||||
{
|
||||
SetWorkerBusyState(static_cast<RenderWorker*>(sender()), false);
|
||||
|
||||
SetFrameHash(dep, hash, job_time);
|
||||
if (SetFrameHash(dep, hash, job_time)
|
||||
&& last_time_requested_ == dep.in()
|
||||
&& frame_cache_.HasHash(hash)) {
|
||||
emit CachedTimeReady(dep.in());
|
||||
}
|
||||
|
||||
// Queue up a new frame for this worker
|
||||
CacheNext();
|
||||
@@ -295,7 +282,8 @@ void VideoRenderBackend::ThreadHashAlreadyExists(NodeDependency dep, qint64 job_
|
||||
{
|
||||
SetWorkerBusyState(static_cast<RenderWorker*>(sender()), false);
|
||||
|
||||
if (SetFrameHash(dep, hash, job_time) && dep.in() == last_time_requested_) {
|
||||
if (SetFrameHash(dep, hash, job_time)
|
||||
&& dep.in() == last_time_requested_) {
|
||||
emit CachedTimeReady(dep.in());
|
||||
}
|
||||
|
||||
@@ -322,7 +310,5 @@ bool VideoRenderBackend::SetFrameHash(const NodeDependency &dep, const QByteArra
|
||||
return true;
|
||||
}
|
||||
|
||||
qDebug() << "Discarded frame" << dep.in().toDouble();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,17 +53,11 @@ QByteArray VideoRenderFrameCache::TimeToHash(const rational &time) const
|
||||
|
||||
void VideoRenderFrameCache::SetHash(const rational &time, const QByteArray &hash)
|
||||
{
|
||||
// No longer currently caching this frame
|
||||
RemoveHashFromCurrentlyCaching(hash);
|
||||
|
||||
// Insert frame into map
|
||||
time_hash_map_.insert(time, hash);
|
||||
}
|
||||
|
||||
void VideoRenderFrameCache::RemoveHash(const rational &time, const QByteArray &hash)
|
||||
{
|
||||
RemoveHashFromCurrentlyCaching(hash);
|
||||
|
||||
time_hash_map_.remove(time);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ public:
|
||||
|
||||
void Truncate(const rational& time);
|
||||
|
||||
private:
|
||||
void RemoveHashFromCurrentlyCaching(const QByteArray& hash);
|
||||
|
||||
private:
|
||||
QMap<rational, QByteArray> time_hash_map_;
|
||||
|
||||
QMutex currently_caching_lock_;
|
||||
|
||||
@@ -45,6 +45,8 @@ NodeValueTable VideoRenderWorker::RenderInternal(const NodeDependency& path, con
|
||||
Download(path, hash, texture, frame_cache_->CachePathName(hash));
|
||||
}
|
||||
|
||||
frame_cache_->RemoveHashFromCurrentlyCaching(hash);
|
||||
|
||||
// Signal that this job is complete
|
||||
emit CompletedDownload(path, job_time, hash);
|
||||
} else {
|
||||
@@ -83,6 +85,17 @@ void VideoRenderWorker::HashNodeRecursively(QCryptographicHash *hash, const Node
|
||||
// For a single frame, we only care about one of the times
|
||||
rational input_time = n->InputTimeAdjustment(input, TimeRange(time, time)).in();
|
||||
|
||||
if (n->IsBlock()) {
|
||||
const Block* b = static_cast<const Block*>(n);
|
||||
|
||||
// Ignore some Block attributes when hashing
|
||||
if (input == b->media_in_input()
|
||||
|| input == b->media_out_input()
|
||||
|| input == b->length_input()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (input->IsConnected()) {
|
||||
// Traverse down this edge
|
||||
HashNodeRecursively(hash, input->get_connected_node(), input_time);
|
||||
|
||||
Reference in New Issue
Block a user