diff --git a/gpu/src/device.zig b/gpu/src/device.zig index b64eb3fc..ce270d03 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -194,10 +194,16 @@ pub const Device = opaque { // TODO: presumably callback should be nullable for unsetting pub inline fn setUncapturedErrorCallback( device: *Device, - callback: ErrorCallback, - userdata: ?*anyopaque, + comptime Context: type, + comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: Context) callconv(.Inline) void, + context: Context, ) void { - Impl.deviceSetUncapturedErrorCallback(device, callback, userdata); + const Helper = struct { + pub fn callback(typ: ErrorType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void { + callback(typ, message, if (Context == void) {} orelse @ptrCast(Context, userdata)); + } + }; + Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null orelse context); } pub inline fn tick(device: *Device) void {