From 78cf48e022c6433a7bf44600e75f9dfb71d70e37 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 14 Oct 2022 11:20:43 -0700 Subject: [PATCH] examples: fix cubemap compilation self-hosted compiler picked up alignment issues better. fixes hexops/mach#578 Signed-off-by: Stephen Gutekanst --- examples/cubemap/main.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cubemap/main.zig b/examples/cubemap/main.zig index 8f883f23..6cc7cdec 100644 --- a/examples/cubemap/main.zig +++ b/examples/cubemap/main.zig @@ -175,7 +175,7 @@ pub fn init(app: *App, core: *mach.Core) !void { // Map a section of the staging buffer var staging_map = staging_buff[i].getMappedRange(u32, 0, @intCast(u64, images[i].width) * @intCast(u64, images[i].height)); // Copy the image data into the mapped buffer - std.mem.copy(u32, staging_map.?, @ptrCast([]u32, pixels)); + std.mem.copy(u32, staging_map.?, @ptrCast([]u32, @alignCast(@alignOf([]u32), pixels))); // And release the mapping staging_buff[i].unmap(); }, @@ -184,7 +184,7 @@ pub fn init(app: *App, core: *mach.Core) !void { // In this case, we have to convert the data to rgba32 first const data = try rgb24ToRgba32(core.allocator, pixels); defer data.deinit(core.allocator); - std.mem.copy(u32, staging_map.?, @ptrCast([]u32, data.rgba32)); + std.mem.copy(u32, staging_map.?, @ptrCast([]u32, @alignCast(@alignOf([]u32), data.rgba32))); staging_buff[i].unmap(); }, else => @panic("unsupported image color format"),