From 8b30cadfc19647487986d14dba9ddba7908dd1d0 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 12 Feb 2026 15:10:17 +0100 Subject: test_demo: Add beat-synchronized CNN post-processing with version selection - Add --cnn-version <1|2> flag to select between CNN v1 and v2 - Implement beat_phase modulation for dynamic blend in both CNN effects - Fix CNN v2 per-layer uniform buffer sharing (each layer needs own buffer) - Fix CNN v2 y-axis orientation to match render pass convention - Add Scene1Effect as base visual layer to test_demo timeline - Reorganize CNN v2 shaders into cnn_v2/ subdirectory - Update asset paths and documentation for new shader organization Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/effects/cnn_v2_effect.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gpu/effects/cnn_v2_effect.h') diff --git a/src/gpu/effects/cnn_v2_effect.h b/src/gpu/effects/cnn_v2_effect.h index 6005cf5..4389e4f 100644 --- a/src/gpu/effects/cnn_v2_effect.h +++ b/src/gpu/effects/cnn_v2_effect.h @@ -5,9 +5,14 @@ #include "gpu/effect.h" #include +struct CNNv2EffectParams { + float blend_amount = 1.0f; +}; + class CNNv2Effect : public PostProcessEffect { public: explicit CNNv2Effect(const GpuContext& ctx); + explicit CNNv2Effect(const GpuContext& ctx, const CNNv2EffectParams& params); ~CNNv2Effect(); void init(MainSequence* demo) override; @@ -18,6 +23,11 @@ public: const CommonPostProcessUniforms& uniforms) override; void update_bind_group(WGPUTextureView input_view) override; + void set_beat_modulation(bool enabled, float scale = 1.0f) { + beat_modulated_ = enabled; + beat_scale_ = scale; + } + private: struct LayerInfo { uint32_t kernel_size; @@ -33,6 +43,7 @@ private: uint32_t out_channels; uint32_t weight_offset; uint32_t is_output_layer; + float blend_amount; }; void create_textures(); @@ -49,7 +60,7 @@ private: // CNN layers (storage buffer architecture) WGPUComputePipeline layer_pipeline_; // Single pipeline for all layers WGPUBuffer weights_buffer_; // Storage buffer for weights - WGPUBuffer layer_params_buffer_; // Uniform buffer for per-layer params + std::vector layer_params_buffers_; // Uniform buffers (one per layer) std::vector layer_info_; // Layer metadata std::vector layer_bind_groups_; // Per-layer bind groups std::vector layer_textures_; // Ping-pong buffers @@ -60,5 +71,8 @@ private: WGPUTextureView input_mip_view_[3]; WGPUTextureView current_input_view_; + float blend_amount_ = 1.0f; + bool beat_modulated_ = false; + float beat_scale_ = 1.0f; bool initialized_; }; -- cgit v1.2.3