From b40c44164646e853239d1b76fd8e4768eb21d9ac Mon Sep 17 00:00:00 2001 From: Dispersia Date: Wed, 19 May 2021 21:04:47 -0700 Subject: [PATCH] Add padding to quad to fix alignment issue --- wgpu/src/quad.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index 9b87ef81..b91e3e89 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -305,6 +305,9 @@ const MAX_INSTANCES: usize = 100_000; struct Uniforms { transform: [f32; 16], scale: f32, + // Uniforms must be aligned to their largest member, + // this uses a mat4x4 which aligns to 16, so align to that + _padding: [f32; 3], } impl Uniforms { @@ -312,6 +315,7 @@ impl Uniforms { Self { transform: *transformation.as_ref(), scale, + _padding: [0.0; 3] } } } @@ -321,6 +325,7 @@ impl Default for Uniforms { Self { transform: *Transformation::identity().as_ref(), scale: 1.0, + _padding: [0.0; 3] } } }