gpu: make ctx parameters in callbacks always first

This matches the order of context parameters always being first in the Zig stdlib
with e.g. sorting and similar places where a context parameter exists.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-12 00:14:32 -07:00 committed by Stephen Gutekanst
parent 7f8c279cbc
commit 58600faa0d
7 changed files with 22 additions and 22 deletions

View file

@ -137,10 +137,10 @@ pub const Device = opaque {
descriptor: *const RenderPipeline.Descriptor,
context: anytype,
comptime callback: fn (
ctx: @TypeOf(context),
status: CreatePipelineAsyncStatus,
pipeline: *RenderPipeline,
message: [*:0]const u8,
ctx: @TypeOf(context),
) callconv(.Inline) void,
) void {
const Context = @TypeOf(context);
@ -152,10 +152,10 @@ pub const Device = opaque {
userdata: ?*anyopaque,
) callconv(.C) void {
callback(
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
status,
pipeline,
message,
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
);
}
};
@ -221,12 +221,12 @@ pub const Device = opaque {
pub inline fn popErrorScope(
device: *Device,
context: anytype,
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
comptime callback: fn (ctx: @TypeOf(context), typ: ErrorType, message: [*:0]const u8) 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, @alignCast(@alignOf(std.meta.Child(Context)), userdata)));
callback(if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata)), typ, message);
}
};
return Impl.devicePopErrorScope(device, Helper.callback, if (Context == void) null else context);
@ -240,12 +240,12 @@ pub const Device = opaque {
pub inline fn setDeviceLostCallback(
device: *Device,
context: anytype,
comptime callback: fn (reason: LostReason, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
comptime callback: fn (ctx: @TypeOf(context), reason: LostReason, message: [*:0]const u8) 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, @alignCast(@alignOf(std.meta.Child(Context)), userdata)));
callback(if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata)), reason, message);
}
};
Impl.deviceSetDeviceLostCallback(device, Helper.callback, if (Context == void) null else context);
@ -259,12 +259,12 @@ pub const Device = opaque {
pub inline fn setLoggingCallback(
device: *Device,
context: anytype,
comptime callback: fn (typ: LoggingType, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
comptime callback: fn (ctx: @TypeOf(context), typ: LoggingType, message: [*:0]const u8) 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, @alignCast(@alignOf(std.meta.Child(Context)), userdata)));
callback(if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata)), typ, message);
}
};
Impl.deviceSetLoggingCallback(device, Helper.callback, if (Context == void) null else context);
@ -274,12 +274,12 @@ pub const Device = opaque {
pub inline fn setUncapturedErrorCallback(
device: *Device,
context: anytype,
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: @TypeOf(context)) callconv(.Inline) void,
comptime callback: fn (ctx: @TypeOf(context), typ: ErrorType, message: [*:0]const u8) 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, @alignCast(@alignOf(std.meta.Child(Context)), userdata)));
callback(if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(std.meta.Child(Context)), userdata)), typ, message);
}
};
Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null else context);