gpu: implement ComputePipeline
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
056e46ec39
commit
ce46b2a652
3 changed files with 58 additions and 6 deletions
28
gpu/src/ComputePipeline.zig
Normal file
28
gpu/src/ComputePipeline.zig
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const ComputePipeline = @This();
|
||||
|
||||
/// The type erased pointer to the ComputePipeline implementation
|
||||
/// Equal to c.WGPUComputePipeline for NativeInstance.
|
||||
ptr: *anyopaque,
|
||||
vtable: *const VTable,
|
||||
|
||||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex);
|
||||
// WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label);
|
||||
};
|
||||
|
||||
pub inline fn reference(pipeline: ComputePipeline) void {
|
||||
pipeline.vtable.reference(pipeline.ptr);
|
||||
}
|
||||
|
||||
pub inline fn release(pipeline: ComputePipeline) void {
|
||||
pipeline.vtable.release(pipeline.ptr);
|
||||
}
|
||||
|
||||
test "syntax" {
|
||||
_ = VTable;
|
||||
_ = reference;
|
||||
_ = release;
|
||||
}
|
||||
|
|
@ -35,6 +35,7 @@ const BindGroupLayout = @import("BindGroupLayout.zig");
|
|||
const Buffer = @import("Buffer.zig");
|
||||
const CommandEncoder = @import("CommandEncoder.zig");
|
||||
const ComputePassEncoder = @import("ComputePassEncoder.zig");
|
||||
const ComputePipeline = @import("ComputePipeline.zig");
|
||||
|
||||
const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
|
|
@ -772,9 +773,9 @@ const buffer_vtable = Buffer.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn wrapCommandEncoder(buffer: c.WGPUCommandEncoder) CommandEncoder {
|
||||
fn wrapCommandEncoder(enc: c.WGPUCommandEncoder) CommandEncoder {
|
||||
return .{
|
||||
.ptr = buffer.?,
|
||||
.ptr = enc.?,
|
||||
.vtable = &command_encoder_vtable,
|
||||
};
|
||||
}
|
||||
|
|
@ -792,14 +793,14 @@ const command_encoder_vtable = CommandEncoder.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn wrapComputePassEncoder(buffer: c.WGPUComputePassEncoder) ComputePassEncoder {
|
||||
fn wrapComputePassEncoder(enc: c.WGPUComputePassEncoder) ComputePassEncoder {
|
||||
return .{
|
||||
.ptr = buffer.?,
|
||||
.vtable = &command_pass_encoder_vtable,
|
||||
.ptr = enc.?,
|
||||
.vtable = &compute_pass_encoder_vtable,
|
||||
};
|
||||
}
|
||||
|
||||
const command_pass_encoder_vtable = ComputePassEncoder.VTable{
|
||||
const compute_pass_encoder_vtable = ComputePassEncoder.VTable{
|
||||
.reference = (struct {
|
||||
pub fn reference(ptr: *anyopaque) void {
|
||||
c.wgpuComputePassEncoderReference(@ptrCast(c.WGPUComputePassEncoder, ptr));
|
||||
|
|
@ -812,6 +813,26 @@ const command_pass_encoder_vtable = ComputePassEncoder.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn wrapComputePipeline(pipeline: c.WGPUComputePipeline) ComputePipeline {
|
||||
return .{
|
||||
.ptr = pipeline.?,
|
||||
.vtable = &compute_pipeline_vtable,
|
||||
};
|
||||
}
|
||||
|
||||
const compute_pipeline_vtable = ComputePipeline.VTable{
|
||||
.reference = (struct {
|
||||
pub fn reference(ptr: *anyopaque) void {
|
||||
c.wgpuComputePipelineReference(@ptrCast(c.WGPUComputePipeline, ptr));
|
||||
}
|
||||
}).reference,
|
||||
.release = (struct {
|
||||
pub fn release(ptr: *anyopaque) void {
|
||||
c.wgpuComputePipelineRelease(@ptrCast(c.WGPUComputePipeline, ptr));
|
||||
}
|
||||
}).release,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
_ = wrap;
|
||||
_ = interface_vtable;
|
||||
|
|
@ -840,4 +861,5 @@ test "syntax" {
|
|||
_ = wrapBuffer;
|
||||
_ = wrapCommandEncoder;
|
||||
_ = wrapComputePassEncoder;
|
||||
_ = wrapComputePipeline;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ pub const BindGroupLayout = @import("BindGroupLayout.zig");
|
|||
pub const Buffer = @import("Buffer.zig");
|
||||
pub const CommandEncoder = @import("CommandEncoder.zig");
|
||||
pub const ComputePassEncoder = @import("ComputePassEncoder.zig");
|
||||
pub const ComputePipeline = @import("ComputePipeline.zig");
|
||||
|
||||
pub const Feature = @import("enums.zig").Feature;
|
||||
pub const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
|
|
@ -124,6 +125,7 @@ test "syntax" {
|
|||
_ = Buffer;
|
||||
_ = CommandEncoder;
|
||||
_ = ComputePassEncoder;
|
||||
_ = ComputePipeline;
|
||||
|
||||
_ = Feature;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue