gpu: remove usingnamespace for callbacks.zig and types.zig (#798)

This commit is contained in:
Tech0tron 2023-06-04 21:04:56 -06:00 committed by GitHub
parent 958664bb0b
commit fef0299886
Failed to generate hash of commit
27 changed files with 965 additions and 987 deletions

View file

@ -1,13 +1,13 @@
const std = @import("std"); const std = @import("std");
const testing = std.testing; const testing = std.testing;
const dawn = @import("dawn.zig"); const dawn = @import("dawn.zig");
const ChainedStructOut = @import("types.zig").ChainedStructOut; const ChainedStructOut = @import("main.zig").ChainedStructOut;
const Device = @import("device.zig").Device; const Device = @import("device.zig").Device;
const FeatureName = @import("types.zig").FeatureName; const FeatureName = @import("main.zig").FeatureName;
const SupportedLimits = @import("types.zig").SupportedLimits; const SupportedLimits = @import("main.zig").SupportedLimits;
const RequestDeviceStatus = @import("types.zig").RequestDeviceStatus; const RequestDeviceStatus = @import("main.zig").RequestDeviceStatus;
const BackendType = @import("types.zig").BackendType; const BackendType = @import("main.zig").BackendType;
const RequestDeviceCallback = @import("callbacks.zig").RequestDeviceCallback; const RequestDeviceCallback = @import("main.zig").RequestDeviceCallback;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const Adapter = opaque { pub const Adapter = opaque {

View file

@ -1,7 +1,7 @@
const Buffer = @import("buffer.zig").Buffer; const Buffer = @import("buffer.zig").Buffer;
const Sampler = @import("sampler.zig").Sampler; const Sampler = @import("sampler.zig").Sampler;
const TextureView = @import("texture_view.zig").TextureView; const TextureView = @import("texture_view.zig").TextureView;
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout; const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
const ExternalTexture = @import("external_texture.zig").ExternalTexture; const ExternalTexture = @import("external_texture.zig").ExternalTexture;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;

View file

@ -1,11 +1,11 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const ShaderStageFlags = @import("types.zig").ShaderStageFlags; const ShaderStageFlags = @import("main.zig").ShaderStageFlags;
const Buffer = @import("buffer.zig").Buffer; const Buffer = @import("buffer.zig").Buffer;
const Sampler = @import("sampler.zig").Sampler; const Sampler = @import("sampler.zig").Sampler;
const Texture = @import("texture.zig").Texture; const Texture = @import("texture.zig").Texture;
const TextureView = @import("texture_view.zig").TextureView; const TextureView = @import("texture_view.zig").TextureView;
const StorageTextureBindingLayout = @import("types.zig").StorageTextureBindingLayout; const StorageTextureBindingLayout = @import("main.zig").StorageTextureBindingLayout;
const StorageTextureAccess = @import("types.zig").StorageTextureAccess; const StorageTextureAccess = @import("main.zig").StorageTextureAccess;
const ExternalTexture = @import("external_texture.zig").ExternalTexture; const ExternalTexture = @import("external_texture.zig").ExternalTexture;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;

View file

@ -1,7 +1,7 @@
const std = @import("std"); const std = @import("std");
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const dawn = @import("dawn.zig"); const dawn = @import("dawn.zig");
const MapModeFlags = @import("types.zig").MapModeFlags; const MapModeFlags = @import("main.zig").MapModeFlags;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const Buffer = opaque { pub const Buffer = opaque {

View file

@ -1,57 +0,0 @@
const CompilationInfoRequestStatus = @import("types.zig").CompilationInfoRequestStatus;
const CompilationInfo = @import("types.zig").CompilationInfo;
const ErrorType = @import("types.zig").ErrorType;
const LoggingType = @import("types.zig").LoggingType;
const RequestDeviceStatus = @import("types.zig").RequestDeviceStatus;
const RequestAdapterStatus = @import("types.zig").RequestAdapterStatus;
const CreatePipelineAsyncStatus = @import("types.zig").CreatePipelineAsyncStatus;
const Device = @import("device.zig").Device;
const Adapter = @import("adapter.zig").Adapter;
const ComputePipeline = @import("compute_pipeline.zig").ComputePipeline;
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
pub const CompilationInfoCallback = *const fn (
status: CompilationInfoRequestStatus,
compilation_info: *const CompilationInfo,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const ErrorCallback = *const fn (
typ: ErrorType,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const LoggingCallback = *const fn (
typ: LoggingType,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const RequestDeviceCallback = *const fn (
status: RequestDeviceStatus,
device: *Device,
message: ?[*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const RequestAdapterCallback = *const fn (
status: RequestAdapterStatus,
adapter: *Adapter,
message: ?[*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const CreateComputePipelineAsyncCallback = *const fn (
status: CreatePipelineAsyncStatus,
compute_pipeline: *ComputePipeline,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const CreateRenderPipelineAsyncCallback = *const fn (
status: CreatePipelineAsyncStatus,
pipeline: *RenderPipeline,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;

View file

@ -1,4 +1,4 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const CommandBuffer = opaque { pub const CommandBuffer = opaque {

View file

@ -4,12 +4,12 @@ const RenderPassEncoder = @import("render_pass_encoder.zig").RenderPassEncoder;
const CommandBuffer = @import("command_buffer.zig").CommandBuffer; const CommandBuffer = @import("command_buffer.zig").CommandBuffer;
const Buffer = @import("buffer.zig").Buffer; const Buffer = @import("buffer.zig").Buffer;
const QuerySet = @import("query_set.zig").QuerySet; const QuerySet = @import("query_set.zig").QuerySet;
const RenderPassDescriptor = @import("types.zig").RenderPassDescriptor; const RenderPassDescriptor = @import("main.zig").RenderPassDescriptor;
const ComputePassDescriptor = @import("types.zig").ComputePassDescriptor; const ComputePassDescriptor = @import("main.zig").ComputePassDescriptor;
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const ImageCopyBuffer = @import("types.zig").ImageCopyBuffer; const ImageCopyBuffer = @import("main.zig").ImageCopyBuffer;
const ImageCopyTexture = @import("types.zig").ImageCopyTexture; const ImageCopyTexture = @import("main.zig").ImageCopyTexture;
const Extent3D = @import("types.zig").Extent3D; const Extent3D = @import("main.zig").Extent3D;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
const dawn = @import("dawn.zig"); const dawn = @import("dawn.zig");

View file

@ -1,5 +1,5 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const ProgrammableStageDescriptor = @import("types.zig").ProgrammableStageDescriptor; const ProgrammableStageDescriptor = @import("main.zig").ProgrammableStageDescriptor;
const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout; const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout;
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout; const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;

View file

@ -1,6 +1,6 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const ChainedStructOut = @import("types.zig").ChainedStructOut; const ChainedStructOut = @import("main.zig").ChainedStructOut;
const PowerPreference = @import("types.zig").PowerPreference; const PowerPreference = @import("main.zig").PowerPreference;
const Texture = @import("texture.zig").Texture; const Texture = @import("texture.zig").Texture;
pub const Interface = @import("dawn_impl.zig").Interface; pub const Interface = @import("dawn_impl.zig").Interface;

View file

@ -16,18 +16,18 @@ const ShaderModule = @import("shader_module.zig").ShaderModule;
const Surface = @import("surface.zig").Surface; const Surface = @import("surface.zig").Surface;
const SwapChain = @import("swap_chain.zig").SwapChain; const SwapChain = @import("swap_chain.zig").SwapChain;
const Texture = @import("texture.zig").Texture; const Texture = @import("texture.zig").Texture;
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const FeatureName = @import("types.zig").FeatureName; const FeatureName = @import("main.zig").FeatureName;
const RequiredLimits = @import("types.zig").RequiredLimits; const RequiredLimits = @import("main.zig").RequiredLimits;
const SupportedLimits = @import("types.zig").SupportedLimits; const SupportedLimits = @import("main.zig").SupportedLimits;
const ErrorType = @import("types.zig").ErrorType; const ErrorType = @import("main.zig").ErrorType;
const ErrorFilter = @import("types.zig").ErrorFilter; const ErrorFilter = @import("main.zig").ErrorFilter;
const LoggingType = @import("types.zig").LoggingType; const LoggingType = @import("main.zig").LoggingType;
const CreatePipelineAsyncStatus = @import("types.zig").CreatePipelineAsyncStatus; const CreatePipelineAsyncStatus = @import("main.zig").CreatePipelineAsyncStatus;
const LoggingCallback = @import("callbacks.zig").LoggingCallback; const LoggingCallback = @import("main.zig").LoggingCallback;
const ErrorCallback = @import("callbacks.zig").ErrorCallback; const ErrorCallback = @import("main.zig").ErrorCallback;
const CreateComputePipelineAsyncCallback = @import("callbacks.zig").CreateComputePipelineAsyncCallback; const CreateComputePipelineAsyncCallback = @import("main.zig").CreateComputePipelineAsyncCallback;
const CreateRenderPipelineAsyncCallback = @import("callbacks.zig").CreateRenderPipelineAsyncCallback; const CreateRenderPipelineAsyncCallback = @import("main.zig").CreateRenderPipelineAsyncCallback;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
const dawn = @import("dawn.zig"); const dawn = @import("dawn.zig");

View file

@ -1,7 +1,7 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const TextureView = @import("texture_view.zig").TextureView; const TextureView = @import("texture_view.zig").TextureView;
const Origin2D = @import("types.zig").Origin2D; const Origin2D = @import("main.zig").Origin2D;
const Extent2D = @import("types.zig").Extent2D; const Extent2D = @import("main.zig").Extent2D;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const ExternalTexture = opaque { pub const ExternalTexture = opaque {

View file

@ -1,9 +1,9 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const RequestAdapterStatus = @import("types.zig").RequestAdapterStatus; const RequestAdapterStatus = @import("main.zig").RequestAdapterStatus;
const Surface = @import("surface.zig").Surface; const Surface = @import("surface.zig").Surface;
const Adapter = @import("adapter.zig").Adapter; const Adapter = @import("adapter.zig").Adapter;
const RequestAdapterOptions = @import("types.zig").RequestAdapterOptions; const RequestAdapterOptions = @import("main.zig").RequestAdapterOptions;
const RequestAdapterCallback = @import("callbacks.zig").RequestAdapterCallback; const RequestAdapterCallback = @import("main.zig").RequestAdapterCallback;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
const dawn = @import("dawn.zig"); const dawn = @import("dawn.zig");

View file

@ -1,10 +1,10 @@
const std = @import("std"); const std = @import("std");
const testing = std.testing;
pub const Adapter = @import("adapter.zig").Adapter; pub const Adapter = @import("adapter.zig").Adapter;
pub const BindGroup = @import("bind_group.zig").BindGroup; pub const BindGroup = @import("bind_group.zig").BindGroup;
pub const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout; pub const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
pub const Buffer = @import("buffer.zig").Buffer; pub const Buffer = @import("buffer.zig").Buffer;
pub usingnamespace @import("callbacks.zig");
pub const CommandBuffer = @import("command_buffer.zig").CommandBuffer; pub const CommandBuffer = @import("command_buffer.zig").CommandBuffer;
pub const CommandEncoder = @import("command_encoder.zig").CommandEncoder; pub const CommandEncoder = @import("command_encoder.zig").CommandEncoder;
pub const ComputePassEncoder = @import("compute_pass_encoder.zig").ComputePassEncoder; pub const ComputePassEncoder = @import("compute_pass_encoder.zig").ComputePassEncoder;
@ -27,13 +27,9 @@ pub const Texture = @import("texture.zig").Texture;
pub const TextureView = @import("texture_view.zig").TextureView; pub const TextureView = @import("texture_view.zig").TextureView;
pub const dawn = @import("dawn.zig"); pub const dawn = @import("dawn.zig");
pub usingnamespace @import("types.zig");
const instance = @import("instance.zig"); const instance = @import("instance.zig");
const device = @import("device.zig"); const device = @import("device.zig");
const interface = @import("interface.zig"); const interface = @import("interface.zig");
const types = @import("types.zig");
pub const Impl = interface.Impl; pub const Impl = interface.Impl;
pub const StubInterface = interface.StubInterface; pub const StubInterface = interface.StubInterface;
@ -44,10 +40,894 @@ pub inline fn createInstance(descriptor: ?*const instance.Instance.Descriptor) ?
return Impl.createInstance(descriptor); return Impl.createInstance(descriptor);
} }
pub inline fn getProcAddress(_device: *device.Device, proc_name: [*:0]const u8) ?types.Proc { pub inline fn getProcAddress(_device: *device.Device, proc_name: [*:0]const u8) ?Proc {
return Impl.getProcAddress(_device, proc_name); return Impl.getProcAddress(_device, proc_name);
} }
pub const array_layer_count_undef = 0xffffffff;
pub const copy_stride_undef = 0xffffffff;
pub const limit_u32_undef = 0xffffffff;
pub const limit_u64_undef = 0xffffffffffffffff;
pub const mip_level_count_undef = 0xffffffff;
pub const whole_map_size = std.math.maxInt(usize);
pub const whole_size = 0xffffffffffffffff;
/// Generic function pointer type, used for returning API function pointers. Must be
/// cast to the right `fn (...) callconv(.C) T` type before use.
pub const Proc = *const fn () callconv(.C) void;
pub const ComputePassTimestampWrite = extern struct {
query_set: *QuerySet,
query_index: u32,
location: ComputePassTimestampLocation,
};
pub const RenderPassDepthStencilAttachment = extern struct {
view: *TextureView,
depth_load_op: LoadOp = .undefined,
depth_store_op: StoreOp = .undefined,
/// deprecated
clear_depth: f32 = std.math.nan(f32),
depth_clear_value: f32 = 0,
depth_read_only: bool = false,
stencil_load_op: LoadOp = .undefined,
stencil_store_op: StoreOp = .undefined,
/// deprecated
clear_stencil: u32 = 0,
stencil_clear_value: u32 = 0,
stencil_read_only: bool = false,
};
pub const RenderPassTimestampWrite = extern struct {
query_set: *QuerySet,
query_index: u32,
location: RenderPassTimestampLocation,
};
pub const RequestAdapterOptions = extern struct {
next_in_chain: ?*const ChainedStruct = null,
compatible_surface: ?*Surface = null,
power_preference: PowerPreference = .undefined,
force_fallback_adapter: bool = false,
};
pub const ComputePassDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
timestamp_write_count: u32 = 0,
timestamp_writes: ?[*]const ComputePassTimestampWrite = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
timestamp_writes: ?[]const ComputePassTimestampWrite = null,
}) ComputePassDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.label = v.label,
.timestamp_write_count = if (v.timestamp_writes) |e| @intCast(u32, e.len) else 0,
.timestamp_writes = if (v.timestamp_writes) |e| e.ptr else null,
};
}
};
pub const RenderPassDescriptor = extern struct {
pub const NextInChain = extern union {
generic: ?*const ChainedStruct,
max_draw_count: *const RenderPassDescriptorMaxDrawCount,
};
next_in_chain: NextInChain = .{ .generic = null },
label: ?[*:0]const u8 = null,
color_attachment_count: u32 = 0,
color_attachments: ?[*]const RenderPassColorAttachment = null,
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,
occlusion_query_set: ?*QuerySet = null,
timestamp_write_count: u32 = 0,
timestamp_writes: ?[*]const RenderPassTimestampWrite = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: NextInChain = .{ .generic = null },
label: ?[*:0]const u8 = null,
color_attachments: ?[]const RenderPassColorAttachment = null,
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,
occlusion_query_set: ?*QuerySet = null,
timestamp_writes: ?[]const RenderPassTimestampWrite = null,
}) RenderPassDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.label = v.label,
.color_attachment_count = if (v.color_attachments) |e| @intCast(u32, e.len) else 0,
.color_attachments = if (v.color_attachments) |e| e.ptr else null,
.depth_stencil_attachment = v.depth_stencil_attachment,
.occlusion_query_set = v.occlusion_query_set,
.timestamp_write_count = if (v.timestamp_writes) |e| @intCast(u32, e.len) else 0,
.timestamp_writes = if (v.timestamp_writes) |e| e.ptr else null,
};
}
};
pub const AlphaMode = enum(u32) { premultiplied = 0x00000000, unpremultiplied = 0x00000001, opaq = 0x00000002 };
pub const BackendType = enum(u32) {
null,
webgpu,
d3d11,
d3d12,
metal,
vulkan,
opengl,
opengles,
pub fn name(t: BackendType) []const u8 {
return switch (t) {
.null => "Null",
.webgpu => "WebGPU",
.d3d11 => "D3D11",
.d3d12 => "D3D12",
.metal => "Metal",
.vulkan => "Vulkan",
.opengl => "OpenGL",
.opengles => "OpenGLES",
};
}
};
pub const BlendFactor = enum(u32) {
zero = 0x00000000,
one = 0x00000001,
src = 0x00000002,
one_minus_src = 0x00000003,
src_alpha = 0x00000004,
one_minus_src_alpha = 0x00000005,
dst = 0x00000006,
one_minus_dst = 0x00000007,
dst_alpha = 0x00000008,
one_minus_dst_alpha = 0x00000009,
src_alpha_saturated = 0x0000000A,
constant = 0x0000000B,
one_minus_constant = 0x0000000C,
};
pub const BlendOperation = enum(u32) {
add = 0x00000000,
subtract = 0x00000001,
reverse_subtract = 0x00000002,
min = 0x00000003,
max = 0x00000004,
};
pub const CompareFunction = enum(u32) {
undefined = 0x00000000,
never = 0x00000001,
less = 0x00000002,
less_equal = 0x00000003,
greater = 0x00000004,
greater_equal = 0x00000005,
equal = 0x00000006,
not_equal = 0x00000007,
always = 0x00000008,
};
pub const CompilationInfoRequestStatus = enum(u32) {
success = 0x00000000,
err = 0x00000001,
device_lost = 0x00000002,
unknown = 0x00000003,
};
pub const CompilationMessageType = enum(u32) {
err = 0x00000000,
warning = 0x00000001,
info = 0x00000002,
};
pub const ComputePassTimestampLocation = enum(u32) {
beginning = 0x00000000,
end = 0x00000001,
};
pub const CreatePipelineAsyncStatus = enum(u32) {
success = 0x00000000,
err = 0x00000001,
device_lost = 0x00000002,
device_destroyed = 0x00000003,
unknown = 0x00000004,
};
pub const CullMode = enum(u32) {
none = 0x00000000,
front = 0x00000001,
back = 0x00000002,
};
pub const ErrorFilter = enum(u32) {
validation = 0x00000000,
out_of_memory = 0x00000001,
internal = 0x00000002,
};
pub const ErrorType = enum(u32) {
no_error = 0x00000000,
validation = 0x00000001,
out_of_memory = 0x00000002,
internal = 0x00000003,
unknown = 0x00000004,
device_lost = 0x00000005,
};
pub const FeatureName = enum(u32) {
undefined = 0x00000000,
depth_clip_control = 0x00000001,
depth32_float_stencil8 = 0x00000002,
timestamp_query = 0x00000003,
pipeline_statistics_query = 0x00000004,
texture_compression_bc = 0x00000005,
texture_compression_etc2 = 0x00000006,
texture_compression_astc = 0x00000007,
indirect_first_instance = 0x00000008,
shader_f16 = 0x00000009,
rg11_b10_ufloat_renderable = 0x0000000A,
dawn_shader_float16 = 0x000003e9,
dawn_internal_usages = 0x000003ea,
dawn_multi_planar_formats = 0x000003eb,
dawn_native = 0x000003ec,
chromium_experimental_dp4a = 0x000003ed,
timestamp_query_inside_passes = 0x000003EE,
};
pub const FilterMode = enum(u32) {
nearest = 0x00000000,
linear = 0x00000001,
};
pub const FrontFace = enum(u32) {
ccw = 0x00000000,
cw = 0x00000001,
};
pub const IndexFormat = enum(u32) {
undefined = 0x00000000,
uint16 = 0x00000001,
uint32 = 0x00000002,
};
pub const LoadOp = enum(u32) {
undefined = 0x00000000,
clear = 0x00000001,
load = 0x00000002,
};
pub const LoggingType = enum(u32) {
verbose = 0x00000000,
info = 0x00000001,
warning = 0x00000002,
err = 0x00000003,
};
pub const PipelineStatisticName = enum(u32) {
vertex_shader_invocations = 0x00000000,
clipper_invocations = 0x00000001,
clipper_primitives_out = 0x00000002,
fragment_shader_invocations = 0x00000003,
compute_shader_invocations = 0x00000004,
};
pub const PowerPreference = enum(u32) {
undefined = 0x00000000,
low_power = 0x00000001,
high_performance = 0x00000002,
};
pub const PresentMode = enum(u32) {
immediate = 0x00000000,
mailbox = 0x00000001,
fifo = 0x00000002,
};
pub const PrimitiveTopology = enum(u32) {
point_list = 0x00000000,
line_list = 0x00000001,
line_strip = 0x00000002,
triangle_list = 0x00000003,
triangle_strip = 0x00000004,
};
pub const QueryType = enum(u32) {
occlusion = 0x00000000,
pipeline_statistics = 0x00000001,
timestamp = 0x00000002,
};
pub const RenderPassTimestampLocation = enum(u32) {
beginning = 0x00000000,
end = 0x00000001,
};
pub const RequestAdapterStatus = enum(u32) {
success = 0x00000000,
unavailable = 0x00000001,
err = 0x00000002,
unknown = 0x00000003,
};
pub const RequestDeviceStatus = enum(u32) {
success = 0x00000000,
err = 0x00000001,
unknown = 0x00000002,
};
pub const SType = enum(u32) {
invalid = 0x00000000,
surface_descriptor_from_metal_layer = 0x00000001,
surface_descriptor_from_windows_hwnd = 0x00000002,
surface_descriptor_from_xlib_window = 0x00000003,
surface_descriptor_from_canvas_html_selector = 0x00000004,
shader_module_spirv_descriptor = 0x00000005,
shader_module_wgsl_descriptor = 0x00000006,
primitive_depth_clip_control = 0x00000007,
surface_descriptor_from_wayland_surface = 0x00000008,
surface_descriptor_from_android_native_window = 0x00000009,
surface_descriptor_from_windows_core_window = 0x0000000B,
external_texture_binding_entry = 0x0000000C,
external_texture_binding_layout = 0x0000000D,
surface_descriptor_from_windows_swap_chain_panel = 0x0000000E,
render_pass_descriptor_max_draw_count = 0x0000000F,
dawn_texture_internal_usage_descriptor = 0x000003E8,
dawn_toggles_device_descriptor = 0x000003EA,
dawn_encoder_internal_usage_descriptor = 0x000003EB,
dawn_instance_descriptor = 0x000003EC,
dawn_cache_device_descriptor = 0x000003ED,
dawn_adapter_properties_power_preference = 0x000003EE,
dawn_buffer_descriptor_error_info_from_wire_client = 0x000003EF,
};
pub const StencilOperation = enum(u32) {
keep = 0x00000000,
zero = 0x00000001,
replace = 0x00000002,
invert = 0x00000003,
increment_clamp = 0x00000004,
decrement_clamp = 0x00000005,
increment_wrap = 0x00000006,
decrement_wrap = 0x00000007,
};
pub const StorageTextureAccess = enum(u32) {
undefined = 0x00000000,
write_only = 0x00000001,
};
pub const StoreOp = enum(u32) {
undefined = 0x00000000,
store = 0x00000001,
discard = 0x00000002,
};
pub const VertexFormat = enum(u32) {
undefined = 0x00000000,
uint8x2 = 0x00000001,
uint8x4 = 0x00000002,
sint8x2 = 0x00000003,
sint8x4 = 0x00000004,
unorm8x2 = 0x00000005,
unorm8x4 = 0x00000006,
snorm8x2 = 0x00000007,
snorm8x4 = 0x00000008,
uint16x2 = 0x00000009,
uint16x4 = 0x0000000a,
sint16x2 = 0x0000000b,
sint16x4 = 0x0000000c,
unorm16x2 = 0x0000000d,
unorm16x4 = 0x0000000e,
snorm16x2 = 0x0000000f,
snorm16x4 = 0x00000010,
float16x2 = 0x00000011,
float16x4 = 0x00000012,
float32 = 0x00000013,
float32x2 = 0x00000014,
float32x3 = 0x00000015,
float32x4 = 0x00000016,
uint32 = 0x00000017,
uint32x2 = 0x00000018,
uint32x3 = 0x00000019,
uint32x4 = 0x0000001a,
sint32 = 0x0000001b,
sint32x2 = 0x0000001c,
sint32x3 = 0x0000001d,
sint32x4 = 0x0000001e,
};
pub const VertexStepMode = enum(u32) {
vertex = 0x00000000,
instance = 0x00000001,
vertex_buffer_not_used = 0x00000002,
};
pub const ColorWriteMaskFlags = packed struct(u32) {
red: bool = false,
green: bool = false,
blue: bool = false,
alpha: bool = false,
_padding: u28 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const all = ColorWriteMaskFlags{
.red = true,
.green = true,
.blue = true,
.alpha = true,
};
pub fn equal(a: ColorWriteMaskFlags, b: ColorWriteMaskFlags) bool {
return @truncate(u4, @bitCast(u32, a)) == @truncate(u4, @bitCast(u32, b));
}
};
pub const MapModeFlags = packed struct(u32) {
read: bool = false,
write: bool = false,
_padding: u30 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const undef = MapModeFlags{};
pub fn equal(a: MapModeFlags, b: MapModeFlags) bool {
return @truncate(u2, @bitCast(u32, a)) == @truncate(u2, @bitCast(u32, b));
}
};
pub const ShaderStageFlags = packed struct(u32) {
vertex: bool = false,
fragment: bool = false,
compute: bool = false,
_padding: u29 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const none = ShaderStageFlags{};
pub fn equal(a: ShaderStageFlags, b: ShaderStageFlags) bool {
return @truncate(u3, @bitCast(u32, a)) == @truncate(u3, @bitCast(u32, b));
}
};
pub const ChainedStruct = extern struct {
// TODO: dawn: not marked as nullable in dawn.json but in fact is.
next: ?*const ChainedStruct = null,
s_type: SType,
};
pub const ChainedStructOut = extern struct {
// TODO: dawn: not marked as nullable in dawn.json but in fact is.
next: ?*ChainedStructOut = null,
s_type: SType,
};
pub const BlendComponent = extern struct {
operation: BlendOperation = .add,
src_factor: BlendFactor = .one,
dst_factor: BlendFactor = .zero,
};
pub const Color = extern struct {
r: f64,
g: f64,
b: f64,
a: f64,
};
pub const Extent2D = extern struct {
width: u32,
height: u32 = 1,
};
pub const Extent3D = extern struct {
width: u32,
height: u32 = 1,
depth_or_array_layers: u32 = 1,
};
pub const Limits = extern struct {
max_texture_dimension_1d: u32 = limit_u32_undef,
max_texture_dimension_2d: u32 = limit_u32_undef,
max_texture_dimension_3d: u32 = limit_u32_undef,
max_texture_array_layers: u32 = limit_u32_undef,
max_bind_groups: u32 = limit_u32_undef,
max_bindings_per_bind_group: u32 = limit_u32_undef,
max_dynamic_uniform_buffers_per_pipeline_layout: u32 = limit_u32_undef,
max_dynamic_storage_buffers_per_pipeline_layout: u32 = limit_u32_undef,
max_sampled_textures_per_shader_stage: u32 = limit_u32_undef,
max_samplers_per_shader_stage: u32 = limit_u32_undef,
max_storage_buffers_per_shader_stage: u32 = limit_u32_undef,
max_storage_textures_per_shader_stage: u32 = limit_u32_undef,
max_uniform_buffers_per_shader_stage: u32 = limit_u32_undef,
max_uniform_buffer_binding_size: u64 = limit_u64_undef,
max_storage_buffer_binding_size: u64 = limit_u64_undef,
min_uniform_buffer_offset_alignment: u32 = limit_u32_undef,
min_storage_buffer_offset_alignment: u32 = limit_u32_undef,
max_vertex_buffers: u32 = limit_u32_undef,
max_buffer_size: u64 = limit_u64_undef,
max_vertex_attributes: u32 = limit_u32_undef,
max_vertex_buffer_array_stride: u32 = limit_u32_undef,
max_inter_stage_shader_components: u32 = limit_u32_undef,
max_inter_stage_shader_variables: u32 = limit_u32_undef,
max_color_attachments: u32 = limit_u32_undef,
max_color_attachment_bytes_per_sample: u32 = limit_u32_undef,
max_compute_workgroup_storage_size: u32 = limit_u32_undef,
max_compute_invocations_per_workgroup: u32 = limit_u32_undef,
max_compute_workgroup_size_x: u32 = limit_u32_undef,
max_compute_workgroup_size_y: u32 = limit_u32_undef,
max_compute_workgroup_size_z: u32 = limit_u32_undef,
max_compute_workgroups_per_dimension: u32 = limit_u32_undef,
};
pub const Origin2D = extern struct {
x: u32 = 0,
y: u32 = 0,
};
pub const Origin3D = extern struct {
x: u32 = 0,
y: u32 = 0,
z: u32 = 0,
};
pub const CompilationMessage = extern struct {
next_in_chain: ?*const ChainedStruct = null,
message: ?[*:0]const u8 = null,
type: CompilationMessageType,
line_num: u64,
line_pos: u64,
offset: u64,
length: u64,
utf16_line_pos: u64,
utf16_offset: u64,
utf16_length: u64,
};
pub const ConstantEntry = extern struct {
next_in_chain: ?*const ChainedStruct = null,
key: [*:0]const u8,
value: f64,
};
pub const CopyTextureForBrowserOptions = extern struct {
next_in_chain: ?*const ChainedStruct = null,
flip_y: bool = false,
needs_color_space_conversion: bool = false,
src_alpha_mode: AlphaMode = .unpremultiplied,
src_transfer_function_parameters: ?*const [7]f32 = null,
conversion_matrix: ?*const [9]f32 = null,
dst_transfer_function_parameters: ?*const [7]f32 = null,
dst_alpha_mode: AlphaMode = .unpremultiplied,
internal_usage: bool = false,
};
pub const MultisampleState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
count: u32 = 1,
mask: u32 = 0xFFFFFFFF,
alpha_to_coverage_enabled: bool = false,
};
pub const PrimitiveDepthClipControl = extern struct {
chain: ChainedStruct = .{ .next = null, .s_type = .primitive_depth_clip_control },
unclipped_depth: bool = false,
};
pub const PrimitiveState = extern struct {
pub const NextInChain = extern union {
generic: ?*const ChainedStruct,
primitive_depth_clip_control: *const PrimitiveDepthClipControl,
};
next_in_chain: NextInChain = .{ .generic = null },
topology: PrimitiveTopology = .triangle_list,
strip_index_format: IndexFormat = .undefined,
front_face: FrontFace = .ccw,
cull_mode: CullMode = .none,
};
pub const RenderPassDescriptorMaxDrawCount = extern struct {
chain: ChainedStruct = .{ .next = null, .s_type = .render_pass_descriptor_max_draw_count },
max_draw_count: u64 = 50000000,
};
pub const StencilFaceState = extern struct {
compare: CompareFunction = .always,
fail_op: StencilOperation = .keep,
depth_fail_op: StencilOperation = .keep,
pass_op: StencilOperation = .keep,
};
pub const StorageTextureBindingLayout = extern struct {
next_in_chain: ?*const ChainedStruct = null,
access: StorageTextureAccess = .undefined,
format: Texture.Format = .undefined,
view_dimension: TextureView.Dimension = .dimension_undef,
};
pub const VertexAttribute = extern struct {
format: VertexFormat,
offset: u64,
shader_location: u32,
};
pub const BlendState = extern struct {
color: BlendComponent = .{},
alpha: BlendComponent = .{},
};
pub const CompilationInfo = extern struct {
next_in_chain: ?*const ChainedStruct = null,
message_count: u32,
messages: ?[*]const CompilationMessage = null,
/// Helper to get messages as a slice.
pub fn getMessages(info: CompilationInfo) ?[]const CompilationMessage {
if (info.messages) |messages| {
return messages[0..info.message_count];
}
return null;
}
};
pub const DepthStencilState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
format: Texture.Format,
depth_write_enabled: bool = false,
depth_compare: CompareFunction = .always,
stencil_front: StencilFaceState = .{},
stencil_back: StencilFaceState = .{},
stencil_read_mask: u32 = 0xFFFFFFFF,
stencil_write_mask: u32 = 0xFFFFFFFF,
depth_bias: i32 = 0,
depth_bias_slope_scale: f32 = 0.0,
depth_bias_clamp: f32 = 0.0,
};
pub const ImageCopyBuffer = extern struct {
next_in_chain: ?*const ChainedStruct = null,
layout: Texture.DataLayout,
buffer: *Buffer,
};
pub const ImageCopyExternalTexture = extern struct {
next_in_chain: ?*const ChainedStruct = null,
external_texture: *ExternalTexture,
origin: Origin3D,
};
pub const ImageCopyTexture = extern struct {
next_in_chain: ?*const ChainedStruct = null,
texture: *Texture,
mip_level: u32 = 0,
origin: Origin3D = .{},
aspect: Texture.Aspect = .all,
};
pub const ProgrammableStageDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constant_count: u32 = 0,
constants: ?[*]const ConstantEntry = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constants: ?[]const ConstantEntry = null,
}) ProgrammableStageDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.module = v.module,
.entry_point = v.entry_point,
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
.constants = if (v.constants) |e| e.ptr else null,
};
}
};
pub const RenderPassColorAttachment = extern struct {
view: ?*TextureView = null,
resolve_target: ?*TextureView = null,
load_op: LoadOp,
store_op: StoreOp,
/// deprecated
clear_color: Color = .{
.r = std.math.nan(f64),
.g = std.math.nan(f64),
.b = std.math.nan(f64),
.a = std.math.nan(f64),
},
clear_value: Color,
};
pub const RequiredLimits = extern struct {
next_in_chain: ?*const ChainedStruct = null,
limits: Limits,
};
/// Used to query limits from a Device or Adapter. Can be used as follows:
///
/// ```
/// var supported: gpu.SupportedLimits = .{};
/// if (!adapter.getLimits(&supported)) @panic("unsupported options");
/// ```
///
/// Note that `getLimits` can only fail if `next_in_chain` options are invalid.
pub const SupportedLimits = extern struct {
next_in_chain: ?*ChainedStructOut = null,
limits: Limits = undefined,
};
pub const VertexBufferLayout = extern struct {
array_stride: u64,
step_mode: VertexStepMode = .vertex,
attribute_count: u32,
attributes: ?[*]const VertexAttribute = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
array_stride: u64,
step_mode: VertexStepMode = .vertex,
attributes: ?[]const VertexAttribute = null,
}) VertexBufferLayout {
return .{
.array_stride = v.array_stride,
.step_mode = v.step_mode,
.attribute_count = if (v.attributes) |e| @intCast(u32, e.len) else 0,
.attributes = if (v.attributes) |e| e.ptr else null,
};
}
};
pub const ColorTargetState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
format: Texture.Format,
blend: ?*const BlendState = null,
write_mask: ColorWriteMaskFlags = ColorWriteMaskFlags.all,
};
pub const VertexState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constant_count: u32 = 0,
constants: ?[*]const ConstantEntry = null,
buffer_count: u32 = 0,
buffers: ?[*]const VertexBufferLayout = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constants: ?[]const ConstantEntry = null,
buffers: ?[]const VertexBufferLayout = null,
}) VertexState {
return .{
.next_in_chain = v.next_in_chain,
.module = v.module,
.entry_point = v.entry_point,
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
.constants = if (v.constants) |e| e.ptr else null,
.buffer_count = if (v.buffers) |e| @intCast(u32, e.len) else 0,
.buffers = if (v.buffers) |e| e.ptr else null,
};
}
};
pub const FragmentState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constant_count: u32 = 0,
constants: ?[*]const ConstantEntry = null,
target_count: u32,
targets: ?[*]const ColorTargetState = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constants: ?[]const ConstantEntry = null,
targets: ?[]const ColorTargetState = null,
}) FragmentState {
return .{
.next_in_chain = v.next_in_chain,
.module = v.module,
.entry_point = v.entry_point,
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
.constants = if (v.constants) |e| e.ptr else null,
.target_count = if (v.targets) |e| @intCast(u32, e.len) else 0,
.targets = if (v.targets) |e| e.ptr else null,
};
}
};
test "BackendType name" {
try testing.expectEqualStrings("Vulkan", BackendType.vulkan.name());
}
test "enum name" {
try testing.expectEqualStrings("front", @tagName(CullMode.front));
}
pub const CompilationInfoCallback = *const fn (
status: CompilationInfoRequestStatus,
compilation_info: *const CompilationInfo,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const ErrorCallback = *const fn (
typ: ErrorType,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const LoggingCallback = *const fn (
typ: LoggingType,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const RequestDeviceCallback = *const fn (
status: RequestDeviceStatus,
device: *Device,
message: ?[*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const RequestAdapterCallback = *const fn (
status: RequestAdapterStatus,
adapter: *Adapter,
message: ?[*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const CreateComputePipelineAsyncCallback = *const fn (
status: CreatePipelineAsyncStatus,
compute_pipeline: *ComputePipeline,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
pub const CreateRenderPipelineAsyncCallback = *const fn (
status: CreatePipelineAsyncStatus,
pipeline: *RenderPipeline,
message: [*:0]const u8,
userdata: ?*anyopaque,
) callconv(.C) void;
test { test {
std.testing.refAllDeclsRecursive(@This()); std.testing.refAllDeclsRecursive(@This());
} }

View file

@ -1,4 +1,4 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout; const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;

View file

@ -1,6 +1,6 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const PipelineStatisticName = @import("types.zig").PipelineStatisticName; const PipelineStatisticName = @import("main.zig").PipelineStatisticName;
const QueryType = @import("types.zig").QueryType; const QueryType = @import("main.zig").QueryType;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const QuerySet = opaque { pub const QuerySet = opaque {

View file

@ -2,11 +2,11 @@ const std = @import("std");
const CommandBuffer = @import("command_buffer.zig").CommandBuffer; const CommandBuffer = @import("command_buffer.zig").CommandBuffer;
const Buffer = @import("buffer.zig").Buffer; const Buffer = @import("buffer.zig").Buffer;
const Texture = @import("texture.zig").Texture; const Texture = @import("texture.zig").Texture;
const ImageCopyTexture = @import("types.zig").ImageCopyTexture; const ImageCopyTexture = @import("main.zig").ImageCopyTexture;
const ImageCopyExternalTexture = @import("types.zig").ImageCopyExternalTexture; const ImageCopyExternalTexture = @import("main.zig").ImageCopyExternalTexture;
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const Extent3D = @import("types.zig").Extent3D; const Extent3D = @import("main.zig").Extent3D;
const CopyTextureForBrowserOptions = @import("types.zig").CopyTextureForBrowserOptions; const CopyTextureForBrowserOptions = @import("main.zig").CopyTextureForBrowserOptions;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const Queue = opaque { pub const Queue = opaque {

View file

@ -1,4 +1,4 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const RenderBundle = opaque { pub const RenderBundle = opaque {

View file

@ -3,8 +3,8 @@ const Buffer = @import("buffer.zig").Buffer;
const BindGroup = @import("bind_group.zig").BindGroup; const BindGroup = @import("bind_group.zig").BindGroup;
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline; const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
const RenderBundle = @import("render_bundle.zig").RenderBundle; const RenderBundle = @import("render_bundle.zig").RenderBundle;
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const IndexFormat = @import("types.zig").IndexFormat; const IndexFormat = @import("main.zig").IndexFormat;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const RenderBundleEncoder = opaque { pub const RenderBundleEncoder = opaque {

View file

@ -3,8 +3,8 @@ const RenderBundle = @import("render_bundle.zig").RenderBundle;
const BindGroup = @import("bind_group.zig").BindGroup; const BindGroup = @import("bind_group.zig").BindGroup;
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline; const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
const QuerySet = @import("query_set.zig").QuerySet; const QuerySet = @import("query_set.zig").QuerySet;
const Color = @import("types.zig").Color; const Color = @import("main.zig").Color;
const IndexFormat = @import("types.zig").IndexFormat; const IndexFormat = @import("main.zig").IndexFormat;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const RenderPassEncoder = opaque { pub const RenderPassEncoder = opaque {

View file

@ -1,9 +1,9 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const DepthStencilState = @import("types.zig").DepthStencilState; const DepthStencilState = @import("main.zig").DepthStencilState;
const MultisampleState = @import("types.zig").MultisampleState; const MultisampleState = @import("main.zig").MultisampleState;
const VertexState = @import("types.zig").VertexState; const VertexState = @import("main.zig").VertexState;
const PrimitiveState = @import("types.zig").PrimitiveState; const PrimitiveState = @import("main.zig").PrimitiveState;
const FragmentState = @import("types.zig").FragmentState; const FragmentState = @import("main.zig").FragmentState;
const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout; const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout;
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout; const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;

View file

@ -1,6 +1,6 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const FilterMode = @import("types.zig").FilterMode; const FilterMode = @import("main.zig").FilterMode;
const CompareFunction = @import("types.zig").CompareFunction; const CompareFunction = @import("main.zig").CompareFunction;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const Sampler = opaque { pub const Sampler = opaque {

View file

@ -1,7 +1,7 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const CompilationInfoCallback = @import("callbacks.zig").CompilationInfoCallback; const CompilationInfoCallback = @import("main.zig").CompilationInfoCallback;
const CompilationInfoRequestStatus = @import("types.zig").CompilationInfoRequestStatus; const CompilationInfoRequestStatus = @import("main.zig").CompilationInfoRequestStatus;
const CompilationInfo = @import("types.zig").CompilationInfo; const CompilationInfo = @import("main.zig").CompilationInfo;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const ShaderModule = opaque { pub const ShaderModule = opaque {

View file

@ -1,4 +1,4 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
pub const Surface = opaque { pub const Surface = opaque {

View file

@ -1,5 +1,5 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const PresentMode = @import("types.zig").PresentMode; const PresentMode = @import("main.zig").PresentMode;
const Texture = @import("texture.zig").Texture; const Texture = @import("texture.zig").Texture;
const TextureView = @import("texture_view.zig").TextureView; const TextureView = @import("texture_view.zig").TextureView;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;

View file

@ -1,9 +1,9 @@
const std = @import("std"); const std = @import("std");
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const TextureView = @import("texture_view.zig").TextureView; const TextureView = @import("texture_view.zig").TextureView;
const Extent3D = @import("types.zig").Extent3D; const Extent3D = @import("main.zig").Extent3D;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
const types = @import("types.zig"); const types = @import("main.zig");
const dawn = @import("dawn.zig"); const dawn = @import("dawn.zig");
pub const Texture = opaque { pub const Texture = opaque {

View file

@ -1,7 +1,7 @@
const ChainedStruct = @import("types.zig").ChainedStruct; const ChainedStruct = @import("main.zig").ChainedStruct;
const Texture = @import("texture.zig").Texture; const Texture = @import("texture.zig").Texture;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
const types = @import("types.zig"); const types = @import("main.zig");
pub const TextureView = opaque { pub const TextureView = opaque {
pub const Dimension = enum(u32) { pub const Dimension = enum(u32) {

View file

@ -1,845 +0,0 @@
const std = @import("std");
const testing = std.testing;
const Texture = @import("texture.zig").Texture;
const ExternalTexture = @import("external_texture.zig").ExternalTexture;
const TextureView = @import("texture_view.zig").TextureView;
const Buffer = @import("buffer.zig").Buffer;
const ShaderModule = @import("shader_module.zig").ShaderModule;
const QuerySet = @import("query_set.zig").QuerySet;
const Surface = @import("surface.zig").Surface;
pub const array_layer_count_undef = 0xffffffff;
pub const copy_stride_undef = 0xffffffff;
pub const limit_u32_undef = 0xffffffff;
pub const limit_u64_undef = 0xffffffffffffffff;
pub const mip_level_count_undef = 0xffffffff;
pub const whole_map_size = std.math.maxInt(usize);
pub const whole_size = 0xffffffffffffffff;
/// Generic function pointer type, used for returning API function pointers. Must be
/// cast to the right `fn (...) callconv(.C) T` type before use.
pub const Proc = *const fn () callconv(.C) void;
pub const ComputePassTimestampWrite = extern struct {
query_set: *QuerySet,
query_index: u32,
location: ComputePassTimestampLocation,
};
pub const RenderPassDepthStencilAttachment = extern struct {
view: *TextureView,
depth_load_op: LoadOp = .undefined,
depth_store_op: StoreOp = .undefined,
/// deprecated
clear_depth: f32 = std.math.nan(f32),
depth_clear_value: f32 = 0,
depth_read_only: bool = false,
stencil_load_op: LoadOp = .undefined,
stencil_store_op: StoreOp = .undefined,
/// deprecated
clear_stencil: u32 = 0,
stencil_clear_value: u32 = 0,
stencil_read_only: bool = false,
};
pub const RenderPassTimestampWrite = extern struct {
query_set: *QuerySet,
query_index: u32,
location: RenderPassTimestampLocation,
};
pub const RequestAdapterOptions = extern struct {
next_in_chain: ?*const ChainedStruct = null,
compatible_surface: ?*Surface = null,
power_preference: PowerPreference = .undefined,
force_fallback_adapter: bool = false,
};
pub const ComputePassDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
timestamp_write_count: u32 = 0,
timestamp_writes: ?[*]const ComputePassTimestampWrite = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
timestamp_writes: ?[]const ComputePassTimestampWrite = null,
}) ComputePassDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.label = v.label,
.timestamp_write_count = if (v.timestamp_writes) |e| @intCast(u32, e.len) else 0,
.timestamp_writes = if (v.timestamp_writes) |e| e.ptr else null,
};
}
};
pub const RenderPassDescriptor = extern struct {
pub const NextInChain = extern union {
generic: ?*const ChainedStruct,
max_draw_count: *const RenderPassDescriptorMaxDrawCount,
};
next_in_chain: NextInChain = .{ .generic = null },
label: ?[*:0]const u8 = null,
color_attachment_count: u32 = 0,
color_attachments: ?[*]const RenderPassColorAttachment = null,
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,
occlusion_query_set: ?*QuerySet = null,
timestamp_write_count: u32 = 0,
timestamp_writes: ?[*]const RenderPassTimestampWrite = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: NextInChain = .{ .generic = null },
label: ?[*:0]const u8 = null,
color_attachments: ?[]const RenderPassColorAttachment = null,
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,
occlusion_query_set: ?*QuerySet = null,
timestamp_writes: ?[]const RenderPassTimestampWrite = null,
}) RenderPassDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.label = v.label,
.color_attachment_count = if (v.color_attachments) |e| @intCast(u32, e.len) else 0,
.color_attachments = if (v.color_attachments) |e| e.ptr else null,
.depth_stencil_attachment = v.depth_stencil_attachment,
.occlusion_query_set = v.occlusion_query_set,
.timestamp_write_count = if (v.timestamp_writes) |e| @intCast(u32, e.len) else 0,
.timestamp_writes = if (v.timestamp_writes) |e| e.ptr else null,
};
}
};
pub const AlphaMode = enum(u32) { premultiplied = 0x00000000, unpremultiplied = 0x00000001, opaq = 0x00000002 };
pub const BackendType = enum(u32) {
null,
webgpu,
d3d11,
d3d12,
metal,
vulkan,
opengl,
opengles,
pub fn name(t: BackendType) []const u8 {
return switch (t) {
.null => "Null",
.webgpu => "WebGPU",
.d3d11 => "D3D11",
.d3d12 => "D3D12",
.metal => "Metal",
.vulkan => "Vulkan",
.opengl => "OpenGL",
.opengles => "OpenGLES",
};
}
};
pub const BlendFactor = enum(u32) {
zero = 0x00000000,
one = 0x00000001,
src = 0x00000002,
one_minus_src = 0x00000003,
src_alpha = 0x00000004,
one_minus_src_alpha = 0x00000005,
dst = 0x00000006,
one_minus_dst = 0x00000007,
dst_alpha = 0x00000008,
one_minus_dst_alpha = 0x00000009,
src_alpha_saturated = 0x0000000A,
constant = 0x0000000B,
one_minus_constant = 0x0000000C,
};
pub const BlendOperation = enum(u32) {
add = 0x00000000,
subtract = 0x00000001,
reverse_subtract = 0x00000002,
min = 0x00000003,
max = 0x00000004,
};
pub const CompareFunction = enum(u32) {
undefined = 0x00000000,
never = 0x00000001,
less = 0x00000002,
less_equal = 0x00000003,
greater = 0x00000004,
greater_equal = 0x00000005,
equal = 0x00000006,
not_equal = 0x00000007,
always = 0x00000008,
};
pub const CompilationInfoRequestStatus = enum(u32) {
success = 0x00000000,
err = 0x00000001,
device_lost = 0x00000002,
unknown = 0x00000003,
};
pub const CompilationMessageType = enum(u32) {
err = 0x00000000,
warning = 0x00000001,
info = 0x00000002,
};
pub const ComputePassTimestampLocation = enum(u32) {
beginning = 0x00000000,
end = 0x00000001,
};
pub const CreatePipelineAsyncStatus = enum(u32) {
success = 0x00000000,
err = 0x00000001,
device_lost = 0x00000002,
device_destroyed = 0x00000003,
unknown = 0x00000004,
};
pub const CullMode = enum(u32) {
none = 0x00000000,
front = 0x00000001,
back = 0x00000002,
};
pub const ErrorFilter = enum(u32) {
validation = 0x00000000,
out_of_memory = 0x00000001,
internal = 0x00000002,
};
pub const ErrorType = enum(u32) {
no_error = 0x00000000,
validation = 0x00000001,
out_of_memory = 0x00000002,
internal = 0x00000003,
unknown = 0x00000004,
device_lost = 0x00000005,
};
pub const FeatureName = enum(u32) {
undefined = 0x00000000,
depth_clip_control = 0x00000001,
depth32_float_stencil8 = 0x00000002,
timestamp_query = 0x00000003,
pipeline_statistics_query = 0x00000004,
texture_compression_bc = 0x00000005,
texture_compression_etc2 = 0x00000006,
texture_compression_astc = 0x00000007,
indirect_first_instance = 0x00000008,
shader_f16 = 0x00000009,
rg11_b10_ufloat_renderable = 0x0000000A,
dawn_shader_float16 = 0x000003e9,
dawn_internal_usages = 0x000003ea,
dawn_multi_planar_formats = 0x000003eb,
dawn_native = 0x000003ec,
chromium_experimental_dp4a = 0x000003ed,
timestamp_query_inside_passes = 0x000003EE,
};
pub const FilterMode = enum(u32) {
nearest = 0x00000000,
linear = 0x00000001,
};
pub const FrontFace = enum(u32) {
ccw = 0x00000000,
cw = 0x00000001,
};
pub const IndexFormat = enum(u32) {
undefined = 0x00000000,
uint16 = 0x00000001,
uint32 = 0x00000002,
};
pub const LoadOp = enum(u32) {
undefined = 0x00000000,
clear = 0x00000001,
load = 0x00000002,
};
pub const LoggingType = enum(u32) {
verbose = 0x00000000,
info = 0x00000001,
warning = 0x00000002,
err = 0x00000003,
};
pub const PipelineStatisticName = enum(u32) {
vertex_shader_invocations = 0x00000000,
clipper_invocations = 0x00000001,
clipper_primitives_out = 0x00000002,
fragment_shader_invocations = 0x00000003,
compute_shader_invocations = 0x00000004,
};
pub const PowerPreference = enum(u32) {
undefined = 0x00000000,
low_power = 0x00000001,
high_performance = 0x00000002,
};
pub const PresentMode = enum(u32) {
immediate = 0x00000000,
mailbox = 0x00000001,
fifo = 0x00000002,
};
pub const PrimitiveTopology = enum(u32) {
point_list = 0x00000000,
line_list = 0x00000001,
line_strip = 0x00000002,
triangle_list = 0x00000003,
triangle_strip = 0x00000004,
};
pub const QueryType = enum(u32) {
occlusion = 0x00000000,
pipeline_statistics = 0x00000001,
timestamp = 0x00000002,
};
pub const RenderPassTimestampLocation = enum(u32) {
beginning = 0x00000000,
end = 0x00000001,
};
pub const RequestAdapterStatus = enum(u32) {
success = 0x00000000,
unavailable = 0x00000001,
err = 0x00000002,
unknown = 0x00000003,
};
pub const RequestDeviceStatus = enum(u32) {
success = 0x00000000,
err = 0x00000001,
unknown = 0x00000002,
};
pub const SType = enum(u32) {
invalid = 0x00000000,
surface_descriptor_from_metal_layer = 0x00000001,
surface_descriptor_from_windows_hwnd = 0x00000002,
surface_descriptor_from_xlib_window = 0x00000003,
surface_descriptor_from_canvas_html_selector = 0x00000004,
shader_module_spirv_descriptor = 0x00000005,
shader_module_wgsl_descriptor = 0x00000006,
primitive_depth_clip_control = 0x00000007,
surface_descriptor_from_wayland_surface = 0x00000008,
surface_descriptor_from_android_native_window = 0x00000009,
surface_descriptor_from_windows_core_window = 0x0000000B,
external_texture_binding_entry = 0x0000000C,
external_texture_binding_layout = 0x0000000D,
surface_descriptor_from_windows_swap_chain_panel = 0x0000000E,
render_pass_descriptor_max_draw_count = 0x0000000F,
dawn_texture_internal_usage_descriptor = 0x000003E8,
dawn_toggles_device_descriptor = 0x000003EA,
dawn_encoder_internal_usage_descriptor = 0x000003EB,
dawn_instance_descriptor = 0x000003EC,
dawn_cache_device_descriptor = 0x000003ED,
dawn_adapter_properties_power_preference = 0x000003EE,
dawn_buffer_descriptor_error_info_from_wire_client = 0x000003EF,
};
pub const StencilOperation = enum(u32) {
keep = 0x00000000,
zero = 0x00000001,
replace = 0x00000002,
invert = 0x00000003,
increment_clamp = 0x00000004,
decrement_clamp = 0x00000005,
increment_wrap = 0x00000006,
decrement_wrap = 0x00000007,
};
pub const StorageTextureAccess = enum(u32) {
undefined = 0x00000000,
write_only = 0x00000001,
};
pub const StoreOp = enum(u32) {
undefined = 0x00000000,
store = 0x00000001,
discard = 0x00000002,
};
pub const VertexFormat = enum(u32) {
undefined = 0x00000000,
uint8x2 = 0x00000001,
uint8x4 = 0x00000002,
sint8x2 = 0x00000003,
sint8x4 = 0x00000004,
unorm8x2 = 0x00000005,
unorm8x4 = 0x00000006,
snorm8x2 = 0x00000007,
snorm8x4 = 0x00000008,
uint16x2 = 0x00000009,
uint16x4 = 0x0000000a,
sint16x2 = 0x0000000b,
sint16x4 = 0x0000000c,
unorm16x2 = 0x0000000d,
unorm16x4 = 0x0000000e,
snorm16x2 = 0x0000000f,
snorm16x4 = 0x00000010,
float16x2 = 0x00000011,
float16x4 = 0x00000012,
float32 = 0x00000013,
float32x2 = 0x00000014,
float32x3 = 0x00000015,
float32x4 = 0x00000016,
uint32 = 0x00000017,
uint32x2 = 0x00000018,
uint32x3 = 0x00000019,
uint32x4 = 0x0000001a,
sint32 = 0x0000001b,
sint32x2 = 0x0000001c,
sint32x3 = 0x0000001d,
sint32x4 = 0x0000001e,
};
pub const VertexStepMode = enum(u32) {
vertex = 0x00000000,
instance = 0x00000001,
vertex_buffer_not_used = 0x00000002,
};
pub const ColorWriteMaskFlags = packed struct(u32) {
red: bool = false,
green: bool = false,
blue: bool = false,
alpha: bool = false,
_padding: u28 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const all = ColorWriteMaskFlags{
.red = true,
.green = true,
.blue = true,
.alpha = true,
};
pub fn equal(a: ColorWriteMaskFlags, b: ColorWriteMaskFlags) bool {
return @truncate(u4, @bitCast(u32, a)) == @truncate(u4, @bitCast(u32, b));
}
};
pub const MapModeFlags = packed struct(u32) {
read: bool = false,
write: bool = false,
_padding: u30 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const undef = MapModeFlags{};
pub fn equal(a: MapModeFlags, b: MapModeFlags) bool {
return @truncate(u2, @bitCast(u32, a)) == @truncate(u2, @bitCast(u32, b));
}
};
pub const ShaderStageFlags = packed struct(u32) {
vertex: bool = false,
fragment: bool = false,
compute: bool = false,
_padding: u29 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const none = ShaderStageFlags{};
pub fn equal(a: ShaderStageFlags, b: ShaderStageFlags) bool {
return @truncate(u3, @bitCast(u32, a)) == @truncate(u3, @bitCast(u32, b));
}
};
pub const ChainedStruct = extern struct {
// TODO: dawn: not marked as nullable in dawn.json but in fact is.
next: ?*const ChainedStruct = null,
s_type: SType,
};
pub const ChainedStructOut = extern struct {
// TODO: dawn: not marked as nullable in dawn.json but in fact is.
next: ?*ChainedStructOut = null,
s_type: SType,
};
pub const BlendComponent = extern struct {
operation: BlendOperation = .add,
src_factor: BlendFactor = .one,
dst_factor: BlendFactor = .zero,
};
pub const Color = extern struct {
r: f64,
g: f64,
b: f64,
a: f64,
};
pub const Extent2D = extern struct {
width: u32,
height: u32 = 1,
};
pub const Extent3D = extern struct {
width: u32,
height: u32 = 1,
depth_or_array_layers: u32 = 1,
};
pub const Limits = extern struct {
max_texture_dimension_1d: u32 = limit_u32_undef,
max_texture_dimension_2d: u32 = limit_u32_undef,
max_texture_dimension_3d: u32 = limit_u32_undef,
max_texture_array_layers: u32 = limit_u32_undef,
max_bind_groups: u32 = limit_u32_undef,
max_bindings_per_bind_group: u32 = limit_u32_undef,
max_dynamic_uniform_buffers_per_pipeline_layout: u32 = limit_u32_undef,
max_dynamic_storage_buffers_per_pipeline_layout: u32 = limit_u32_undef,
max_sampled_textures_per_shader_stage: u32 = limit_u32_undef,
max_samplers_per_shader_stage: u32 = limit_u32_undef,
max_storage_buffers_per_shader_stage: u32 = limit_u32_undef,
max_storage_textures_per_shader_stage: u32 = limit_u32_undef,
max_uniform_buffers_per_shader_stage: u32 = limit_u32_undef,
max_uniform_buffer_binding_size: u64 = limit_u64_undef,
max_storage_buffer_binding_size: u64 = limit_u64_undef,
min_uniform_buffer_offset_alignment: u32 = limit_u32_undef,
min_storage_buffer_offset_alignment: u32 = limit_u32_undef,
max_vertex_buffers: u32 = limit_u32_undef,
max_buffer_size: u64 = limit_u64_undef,
max_vertex_attributes: u32 = limit_u32_undef,
max_vertex_buffer_array_stride: u32 = limit_u32_undef,
max_inter_stage_shader_components: u32 = limit_u32_undef,
max_inter_stage_shader_variables: u32 = limit_u32_undef,
max_color_attachments: u32 = limit_u32_undef,
max_color_attachment_bytes_per_sample: u32 = limit_u32_undef,
max_compute_workgroup_storage_size: u32 = limit_u32_undef,
max_compute_invocations_per_workgroup: u32 = limit_u32_undef,
max_compute_workgroup_size_x: u32 = limit_u32_undef,
max_compute_workgroup_size_y: u32 = limit_u32_undef,
max_compute_workgroup_size_z: u32 = limit_u32_undef,
max_compute_workgroups_per_dimension: u32 = limit_u32_undef,
};
pub const Origin2D = extern struct {
x: u32 = 0,
y: u32 = 0,
};
pub const Origin3D = extern struct {
x: u32 = 0,
y: u32 = 0,
z: u32 = 0,
};
pub const CompilationMessage = extern struct {
next_in_chain: ?*const ChainedStruct = null,
message: ?[*:0]const u8 = null,
type: CompilationMessageType,
line_num: u64,
line_pos: u64,
offset: u64,
length: u64,
utf16_line_pos: u64,
utf16_offset: u64,
utf16_length: u64,
};
pub const ConstantEntry = extern struct {
next_in_chain: ?*const ChainedStruct = null,
key: [*:0]const u8,
value: f64,
};
pub const CopyTextureForBrowserOptions = extern struct {
next_in_chain: ?*const ChainedStruct = null,
flip_y: bool = false,
needs_color_space_conversion: bool = false,
src_alpha_mode: AlphaMode = .unpremultiplied,
src_transfer_function_parameters: ?*const [7]f32 = null,
conversion_matrix: ?*const [9]f32 = null,
dst_transfer_function_parameters: ?*const [7]f32 = null,
dst_alpha_mode: AlphaMode = .unpremultiplied,
internal_usage: bool = false,
};
pub const MultisampleState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
count: u32 = 1,
mask: u32 = 0xFFFFFFFF,
alpha_to_coverage_enabled: bool = false,
};
pub const PrimitiveDepthClipControl = extern struct {
chain: ChainedStruct = .{ .next = null, .s_type = .primitive_depth_clip_control },
unclipped_depth: bool = false,
};
pub const PrimitiveState = extern struct {
pub const NextInChain = extern union {
generic: ?*const ChainedStruct,
primitive_depth_clip_control: *const PrimitiveDepthClipControl,
};
next_in_chain: NextInChain = .{ .generic = null },
topology: PrimitiveTopology = .triangle_list,
strip_index_format: IndexFormat = .undefined,
front_face: FrontFace = .ccw,
cull_mode: CullMode = .none,
};
pub const RenderPassDescriptorMaxDrawCount = extern struct {
chain: ChainedStruct = .{ .next = null, .s_type = .render_pass_descriptor_max_draw_count },
max_draw_count: u64 = 50000000,
};
pub const StencilFaceState = extern struct {
compare: CompareFunction = .always,
fail_op: StencilOperation = .keep,
depth_fail_op: StencilOperation = .keep,
pass_op: StencilOperation = .keep,
};
pub const StorageTextureBindingLayout = extern struct {
next_in_chain: ?*const ChainedStruct = null,
access: StorageTextureAccess = .undefined,
format: Texture.Format = .undefined,
view_dimension: TextureView.Dimension = .dimension_undef,
};
pub const VertexAttribute = extern struct {
format: VertexFormat,
offset: u64,
shader_location: u32,
};
pub const BlendState = extern struct {
color: BlendComponent = .{},
alpha: BlendComponent = .{},
};
pub const CompilationInfo = extern struct {
next_in_chain: ?*const ChainedStruct = null,
message_count: u32,
messages: ?[*]const CompilationMessage = null,
/// Helper to get messages as a slice.
pub fn getMessages(info: CompilationInfo) ?[]const CompilationMessage {
if (info.messages) |messages| {
return messages[0..info.message_count];
}
return null;
}
};
pub const DepthStencilState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
format: Texture.Format,
depth_write_enabled: bool = false,
depth_compare: CompareFunction = .always,
stencil_front: StencilFaceState = .{},
stencil_back: StencilFaceState = .{},
stencil_read_mask: u32 = 0xFFFFFFFF,
stencil_write_mask: u32 = 0xFFFFFFFF,
depth_bias: i32 = 0,
depth_bias_slope_scale: f32 = 0.0,
depth_bias_clamp: f32 = 0.0,
};
pub const ImageCopyBuffer = extern struct {
next_in_chain: ?*const ChainedStruct = null,
layout: Texture.DataLayout,
buffer: *Buffer,
};
pub const ImageCopyExternalTexture = extern struct {
next_in_chain: ?*const ChainedStruct = null,
external_texture: *ExternalTexture,
origin: Origin3D,
};
pub const ImageCopyTexture = extern struct {
next_in_chain: ?*const ChainedStruct = null,
texture: *Texture,
mip_level: u32 = 0,
origin: Origin3D = .{},
aspect: Texture.Aspect = .all,
};
pub const ProgrammableStageDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constant_count: u32 = 0,
constants: ?[*]const ConstantEntry = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constants: ?[]const ConstantEntry = null,
}) ProgrammableStageDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.module = v.module,
.entry_point = v.entry_point,
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
.constants = if (v.constants) |e| e.ptr else null,
};
}
};
pub const RenderPassColorAttachment = extern struct {
view: ?*TextureView = null,
resolve_target: ?*TextureView = null,
load_op: LoadOp,
store_op: StoreOp,
/// deprecated
clear_color: Color = .{
.r = std.math.nan(f64),
.g = std.math.nan(f64),
.b = std.math.nan(f64),
.a = std.math.nan(f64),
},
clear_value: Color,
};
pub const RequiredLimits = extern struct {
next_in_chain: ?*const ChainedStruct = null,
limits: Limits,
};
/// Used to query limits from a Device or Adapter. Can be used as follows:
///
/// ```
/// var supported: gpu.SupportedLimits = .{};
/// if (!adapter.getLimits(&supported)) @panic("unsupported options");
/// ```
///
/// Note that `getLimits` can only fail if `next_in_chain` options are invalid.
pub const SupportedLimits = extern struct {
next_in_chain: ?*ChainedStructOut = null,
limits: Limits = undefined,
};
pub const VertexBufferLayout = extern struct {
array_stride: u64,
step_mode: VertexStepMode = .vertex,
attribute_count: u32,
attributes: ?[*]const VertexAttribute = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
array_stride: u64,
step_mode: VertexStepMode = .vertex,
attributes: ?[]const VertexAttribute = null,
}) VertexBufferLayout {
return .{
.array_stride = v.array_stride,
.step_mode = v.step_mode,
.attribute_count = if (v.attributes) |e| @intCast(u32, e.len) else 0,
.attributes = if (v.attributes) |e| e.ptr else null,
};
}
};
pub const ColorTargetState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
format: Texture.Format,
blend: ?*const BlendState = null,
write_mask: ColorWriteMaskFlags = ColorWriteMaskFlags.all,
};
pub const VertexState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constant_count: u32 = 0,
constants: ?[*]const ConstantEntry = null,
buffer_count: u32 = 0,
buffers: ?[*]const VertexBufferLayout = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constants: ?[]const ConstantEntry = null,
buffers: ?[]const VertexBufferLayout = null,
}) VertexState {
return .{
.next_in_chain = v.next_in_chain,
.module = v.module,
.entry_point = v.entry_point,
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
.constants = if (v.constants) |e| e.ptr else null,
.buffer_count = if (v.buffers) |e| @intCast(u32, e.len) else 0,
.buffers = if (v.buffers) |e| e.ptr else null,
};
}
};
pub const FragmentState = extern struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constant_count: u32 = 0,
constants: ?[*]const ConstantEntry = null,
target_count: u32,
targets: ?[*]const ColorTargetState = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
module: *ShaderModule,
entry_point: [*:0]const u8,
constants: ?[]const ConstantEntry = null,
targets: ?[]const ColorTargetState = null,
}) FragmentState {
return .{
.next_in_chain = v.next_in_chain,
.module = v.module,
.entry_point = v.entry_point,
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
.constants = if (v.constants) |e| e.ptr else null,
.target_count = if (v.targets) |e| @intCast(u32, e.len) else 0,
.targets = if (v.targets) |e| e.ptr else null,
};
}
};
test "BackendType name" {
try testing.expectEqualStrings("Vulkan", BackendType.vulkan.name());
}
test "enum name" {
try testing.expectEqualStrings("front", @tagName(CullMode.front));
}