summaryrefslogtreecommitdiff
path: root/src/test_demo.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-12 00:40:53 +0100
committerskal <pascal.massimino@gmail.com>2026-02-12 00:40:53 +0100
commit05fdd78a78b83a322abc1b507325644662f3a9c1 (patch)
tree5568a45c7dade1076eeb9b42b97e1d8341050976 /src/test_demo.cc
parente16e9dd41b7487753889fb9c86b5c4cbe3eaf3fd (diff)
refactor: use CommonUniforms from common_uniforms.wgsl in test_demo
Instead of duplicating the uniform structure definition, PeakMeterEffect now uses ShaderComposer to include the common_uniforms snippet, ensuring the struct definition always matches the canonical version. Changes: - Added shader_composer.h include - Use ShaderComposer::Get().Compose() to prepend common_uniforms - Changed 'Uniforms' → 'CommonUniforms' in shader - Removed duplicate struct definition This ensures consistency across all shaders and eliminates potential drift between duplicate definitions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/test_demo.cc')
-rw-r--r--src/test_demo.cc24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/test_demo.cc b/src/test_demo.cc
index 595ca6a..b564b9b 100644
--- a/src/test_demo.cc
+++ b/src/test_demo.cc
@@ -21,33 +21,25 @@ extern void LoadTimeline(MainSequence& main_seq, const GpuContext& ctx);
// Inline peak meter effect for debugging audio-visual sync
#include "gpu/effects/post_process_helper.h"
+#include "gpu/effects/shader_composer.h"
+
class PeakMeterEffect : public PostProcessEffect {
public:
PeakMeterEffect(const GpuContext& ctx) : PostProcessEffect(ctx) {
- // Use standard post-process binding macros
- const char* shader_code = R"(
+ // Use ShaderComposer to include CommonUniforms from common_uniforms.wgsl
+ const char* shader_main = R"(
struct VertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv: vec2<f32>,
};
- struct Uniforms {
- resolution: vec2<f32>,
- aspect_ratio: f32,
- time: f32,
- beat_time: f32,
- beat_phase: f32,
- audio_intensity: f32,
- _pad: f32,
- };
-
struct EffectParams {
unused: f32,
};
@group(0) @binding(0) var inputSampler: sampler;
@group(0) @binding(1) var inputTexture: texture_2d<f32>;
- @group(0) @binding(2) var<uniform> uniforms: Uniforms;
+ @group(0) @binding(2) var<uniform> uniforms: CommonUniforms;
@group(0) @binding(3) var<uniform> params: EffectParams;
@vertex
@@ -86,8 +78,12 @@ class PeakMeterEffect : public PostProcessEffect {
}
)";
+ // Compose shader with common_uniforms to get CommonUniforms definition
+ std::string shader_code = ShaderComposer::Get().Compose(
+ {"common_uniforms"}, shader_main);
+
pipeline_ =
- create_post_process_pipeline(ctx_.device, ctx_.format, shader_code);
+ create_post_process_pipeline(ctx_.device, ctx_.format, shader_code.c_str());
}
void update_bind_group(WGPUTextureView input_view) {