examples: make sure some structs has guaranteed in-memory layout

This commit is contained in:
Ali Chraghi 2022-10-08 18:49:21 +03:30 committed by Stephen Gutekanst
parent 4e47477e9a
commit 288299b88b
13 changed files with 14 additions and 14 deletions

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
col: @Vector(4, f32),
uv: @Vector(2, f32),

View file

@ -16,7 +16,7 @@ pub const module = ecs.Module(.{
.update = update,
});
pub const Vec2 = struct { x: f32, y: f32 };
pub const Vec2 = extern struct { x: f32, y: f32 };
fn update(msg: Message) void {
switch (msg) {

View file

@ -10,4 +10,4 @@ pub const module = ecs.Module(.{
// with renderer components like `.geometry` and render them for example!
});
pub const Vec3 = struct { x: f32, y: f32, z: f32 };
pub const Vec3 = extern struct { x: f32, y: f32, z: f32 };

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
col: @Vector(4, f32),
uv: @Vector(2, f32),

View file

@ -46,7 +46,7 @@ pub const Region = struct {
}
};
pub const UVData = struct {
pub const UVData = extern struct {
bottom_left: @Vector(2, f32),
width_and_height: @Vector(2, f32),
};

View file

@ -7,7 +7,7 @@ const UVData = @import("atlas.zig").UVData;
const Vec2 = @Vector(2, f32);
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
uv: Vec2,
};
@ -31,7 +31,7 @@ const GkurveType = enum(u32) {
filled = 2,
};
pub const FragUniform = struct {
pub const FragUniform = extern struct {
type: GkurveType = .filled,
// Padding for struct alignment to 16 bytes (minimum in WebGPU uniform).
padding: @Vector(3, f32) = undefined,

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
col: @Vector(4, f32),
uv: @Vector(2, f32),

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(3, f32),
normal: @Vector(3, f32),
uv: @Vector(2, f32),

View file

@ -16,7 +16,7 @@ const pixel_size = 8;
const UniformBufferObject = struct {
mat: zm.Mat,
};
const PostUniformBufferObject = struct {
const PostUniformBufferObject = extern struct {
width: u32,
height: u32,
pixel_size: u32 = pixel_size,

View file

@ -1,4 +1,4 @@
pub const Quad = struct {
pub const Quad = extern struct {
pos: @Vector(3, f32),
uv: @Vector(2, f32),
};

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
col: @Vector(4, f32),
uv: @Vector(2, f32),

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
col: @Vector(4, f32),
uv: @Vector(2, f32),

View file

@ -1,4 +1,4 @@
pub const Vertex = struct {
pub const Vertex = extern struct {
pos: @Vector(4, f32),
col: @Vector(4, f32),
uv: @Vector(2, f32),