transform: hash the generated matrix

Making an exception for the transform node, we use a slightly
heavier hash to save more rendering time later.

Fixes #1560
Addresses some of #1360
This commit is contained in:
itsmattkc
2021-04-22 18:01:26 +10:00
parent 97b9bcc79f
commit 74ad4110be
23 changed files with 93 additions and 51 deletions
+10 -3
View File
@@ -22,6 +22,7 @@
#include <OpenEXR/ImfFloatAttribute.h>
#include <OpenEXR/ImfInputFile.h>
#include <OpenEXR/ImfIntAttribute.h>
#include <OpenEXR/ImfOutputFile.h>
#include <OpenEXR/ImfChannelList.h>
#include <QDir>
@@ -257,6 +258,8 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn)
int height = dw.max.y - dw.min.y + 1;
bool has_alpha = file.header().channels().findChannel("A");
int div = qMax(1, static_cast<const Imf::IntAttribute&>(file.header()["oliveDivider"]).value());
VideoParams::Format image_format;
if (pix_type == Imf::HALF) {
image_format = VideoParams::kFormatFloat16;
@@ -267,11 +270,13 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn)
int channel_count = has_alpha ? VideoParams::kRGBAChannelCount : VideoParams::kRGBChannelCount;
frame = Frame::Create();
frame->set_video_params(VideoParams(width,
height,
frame->set_video_params(VideoParams(width * div,
height * div,
image_format,
channel_count,
rational::fromDouble(file.header().pixelAspectRatio())));
rational::fromDouble(file.header().pixelAspectRatio()),
VideoParams::kInterlaceNone,
div));
frame->allocate();
@@ -445,6 +450,8 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, char *data, const V
header.insert("dwaCompressionLevel", Imf::FloatAttribute(200.0f));
header.pixelAspectRatio() = vparam.pixel_aspect_ratio().toDouble();
header.insert("oliveDivider", Imf::IntAttribute(vparam.divider()));
Imf::OutputFile out(filename.toUtf8(), header, 0);
int bpc = VideoParams::GetBytesPerChannel(vparam.format());
+1 -1
View File
@@ -93,7 +93,7 @@ QByteArray RenderManager::Hash(const Node *n, const QString& output, const Video
hasher.addData(reinterpret_cast<const char*>(&format), sizeof(VideoParams::Format));
if (n) {
n->Hash(output, hasher, time);
n->Hash(output, hasher, time, params);
}
return hasher.result();
-9
View File
@@ -556,15 +556,6 @@ QVariant RenderProcessor::GetCachedTexture(const QByteArray& hash)
FramePtr f = FrameHashCache::LoadCacheFrame(cache_dir, hash);
if (f) {
// The cached frame won't load with the correct divider by default, so we enforce it here
VideoParams p = f->video_params();
p.set_width(f->width() * video_params.divider());
p.set_height(f->height() * video_params.divider());
p.set_divider(video_params.divider());
f->set_video_params(p);
TexturePtr texture = render_ctx_->CreateTexture(f->video_params(), f->data(), f->linesize_pixels());
qDebug() << "Loaded mid-render frame from cache";
return QVariant::fromValue(texture);