implemented core UI caching feedback functionality
Not a perfect implementation yet, but this shows UI feedback on what frames are cached and which ones aren't.
This commit is contained in:
@@ -39,10 +39,7 @@ void AudioRenderBackend::InvalidateCache(const rational &start_range, const rati
|
||||
rational end_range_adj = qMin(GetSequenceLength(), end_range);
|
||||
|
||||
// Add the range to the list
|
||||
cache_queue_.append(TimeRange(start_range_adj, end_range_adj));
|
||||
|
||||
// Remove any overlaps so we don't render the same thing twice
|
||||
ValidateRanges();
|
||||
cache_queue_.InsertTimeRange(TimeRange(start_range_adj, end_range_adj));
|
||||
|
||||
// Queue value update
|
||||
QueueValueUpdate();
|
||||
@@ -87,26 +84,6 @@ NodeInput *AudioRenderBackend::GetDependentInput()
|
||||
return viewer_node()->samples_input();
|
||||
}
|
||||
|
||||
void AudioRenderBackend::ValidateRanges()
|
||||
{
|
||||
for (int i=0;i<cache_queue_.size();i++) {
|
||||
const TimeRange& range1 = cache_queue_.at(i);
|
||||
|
||||
for (int j=0;j<cache_queue_.size();j++) {
|
||||
const TimeRange& range2 = cache_queue_.at(j);
|
||||
|
||||
if (TimeRange::Overlap(range1, range2) && i != j) {
|
||||
// Combine with the first range
|
||||
cache_queue_[i] = TimeRange::Combine(range1, range2);
|
||||
|
||||
// Remove the second range
|
||||
cache_queue_.removeAt(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString AudioRenderBackend::CachePathName()
|
||||
{
|
||||
QDir this_cache_dir = QDir(GetMediaCacheLocation()).filePath(cache_id());
|
||||
|
||||
@@ -42,8 +42,6 @@ protected:
|
||||
virtual bool CanRender() override;
|
||||
|
||||
private:
|
||||
void ValidateRanges();
|
||||
|
||||
AudioRenderingParams params_;
|
||||
|
||||
};
|
||||
|
||||
@@ -141,7 +141,7 @@ void OpenGLBackend::DecompileInternal()
|
||||
shader_cache_.Clear();
|
||||
}
|
||||
|
||||
void OpenGLBackend::EmitCachedFrameReady(const QList<rational> ×, const QVariant &value)
|
||||
void OpenGLBackend::EmitCachedFrameReady(const QList<rational> ×, const QVariant &value, qint64 job_time)
|
||||
{
|
||||
OpenGLTextureCache::ReferencePtr ref = value.value<OpenGLTextureCache::ReferencePtr>();
|
||||
OpenGLTexturePtr tex;
|
||||
@@ -153,7 +153,7 @@ void OpenGLBackend::EmitCachedFrameReady(const QList<rational> ×, const QVa
|
||||
}
|
||||
|
||||
foreach (const rational& t, times) {
|
||||
emit CachedFrameReady(t, QVariant::fromValue(tex));
|
||||
emit CachedFrameReady(t, QVariant::fromValue(tex), job_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ protected:
|
||||
|
||||
virtual void DecompileInternal() override;
|
||||
|
||||
virtual void EmitCachedFrameReady(const QList<rational> ×, const QVariant& value) override;
|
||||
virtual void EmitCachedFrameReady(const QList<rational> ×, const QVariant& value, qint64 job_time) override;
|
||||
|
||||
private:
|
||||
OpenGLTexturePtr CopyTexture(OpenGLTexturePtr input);
|
||||
|
||||
@@ -90,7 +90,7 @@ protected:
|
||||
bool WorkerIsBusy(RenderWorker* worker) const;
|
||||
void SetWorkerBusyState(RenderWorker* worker, bool busy);
|
||||
|
||||
QList<TimeRange> cache_queue_;
|
||||
TimeRangeList cache_queue_;
|
||||
|
||||
QVector<RenderWorker*> processors_;
|
||||
|
||||
|
||||
@@ -159,6 +159,13 @@ void VideoRenderBackend::SetExportMode(bool enabled)
|
||||
export_mode_ = enabled;
|
||||
}
|
||||
|
||||
bool VideoRenderBackend::IsRendered(const rational &time) const
|
||||
{
|
||||
TimeRange range(time, time);
|
||||
|
||||
return !TimeIsQueued(range) && !render_job_info_.contains(range);
|
||||
}
|
||||
|
||||
bool VideoRenderBackend::GenerateCacheIDInternal(QCryptographicHash& hash)
|
||||
{
|
||||
if (!params_.is_valid()) {
|
||||
@@ -250,7 +257,7 @@ bool VideoRenderBackend::CanRender()
|
||||
void VideoRenderBackend::ThreadCompletedFrame(NodeDependency path, qint64 job_time, QByteArray hash, QVariant value)
|
||||
{
|
||||
if (last_time_requested_ == path.in() || frame_cache_.TimeToHash(last_time_requested_) == hash) {
|
||||
EmitCachedFrameReady({last_time_requested_}, value);
|
||||
EmitCachedFrameReady({last_time_requested_}, value, job_time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +265,13 @@ void VideoRenderBackend::ThreadCompletedDownload(NodeDependency dep, qint64 job_
|
||||
{
|
||||
SetWorkerBusyState(static_cast<RenderWorker*>(sender()), false);
|
||||
|
||||
SetFrameHash(dep, hash, job_time);
|
||||
if (SetFrameHash(dep, hash, job_time)) {
|
||||
QList<rational> hashes_with_time = frame_cache()->FramesWithHash(hash);
|
||||
|
||||
foreach (const rational& t, hashes_with_time) {
|
||||
emit CachedTimeReady(t, job_time);
|
||||
}
|
||||
}
|
||||
|
||||
// Queue up a new frame for this worker
|
||||
CacheNext();
|
||||
@@ -269,9 +282,8 @@ void VideoRenderBackend::ThreadSkippedFrame(NodeDependency dep, qint64 job_time,
|
||||
SetWorkerBusyState(static_cast<RenderWorker*>(sender()), false);
|
||||
|
||||
if (SetFrameHash(dep, hash, job_time)
|
||||
&& last_time_requested_ == dep.in()
|
||||
&& frame_cache_.HasHash(hash)) {
|
||||
emit CachedTimeReady(dep.in());
|
||||
emit CachedTimeReady(dep.in(), job_time);
|
||||
}
|
||||
|
||||
// Queue up a new frame for this worker
|
||||
@@ -282,9 +294,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_) {
|
||||
emit CachedTimeReady(dep.in());
|
||||
if (SetFrameHash(dep, hash, job_time)) {
|
||||
emit CachedTimeReady(dep.in(), job_time);
|
||||
}
|
||||
|
||||
// Queue up a new frame for this worker
|
||||
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
|
||||
void SetExportMode(bool enabled);
|
||||
|
||||
bool IsRendered(const rational& time) const;
|
||||
|
||||
public slots:
|
||||
virtual void InvalidateCache(const rational &start_range, const rational &end_range) override;
|
||||
|
||||
@@ -97,13 +99,13 @@ protected:
|
||||
|
||||
virtual void ConnectWorkerToThis(RenderWorker* processor) override;
|
||||
|
||||
virtual void EmitCachedFrameReady(const QList<rational> ×, const QVariant& value) = 0;
|
||||
virtual void EmitCachedFrameReady(const QList<rational> ×, const QVariant& value, qint64 job_time) = 0;
|
||||
|
||||
bool export_mode_;
|
||||
|
||||
signals:
|
||||
void CachedFrameReady(const rational& time, QVariant value);
|
||||
void CachedTimeReady(const rational& time);
|
||||
void CachedFrameReady(const rational& time, QVariant value, qint64 job_time);
|
||||
void CachedTimeReady(const rational& time, qint64 job_time);
|
||||
|
||||
private:
|
||||
bool TimeIsQueued(const TimeRange &time) const;
|
||||
|
||||
@@ -81,6 +81,21 @@ void VideoRenderFrameCache::RemoveHashFromCurrentlyCaching(const QByteArray &has
|
||||
currently_caching_lock_.unlock();
|
||||
}
|
||||
|
||||
QList<rational> VideoRenderFrameCache::FramesWithHash(const QByteArray &hash)
|
||||
{
|
||||
QList<rational> times;
|
||||
|
||||
QMap<rational, QByteArray>::const_iterator iterator;
|
||||
|
||||
for (iterator=time_hash_map_.begin();iterator!=time_hash_map_.end();iterator++) {
|
||||
if (iterator.value() == hash) {
|
||||
times.append(iterator.key());
|
||||
}
|
||||
}
|
||||
|
||||
return times;
|
||||
}
|
||||
|
||||
QString VideoRenderFrameCache::CachePathName(const QByteArray &hash) const
|
||||
{
|
||||
QDir this_cache_dir = QDir(GetMediaCacheLocation()).filePath(cache_id_);
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
|
||||
void RemoveHashFromCurrentlyCaching(const QByteArray& hash);
|
||||
|
||||
QList<rational> FramesWithHash(const QByteArray& hash);
|
||||
|
||||
private:
|
||||
QMap<rational, QByteArray> time_hash_map_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user