gpu: make Device.popErrorScope friendlier

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-31 13:43:17 -07:00 committed by Stephen Gutekanst
parent 2e611565b4
commit dec1f08dd1

View file

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