gpu: simplify callback context types
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
48c8964679
commit
4ed932be0f
6 changed files with 33 additions and 33 deletions
|
|
@ -73,15 +73,15 @@ pub const Adapter = opaque {
|
|||
pub inline fn requestDevice(
|
||||
adapter: *Adapter,
|
||||
descriptor: ?*const Device.Descriptor,
|
||||
comptime Context: type,
|
||||
context: anytype,
|
||||
comptime callback: fn (
|
||||
status: RequestDeviceStatus,
|
||||
device: *Device,
|
||||
message: ?[*:0]const u8,
|
||||
ctx: Context,
|
||||
ctx: @TypeOf(context),
|
||||
) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(status: RequestDeviceStatus, device: *Device, message: ?[*:0]const u8, userdata: ?*anyopaque) callconv(.C) void {
|
||||
callback(
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ pub const Buffer = opaque {
|
|||
mode: MapModeFlags,
|
||||
offset: usize,
|
||||
size: usize,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (status: MapAsyncStatus, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
context: anytype,
|
||||
comptime callback: fn (status: MapAsyncStatus, ctx: @TypeOf(context)) callconv(.Inline) void,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||
callback(status, if (Context == void) {} else @ptrCast(Context, userdata));
|
||||
|
|
|
|||
|
|
@ -72,15 +72,15 @@ pub const Device = opaque {
|
|||
pub inline fn createComputePipelineAsync(
|
||||
device: *Device,
|
||||
descriptor: *const ComputePipeline.Descriptor,
|
||||
comptime Context: type,
|
||||
context: anytype,
|
||||
comptime callback: fn (
|
||||
status: CreatePipelineAsyncStatus,
|
||||
compute_pipeline: *ComputePipeline,
|
||||
message: [*:0]const u8,
|
||||
ctx: Context,
|
||||
ctx: @TypeOf(context),
|
||||
) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(
|
||||
status: CreatePipelineAsyncStatus,
|
||||
|
|
@ -130,15 +130,15 @@ pub const Device = opaque {
|
|||
pub inline fn createRenderPipelineAsync(
|
||||
device: *Device,
|
||||
descriptor: *const RenderPipeline.Descriptor,
|
||||
comptime Context: type,
|
||||
context: anytype,
|
||||
comptime callback: fn (
|
||||
status: CreatePipelineAsyncStatus,
|
||||
pipeline: *RenderPipeline,
|
||||
message: [*:0]const u8,
|
||||
ctx: Context,
|
||||
ctx: @TypeOf(context),
|
||||
) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(
|
||||
status: CreatePipelineAsyncStatus,
|
||||
|
|
@ -203,10 +203,10 @@ pub const Device = opaque {
|
|||
|
||||
pub inline fn popErrorScope(
|
||||
device: *Device,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
context: anytype,
|
||||
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
|
||||
) bool {
|
||||
const Context = @TypeOf(context);
|
||||
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));
|
||||
|
|
@ -222,10 +222,10 @@ pub const Device = opaque {
|
|||
// TODO: presumably callback should be nullable for unsetting
|
||||
pub inline fn setDeviceLostCallback(
|
||||
device: *Device,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (reason: LostReason, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
context: anytype,
|
||||
comptime callback: fn (reason: LostReason, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
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));
|
||||
|
|
@ -241,10 +241,10 @@ pub const Device = opaque {
|
|||
// TODO: presumably callback should be nullable for unsetting
|
||||
pub inline fn setLoggingCallback(
|
||||
device: *Device,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (typ: LoggingType, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
context: anytype,
|
||||
comptime callback: fn (typ: LoggingType, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
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));
|
||||
|
|
@ -256,10 +256,10 @@ pub const Device = opaque {
|
|||
// TODO: presumably callback should be nullable for unsetting
|
||||
pub inline fn setUncapturedErrorCallback(
|
||||
device: *Device,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
context: anytype,
|
||||
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ pub const Instance = opaque {
|
|||
pub inline fn requestAdapter(
|
||||
instance: *Instance,
|
||||
options: *const RequestAdapterOptions,
|
||||
comptime Context: type,
|
||||
context: anytype,
|
||||
comptime callback: fn (
|
||||
status: RequestAdapterStatus,
|
||||
adapter: *Adapter,
|
||||
message: ?[*:0]const u8,
|
||||
ctx: Context,
|
||||
ctx: @TypeOf(context),
|
||||
) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(
|
||||
status: RequestAdapterStatus,
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ pub const Queue = opaque {
|
|||
pub inline fn onSubmittedWorkDone(
|
||||
queue: *Queue,
|
||||
signal_value: u64,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (status: WorkDoneStatus, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
context: anytype,
|
||||
comptime callback: fn (status: WorkDoneStatus, ctx: @TypeOf(context)) callconv(.Inline) void,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(status: WorkDoneStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||
callback(status, if (Context == void) {} else @ptrCast(Context, userdata));
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ pub const ShaderModule = opaque {
|
|||
|
||||
pub inline fn getCompilationInfo(
|
||||
shader_module: *ShaderModule,
|
||||
comptime Context: type,
|
||||
context: anytype,
|
||||
comptime callback: fn (
|
||||
status: CompilationInfoRequestStatus,
|
||||
compilation_info: *const CompilationInfo,
|
||||
ctx: Context,
|
||||
ctx: @TypeOf(context),
|
||||
) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
const Context = @TypeOf(context);
|
||||
const Helper = struct {
|
||||
pub fn callback(
|
||||
status: CompilationInfoRequestStatus,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue