From aa2050bf6e10af099257d38b20253254e443f1d9 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 2 Nov 2019 21:38:48 +0200
Subject: [PATCH] Allow application to a frameset

---
 applications/reconstruct/src/main.cpp |  6 ++++--
 components/operators/src/operator.cpp | 23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp
index 9b2eda9de..f981494cb 100644
--- a/applications/reconstruct/src/main.cpp
+++ b/applications/reconstruct/src/main.cpp
@@ -282,11 +282,13 @@ static void run(ftl::Configurable *root) {
 			UNIQUE_LOCK(scene_A.mtx, lk);
 
 			// Apply pre-filters to all frames
-			for (int i=0; i<scene_A.frames.size(); ++i) {
+			/*for (int i=0; i<scene_A.frames.size(); ++i) {
 				auto &f = scene_A.frames[i];
 				auto s = scene_A.sources[i];
 				prefilter->apply(f, f, s, 0);
-			}
+			}*/
+
+			prefilter->apply(scene_A, scene_A, 0);
 
 			// Send all frames to GPU, block until done?
 			//scene_A.upload(Channel::Colour + Channel::Depth);  // TODO: (Nick) Add scene stream.
diff --git a/components/operators/src/operator.cpp b/components/operators/src/operator.cpp
index c877977a9..91dada28b 100644
--- a/components/operators/src/operator.cpp
+++ b/components/operators/src/operator.cpp
@@ -38,6 +38,29 @@ Graph::~Graph() {
 
 }
 
+bool Graph::apply(FrameSet &in, FrameSet &out, cudaStream_t stream) {
+	if (!value("enabled", true)) return false;
+
+	if (in.frames.size() != out.frames.size()) return false;
+
+	for (auto &i : operators_) {
+		// Make sure there are enough instances
+		while (i.instances.size() < in.frames.size()) {
+			i.instances.push_back(i.maker->make());
+		}
+
+		for (int j=0; j<in.frames.size(); ++j) {
+			auto *instance = i.instances[j];
+
+			if (instance->enabled()) {
+				instance->apply(in.frames[j], out.frames[j], in.sources[j], stream);
+			}
+		}
+	}
+
+	return true;
+}
+
 bool Graph::apply(Frame &in, Frame &out, Source *s, cudaStream_t stream) {
 	if (!value("enabled", true)) return false;
 
-- 
GitLab