gpu: make Device.setLoggingCallback friendlier
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
6f2f7056b7
commit
29cd383f0e
6 changed files with 22 additions and 15 deletions
|
|
@ -88,11 +88,11 @@ pub const Adapter = opaque {
|
||||||
status,
|
status,
|
||||||
device,
|
device,
|
||||||
message,
|
message,
|
||||||
if (Context == void) {} orelse @ptrCast(Context, userdata),
|
if (Context == void) {} else @ptrCast(Context, userdata),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.adapterRequestDevice(adapter, descriptor, Helper.callback, if (Context == void) null orelse context);
|
Impl.adapterRequestDevice(adapter, descriptor, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn reference(adapter: *Adapter) void {
|
pub inline fn reference(adapter: *Adapter) void {
|
||||||
|
|
|
||||||
|
|
@ -100,10 +100,10 @@ pub const Buffer = opaque {
|
||||||
) void {
|
) void {
|
||||||
const Helper = struct {
|
const Helper = struct {
|
||||||
pub fn callback(status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void {
|
pub fn callback(status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||||
callback(status, if (Context == void) {} orelse @ptrCast(Context, userdata));
|
callback(status, if (Context == void) {} else @ptrCast(Context, userdata));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.bufferMapAsync(buffer, mode, offset, size, Helper.callback, if (Context == void) null orelse context);
|
Impl.bufferMapAsync(buffer, mode, offset, size, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setLabel(buffer: *Buffer, label: [*:0]const u8) void {
|
pub inline fn setLabel(buffer: *Buffer, label: [*:0]const u8) void {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ const RequiredLimits = @import("types.zig").RequiredLimits;
|
||||||
const SupportedLimits = @import("types.zig").SupportedLimits;
|
const SupportedLimits = @import("types.zig").SupportedLimits;
|
||||||
const ErrorType = @import("types.zig").ErrorType;
|
const ErrorType = @import("types.zig").ErrorType;
|
||||||
const ErrorFilter = @import("types.zig").ErrorFilter;
|
const ErrorFilter = @import("types.zig").ErrorFilter;
|
||||||
|
const LoggingType = @import("types.zig").LoggingType;
|
||||||
const LoggingCallback = @import("callbacks.zig").LoggingCallback;
|
const LoggingCallback = @import("callbacks.zig").LoggingCallback;
|
||||||
const ErrorCallback = @import("callbacks.zig").ErrorCallback;
|
const ErrorCallback = @import("callbacks.zig").ErrorCallback;
|
||||||
const CreateComputePipelineAsyncCallback = @import("callbacks.zig").CreateComputePipelineAsyncCallback;
|
const CreateComputePipelineAsyncCallback = @import("callbacks.zig").CreateComputePipelineAsyncCallback;
|
||||||
|
|
@ -185,10 +186,16 @@ pub const Device = opaque {
|
||||||
// TODO: presumably callback should be nullable for unsetting
|
// TODO: presumably callback should be nullable for unsetting
|
||||||
pub inline fn setLoggingCallback(
|
pub inline fn setLoggingCallback(
|
||||||
device: *Device,
|
device: *Device,
|
||||||
callback: LoggingCallback,
|
comptime Context: type,
|
||||||
userdata: ?*anyopaque,
|
comptime callback: fn (typ: LoggingType, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||||
|
context: Context,
|
||||||
) void {
|
) void {
|
||||||
Impl.deviceSetLoggingCallback(device, callback, userdata);
|
const Helper = struct {
|
||||||
|
pub fn callback(typ: LoggingType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void {
|
||||||
|
callback(typ, message, if (Context == void) {} else @ptrCast(Context, userdata));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Impl.deviceSetLoggingCallback(device, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: presumably callback should be nullable for unsetting
|
// TODO: presumably callback should be nullable for unsetting
|
||||||
|
|
@ -200,10 +207,10 @@ pub const Device = opaque {
|
||||||
) void {
|
) void {
|
||||||
const Helper = struct {
|
const Helper = struct {
|
||||||
pub fn callback(typ: ErrorType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void {
|
pub fn callback(typ: ErrorType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void {
|
||||||
callback(typ, message, if (Context == void) {} orelse @ptrCast(Context, userdata));
|
callback(typ, message, if (Context == void) {} else @ptrCast(Context, userdata));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null orelse context);
|
Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn tick(device: *Device) void {
|
pub inline fn tick(device: *Device) void {
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ pub const Instance = opaque {
|
||||||
status,
|
status,
|
||||||
adapter,
|
adapter,
|
||||||
message,
|
message,
|
||||||
if (Context == void) {} orelse @ptrCast(Context, userdata),
|
if (Context == void) {} else @ptrCast(Context, userdata),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.instanceRequestAdapter(instance, options, Helper.callback, if (Context == void) null orelse context);
|
Impl.instanceRequestAdapter(instance, options, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn reference(instance: *Instance) void {
|
pub inline fn reference(instance: *Instance) void {
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ pub const Queue = opaque {
|
||||||
) void {
|
) void {
|
||||||
const Helper = struct {
|
const Helper = struct {
|
||||||
pub fn callback(status: WorkDoneStatus, userdata: ?*anyopaque) callconv(.C) void {
|
pub fn callback(status: WorkDoneStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||||
callback(status, if (Context == void) {} orelse @ptrCast(Context, userdata));
|
callback(status, if (Context == void) {} else @ptrCast(Context, userdata));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.queueOnSubmittedWorkDone(queue, signal_value, Helper.callback, if (Context == void) null orelse context);
|
Impl.queueOnSubmittedWorkDone(queue, signal_value, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setLabel(queue: *Queue, label: [*:0]const u8) void {
|
pub inline fn setLabel(queue: *Queue, label: [*:0]const u8) void {
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ pub const ShaderModule = opaque {
|
||||||
callback(
|
callback(
|
||||||
status,
|
status,
|
||||||
compilation_info,
|
compilation_info,
|
||||||
if (Context == void) {} orelse @ptrCast(Context, userdata),
|
if (Context == void) {} else @ptrCast(Context, userdata),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.shaderModuleGetCompilationInfo(shader_module, Helper.callback, if (Context == void) null orelse context);
|
Impl.shaderModuleGetCompilationInfo(shader_module, Helper.callback, if (Context == void) null else context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setLabel(shader_module: *ShaderModule, label: [*:0]const u8) void {
|
pub inline fn setLabel(shader_module: *ShaderModule, label: [*:0]const u8) void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue