diff --git a/gpu/src/bind_group_layout.zig b/gpu/src/bind_group_layout.zig index 38a6341a..5cf0a91c 100644 --- a/gpu/src/bind_group_layout.zig +++ b/gpu/src/bind_group_layout.zig @@ -18,75 +18,75 @@ pub const BindGroupLayout = opaque { texture: Texture.BindingLayout = .{}, storage_texture: StorageTextureBindingLayout = .{}, - /// Helper to create a buffer BindGroupLayout.Entry. - pub fn buffer( - binding: u32, - visibility: ShaderStageFlags, - binding_type: Buffer.BindingType, - has_dynamic_offset: bool, - min_binding_size: u64, - ) Entry { - return .{ - .binding = binding, - .visibility = visibility, - .buffer = .{ - .type = binding_type, - .has_dynamic_offset = has_dynamic_offset, - .min_binding_size = min_binding_size, - }, - }; - } + /// Helper to create a buffer BindGroupLayout.Entry. + pub fn buffer( + binding: u32, + visibility: ShaderStageFlags, + binding_type: Buffer.BindingType, + has_dynamic_offset: bool, + min_binding_size: u64, + ) Entry { + return .{ + .binding = binding, + .visibility = visibility, + .buffer = .{ + .type = binding_type, + .has_dynamic_offset = has_dynamic_offset, + .min_binding_size = min_binding_size, + }, + }; + } - /// Helper to create a sampler BindGroupLayout.Entry. - pub fn sampler( - binding: u32, - visibility: ShaderStageFlags, - binding_type: Sampler.BindingType, - ) Entry { - return .{ - .binding = binding, - .visibility = visibility, - .sampler = .{ .type = binding_type }, - }; - } + /// Helper to create a sampler BindGroupLayout.Entry. + pub fn sampler( + binding: u32, + visibility: ShaderStageFlags, + binding_type: Sampler.BindingType, + ) Entry { + return .{ + .binding = binding, + .visibility = visibility, + .sampler = .{ .type = binding_type }, + }; + } - /// Helper to create a texture BindGroupLayout.Entry. - pub fn texture( - binding: u32, - visibility: ShaderStageFlags, - sample_type: Texture.SampleType, - view_dimension: TextureView.Dimension, - multisampled: bool, - ) Entry { - return .{ - .binding = binding, - .visibility = visibility, - .texture = .{ - .sample_type = sample_type, - .view_dimension = view_dimension, - .multisampled = multisampled, - }, - }; - } + /// Helper to create a texture BindGroupLayout.Entry. + pub fn texture( + binding: u32, + visibility: ShaderStageFlags, + sample_type: Texture.SampleType, + view_dimension: TextureView.Dimension, + multisampled: bool, + ) Entry { + return .{ + .binding = binding, + .visibility = visibility, + .texture = .{ + .sample_type = sample_type, + .view_dimension = view_dimension, + .multisampled = multisampled, + }, + }; + } - /// Helper to create a storage texture BindGroupLayout.Entry. - pub fn storageTexture( - binding: u32, - visibility: ShaderStageFlags, - access: StorageTextureAccess, - format: Texture.Format, - view_dimension: TextureView.Dimension, - ) Entry { - return .{ - .binding = binding, - .visibility = visibility, - .storage_texture = .{ - .access = access, - .format = format, - .view_dimension = view_dimension, - }, - }; - } + /// Helper to create a storage texture BindGroupLayout.Entry. + pub fn storageTexture( + binding: u32, + visibility: ShaderStageFlags, + access: StorageTextureAccess, + format: Texture.Format, + view_dimension: TextureView.Dimension, + ) Entry { + return .{ + .binding = binding, + .visibility = visibility, + .storage_texture = .{ + .access = access, + .format = format, + .view_dimension = view_dimension, + }, + }; + } }; pub const Descriptor = extern struct { diff --git a/gpu/src/buffer.zig b/gpu/src/buffer.zig index 0648177b..ef14dec0 100644 --- a/gpu/src/buffer.zig +++ b/gpu/src/buffer.zig @@ -122,7 +122,7 @@ pub const Buffer = opaque { const Context = @TypeOf(context); const Helper = struct { pub fn callback(status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void { - callback(status, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata))); + callback(status, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata))); } }; Impl.bufferMapAsync(buffer, mode, offset, size, Helper.callback, if (Context == void) null else context); diff --git a/gpu/src/device.zig b/gpu/src/device.zig index 5844df80..b49f3151 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -226,7 +226,7 @@ pub const Device = opaque { const Context = @TypeOf(context); const Helper = struct { pub fn callback(typ: ErrorType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void { - callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata))); + callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata))); } }; return Impl.devicePopErrorScope(device, Helper.callback, if (Context == void) null else context); @@ -245,7 +245,7 @@ pub const Device = opaque { const Context = @TypeOf(context); const Helper = struct { pub fn callback(reason: LostReason, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void { - callback(reason, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata))); + callback(reason, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata))); } }; Impl.deviceSetDeviceLostCallback(device, Helper.callback, if (Context == void) null else context); @@ -264,7 +264,7 @@ pub const Device = opaque { const Context = @TypeOf(context); const Helper = struct { pub fn callback(typ: LoggingType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void { - callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata))); + callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata))); } }; Impl.deviceSetLoggingCallback(device, Helper.callback, if (Context == void) null else context); @@ -279,7 +279,7 @@ pub const Device = opaque { const Context = @TypeOf(context); const Helper = struct { pub fn callback(typ: ErrorType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void { - callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata))); + callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata))); } }; Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null else context); diff --git a/gpu/src/queue.zig b/gpu/src/queue.zig index c2d1d483..0da6c7df 100644 --- a/gpu/src/queue.zig +++ b/gpu/src/queue.zig @@ -40,7 +40,7 @@ pub const Queue = opaque { const Context = @TypeOf(context); const Helper = struct { pub fn callback(status: WorkDoneStatus, userdata: ?*anyopaque) callconv(.C) void { - callback(status, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata))); + callback(status, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata))); } }; Impl.queueOnSubmittedWorkDone(queue, signal_value, Helper.callback, if (Context == void) null else context);