summaryrefslogtreecommitdiff
path: root/src/gpu/effects/fade_effect.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-09 10:34:01 +0100
committerskal <pascal.massimino@gmail.com>2026-02-09 10:34:01 +0100
commite50db1721f67a6c1b565b0ac151ba32fcae21cbf (patch)
tree306bf626fb0283e1c3b173eb6f3abf556679d1ec /src/gpu/effects/fade_effect.cc
parentdf39c7e3efa70376fac579b178c803eb319d517f (diff)
fix: Resolve WebGPU uniform buffer alignment issues (Task #74)
Fixed multiple WGSL/C++ struct alignment mismatches causing validation errors: Padding fixes: - fade_effect.cc: Changed EffectParams padding from vec3<f32> to _pad0/1/2 - theme_modulation_effect.cc: Same padding fix for EffectParams - Root cause: WGSL vec3<f32> has 16-byte alignment, creating 32-byte structs ODR violation fix: - demo_effects.h: Added includes for fade_effect.h, theme_modulation_effect.h - Removed incomplete forward declarations (88 bytes) conflicting with complete definitions (96 bytes), causing heap buffer overflow in make_shared Member shadowing cleanup: - Renamed Effect::uniforms_ shadowing members to descriptive names: - FadeEffect: uniforms_ -> common_uniforms_ - FlashEffect: uniforms_ -> flash_uniforms_ - ThemeModulationEffect: uniforms_ -> common_uniforms_ Results: - demo64k runs without crashes - 33/33 tests passing (100%) - Added Task #75: WGSL uniform validation tool handoff(Claude): Uniform buffer alignment debugged and fixed
Diffstat (limited to 'src/gpu/effects/fade_effect.cc')
-rw-r--r--src/gpu/effects/fade_effect.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gpu/effects/fade_effect.cc b/src/gpu/effects/fade_effect.cc
index c70177e..3efc583 100644
--- a/src/gpu/effects/fade_effect.cc
+++ b/src/gpu/effects/fade_effect.cc
@@ -24,7 +24,9 @@ FadeEffect::FadeEffect(const GpuContext& ctx) : PostProcessEffect(ctx) {
struct EffectParams {
fade_amount: f32,
- _pad: vec3<f32>,
+ _pad0: f32,
+ _pad1: f32,
+ _pad2: f32,
};
@group(0) @binding(0) var inputSampler: sampler;
@@ -55,14 +57,14 @@ FadeEffect::FadeEffect(const GpuContext& ctx) : PostProcessEffect(ctx) {
pipeline_ =
create_post_process_pipeline(ctx_.device, ctx_.format, shader_code);
- uniforms_.init(ctx_.device);
+ common_uniforms_.init(ctx_.device);
params_buffer_ = gpu_create_buffer(
ctx_.device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
}
void FadeEffect::update_bind_group(WGPUTextureView input_view) {
pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view,
- uniforms_.get(), params_buffer_);
+ common_uniforms_.get(), params_buffer_);
}
void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat,
@@ -74,7 +76,7 @@ void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat,
.beat = beat,
.audio_intensity = intensity,
};
- uniforms_.update(ctx_.queue, u);
+ common_uniforms_.update(ctx_.queue, u);
// Example fade pattern: fade in at start, fade out at end
// Customize this based on your needs