From a6fa17e12a067d95774ba513500567ccea9ff767 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 30 Jun 2023 18:52:42 -0700 Subject: [PATCH] gpu: update to latest Dawn webgpu.h API Signed-off-by: Stephen Gutekanst --- libs/gpu/src/dawn.zig | 10 ++++++++++ libs/gpu/src/main.zig | 29 +++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/libs/gpu/src/dawn.zig b/libs/gpu/src/dawn.zig index c4a654d1..f412732c 100644 --- a/libs/gpu/src/dawn.zig +++ b/libs/gpu/src/dawn.zig @@ -14,6 +14,16 @@ pub const EncoderInternalUsageDescriptor = extern struct { use_internal_usages: bool = false, }; +pub const MultisampleStateRenderToSingleSampled = extern struct { + chain: ChainedStruct = .{ .next = null, .s_type = .dawn_multisample_state_render_to_single_sampled }, + enabled: bool = false, +}; + +pub const RenderPassColorAttachmentRenderToSingleSampled = extern struct { + chain: ChainedStruct = .{ .next = null, .s_type = .dawn_render_pass_color_attachment_render_to_single_sampled }, + implicit_sample_count: u32 = 1, +}; + pub const TextureInternalUsageDescriptor = extern struct { chain: ChainedStruct = .{ .next = null, .s_type = .dawn_texture_internal_usage_descriptor }, internal_usage: Texture.UsageFlags = Texture.UsageFlags.none, diff --git a/libs/gpu/src/main.zig b/libs/gpu/src/main.zig index 9b9ac8bb..d2f2c63d 100644 --- a/libs/gpu/src/main.zig +++ b/libs/gpu/src/main.zig @@ -81,9 +81,15 @@ pub const RenderPassTimestampWrite = extern struct { }; pub const RequestAdapterOptions = extern struct { - next_in_chain: ?*const ChainedStruct = null, + pub const NextInChain = extern union { + generic: ?*const ChainedStruct, + dawn_toggles_descriptor: *const dawn.TogglesDescriptor, + }; + + next_in_chain: NextInChain = .{ .generic = null }, compatible_surface: ?*Surface = null, power_preference: PowerPreference = .undefined, + backend_type: BackendType = .undefined, force_fallback_adapter: bool = false, compatibility_mode: bool = false, }; @@ -149,6 +155,7 @@ pub const RenderPassDescriptor = extern struct { pub const AlphaMode = enum(u32) { premultiplied = 0x00000000, unpremultiplied = 0x00000001, opaq = 0x00000002 }; pub const BackendType = enum(u32) { + undefined, null, webgpu, d3d11, @@ -160,6 +167,7 @@ pub const BackendType = enum(u32) { pub fn name(t: BackendType) []const u8 { return switch (t) { + .undef => "Undefined", .null => "Null", .webgpu => "WebGPU", .d3d11 => "D3D11", @@ -279,6 +287,7 @@ pub const FeatureName = enum(u32) { implicit_device_synchronization = 0x000003EF, surface_capabilities = 0x000003F0, transient_attachments = 0x000003F1, + msaa_render_to_single_sampled = 0x000003F2, }; pub const FilterMode = enum(u32) { @@ -391,6 +400,10 @@ pub const SType = enum(u32) { dawn_buffer_descriptor_error_info_from_wire_client = 0x000003EF, dawn_toggles_descriptor = 0x000003F0, dawn_shader_module_spirv_options_descriptor = 0x000003F1, + request_adapter_options_luid = 0x000003F2, + request_adapter_options_get_gl_proc = 0x000003F3, + dawn_multisample_state_render_to_single_sampled = 0x000003F4, + dawn_render_pass_color_attachment_render_to_single_sampled = 0x000003F5, }; pub const StencilOperation = enum(u32) { @@ -565,6 +578,7 @@ pub const Limits = extern struct { max_texture_dimension_3d: u32 = limit_u32_undef, max_texture_array_layers: u32 = limit_u32_undef, max_bind_groups: u32 = limit_u32_undef, + max_bind_groups_plus_vertex_buffers: 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, @@ -636,7 +650,12 @@ pub const CopyTextureForBrowserOptions = extern struct { }; pub const MultisampleState = extern struct { - next_in_chain: ?*const ChainedStruct = null, + pub const NextInChain = extern union { + generic: ?*const ChainedStruct, + dawn_multisample_state_render_to_single_sampled: *const dawn.MultisampleStateRenderToSingleSampled, + }; + + next_in_chain: NextInChain = .{ .generic = null }, count: u32 = 1, mask: u32 = 0xFFFFFFFF, alpha_to_coverage_enabled: bool = false, @@ -764,6 +783,12 @@ pub const ProgrammableStageDescriptor = extern struct { }; pub const RenderPassColorAttachment = extern struct { + pub const NextInChain = extern union { + generic: ?*const ChainedStruct, + dawn_render_pass_color_attachment_render_to_single_sampled: *const dawn.RenderPassColorAttachmentRenderToSingleSampled, + }; + + next_in_chain: NextInChain = .{ .generic = null }, view: ?*TextureView = null, resolve_target: ?*TextureView = null, load_op: LoadOp,