gpu: add CommandBuffer; CommandBuffer.setLabel
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
a397631045
commit
5547594fd7
2 changed files with 32 additions and 2 deletions
|
|
@ -8,8 +8,7 @@ vtable: *const VTable,
|
|||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label);
|
||||
setLabel: fn (ptr: *anyopaque, label: [:0]const u8) void,
|
||||
};
|
||||
|
||||
pub inline fn reference(buf: CommandBuffer) void {
|
||||
|
|
@ -20,8 +19,13 @@ pub inline fn release(buf: CommandBuffer) void {
|
|||
buf.vtable.release(buf.ptr);
|
||||
}
|
||||
|
||||
pub inline fn setLabel(group: CommandBuffer, label: [:0]const u8) void {
|
||||
group.vtable.setLabel(group.ptr, label);
|
||||
}
|
||||
|
||||
test "syntax" {
|
||||
_ = VTable;
|
||||
_ = reference;
|
||||
_ = release;
|
||||
_ = setLabel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -788,6 +788,31 @@ const buffer_vtable = Buffer.VTable{
|
|||
}).setLabel,
|
||||
};
|
||||
|
||||
fn wrapCommandBuffer(buffer: c.WGPUCommandBuffer) CommandBuffer {
|
||||
return .{
|
||||
.ptr = buffer.?,
|
||||
.vtable = &command_buffer_vtable,
|
||||
};
|
||||
}
|
||||
|
||||
const command_buffer_vtable = CommandBuffer.VTable{
|
||||
.reference = (struct {
|
||||
pub fn reference(ptr: *anyopaque) void {
|
||||
c.wgpuCommandBufferReference(@ptrCast(c.WGPUCommandBuffer, ptr));
|
||||
}
|
||||
}).reference,
|
||||
.release = (struct {
|
||||
pub fn release(ptr: *anyopaque) void {
|
||||
c.wgpuCommandBufferRelease(@ptrCast(c.WGPUCommandBuffer, ptr));
|
||||
}
|
||||
}).release,
|
||||
.setLabel = (struct {
|
||||
pub fn setLabel(ptr: *anyopaque, label: [:0]const u8) void {
|
||||
c.wgpuCommandBufferLayoutSetLabel(@ptrCast(c.WGPUCommandBufferLayout, ptr), label);
|
||||
}
|
||||
}).setLabel,
|
||||
};
|
||||
|
||||
fn wrapCommandEncoder(enc: c.WGPUCommandEncoder) CommandEncoder {
|
||||
return .{
|
||||
.ptr = enc.?,
|
||||
|
|
@ -874,6 +899,7 @@ test "syntax" {
|
|||
_ = wrapBindGroup;
|
||||
_ = wrapBindGroupLayout;
|
||||
_ = wrapBuffer;
|
||||
_ = wrapCommandBuffer;
|
||||
_ = wrapCommandEncoder;
|
||||
_ = wrapComputePassEncoder;
|
||||
_ = wrapComputePipeline;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue