From 616395c583e4ade99c1e155ec94acca6ca07da0c Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 16 Jul 2022 21:08:22 -0700 Subject: [PATCH] gpu: add RenderPipeline.Descriptor Signed-off-by: Stephen Gutekanst --- gpu/TODO-webgpu.h | 11 ----------- gpu/src/render_pipeline.zig | 19 +++++++++++++++++++ gpu/src/types.zig | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gpu/TODO-webgpu.h b/gpu/TODO-webgpu.h index 9b976b35..c378f283 100644 --- a/gpu/TODO-webgpu.h +++ b/gpu/TODO-webgpu.h @@ -1,14 +1,3 @@ -pub const WGPURenderPipelineDescriptor = extern struct { - next_in_chain: *const ChainedStruct, - label: ?[*:0]const u8 = null, - layout: PipelineLayout = PipelineLayout.none, // nullable - vertex: VertexState, - primitive: PrimitiveState, - depth_stencil: ?*const DepthStencilState = null, // nullable - multisample: MultisampleState, - fragment: ?*const FragmentState = null, // nullable -}; - typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata); typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, WGPUCompilationInfo const * compilationInfo, void * userdata); typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata); diff --git a/gpu/src/render_pipeline.zig b/gpu/src/render_pipeline.zig index b29032cf..24b09ec7 100644 --- a/gpu/src/render_pipeline.zig +++ b/gpu/src/render_pipeline.zig @@ -1,6 +1,25 @@ +const ChainedStruct = @import("types.zig").ChainedStruct; +const DepthStencilState = @import("types.zig").DepthStencilState; +const MultisampleState = @import("types.zig").MultisampleState; +const VertexState = @import("types.zig").VertexState; +const PrimitiveState = @import("types.zig").PrimitiveState; +const FragmentState = @import("types.zig").FragmentState; +const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout; + pub const RenderPipeline = enum(usize) { _, // TODO: verify there is a use case for nullable value of this type. pub const none: RenderPipeline = @intToEnum(RenderPipeline, 0); + + pub const Descriptor = extern struct { + next_in_chain: *const ChainedStruct, + label: ?[*:0]const u8 = null, + layout: PipelineLayout = PipelineLayout.none, // nullable + vertex: VertexState, + primitive: PrimitiveState, + depth_stencil: ?*const DepthStencilState = null, // nullable + multisample: MultisampleState, + fragment: ?*const FragmentState = null, // nullable + }; }; diff --git a/gpu/src/types.zig b/gpu/src/types.zig index b9450b1a..df6e3fc5 100644 --- a/gpu/src/types.zig +++ b/gpu/src/types.zig @@ -461,7 +461,7 @@ pub const CopyTextureForBrowserOptions = extern struct { dst_alpha_mode: AlphaMode, }; -pub const MultisampleState = struct { +pub const MultisampleState = extern struct { next_in_chain: *const ChainedStruct, count: u32, mask: u32,