gpu: implement CommandEncoder
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
ca6ff5d46c
commit
080aa950bb
3 changed files with 67 additions and 0 deletions
43
gpu/src/CommandEncoder.zig
Normal file
43
gpu/src/CommandEncoder.zig
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
const CommandEncoder = @This();
|
||||
|
||||
/// The type erased pointer to the CommandEncoder implementation
|
||||
/// Equal to c.WGPUCommandEncoder for NativeInstance.
|
||||
ptr: *anyopaque,
|
||||
vtable: *const VTable,
|
||||
|
||||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor);
|
||||
// WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTextureInternal(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
|
||||
// WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderInjectValidationError(WGPUCommandEncoder commandEncoder, char const * message);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderWriteBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t bufferOffset, uint8_t const * data, uint64_t size);
|
||||
// WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex);
|
||||
};
|
||||
|
||||
pub inline fn reference(enc: CommandEncoder) void {
|
||||
enc.vtable.reference(enc.ptr);
|
||||
}
|
||||
|
||||
pub inline fn release(enc: CommandEncoder) void {
|
||||
enc.vtable.release(enc.ptr);
|
||||
}
|
||||
|
||||
test "syntax" {
|
||||
_ = VTable;
|
||||
_ = reference;
|
||||
_ = release;
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ const ExternalTexture = @import("ExternalTexture.zig");
|
|||
const BindGroup = @import("BindGroup.zig");
|
||||
const BindGroupLayout = @import("BindGroupLayout.zig");
|
||||
const Buffer = @import("Buffer.zig");
|
||||
const CommandEncoder = @import("CommandEncoder.zig");
|
||||
|
||||
const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
|
|
@ -770,6 +771,26 @@ const buffer_vtable = Buffer.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn wrapCommandEncoder(buffer: c.WGPUCommandEncoder) CommandEncoder {
|
||||
return .{
|
||||
.ptr = buffer.?,
|
||||
.vtable = &command_encoder_vtable,
|
||||
};
|
||||
}
|
||||
|
||||
const command_encoder_vtable = CommandEncoder.VTable{
|
||||
.reference = (struct {
|
||||
pub fn reference(ptr: *anyopaque) void {
|
||||
c.wgpuCommandEncoderReference(@ptrCast(c.WGPUCommandEncoder, ptr));
|
||||
}
|
||||
}).reference,
|
||||
.release = (struct {
|
||||
pub fn release(ptr: *anyopaque) void {
|
||||
c.wgpuCommandEncoderRelease(@ptrCast(c.WGPUCommandEncoder, ptr));
|
||||
}
|
||||
}).release,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
_ = wrap;
|
||||
_ = interface_vtable;
|
||||
|
|
@ -796,4 +817,5 @@ test "syntax" {
|
|||
_ = wrapBindGroup;
|
||||
_ = wrapBindGroupLayout;
|
||||
_ = wrapBuffer;
|
||||
_ = wrapCommandEncoder;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ pub const ExternalTexture = @import("ExternalTexture.zig");
|
|||
pub const BindGroup = @import("BindGroup.zig");
|
||||
pub const BindGroupLayout = @import("BindGroupLayout.zig");
|
||||
pub const Buffer = @import("Buffer.zig");
|
||||
pub const CommandEncoder = @import("CommandEncoder.zig");
|
||||
|
||||
pub const Feature = @import("enums.zig").Feature;
|
||||
pub const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
|
|
@ -120,6 +121,7 @@ test "syntax" {
|
|||
_ = BindGroup;
|
||||
_ = BindGroupLayout;
|
||||
_ = Buffer;
|
||||
_ = CommandEncoder;
|
||||
|
||||
_ = Feature;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue