diff --git a/gpu/src/device.zig b/gpu/src/device.zig index b73add5d..1565e646 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -203,10 +203,16 @@ pub const Device = opaque { pub inline fn popErrorScope( 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, ) bool { - return Impl.devicePopErrorScope(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) {} else @ptrCast(Context, userdata)); + } + }; + return Impl.devicePopErrorScope(device, Helper.callback, if (Context == void) null else context); } pub inline fn pushErrorScope(device: *Device, filter: ErrorFilter) void {