gpu: make Device.setUncapturedErrorCallback friendlier

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-31 11:03:48 -07:00 committed by Stephen Gutekanst
parent be402d4b6d
commit 6f2f7056b7

View file

@ -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 {