fix(renderer): align LightsUniform to match WGSL vec3 padding (1056 bytes)

WGSL vec3<f32> 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) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 20:57:10 +09:00
parent fdfe4aaf5f
commit 62f505c838

View File

@@ -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,
}
}