From 3ec84f516a66ddcb52ec2ee316259890d4f970cc Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 11 Mar 2022 16:21:09 -0700 Subject: [PATCH] gpu: add DepthStencilState Signed-off-by: Stephen Gutekanst --- gpu/src/TODO | 14 -------------- gpu/src/main.zig | 3 ++- gpu/src/structs.zig | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gpu/src/TODO b/gpu/src/TODO index 1bbe7a0f..3ad0dce8 100644 --- a/gpu/src/TODO +++ b/gpu/src/TODO @@ -204,20 +204,6 @@ typedef struct WGPUCopyTextureForBrowserOptions { WGPUAlphaMode dstAlphaMode; } WGPUCopyTextureForBrowserOptions; -typedef struct WGPUDepthStencilState { - WGPUChainedStruct const * nextInChain; - WGPUTextureFormat format; - bool depthWriteEnabled; - WGPUCompareFunction depthCompare; - WGPUStencilFaceState stencilFront; - WGPUStencilFaceState stencilBack; - uint32_t stencilReadMask; - uint32_t stencilWriteMask; - int32_t depthBias; - float depthBiasSlopeScale; - float depthBiasClamp; -} WGPUDepthStencilState; - typedef struct WGPUImageCopyBuffer { WGPUChainedStruct const * nextInChain; WGPUTextureDataLayout layout; diff --git a/gpu/src/main.zig b/gpu/src/main.zig index 5b1df2a8..f3e3bb78 100644 --- a/gpu/src/main.zig +++ b/gpu/src/main.zig @@ -89,10 +89,11 @@ pub const VertexBufferLayout = @import("data.zig").VertexBufferLayout; // Data structures not ABI-compatible with webgpu.h pub const CompilationMessage = @import("structs.zig").CompilationMessage; -pub const CompilationInfo = @Import("structs.zig").CompilationInfo; +pub const CompilationInfo = @import("structs.zig").CompilationInfo; pub const MultisampleState = @import("structs.zig").MultisampleState; pub const PrimitiveState = @import("structs.zig").PrimitiveState; pub const StorageTextureBindingLayout = @import("structs.zig").StorageTextureBindingLayout; +pub const DepthStencilState = @import("structs.zig").DepthStencilState; // Enumerations pub const Feature = @import("enums.zig").Feature; diff --git a/gpu/src/structs.zig b/gpu/src/structs.zig index 378f9f05..9926b56c 100644 --- a/gpu/src/structs.zig +++ b/gpu/src/structs.zig @@ -3,12 +3,14 @@ const Buffer = @import("Buffer.zig"); const Sampler = @import("Sampler.zig"); const Texture = @import("Texture.zig"); const TextureView = @import("TextureView.zig"); +const StencilFaceState = @import("data.zig").StencilFaceState; const CompilationMessageType = @import("enums.zig").CompilationMessageType; const PrimitiveTopology = @import("enums.zig").PrimitiveTopology; const IndexFormat = @import("enums.zig").IndexFormat; const FrontFace = @import("enums.zig").FrontFace; const CullMode = @import("enums.zig").CullMode; const StorageTextureAccess = @import("enums.zig").StorageTextureAccess; +const CompareFunction = @import("enums.zig").CompareFunction; pub const CompilationMessage = struct { message: [:0]const u8, @@ -42,10 +44,24 @@ pub const StorageTextureBindingLayout = struct { view_dimension: Texture.ViewDimension, }; +pub const DepthStencilState = struct { + format: Texture.Format, + depth_write_enabled: bool, + depth_compare: CompareFunction, + stencil_front: StencilFaceState, + stencil_back: StencilFaceState, + stencil_read_mask: u32, + stencil_write_mask: u32, + depth_bias: i32, + depth_bias_slope_scale: f32, + depth_bias_clamp: f32, +}; + test "syntax" { _ = CompilationMessage; _ = CompilationInfo; _ = MultisampleState; _ = PrimitiveState; _ = StorageTextureBindingLayout; + _ = DepthStencilState; }