gpu: Add default values for some structs (taken from the spec). (#218)
Helps hexops/mach#182
This commit is contained in:
parent
02e357ab44
commit
fe8e0e7c98
3 changed files with 43 additions and 42 deletions
|
|
@ -218,7 +218,7 @@ pub const BindingLayout = extern struct {
|
||||||
|
|
||||||
pub const DataLayout = extern struct {
|
pub const DataLayout = extern struct {
|
||||||
reserved: ?*anyopaque = null,
|
reserved: ?*anyopaque = null,
|
||||||
offset: u64,
|
offset: u64 = 0,
|
||||||
bytes_per_row: u32,
|
bytes_per_row: u32,
|
||||||
rows_per_image: u32,
|
rows_per_image: u32,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,21 +45,21 @@ pub const Color = extern struct {
|
||||||
|
|
||||||
pub const Extent3D = extern struct {
|
pub const Extent3D = extern struct {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32 = 1,
|
||||||
depth_or_array_layers: u32,
|
depth_or_array_layers: u32 = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Origin3D = extern struct {
|
pub const Origin3D = extern struct {
|
||||||
x: u32,
|
x: u32 = 0,
|
||||||
y: u32,
|
y: u32 = 0,
|
||||||
z: u32,
|
z: u32 = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const StencilFaceState = extern struct {
|
pub const StencilFaceState = extern struct {
|
||||||
compare: CompareFunction,
|
compare: CompareFunction = .always,
|
||||||
fail_op: StencilOperation,
|
fail_op: StencilOperation = .keep,
|
||||||
depth_fail_op: StencilOperation,
|
depth_fail_op: StencilOperation = .keep,
|
||||||
pass_op: StencilOperation,
|
pass_op: StencilOperation = .keep,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const VertexAttribute = extern struct {
|
pub const VertexAttribute = extern struct {
|
||||||
|
|
@ -69,9 +69,9 @@ pub const VertexAttribute = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BlendComponent = extern struct {
|
pub const BlendComponent = extern struct {
|
||||||
operation: BlendOperation,
|
operation: BlendOperation = .add,
|
||||||
src_factor: BlendFactor,
|
src_factor: BlendFactor = .one,
|
||||||
dst_factor: BlendFactor,
|
dst_factor: BlendFactor = .zero,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BlendState = extern struct {
|
pub const BlendState = extern struct {
|
||||||
|
|
@ -81,7 +81,7 @@ pub const BlendState = extern struct {
|
||||||
|
|
||||||
pub const VertexBufferLayout = extern struct {
|
pub const VertexBufferLayout = extern struct {
|
||||||
array_stride: u64,
|
array_stride: u64,
|
||||||
step_mode: VertexStepMode,
|
step_mode: VertexStepMode = .vertex,
|
||||||
attribute_count: u32,
|
attribute_count: u32,
|
||||||
attributes: [*]const VertexAttribute,
|
attributes: [*]const VertexAttribute,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//! Structures which are not ABI compatible with webgpu.h
|
//! Structures which are not ABI compatible with webgpu.h
|
||||||
|
const math = @import("std").math;
|
||||||
const Buffer = @import("Buffer.zig");
|
const Buffer = @import("Buffer.zig");
|
||||||
const Sampler = @import("Sampler.zig");
|
const Sampler = @import("Sampler.zig");
|
||||||
const Texture = @import("Texture.zig");
|
const Texture = @import("Texture.zig");
|
||||||
|
|
@ -25,16 +26,16 @@ const ErrorType = @import("enums.zig").ErrorType;
|
||||||
const LoggingType = @import("enums.zig").LoggingType;
|
const LoggingType = @import("enums.zig").LoggingType;
|
||||||
|
|
||||||
pub const MultisampleState = struct {
|
pub const MultisampleState = struct {
|
||||||
count: u32,
|
count: u32 = 1,
|
||||||
mask: u32,
|
mask: u32 = 0xffff_ffff,
|
||||||
alpha_to_coverage_enabled: bool,
|
alpha_to_coverage_enabled: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PrimitiveState = struct {
|
pub const PrimitiveState = struct {
|
||||||
topology: PrimitiveTopology,
|
topology: PrimitiveTopology = .triangle_list,
|
||||||
strip_index_format: IndexFormat,
|
strip_index_format: IndexFormat = .none,
|
||||||
front_face: FrontFace,
|
front_face: FrontFace = .ccw,
|
||||||
cull_mode: CullMode,
|
cull_mode: CullMode = .none,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const StorageTextureBindingLayout = extern struct {
|
pub const StorageTextureBindingLayout = extern struct {
|
||||||
|
|
@ -46,15 +47,15 @@ pub const StorageTextureBindingLayout = extern struct {
|
||||||
|
|
||||||
pub const DepthStencilState = struct {
|
pub const DepthStencilState = struct {
|
||||||
format: Texture.Format,
|
format: Texture.Format,
|
||||||
depth_write_enabled: bool,
|
depth_write_enabled: bool = false,
|
||||||
depth_compare: CompareFunction,
|
depth_compare: CompareFunction = .always,
|
||||||
stencil_front: StencilFaceState,
|
stencil_front: StencilFaceState = .{},
|
||||||
stencil_back: StencilFaceState,
|
stencil_back: StencilFaceState = .{},
|
||||||
stencil_read_mask: u32,
|
stencil_read_mask: u32 = 0xffff_ffff,
|
||||||
stencil_write_mask: u32,
|
stencil_write_mask: u32 = 0xffff_ffff,
|
||||||
depth_bias: i32,
|
depth_bias: i32 = 0,
|
||||||
depth_bias_slope_scale: f32,
|
depth_bias_slope_scale: f32 = 0.0,
|
||||||
depth_bias_clamp: f32,
|
depth_bias_clamp: f32 = 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: how does this map to browser API?
|
// TODO: how does this map to browser API?
|
||||||
|
|
@ -87,22 +88,22 @@ pub const RenderPassDepthStencilAttachment = struct {
|
||||||
view: TextureView,
|
view: TextureView,
|
||||||
depth_load_op: LoadOp,
|
depth_load_op: LoadOp,
|
||||||
depth_store_op: StoreOp,
|
depth_store_op: StoreOp,
|
||||||
clear_depth: f32,
|
clear_depth: f32 = math.nan_f32,
|
||||||
depth_clear_value: f32,
|
depth_clear_value: f32 = 0.0,
|
||||||
depth_read_only: bool,
|
depth_read_only: bool = false,
|
||||||
stencil_load_op: LoadOp,
|
stencil_load_op: LoadOp,
|
||||||
stencil_store_op: StoreOp,
|
stencil_store_op: StoreOp,
|
||||||
clear_stencil: u32,
|
clear_stencil: u32 = 0,
|
||||||
stencil_clear_value: u32,
|
stencil_clear_value: u32 = 0.0,
|
||||||
stencil_read_only: bool,
|
stencil_read_only: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const RenderPassColorAttachment = struct {
|
pub const RenderPassColorAttachment = struct {
|
||||||
view: TextureView,
|
view: TextureView,
|
||||||
resolve_target: ?TextureView,
|
resolve_target: ?TextureView = null,
|
||||||
load_op: LoadOp,
|
load_op: LoadOp,
|
||||||
store_op: StoreOp,
|
store_op: StoreOp,
|
||||||
clear_value: Color,
|
clear_value: Color = .{ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const VertexState = struct {
|
pub const VertexState = struct {
|
||||||
|
|
@ -123,7 +124,7 @@ pub const ColorTargetState = extern struct {
|
||||||
reserved: ?*anyopaque = null,
|
reserved: ?*anyopaque = null,
|
||||||
format: Texture.Format,
|
format: Texture.Format,
|
||||||
blend: *const BlendState,
|
blend: *const BlendState,
|
||||||
write_mask: ColorWriteMask,
|
write_mask: ColorWriteMask = ColorWriteMask.all,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ImageCopyBuffer = struct {
|
pub const ImageCopyBuffer = struct {
|
||||||
|
|
@ -133,9 +134,9 @@ pub const ImageCopyBuffer = struct {
|
||||||
|
|
||||||
pub const ImageCopyTexture = struct {
|
pub const ImageCopyTexture = struct {
|
||||||
texture: Texture,
|
texture: Texture,
|
||||||
mip_level: u32,
|
mip_level: u32 = 0,
|
||||||
origin: Origin3D,
|
origin: Origin3D = .{},
|
||||||
aspect: Texture.Aspect,
|
aspect: Texture.Aspect = .all,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ErrorCallback = struct {
|
pub const ErrorCallback = struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue