summaryrefslogtreecommitdiff
path: root/src/gpu/effects/cnn_v2_effect.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-12 15:10:17 +0100
committerskal <pascal.massimino@gmail.com>2026-02-12 15:10:17 +0100
commit8b30cadfc19647487986d14dba9ddba7908dd1d0 (patch)
treef865b42945f72bfc480e2c2a6849127bf56d1a59 /src/gpu/effects/cnn_v2_effect.h
parent1effb125973ac0948de3015be1d53ae72463858b (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effects/cnn_v2_effect.h')
-rw-r--r--src/gpu/effects/cnn_v2_effect.h16
1 files changed, 15 insertions, 1 deletions
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 <vector>
+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<WGPUBuffer> layer_params_buffers_; // Uniform buffers (one per layer)
std::vector<LayerInfo> layer_info_; // Layer metadata
std::vector<WGPUBindGroup> layer_bind_groups_; // Per-layer bind groups
std::vector<WGPUTexture> 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_;
};