gpu: implement RenderPipeline
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
b29fa9e13d
commit
8684195e19
4 changed files with 52 additions and 11 deletions
|
|
@ -23,6 +23,7 @@ const SwapChain = @import("SwapChain.zig");
|
|||
const TextureView = @import("TextureView.zig");
|
||||
const Texture = @import("Texture.zig");
|
||||
const Sampler = @import("Sampler.zig");
|
||||
const RenderPipeline = @import("RenderPipeline.zig");
|
||||
|
||||
const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
const TextureFormat = @import("enums.zig").TextureFormat;
|
||||
|
|
@ -560,6 +561,26 @@ const sampler_vtable = Sampler.VTable{
|
|||
}).release,
|
||||
};
|
||||
|
||||
fn wrapRenderPipeline(render_pipeline: c.WGPURenderPipeline) RenderPipeline {
|
||||
return .{
|
||||
.ptr = render_pipeline.?,
|
||||
.vtable = &render_pipeline_vtable,
|
||||
};
|
||||
}
|
||||
|
||||
const render_pipeline_vtable = RenderPipeline.VTable{
|
||||
.reference = (struct {
|
||||
pub fn reference(ptr: *anyopaque) void {
|
||||
c.wgpuRenderPipelineReference(@ptrCast(c.WGPURenderPipeline, ptr));
|
||||
}
|
||||
}).reference,
|
||||
.release = (struct {
|
||||
pub fn release(ptr: *anyopaque) void {
|
||||
c.wgpuRenderPipelineRelease(@ptrCast(c.WGPURenderPipeline, ptr));
|
||||
}
|
||||
}).release,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
_ = wrap;
|
||||
_ = interface_vtable;
|
||||
|
|
@ -576,4 +597,5 @@ test "syntax" {
|
|||
_ = wrapTextureView;
|
||||
_ = wrapTexture;
|
||||
_ = wrapSampler;
|
||||
_ = wrapRenderPipeline;
|
||||
}
|
||||
|
|
|
|||
28
gpu/src/RenderPipeline.zig
Normal file
28
gpu/src/RenderPipeline.zig
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const RenderPipeline = @This();
|
||||
|
||||
/// The type erased pointer to the RenderPipeline implementation
|
||||
/// Equal to c.WGPURenderPipeline 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 wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex);
|
||||
// WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label);
|
||||
};
|
||||
|
||||
pub inline fn reference(pipeline: RenderPipeline) void {
|
||||
pipeline.vtable.reference(pipeline.ptr);
|
||||
}
|
||||
|
||||
pub inline fn release(pipeline: RenderPipeline) void {
|
||||
pipeline.vtable.release(pipeline.ptr);
|
||||
}
|
||||
|
||||
test "syntax" {
|
||||
_ = VTable;
|
||||
_ = reference;
|
||||
_ = release;
|
||||
}
|
||||
11
gpu/src/TODO
11
gpu/src/TODO
|
|
@ -657,17 +657,6 @@ WGPU_EXPORT void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder rende
|
|||
WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder);
|
||||
WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder);
|
||||
|
||||
// Methods of RenderPipeline
|
||||
WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex);
|
||||
WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label);
|
||||
WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline);
|
||||
WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline);
|
||||
|
||||
// Methods of Sampler
|
||||
WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label);
|
||||
WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler);
|
||||
WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler);
|
||||
|
||||
typedef enum WGPUSType {
|
||||
// webgpu.h upstream:
|
||||
WGPUSType_Invalid = 0x00000000,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ pub const SwapChain = @import("SwapChain.zig");
|
|||
pub const TextureView = @import("TextureView.zig");
|
||||
pub const Texture = @import("Texture.zig");
|
||||
pub const Sampler = @import("Sampler.zig");
|
||||
pub const RenderPipeline = @import("RenderPipeline.zig");
|
||||
|
||||
pub const Feature = @import("enums.zig").Feature;
|
||||
pub const TextureUsage = @import("enums.zig").TextureUsage;
|
||||
|
|
@ -100,6 +101,7 @@ test "syntax" {
|
|||
_ = TextureView;
|
||||
_ = Texture;
|
||||
_ = Sampler;
|
||||
_ = RenderPipeline;
|
||||
|
||||
_ = Feature;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue