summaryrefslogtreecommitdiff
path: root/cnn_v3/src/gbuffer_effect.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-23 07:31:14 +0100
committerskal <pascal.massimino@gmail.com>2026-03-23 07:31:14 +0100
commit1e3813355e37f903314ec2069ff788c6f69becfd (patch)
treecb9ace6456a40eabb4ab0478f912c1adadffb6d1 /cnn_v3/src/gbuffer_effect.h
parent13cf1438caa56b34529d4031ddf73d38286b70e5 (diff)
feat(cnn_v3): GBufferEffect temporal feedback via post_render()
- Add Effect::post_render() virtual hook, called after all effects in the sequence have rendered each frame. Default is no-op. - Sequence::render_effects() runs a second pass invoking post_render() on all DAG nodes after the render pass completes. - GBufferEffect: declare internal node_prev_tex_ (U8X4_NORM) for persistent prev-frame CNN output. post_render() copies cnn_output_node_ → node_prev_tex_ via CopyTextureToTexture. render() binds node_prev_tex_ as prev_cnn (binding 6) — zero on frame 0 (matches training convention). - Expose set_cnn_output_node(name) API; call once at setup. - Drop brittle ping-pong / input_nodes_[0] fallback. - Update doc/SEQUENCE.md: post_render() semantics, frame execution order, temporal feedback canonical pattern, node types table with G-buffer types. - Update cnn_v3/docs/HOWTO.md: temporal feedback wiring section. 36/36 tests passing. handoff(Gemini): prev.rgb temporal feedback now correct and generic. Set set_cnn_output_node("sink") (or CNN output node name) once at setup.
Diffstat (limited to 'cnn_v3/src/gbuffer_effect.h')
-rw-r--r--cnn_v3/src/gbuffer_effect.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/cnn_v3/src/gbuffer_effect.h b/cnn_v3/src/gbuffer_effect.h
index 13d394d..8e777f8 100644
--- a/cnn_v3/src/gbuffer_effect.h
+++ b/cnn_v3/src/gbuffer_effect.h
@@ -46,6 +46,9 @@ class GBufferEffect : public Effect {
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
+ // Copies cnn_output_node_ → node_prev_tex_ after all effects have rendered.
+ void post_render(WGPUCommandEncoder encoder, NodeRegistry& nodes) override;
+
// Populate the internal scene with ~20 rotating cubes and a few pumping
// spheres. Must be called once before the first render().
void set_scene();
@@ -68,6 +71,16 @@ class GBufferEffect : public Effect {
std::string node_depth_;
std::string node_shadow_;
std::string node_transp_;
+ std::string node_prev_tex_; // persistent prev-frame CNN output (rgba8unorm)
+
+ // Name of the CNN effect's output node; set by caller before first render.
+ // When non-empty, the CNN output is copied into node_prev_tex_ each frame.
+ std::string cnn_output_node_;
+
+ public:
+ void set_cnn_output_node(const std::string& name) { cnn_output_node_ = name; }
+
+ private:
// Owned scene and camera — populated by set_scene()
Scene scene_;