gpu: internalize RenderPipeline types

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-29 23:56:14 -07:00 committed by Stephen Gutekanst
parent 0fac1d9336
commit 550c5fd55e
3 changed files with 19 additions and 20 deletions

View file

@ -9,7 +9,6 @@ const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout;
const QuerySet = @import("query_set.zig").QuerySet; const QuerySet = @import("query_set.zig").QuerySet;
const RenderBundleEncoder = @import("render_bundle_encoder.zig").RenderBundleEncoder; const RenderBundleEncoder = @import("render_bundle_encoder.zig").RenderBundleEncoder;
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline; const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
const RenderPipelineDescriptor = @import("render_pipeline.zig").RenderPipelineDescriptor;
const Sampler = @import("sampler.zig").Sampler; const Sampler = @import("sampler.zig").Sampler;
const SamplerDescriptor = @import("sampler.zig").SamplerDescriptor; const SamplerDescriptor = @import("sampler.zig").SamplerDescriptor;
const ShaderModule = @import("shader_module.zig").ShaderModule; const ShaderModule = @import("shader_module.zig").ShaderModule;
@ -100,11 +99,11 @@ pub const Device = opaque {
return Impl.deviceCreateRenderBundleEncoder(device, descriptor); return Impl.deviceCreateRenderBundleEncoder(device, descriptor);
} }
pub inline fn createRenderPipeline(device: *Device, descriptor: *const RenderPipelineDescriptor) *RenderPipeline { pub inline fn createRenderPipeline(device: *Device, descriptor: *const RenderPipeline.Descriptor) *RenderPipeline {
return Impl.deviceCreateRenderPipeline(device, descriptor); return Impl.deviceCreateRenderPipeline(device, descriptor);
} }
pub inline fn createRenderPipelineAsync(device: *Device, descriptor: *const RenderPipelineDescriptor, callback: CreateRenderPipelineAsyncCallback, userdata: *anyopaque) void { pub inline fn createRenderPipelineAsync(device: *Device, descriptor: *const RenderPipeline.Descriptor, callback: CreateRenderPipelineAsyncCallback, userdata: *anyopaque) void {
Impl.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata); Impl.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata);
} }

View file

@ -91,8 +91,8 @@ pub fn Interface(comptime T: type) type {
assertDecl(T, "deviceCreatePipelineLayout", fn (device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayout.Descriptor) callconv(.Inline) *gpu.PipelineLayout); assertDecl(T, "deviceCreatePipelineLayout", fn (device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayout.Descriptor) callconv(.Inline) *gpu.PipelineLayout);
assertDecl(T, "deviceCreateQuerySet", fn (device: *gpu.Device, descriptor: *const gpu.QuerySet.Descriptor) callconv(.Inline) *gpu.QuerySet); assertDecl(T, "deviceCreateQuerySet", fn (device: *gpu.Device, descriptor: *const gpu.QuerySet.Descriptor) callconv(.Inline) *gpu.QuerySet);
assertDecl(T, "deviceCreateRenderBundleEncoder", fn (device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoder.Descriptor) callconv(.Inline) *gpu.RenderBundleEncoder); assertDecl(T, "deviceCreateRenderBundleEncoder", fn (device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoder.Descriptor) callconv(.Inline) *gpu.RenderBundleEncoder);
assertDecl(T, "deviceCreateRenderPipeline", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor) callconv(.Inline) *gpu.RenderPipeline); assertDecl(T, "deviceCreateRenderPipeline", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor) callconv(.Inline) *gpu.RenderPipeline);
assertDecl(T, "deviceCreateRenderPipelineAsync", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) callconv(.Inline) void); assertDecl(T, "deviceCreateRenderPipelineAsync", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) callconv(.Inline) void);
assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.SamplerDescriptor) callconv(.Inline) *gpu.Sampler); assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.SamplerDescriptor) callconv(.Inline) *gpu.Sampler);
assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModuleDescriptor) callconv(.Inline) *gpu.ShaderModule); assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModuleDescriptor) callconv(.Inline) *gpu.ShaderModule);
assertDecl(T, "deviceCreateSwapChain", fn (device: *gpu.Device, surface: ?*gpu.Surface, descriptor: *const gpu.SwapChainDescriptor) callconv(.Inline) *gpu.SwapChain); assertDecl(T, "deviceCreateSwapChain", fn (device: *gpu.Device, surface: ?*gpu.Surface, descriptor: *const gpu.SwapChainDescriptor) callconv(.Inline) *gpu.SwapChain);
@ -609,12 +609,12 @@ pub fn Export(comptime T: type) type {
} }
// WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); // WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor);
export fn wgpuDeviceCreateRenderPipeline(device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor) *gpu.RenderPipeline { export fn wgpuDeviceCreateRenderPipeline(device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor) *gpu.RenderPipeline {
return T.deviceCreateRenderPipeline(device, descriptor); return T.deviceCreateRenderPipeline(device, descriptor);
} }
// WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata); // WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata);
export fn wgpuDeviceCreateRenderPipelineAsync(device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) void { export fn wgpuDeviceCreateRenderPipelineAsync(device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) void {
T.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata); T.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata);
} }
@ -1689,13 +1689,13 @@ pub const StubInterface = Interface(struct {
unreachable; unreachable;
} }
pub inline fn deviceCreateRenderPipeline(device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor) *gpu.RenderPipeline { pub inline fn deviceCreateRenderPipeline(device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor) *gpu.RenderPipeline {
_ = device; _ = device;
_ = descriptor; _ = descriptor;
unreachable; unreachable;
} }
pub inline fn deviceCreateRenderPipelineAsync(device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) void { pub inline fn deviceCreateRenderPipelineAsync(device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) void {
_ = device; _ = device;
_ = descriptor; _ = descriptor;
_ = callback; _ = callback;

View file

@ -9,6 +9,17 @@ const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const RenderPipeline = opaque { pub const RenderPipeline = opaque {
pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
layout: ?*PipelineLayout,
vertex: VertexState,
primitive: PrimitiveState,
depth_stencil: ?*const DepthStencilState,
multisample: MultisampleState,
fragment: ?*const FragmentState,
};
pub inline fn getBindGroupLayout(render_pipeline: *RenderPipeline, group_index: u32) *BindGroupLayout { pub inline fn getBindGroupLayout(render_pipeline: *RenderPipeline, group_index: u32) *BindGroupLayout {
return Impl.renderPipelineGetBindGroupLayout(render_pipeline, group_index); return Impl.renderPipelineGetBindGroupLayout(render_pipeline, group_index);
} }
@ -25,14 +36,3 @@ pub const RenderPipeline = opaque {
Impl.renderPipelineRelease(render_pipeline); Impl.renderPipelineRelease(render_pipeline);
} }
}; };
pub const RenderPipelineDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
layout: ?*PipelineLayout,
vertex: VertexState,
primitive: PrimitiveState,
depth_stencil: ?*const DepthStencilState,
multisample: MultisampleState,
fragment: ?*const FragmentState,
};