gpu: make Device.setDeviceLostCallback friendlier
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
dec1f08dd1
commit
0228b50dba
1 changed files with 9 additions and 3 deletions
|
|
@ -222,10 +222,16 @@ pub const Device = opaque {
|
|||
// TODO: presumably callback should be nullable for unsetting
|
||||
pub inline fn setDeviceLostCallback(
|
||||
device: *Device,
|
||||
callback: Device.LostCallback,
|
||||
userdata: ?*anyopaque,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (reason: LostReason, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
Impl.deviceSetDeviceLostCallback(device, callback, userdata);
|
||||
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, userdata));
|
||||
}
|
||||
};
|
||||
Impl.deviceSetDeviceLostCallback(device, Helper.callback, if (Context == void) null else context);
|
||||
}
|
||||
|
||||
pub inline fn setLabel(device: *Device, label: [*:0]const u8) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue