summaryrefslogtreecommitdiff
path: root/src/gpu/effects/cnn_effect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/effects/cnn_effect.cc')
-rw-r--r--src/gpu/effects/cnn_effect.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gpu/effects/cnn_effect.cc b/src/gpu/effects/cnn_effect.cc
new file mode 100644
index 0000000..25db0c2
--- /dev/null
+++ b/src/gpu/effects/cnn_effect.cc
@@ -0,0 +1,36 @@
+// CNN post-processing effect implementation
+// Neural network-based stylization with modular WGSL
+
+#include "gpu/effects/cnn_effect.h"
+#include "gpu/effects/post_process_helper.h"
+#include "gpu/effects/shaders.h"
+
+CNNEffect::CNNEffect(const GpuContext& ctx, int num_layers)
+ : PostProcessEffect(ctx), num_layers_(num_layers), input_view_(nullptr),
+ bind_group_(nullptr) {
+ pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format,
+ cnn_layer_shader_wgsl);
+}
+
+void CNNEffect::init(MainSequence* demo) {
+ PostProcessEffect::init(demo);
+ params_buffer_.init(ctx_.device);
+
+ CNNLayerParams params = {0, 1, {0.0f, 0.0f}};
+ params_buffer_.update(ctx_.queue, params);
+}
+
+void CNNEffect::render(WGPURenderPassEncoder pass, float time, float beat,
+ float intensity, float aspect_ratio) {
+ if (!bind_group_) return;
+
+ wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
+ wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
+ wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
+}
+
+void CNNEffect::update_bind_group(WGPUTextureView input_view) {
+ input_view_ = input_view;
+ pp_update_bind_group(ctx_.device, pipeline_, &bind_group_,
+ input_view_, uniforms_.get(), params_buffer_.get());
+}