send list to EmitCachedFrameReady() rather than one rational at a time

Since EmitCachedFrameReady() makes a copy of the texture, we can economize a lot
by re-using the same copied texture for all the times rather than making a
separate copy for each time.
This commit is contained in:
itsmattkc
2019-12-27 05:17:18 +11:00
parent a4b3dc2ab4
commit 9272858de2
4 changed files with 17 additions and 10 deletions
+4 -2
View File
@@ -141,7 +141,7 @@ void OpenGLBackend::DecompileInternal()
shader_cache_.Clear();
}
void OpenGLBackend::EmitCachedFrameReady(const rational &time, const QVariant &value)
void OpenGLBackend::EmitCachedFrameReady(const QList<rational> &times, const QVariant &value)
{
OpenGLTextureCache::ReferencePtr ref = value.value<OpenGLTextureCache::ReferencePtr>();
OpenGLTexturePtr tex;
@@ -152,7 +152,9 @@ void OpenGLBackend::EmitCachedFrameReady(const rational &time, const QVariant &v
tex = nullptr;
}
emit CachedFrameReady(time, QVariant::fromValue(tex));
foreach (const rational& t, times) {
emit CachedFrameReady(t, QVariant::fromValue(tex));
}
}
OpenGLTexturePtr OpenGLBackend::CopyTexture(OpenGLTexturePtr input)
+1 -1
View File
@@ -28,7 +28,7 @@ protected:
virtual void DecompileInternal() override;
virtual void EmitCachedFrameReady(const rational& time, const QVariant& value) override;
virtual void EmitCachedFrameReady(const QList<rational> &times, const QVariant& value) override;
private:
OpenGLTexturePtr CopyTexture(OpenGLTexturePtr input);
+11 -6
View File
@@ -253,16 +253,21 @@ void VideoRenderBackend::ThreadCompletedFrame(NodeDependency path, QByteArray ha
QVariant texture = table.Get(NodeParam::kTexture);
// Check if this frame has changed once again, in which case we may not want to draw it (it'll look jittery to the user)
QList<rational> times_with_this_hash;
if (last_time_requested_ == path.in() || export_mode_) {
EmitCachedFrameReady(path.in(), texture);
times_with_this_hash.append(path.in());
}
if (export_mode_) {
QList<rational> times_with_this_hash = frame_cache()->DeferredMapsWithHash(hash);
foreach (const rational& t, times_with_this_hash) {
EmitCachedFrameReady(t, texture);
}
} else {
times_with_this_hash.append(frame_cache()->DeferredMapsWithHash(hash));
}
if (!times_with_this_hash.isEmpty()) {
EmitCachedFrameReady(times_with_this_hash, texture);
}
if (!export_mode_) {
if (texture.isNull()) {
// No frame received, we set hash to an empty
frame_cache()->RemoveHash(path.in(), hash);
+1 -1
View File
@@ -97,7 +97,7 @@ protected:
virtual void ConnectWorkerToThis(RenderWorker* processor) override;
virtual void EmitCachedFrameReady(const rational& time, const QVariant& value) = 0;
virtual void EmitCachedFrameReady(const QList<rational> &times, const QVariant& value) = 0;
bool export_mode_;