From fd19130b3360d17b44247ec26533b20e051b7f8c Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 11:17:53 +0100 Subject: feat: WGSL Uniform Buffer Validation & Consolidation (Task #75) - Added to validate WGSL/C++ struct alignment. - Integrated validation into . - Standardized uniform usage in , , , . - Renamed generic to specific names in WGSL and C++ to avoid collisions. - Added and updated . - handoff(Gemini): Completed Task #75. --- src/gpu/effects/theme_modulation_effect.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/gpu/effects/theme_modulation_effect.cc') diff --git a/src/gpu/effects/theme_modulation_effect.cc b/src/gpu/effects/theme_modulation_effect.cc index f9ae636..7c222aa 100644 --- a/src/gpu/effects/theme_modulation_effect.cc +++ b/src/gpu/effects/theme_modulation_effect.cc @@ -6,6 +6,12 @@ #include "gpu/effects/shaders.h" #include +struct ThemeModulationParams { + float theme_brightness; + float _pad[3]; +}; +static_assert(sizeof(ThemeModulationParams) == 16, "ThemeModulationParams must be 16 bytes for WGSL alignment"); + ThemeModulationEffect::ThemeModulationEffect(const GpuContext& ctx) : PostProcessEffect(ctx) { const char* shader_code = R"( @@ -24,7 +30,7 @@ ThemeModulationEffect::ThemeModulationEffect(const GpuContext& ctx) audio_intensity: f32, }; - struct EffectParams { + struct ThemeModulationParams { theme_brightness: f32, _pad0: f32, _pad1: f32, @@ -34,7 +40,7 @@ ThemeModulationEffect::ThemeModulationEffect(const GpuContext& ctx) @group(0) @binding(0) var inputSampler: sampler; @group(0) @binding(1) var inputTexture: texture_2d; @group(0) @binding(2) var uniforms: CommonUniforms; - @group(0) @binding(3) var params: EffectParams; + @group(0) @binding(3) var params: ThemeModulationParams; @vertex fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { @@ -97,8 +103,8 @@ void ThemeModulationEffect::render(WGPURenderPassEncoder pass, float time, bright_value + (dark_value - bright_value) * transition; // Update params buffer - float params[4] = {theme_brightness, 0.0f, 0.0f, 0.0f}; - wgpuQueueWriteBuffer(ctx_.queue, params_buffer_.buffer, 0, params, + ThemeModulationParams params = {theme_brightness, {0.0f, 0.0f, 0.0f}}; + wgpuQueueWriteBuffer(ctx_.queue, params_buffer_.buffer, 0, ¶ms, sizeof(params)); // Render -- cgit v1.2.3