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:
@@ -117,9 +117,11 @@ impl LightData {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
|
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
|
||||||
pub struct LightsUniform {
|
pub struct LightsUniform {
|
||||||
pub lights: [LightData; MAX_LIGHTS],
|
pub lights: [LightData; MAX_LIGHTS], // 1024 bytes
|
||||||
pub count: u32,
|
pub count: u32, // 4 bytes
|
||||||
pub ambient_color: [f32; 3],
|
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 {
|
impl LightsUniform {
|
||||||
@@ -127,7 +129,9 @@ impl LightsUniform {
|
|||||||
Self {
|
Self {
|
||||||
lights: [LightData::zeroed(); MAX_LIGHTS],
|
lights: [LightData::zeroed(); MAX_LIGHTS],
|
||||||
count: 0,
|
count: 0,
|
||||||
|
_pad_count: [0.0; 3],
|
||||||
ambient_color: [0.03, 0.03, 0.03],
|
ambient_color: [0.03, 0.03, 0.03],
|
||||||
|
_pad_end: 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user