From eefe74fc062eba756b812b37afda51d65aad8c0f Mon Sep 17 00:00:00 2001 From: Julian Rachele Date: Tue, 13 Jun 2023 12:53:46 -0400 Subject: [PATCH] gfx2d: align Uniforms struct on 16 bytes (#805) --- src/gfx2d/Sprite2D.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gfx2d/Sprite2D.zig b/src/gfx2d/Sprite2D.zig index 980d8a92..7cf92110 100644 --- a/src/gfx2d/Sprite2D.zig +++ b/src/gfx2d/Sprite2D.zig @@ -44,12 +44,15 @@ pub const components = .{ .size = Vec2, }; -const Uniforms = packed struct { +const Uniforms = extern struct { + // WebGPU requires that the size of struct fields are multiples of 16 + // So we use align(16) and 'extern' to maintain field order + /// The view * orthographic projection matrix - view_projection: Mat4x4, + view_projection: Mat4x4 align(16), /// Total size of the sprite texture in pixels - texture_size: Vec2, + texture_size: Vec2 align(16), }; pub fn machSprite2DInit(adapter: anytype) !void {