From 62f505c83826f24997bd84e28137e78ca8e72633 Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Tue, 24 Mar 2026 20:57:10 +0900 Subject: [PATCH] fix(renderer): align LightsUniform to match WGSL vec3 padding (1056 bytes) WGSL vec3 requires 16-byte alignment, causing the shader to expect 1056 bytes while Rust struct was 1040. Added padding fields to match. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/voltex_renderer/src/light.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/voltex_renderer/src/light.rs b/crates/voltex_renderer/src/light.rs index 35fb4dc..d1fd11f 100644 --- a/crates/voltex_renderer/src/light.rs +++ b/crates/voltex_renderer/src/light.rs @@ -117,9 +117,11 @@ impl LightData { #[repr(C)] #[derive(Copy, Clone, Debug, Pod, Zeroable)] pub struct LightsUniform { - pub lights: [LightData; MAX_LIGHTS], - pub count: u32, - pub ambient_color: [f32; 3], + pub lights: [LightData; MAX_LIGHTS], // 1024 bytes + pub count: u32, // 4 bytes + pub _pad_count: [f32; 3], // 12 bytes (align ambient_color to 16-byte for WGSL vec3) + pub ambient_color: [f32; 3], // 12 bytes at offset 1040 + pub _pad_end: f32, // 4 bytes → total 1056 (matches WGSL) } impl LightsUniform { @@ -127,7 +129,9 @@ impl LightsUniform { Self { lights: [LightData::zeroed(); MAX_LIGHTS], count: 0, + _pad_count: [0.0; 3], ambient_color: [0.03, 0.03, 0.03], + _pad_end: 0.0, } }