gpu: correct context pointer alignments

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-31 17:09:35 -07:00 committed by Stephen Gutekanst
parent 4ed932be0f
commit 8a0d47b94b
6 changed files with 11 additions and 11 deletions

View file

@ -88,7 +88,7 @@ pub const Adapter = opaque {
status,
device,
message,
if (Context == void) {} else @ptrCast(Context, userdata),
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
);
}
};

View file

@ -100,7 +100,7 @@ pub const Buffer = opaque {
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));
callback(status, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)));
}
};
Impl.bufferMapAsync(buffer, mode, offset, size, Helper.callback, if (Context == void) null else context);

View file

@ -92,7 +92,7 @@ pub const Device = opaque {
status,
compute_pipeline,
message,
if (Context == void) {} else @ptrCast(Context, userdata),
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
);
}
};
@ -150,7 +150,7 @@ pub const Device = opaque {
status,
pipeline,
message,
if (Context == void) {} else @ptrCast(Context, userdata),
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
);
}
};
@ -209,7 +209,7 @@ pub const Device = opaque {
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));
callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)));
}
};
return Impl.devicePopErrorScope(device, Helper.callback, if (Context == void) null else context);
@ -228,7 +228,7 @@ pub const Device = opaque {
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));
callback(reason, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)));
}
};
Impl.deviceSetDeviceLostCallback(device, Helper.callback, if (Context == void) null else context);
@ -247,7 +247,7 @@ pub const Device = opaque {
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));
callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)));
}
};
Impl.deviceSetLoggingCallback(device, Helper.callback, if (Context == void) null else context);
@ -262,7 +262,7 @@ pub const Device = opaque {
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));
callback(typ, message, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)));
}
};
Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null else context);

View file

@ -38,7 +38,7 @@ pub const Instance = opaque {
status,
adapter,
message,
if (Context == void) {} else @ptrCast(Context, userdata),
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
);
}
};

View file

@ -39,7 +39,7 @@ pub const Queue = opaque {
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));
callback(status, if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)));
}
};
Impl.queueOnSubmittedWorkDone(queue, signal_value, Helper.callback, if (Context == void) null else context);

View file

@ -40,7 +40,7 @@ pub const ShaderModule = opaque {
callback(
status,
compilation_info,
if (Context == void) {} else @ptrCast(Context, userdata),
if (Context == void) {} else @ptrCast(Context, @alignCast(@alignOf(Context), userdata)),
);
}
};