From ced248b0a8973db6d11b79e8290e2f5bb17ffcaa Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 16:48:02 +0100 Subject: CNN v2: Add mip-level support to runtime effect Binary format v2 includes mip_level in header (20 bytes, was 16). Effect reads mip_level and passes to static features shader via uniform. Shader samples from correct mip texture based on mip_level. Changes: - export_cnn_v2_weights.py: Header v2 with mip_level field - cnn_v2_effect.h: Add StaticFeatureParams, mip_level member, params buffer - cnn_v2_effect.cc: Read mip_level from weights, create/bind params buffer, update per-frame - cnn_v2_static.wgsl: Accept params uniform, sample from selected mip level Binary format v2: - Header: 20 bytes (magic, version=2, num_layers, total_weights, mip_level) - Backward compatible: v1 weights load with mip_level=0 Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/effects/cnn_v2_effect.h | 7 +++++++ 1 file changed, 7 insertions(+) (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 28aec8c..47dedf5 100644 --- a/src/gpu/effects/cnn_v2_effect.h +++ b/src/gpu/effects/cnn_v2_effect.h @@ -47,6 +47,11 @@ private: float blend_amount; }; + struct StaticFeatureParams { + uint32_t mip_level; + uint32_t padding[3]; + }; + void create_textures(); void create_pipelines(); void load_weights(); @@ -55,6 +60,7 @@ private: // Static features compute WGPUComputePipeline static_pipeline_; WGPUBindGroup static_bind_group_; + WGPUBuffer static_params_buffer_; WGPUTexture static_features_tex_; WGPUTextureView static_features_view_; @@ -75,5 +81,6 @@ private: float blend_amount_ = 1.0f; bool beat_modulated_ = false; float beat_scale_ = 1.0f; + uint32_t mip_level_ = 0; bool initialized_; }; -- cgit v1.2.3