summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-09 11:41:59 +0100
committerskal <pascal.massimino@gmail.com>2026-02-09 11:41:59 +0100
commita07735cf6036669a9b4bebb38cc51d2ba92fff66 (patch)
treea5ce62676ed53989d558f0257ce21947cf479470 /src
parentd48aac685ecd47a80e0752011a1d78bc86094947 (diff)
Fix test_demo build failure after Effect refactor
Updated PeakMeterEffect in test_demo.cc to use the new Effect::uniforms_ (UniformBuffer<CommonPostProcessUniforms>) instead of manual buffer management. Mapped peak_value to audio_intensity.
Diffstat (limited to 'src')
-rw-r--r--src/test_demo.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/test_demo.cc b/src/test_demo.cc
index a438bbc..d116f85 100644
--- a/src/test_demo.cc
+++ b/src/test_demo.cc
@@ -32,10 +32,13 @@ class PeakMeterEffect : public PostProcessEffect {
};
struct Uniforms {
- peak_value: f32,
+ resolution: vec2<f32>,
_pad0: f32,
_pad1: f32,
- _pad2: f32,
+ aspect_ratio: f32,
+ time: f32,
+ beat: f32,
+ audio_intensity: f32,
};
@group(0) @binding(0) var inputSampler: sampler;
@@ -69,7 +72,7 @@ class PeakMeterEffect : public PostProcessEffect {
// Optimization: Return bar color early (avoids texture sampling for ~5% of pixels)
if (in_bar_y && in_bar_x) {
let uv_x = (input.uv.x - bar_x_min) / (bar_x_max - bar_x_min);
- let factor = step(uv_x, uniforms.peak_value);
+ let factor = step(uv_x, uniforms.audio_intensity);
return mix(vec4<f32>(0.0, 0.0, 0.0, 1.0), vec4<f32>(1.0, 0.0, 0.0,1.0), factor);
}
@@ -80,24 +83,26 @@ class PeakMeterEffect : public PostProcessEffect {
pipeline_ =
create_post_process_pipeline(ctx_.device, ctx_.format, shader_code);
- uniforms_ = gpu_create_buffer(
- ctx_.device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
}
void update_bind_group(WGPUTextureView input_view) {
pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view,
- uniforms_, {});
+ uniforms_.get(), {});
}
void render(WGPURenderPassEncoder pass, float time, float beat,
float peak_value, float aspect_ratio) {
(void)time;
(void)beat;
- (void)aspect_ratio;
- float uniforms[4] = {peak_value, 0.0f, 0.0f, 0.0f};
- wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms,
- sizeof(uniforms));
+ CommonPostProcessUniforms u = {
+ .resolution = {(float)width_, (float)height_},
+ .aspect_ratio = aspect_ratio,
+ .time = time,
+ .beat = beat,
+ .audio_intensity = peak_value,
+ };
+ uniforms_.update(ctx_.queue, u);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);