gpu: implement RenderPipeline.getBindGroupLayout

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-15 21:21:33 -07:00 committed by Stephen Gutekanst
parent 856c98c4c1
commit 7e54d9b4ae
2 changed files with 16 additions and 2 deletions

View file

@ -855,6 +855,14 @@ const render_pipeline_vtable = RenderPipeline.VTable{
c.wgpuRenderPipelineSetLabel(@ptrCast(c.WGPURenderPipeline, ptr), label); c.wgpuRenderPipelineSetLabel(@ptrCast(c.WGPURenderPipeline, ptr), label);
} }
}).setLabel, }).setLabel,
.getBindGroupLayout = (struct {
pub fn getBindGroupLayout(ptr: *anyopaque, group_index: u32) BindGroupLayout {
return wrapBindGroupLayout(c.wgpuRenderPipelineGetBindGroupLayout(
@ptrCast(c.WGPURenderPipeline, ptr),
group_index,
));
}
}).getBindGroupLayout,
}; };
fn wrapRenderPassEncoder(pass: c.WGPURenderPassEncoder) RenderPassEncoder { fn wrapRenderPassEncoder(pass: c.WGPURenderPassEncoder) RenderPassEncoder {

View file

@ -4,6 +4,7 @@ const PrimitiveState = @import("structs.zig").PrimitiveState;
const DepthStencilState = @import("structs.zig").DepthStencilState; const DepthStencilState = @import("structs.zig").DepthStencilState;
const MultisampleState = @import("structs.zig").MultisampleState; const MultisampleState = @import("structs.zig").MultisampleState;
const FragmentState = @import("structs.zig").FragmentState; const FragmentState = @import("structs.zig").FragmentState;
const BindGroupLayout = @import("BindGroupLayout.zig");
const RenderPipeline = @This(); const RenderPipeline = @This();
@ -15,9 +16,8 @@ vtable: *const VTable,
pub const VTable = struct { pub const VTable = struct {
reference: fn (ptr: *anyopaque) void, reference: fn (ptr: *anyopaque) void,
release: fn (ptr: *anyopaque) void, release: fn (ptr: *anyopaque) void,
// TODO:
// WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex);
setLabel: fn (ptr: *anyopaque, label: [:0]const u8) void, setLabel: fn (ptr: *anyopaque, label: [:0]const u8) void,
getBindGroupLayout: fn (ptr: *anyopaque, group_index: u32) BindGroupLayout,
}; };
pub inline fn reference(pipeline: RenderPipeline) void { pub inline fn reference(pipeline: RenderPipeline) void {
@ -32,6 +32,10 @@ pub inline fn setLabel(pipeline: RenderPipeline, label: [:0]const u8) void {
pipeline.vtable.setLabel(pipeline.ptr, label); pipeline.vtable.setLabel(pipeline.ptr, label);
} }
pub inline fn getBindGroupLayout(pipeline: RenderPipeline, group_index: u32) BindGroupLayout {
return pipeline.vtable.getBindGroupLayout(pipeline.ptr, group_index);
}
pub const Descriptor = struct { pub const Descriptor = struct {
label: ?[*:0]const u8 = null, label: ?[*:0]const u8 = null,
layout: ?PipelineLayout, layout: ?PipelineLayout,
@ -96,6 +100,8 @@ test "syntax" {
_ = VTable; _ = VTable;
_ = reference; _ = reference;
_ = release; _ = release;
_ = setLabel;
_ = getBindGroupLayout;
_ = Descriptor; _ = Descriptor;
_ = CreateStatus; _ = CreateStatus;
_ = CreateCallback; _ = CreateCallback;