gpu: make Buffer.bufferMapAsync friendlier
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
13058274b0
commit
2b4ba59cc8
2 changed files with 18 additions and 5 deletions
|
|
@ -82,8 +82,8 @@ pub const Adapter = opaque {
|
||||||
) callconv(.Inline) void,
|
) callconv(.Inline) void,
|
||||||
context: Context,
|
context: Context,
|
||||||
) void {
|
) void {
|
||||||
const c_callback = struct {
|
const Helper = struct {
|
||||||
pub fn callback(status: RequestDeviceStatus, device: *Device, message: ?[*:0]const u8, userdata: ?*anyopaque) void {
|
pub fn callback(status: RequestDeviceStatus, device: *Device, message: ?[*:0]const u8, userdata: ?*anyopaque) callconv(.C) void {
|
||||||
callback(
|
callback(
|
||||||
status,
|
status,
|
||||||
device,
|
device,
|
||||||
|
|
@ -92,7 +92,7 @@ pub const Adapter = opaque {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Impl.adapterRequestDevice(adapter, descriptor, c_callback, if (Context == void) null orelse context);
|
Impl.adapterRequestDevice(adapter, descriptor, Helper.callback, if (Context == void) null orelse context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn reference(adapter: *Adapter) void {
|
pub inline fn reference(adapter: *Adapter) void {
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,21 @@ pub const Buffer = opaque {
|
||||||
return Impl.bufferGetUsage(buffer);
|
return Impl.bufferGetUsage(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bufferMapAsync(buffer: *Buffer, mode: MapModeFlags, offset: usize, size: usize, callback: MapCallback, userdata: ?*anyopaque) void {
|
pub inline fn bufferMapAsync(
|
||||||
Impl.bufferMapAsync(buffer, mode, offset, size, callback, userdata);
|
buffer: *Buffer,
|
||||||
|
mode: MapModeFlags,
|
||||||
|
offset: usize,
|
||||||
|
size: usize,
|
||||||
|
comptime Context: type,
|
||||||
|
comptime callback: fn (status: MapAsyncStatus, ctx: Context) callconv(.Inline) void,
|
||||||
|
context: Context,
|
||||||
|
) void {
|
||||||
|
const Helper = struct {
|
||||||
|
pub fn callback(status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||||
|
callback(status, if (Context == void) {} orelse @ptrCast(Context, userdata));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Impl.bufferMapAsync(buffer, mode, offset, size, Helper.callback, if (Context == void) null orelse context);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bufferSetLabel(buffer: *Buffer, label: [*:0]const u8) void {
|
pub inline fn bufferSetLabel(buffer: *Buffer, label: [*:0]const u8) void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue