From 46f672599d7c4979b185cca524a49fa0b9396d6f Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 8 Aug 2025 23:20:44 +0300 Subject: [PATCH] Upgrade to wgpu-native version 25.0.2.1 --- CMakeLists.txt | 2 +- libs/sdl2/source/window.cpp | 38 +- libs/wgpu/include/psemek/wgpu/adapter.hpp | 51 +- .../include/psemek/wgpu/bind_group_layout.hpp | 35 +- libs/wgpu/include/psemek/wgpu/buffer.hpp | 53 +- .../include/psemek/wgpu/callback_mode.hpp | 15 + .../include/psemek/wgpu/chained_struct.hpp | 1 + .../include/psemek/wgpu/command_encoder.hpp | 6 +- .../psemek/wgpu/compute_pass_encoder.hpp | 2 + .../include/psemek/wgpu/detail/status.hpp | 18 + .../psemek/wgpu/detail/string_view.hpp | 21 + libs/wgpu/include/psemek/wgpu/device.hpp | 112 +- .../include/psemek/wgpu/external/webgpu.h | 3311 +++++++++++++---- libs/wgpu/include/psemek/wgpu/external/wgpu.h | 175 +- libs/wgpu/include/psemek/wgpu/image_copy.hpp | 19 +- libs/wgpu/include/psemek/wgpu/instance.hpp | 4 +- libs/wgpu/include/psemek/wgpu/query_set.hpp | 4 +- libs/wgpu/include/psemek/wgpu/queue.hpp | 13 +- .../psemek/wgpu/render_bundle_encoder.hpp | 4 +- .../psemek/wgpu/render_pass_encoder.hpp | 14 +- .../include/psemek/wgpu/render_pipeline.hpp | 180 +- libs/wgpu/include/psemek/wgpu/sampler.hpp | 35 +- .../include/psemek/wgpu/shader_module.hpp | 36 +- .../wgpu/include/psemek/wgpu/shader_stage.hpp | 10 +- libs/wgpu/include/psemek/wgpu/surface.hpp | 40 +- libs/wgpu/include/psemek/wgpu/texture.hpp | 246 +- .../wgpu/include/psemek/wgpu/texture_view.hpp | 12 +- libs/wgpu/source/adapter.cpp | 150 +- libs/wgpu/source/bind_group.cpp | 5 +- libs/wgpu/source/bind_group_layout.cpp | 5 +- libs/wgpu/source/buffer.cpp | 18 +- libs/wgpu/source/chained_struct.cpp | 26 + libs/wgpu/source/command_buffer.cpp | 5 +- libs/wgpu/source/command_encoder.cpp | 100 +- libs/wgpu/source/compute_pass_encoder.cpp | 20 +- libs/wgpu/source/compute_pipeline.cpp | 5 +- libs/wgpu/source/device.cpp | 177 +- libs/wgpu/source/instance.cpp | 25 +- libs/wgpu/source/logging.cpp | 4 +- libs/wgpu/source/pipeline_layout.cpp | 5 +- libs/wgpu/source/query_set.cpp | 5 +- libs/wgpu/source/queue.cpp | 40 +- libs/wgpu/source/render_bundle.cpp | 5 +- libs/wgpu/source/render_bundle_encoder.cpp | 15 +- libs/wgpu/source/render_pass_encoder.cpp | 20 +- libs/wgpu/source/render_pipeline.cpp | 5 +- libs/wgpu/source/sampler.cpp | 5 +- libs/wgpu/source/shader_module.cpp | 57 +- libs/wgpu/source/surface.cpp | 52 +- libs/wgpu/source/texture.cpp | 7 +- libs/wgpu/source/texture_view.cpp | 5 +- 51 files changed, 3813 insertions(+), 1405 deletions(-) create mode 100644 libs/wgpu/include/psemek/wgpu/callback_mode.hpp create mode 100644 libs/wgpu/include/psemek/wgpu/detail/status.hpp create mode 100644 libs/wgpu/include/psemek/wgpu/detail/string_view.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5952c592..faf923b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ if(NOT DEFINED PSEMEK_GRAPHICS_API) endif() if(PSEMEK_GRAPHICS_API STREQUAL WEBGPU) - find_package(wgpu-native REQUIRED) + find_package(wgpu-native 25.0.2.1 REQUIRED) endif() message(STATUS "Using graphics API ${PSEMEK_GRAPHICS_API}") diff --git a/libs/sdl2/source/window.cpp b/libs/sdl2/source/window.cpp index b673046a..34009f34 100644 --- a/libs/sdl2/source/window.cpp +++ b/libs/sdl2/source/window.cpp @@ -92,21 +92,43 @@ namespace psemek::sdl2 wgpu_surface_ = instance.create_surface(surface_descriptor); wgpu::adapter::request_options adapter_request_options; + // adapter_request_options.feature_level = wgpu::feature_level::compatibility; adapter_request_options.compatible_surface = wgpu_surface_; adapter_request_options.backend_type = wgpu::backend_type::undefined; - instance.request_adapter(adapter_request_options, [this](wgpu::adapter::request_status status, wgpu::adapter adapter_in, std::string const & message) + instance.request_adapter(wgpu::callback_mode::allow_process_events, adapter_request_options, [this](wgpu::adapter::request_status status, wgpu::adapter adapter_in, std::string_view message) { if (status != wgpu::adapter::request_status::success) - throw std::runtime_error("Failed to request WebGPU adapter: " + message); + throw std::runtime_error("Failed to request WebGPU adapter: " + std::string(message)); wgpu_adapter_ = std::move(adapter_in); }); + [[maybe_unused]] auto adapter_limits = wgpu_adapter_.get_limits(); + wgpu::device::descriptor device_descriptor { .required_features = options.required_features, .required_limits = std::nullopt, + .lost_callback = [](wgpu::device::lost_reason reason, std::string_view message) + { + std::ostringstream os; + os << "WebGPU device lost, reason: " << static_cast(reason) << ", message: " << message; + auto str = os.str(); + log::error() << str; + // This will most probably panic in wgpu-native internals + throw util::exception(std::move(str)); + }, + .lost_callback_mode = wgpu::callback_mode::allow_process_events, + .uncaptured_error_callback = [](wgpu::error_type type, std::string_view message) + { + std::ostringstream os; + os << "Uncaptured WebGPU error, type: " << static_cast(type) << ", message: " << message; + auto str = os.str(); + log::error() << str; + // This will most probably panic in wgpu-native internals + throw util::exception(std::move(str)); + }, }; if (options.required_limits || options.required_native_limits) @@ -118,16 +140,18 @@ namespace psemek::sdl2 if (options.required_native_limits) device_descriptor.required_limits->chain.push_back(wgpu::native_limits{*options.required_native_limits}); - wgpu_adapter_.request_device(device_descriptor, [this](wgpu::device::request_status status, wgpu::device device_in, std::string const & message) + wgpu_adapter_.request_device(wgpu::callback_mode::allow_process_events, device_descriptor, [this](wgpu::device::request_status status, wgpu::device device_in, std::string_view message) { if (status != wgpu::device::request_status::success) - throw std::runtime_error("Failed to request WebGPU device: " + message); + throw std::runtime_error("Failed to request WebGPU device: " + std::string(message)); wgpu_device_ = std::move(device_in); }); - auto adapter_properties = wgpu_adapter_.get_properties(); + [[maybe_unused]] auto device_limits = wgpu_device_.get_limits(); + + auto adapter_info = wgpu_adapter_.get_info(); std::string adapter_backend_str; - switch (adapter_properties.backend_type) + switch (adapter_info.backend_type) { case wgpu::backend_type::undefined: adapter_backend_str = "undefined"; @@ -158,7 +182,7 @@ namespace psemek::sdl2 break; } - log::info() << "Initialized WebGPU: " << adapter_properties.name << ", " << adapter_backend_str << " backend"; + log::info() << "Initialized WebGPU: " << adapter_info.device << ", " << adapter_backend_str << " backend"; log::info() << "Using wgpu-native version " << wgpu::get_version(); #endif } diff --git a/libs/wgpu/include/psemek/wgpu/adapter.hpp b/libs/wgpu/include/psemek/wgpu/adapter.hpp index 25b27919..fc560ba3 100644 --- a/libs/wgpu/include/psemek/wgpu/adapter.hpp +++ b/libs/wgpu/include/psemek/wgpu/adapter.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -11,6 +12,12 @@ namespace psemek::wgpu { + enum class feature_level : std::uint32_t + { + compatibility = 1, + core = 2, + }; + enum class power_preference : std::uint32_t { undefined = 0x00000000, @@ -39,47 +46,49 @@ namespace psemek::wgpu struct request_options { std::vector chain = {}; - surface compatible_surface = {}; + wgpu::feature_level feature_level = feature_level::core; wgpu::power_preference power_preference = power_preference::high; - wgpu::backend_type backend_type = backend_type::vulkan; bool force_fallback_adapter = false; + wgpu::backend_type backend_type = backend_type::vulkan; + surface compatible_surface = {}; }; enum class request_status : std::uint32_t { - success = 0x00000000, - unavailable = 0x00000001, - error = 0x00000002, - unknown = 0x00000003, + success = 0x00000001, + instance_dropped = 0x00000002, + unavailable = 0x00000003, + error = 0x00000004, + unknown = 0x00000005, }; - using request_callback = std::function; + using request_callback = std::function; enum class type : std::uint32_t { - discrete_gpu = 0x00000000, - integrated_gpu = 0x00000001, - cpu = 0x00000002, - unknown = 0x00000003, + discrete_gpu = 0x00000001, + integrated_gpu = 0x00000002, + cpu = 0x00000003, + unknown = 0x00000004, }; - struct properties + struct info { - std::uint32_t vendor_id; - std::string vendor_name; - std::string architecture; - std::uint32_t device_id; - std::string name; - std::string driver_description; - enum type adapter_type; + std::string_view vendor; + std::string_view architecture; + std::string_view device; + std::string_view description; wgpu::backend_type backend_type; + type adapter_type; + uint32_t vendor_id; + uint32_t device_id; }; std::vector enumerate_features(); limits get_limits(); - properties get_properties(); + info get_info(); bool has_feature(feature feature); - void request_device(device::descriptor const & descriptor, device::request_callback const & callback); + void request_device(callback_mode mode, device::descriptor const & descriptor, device::request_callback const & callback); static void reference(void * ptr); static void release(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/bind_group_layout.hpp b/libs/wgpu/include/psemek/wgpu/bind_group_layout.hpp index d9b0726f..270a292c 100644 --- a/libs/wgpu/include/psemek/wgpu/bind_group_layout.hpp +++ b/libs/wgpu/include/psemek/wgpu/bind_group_layout.hpp @@ -14,54 +14,57 @@ namespace psemek::wgpu enum class buffer_binding_type : std::uint32_t { - undefined = 0x00000000, - uniform = 0x00000001, - storage = 0x00000002, - read_only_storage = 0x00000003, + binding_not_used = 0x00000000, + undefined = 0x00000001, + uniform = 0x00000002, + storage = 0x00000003, + read_only_storage = 0x00000004, }; struct buffer_binding_layout { std::vector chain = {}; - buffer_binding_type type = buffer_binding_type::undefined; + buffer_binding_type type = buffer_binding_type::binding_not_used; bool has_dynamic_offset = false; std::uint64_t min_binding_size = 0; }; enum class sampler_binding_type : std::uint32_t { - undefined = 0x00000000, - filtering = 0x00000001, - nonfiltering = 0x00000002, - comparison = 0x00000003, + binding_not_used = 0x00000000, + undefined = 0x00000001, + filtering = 0x00000002, + nonfiltering = 0x00000003, + comparison = 0x00000004, }; struct sampler_binding_layout { std::vector chain = {}; - sampler_binding_type type = sampler_binding_type::undefined; + sampler_binding_type type = sampler_binding_type::binding_not_used; }; struct texture_binding_layout { std::vector chain = {}; - texture::sample_type sample_type = texture::sample_type::undefined; + texture::sample_type sample_type = texture::sample_type::binding_not_used; texture_view::dimension view_dimension = texture_view::dimension::undefined; bool multisampled = false; }; enum class storage_texture_access : std::uint32_t { - undefined = 0x00000000, - write_only = 0x00000001, - read_only = 0x00000002, - read_write = 0x00000003, + binding_not_used = 0x00000000, + undefined = 0x00000001, + write_only = 0x00000002, + read_only = 0x00000003, + read_write = 0x00000004, }; struct storage_texture_binding_layout { std::vector chain = {}; - storage_texture_access access = storage_texture_access::undefined; + storage_texture_access access = storage_texture_access::binding_not_used; texture::format format = texture::format::undefined; texture_view::dimension view_dimension = texture_view::dimension::undefined; }; diff --git a/libs/wgpu/include/psemek/wgpu/buffer.hpp b/libs/wgpu/include/psemek/wgpu/buffer.hpp index 4d05e1f6..ba0ded37 100644 --- a/libs/wgpu/include/psemek/wgpu/buffer.hpp +++ b/libs/wgpu/include/psemek/wgpu/buffer.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -15,46 +16,42 @@ namespace psemek::wgpu { using detail::object::object; - enum class usage : std::uint32_t + enum class usage : std::uint64_t { - none = 0x00000000, - map_read = 0x00000001, - map_write = 0x00000002, - copy_src = 0x00000004, - copy_dst = 0x00000008, - index = 0x00000010, - vertex = 0x00000020, - uniform = 0x00000040, - storage = 0x00000080, - indirect = 0x00000100, + none = 0x00000000, + map_read = 0x00000001, + map_write = 0x00000002, + copy_src = 0x00000004, + copy_dst = 0x00000008, + index = 0x00000010, + vertex = 0x00000020, + uniform = 0x00000040, + storage = 0x00000080, + indirect = 0x00000100, query_resolve = 0x00000200, }; - enum class map_mode : std::uint32_t + enum class map_mode : std::uint64_t { - none = 0x00000000, - read = 0x00000001, + none = 0x00000000, + read = 0x00000001, write = 0x00000002, }; enum class map_state : std::uint32_t { - unmapped = 0x00000000, - pending = 0x00000001, - mapped = 0x00000002, + unmapped = 0x00000001, + pending = 0x00000002, + mapped = 0x00000003, }; enum class map_async_status : std::uint32_t { - success = 0x00000000, - validation_error = 0x00000001, - unknown = 0x00000002, - device_lost = 0x00000003, - destroyed_before_callback = 0x00000004, - unmapped_before_callback = 0x00000005, - mapping_already_pending = 0x00000006, - offset_out_of_range = 0x00000007, - size_out_of_range = 0x00000008, + success = 0x00000001, + instance_dropped = 0x00000002, + error = 0x00000003, + aborted = 0x00000004, + unknown = 0x00000005, }; struct descriptor { @@ -65,7 +62,7 @@ namespace psemek::wgpu bool mapped_at_creation = false; }; - using map_callback = std::function; + using map_callback = std::function; void destroy(); std::uint64_t get_size(); @@ -73,7 +70,7 @@ namespace psemek::wgpu map_state get_map_state(); void const * get_const_mapped_range(std::size_t offset, std::size_t size); void * get_mapped_range(std::size_t offset, std::size_t size); - void map_async(map_mode flags, std::size_t offset, std::size_t size, map_callback const & callback); + void map_async(callback_mode mode, map_mode flags, std::size_t offset, std::size_t size, map_callback const & callback); void unmap(); void set_label(std::string const & label); diff --git a/libs/wgpu/include/psemek/wgpu/callback_mode.hpp b/libs/wgpu/include/psemek/wgpu/callback_mode.hpp new file mode 100644 index 00000000..5b8262f3 --- /dev/null +++ b/libs/wgpu/include/psemek/wgpu/callback_mode.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace psemek::wgpu +{ + + enum class callback_mode : std::uint32_t + { + wait_any_only = 0x00000001, + allow_process_events = 0x00000002, + allow_spontaneous = 0x00000003, + }; + +} diff --git a/libs/wgpu/include/psemek/wgpu/chained_struct.hpp b/libs/wgpu/include/psemek/wgpu/chained_struct.hpp index f13b0472..2e018d99 100644 --- a/libs/wgpu/include/psemek/wgpu/chained_struct.hpp +++ b/libs/wgpu/include/psemek/wgpu/chained_struct.hpp @@ -45,6 +45,7 @@ namespace psemek::wgpu }; void * fill_chain(std::vector const & chain); + void * fill_chain_out(std::vector const & chain); using chained_struct_ptr = std::shared_ptr; diff --git a/libs/wgpu/include/psemek/wgpu/command_encoder.hpp b/libs/wgpu/include/psemek/wgpu/command_encoder.hpp index ed5d7c7d..4c466caf 100644 --- a/libs/wgpu/include/psemek/wgpu/command_encoder.hpp +++ b/libs/wgpu/include/psemek/wgpu/command_encoder.hpp @@ -31,9 +31,9 @@ namespace psemek::wgpu render_pass_encoder begin_render_pass(render_pass_encoder::descriptor const & desc); void clear_buffer(buffer const & buffer, std::uint64_t offset, std::uint64_t size); void copy_buffer_to_buffer(buffer const & source, std::uint64_t source_offset, buffer const & destination, std::uint64_t destination_offset, std::uint64_t size); - void copy_buffer_to_texture(image_copy_buffer const & source, image_copy_texture const & destination, math::vector const & extent); - void copy_texture_to_buffer(image_copy_texture const & source, image_copy_buffer const & destination, math::vector const & extent); - void copy_texture_to_texture(image_copy_texture const & source, image_copy_texture const & destination, math::vector const & extent); + void copy_buffer_to_texture(texel_copy_buffer_info const & source, texel_copy_texture_info const & destination, math::vector const & extent); + void copy_texture_to_buffer(texel_copy_texture_info const & source, texel_copy_buffer_info const & destination, math::vector const & extent); + void copy_texture_to_texture(texel_copy_texture_info const & source, texel_copy_texture_info const & destination, math::vector const & extent); void insert_debug_marker(std::string const & marker_label); void push_debug_group(std::string const & group_label); void pop_debug_group(); diff --git a/libs/wgpu/include/psemek/wgpu/compute_pass_encoder.hpp b/libs/wgpu/include/psemek/wgpu/compute_pass_encoder.hpp index 14b30fc8..b3d1d4d1 100644 --- a/libs/wgpu/include/psemek/wgpu/compute_pass_encoder.hpp +++ b/libs/wgpu/include/psemek/wgpu/compute_pass_encoder.hpp @@ -37,6 +37,8 @@ namespace psemek::wgpu void set_pipeline(compute_pipeline const & pipeline); void dispatch_workgroups(math::vector const & workgroup_count); void dispatch_workgroups_indirect(buffer const & indirect_buffer, std::uint64_t offset); + void set_push_constants(std::uint32_t offset, util::span data); + void write_timestamp(query_set const & query_set, std::uint32_t query_index); void insert_debug_marker(std::string const & marker_label); void push_debug_group(std::string const & group_label); void pop_debug_group(); diff --git a/libs/wgpu/include/psemek/wgpu/detail/status.hpp b/libs/wgpu/include/psemek/wgpu/detail/status.hpp new file mode 100644 index 00000000..f4bde899 --- /dev/null +++ b/libs/wgpu/include/psemek/wgpu/detail/status.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +#include +#include + +namespace psemek::wgpu::detail +{ + + inline void check_status(std::string_view caption, WGPUStatus status) + { + if (status != WGPUStatus_Success) + throw util::exception("wgpu error in " + std::string(caption)); + } + +} diff --git a/libs/wgpu/include/psemek/wgpu/detail/string_view.hpp b/libs/wgpu/include/psemek/wgpu/detail/string_view.hpp new file mode 100644 index 00000000..646dc6c9 --- /dev/null +++ b/libs/wgpu/include/psemek/wgpu/detail/string_view.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include + +#include +#include + +namespace psemek::wgpu::detail +{ + + inline WGPUStringView to_string_view(std::string const & string) + { + return {.data = string.data(), .length = string.size()}; + } + + inline WGPUStringView to_string_view(std::string_view const & string_view) + { + return {.data = string_view.data(), .length = string_view.size()}; + } + +} diff --git a/libs/wgpu/include/psemek/wgpu/device.hpp b/libs/wgpu/include/psemek/wgpu/device.hpp index 27fef999..b0f5f432 100644 --- a/libs/wgpu/include/psemek/wgpu/device.hpp +++ b/libs/wgpu/include/psemek/wgpu/device.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -26,16 +27,22 @@ namespace psemek::wgpu enum class feature : std::uint32_t { undefined = 0x00000000, depth_clip_control = 0x00000001, - depth32float_stencil8 = 0x00000002, + depth32_float_stencil8 = 0x00000002, timestamp_query = 0x00000003, - texture_compression_bc = 0x00000004, - texture_compression_etc2 = 0x00000005, - texture_compression_astc = 0x00000006, - indirect_first_instance = 0x00000007, - shader_f16 = 0x00000008, - rg11b10ufloat_renderable = 0x00000009, - bgra8unorm_storage = 0x0000000a, - float32_filterable = 0x0000000b, + texture_compression_BC = 0x00000004, + texture_compression_BC_sliced_3D = 0x00000005, + texture_compression_ETC2 = 0x00000006, + texture_compression_ASTC = 0x00000007, + texture_compression_ASTC_sliced_3D = 0x00000008, + indirect_first_instance = 0x00000009, + shader_f16 = 0x0000000A, + rg11b10_ufloat_renderable = 0x0000000B, + bgra8_unorm_storage = 0x0000000C, + float32_filterable = 0x0000000D, + float32_blendable = 0x0000000E, + clip_distances = 0x0000000F, + dual_source_blending = 0x00000010, + push_constants = 0x00030001, texture_adapter_specific_format_features = 0x00030002, @@ -45,6 +52,27 @@ namespace psemek::wgpu texture_binding_array = 0x00030006, sampled_texture_and_storage_buffer_array_non_uniform_indexing = 0x00030007, pipeline_statistics_query = 0x00030008, + storage_resource_binding_array = 0x00030009, + partially_bound_binding_array = 0x0003000a, + texture_format16bit_norm = 0x0003000b, + texture_compression_astc_hdr = 0x0003000c, + mappable_primary_buffers = 0x0003000e, + buffer_binding_array = 0x0003000f, + uniform_buffer_and_storage_texture_array_non_uniform_indexing = 0x00030010, + spirv_shader_passthrough = 0x00030017, + vertex_attribute64bit = 0x00030019, + texture_format_nv12 = 0x0003001a, + ray_tracing_acceleration_structure = 0x0003001b, + ray_query = 0x0003001c, + shader_f64 = 0x0003001d, + shader_i16 = 0x0003001e, + shader_primitive_index = 0x0003001f, + shader_early_depth_test = 0x00030020, + subgroup = 0x00030021, + subgroup_vertex = 0x00030022, + subgroup_barrier = 0x00030023, + timestamp_query_inside_encoders = 0x00030024, + timestamp_query_inside_passes = 0x00030025, }; struct limits @@ -71,7 +99,6 @@ namespace psemek::wgpu std::uint64_t max_buffer_size = 256 * 1024 * 1024; std::uint32_t max_vertex_attributes = 16; std::uint32_t max_vertex_buffer_array_stride = 2048; - std::uint32_t max_inter_stage_shader_components = 60; std::uint32_t max_inter_stage_shader_variables = 15; std::uint32_t max_color_attachments = 1; std::uint32_t max_color_attachment_bytes_per_sample = 4; @@ -91,29 +118,34 @@ namespace psemek::wgpu enum class create_pipeline_async_status : std::uint32_t { - success = 0x00000000, - validation_error = 0x00000001, - internal_error = 0x00000002, - device_lost = 0x00000003, - device_destroyed = 0x00000004, - unknown = 0x00000005, + success = 0x00000001, + instance_dropped = 0x00000002, + validation_error = 0x00000003, + internal_error = 0x00000004, + unknown = 0x00000005, }; enum class error_filter : std::uint32_t { - validation = 0x00000000, - out_of_memory = 0x00000001, - internal = 0x00000002, + validation = 0x00000001, + out_of_memory = 0x00000002, + internal = 0x00000003, }; enum class error_type : std::uint32_t { - no_error = 0x00000000, - validation = 0x00000001, - out_of_memory = 0x00000002, - internal = 0x00000003, - unknown = 0x00000004, - device_lost = 0x00000005, + no_error = 0x00000001, + validation = 0x00000002, + out_of_memory = 0x00000003, + internal = 0x00000004, + unknown = 0x00000005, + }; + + enum class pop_error_scope_status : std::uint32_t + { + success = 0x00000001, + instance_dropped = 0x00000002, + empty_stack = 0x00000003, }; struct device @@ -123,11 +155,14 @@ namespace psemek::wgpu enum class lost_reason : std::uint32_t { - undefined = 0x00000000, - destroyed = 0x00000001, + unknown = 0x00000001, + destroyed = 0x00000002, + instance_dropped = 0x00000003, + failed_creation = 0x00000004, }; - using lost_callback = std::function; + using lost_callback = std::function; + using uncaptured_error_callback = std::function; struct required_limits { @@ -143,18 +178,22 @@ namespace psemek::wgpu std::optional required_limits = {}; queue::descriptor default_queue = {}; device::lost_callback lost_callback = {}; + callback_mode lost_callback_mode = {}; + device::uncaptured_error_callback uncaptured_error_callback = {}; }; enum class request_status : std::uint32_t { - success = 0x00000000, - error = 0x00000001, - unknown = 0x00000002, + success = 0x00000001, + instance_dropped = 0x00000002, + error = 0x00000003, + unknown = 0x00000004, }; using request_callback = std::function; - using create_compute_pipeline_async_callback = std::function; - using create_render_pipeline_async_callback = std::function; + using create_compute_pipeline_async_callback = std::function; + using create_render_pipeline_async_callback = std::function; + using pop_error_callback = std::function; using error_callback = std::function; queue get_queue(); @@ -163,11 +202,11 @@ namespace psemek::wgpu buffer create_buffer(buffer::descriptor const & desc); command_encoder create_command_encoder(command_encoder::descriptor const & desc); compute_pipeline create_compute_pipeline(compute_pipeline::descriptor const & desc); - void create_compute_pipeline_async(compute_pipeline::descriptor const & desc, create_compute_pipeline_async_callback const & callback); + void create_compute_pipeline_async(callback_mode mode, compute_pipeline::descriptor const & desc, create_compute_pipeline_async_callback const & callback); pipeline_layout create_pipeline_layout(pipeline_layout::descriptor const & desc); query_set create_query_set(query_set::descriptor const & desc); render_pipeline create_render_pipeline(render_pipeline::descriptor const & desc); - void create_render_pipeline_async(render_pipeline::descriptor const & desc, create_render_pipeline_async_callback const & callback); + void create_render_pipeline_async(callback_mode mode, render_pipeline::descriptor const & desc, create_render_pipeline_async_callback const & callback); render_bundle_encoder create_render_bundle_encoder(render_bundle_encoder::descriptor const & desc); sampler create_sampler(sampler::descriptor const & desc); shader_module create_shader_module(shader_module::descriptor const & desc); @@ -177,8 +216,7 @@ namespace psemek::wgpu limits get_limits(); bool has_feature(feature feature); void push_error_scope(error_filter filter); - void pop_error_scope(error_callback const & callback); - void set_uncaptured_error_callback(error_callback const & callback); + void pop_error_scope(callback_mode mode, pop_error_callback const & callback); void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/external/webgpu.h b/libs/wgpu/include/psemek/wgpu/external/webgpu.h index d2533513..084ac1bb 100644 --- a/libs/wgpu/include/psemek/wgpu/external/webgpu.h +++ b/libs/wgpu/include/psemek/wgpu/external/webgpu.h @@ -1,32 +1,20 @@ -// BSD 3-Clause License -// -// Copyright (c) 2019, "WebGPU native" developers -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/** + * Copyright 2019-2023 WebGPU-Native developers + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** @file */ + +/** + * \mainpage + * + * **Important:** *This documentation is a Work In Progress.* + * + * This is the home of WebGPU C API specification. We define here the standard + * `webgpu.h` header that all implementations should provide. + */ + #ifndef WEBGPU_H_ #define WEBGPU_H_ @@ -67,18 +55,93 @@ #include #include -#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL) -#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL) -#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL) -#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL) -#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL) -#define WGPU_QUERY_SET_INDEX_UNDEFINED (0xffffffffUL) -#define WGPU_WHOLE_MAP_SIZE SIZE_MAX -#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) +#define _wgpu_COMMA , +#if defined(__cplusplus) +# if __cplusplus >= 201103L +# define _wgpu_MAKE_INIT_STRUCT(type, value) (type value) +# else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +# endif +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define _wgpu_MAKE_INIT_STRUCT(type, value) ((type) value) +#else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +#endif -typedef uint32_t WGPUFlags; + +/** + * \defgroup Constants + * \brief Constants. + * + * @{ + */ +#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX) +#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX) +#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) +#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) +#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX) +#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX) +#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX) +#define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) +#define WGPU_WHOLE_SIZE (UINT64_MAX) + + +/** @} */ + +/** + * \defgroup UtilityTypes Utility Types + * + * @{ + */ +typedef uint64_t WGPUFlags; typedef uint32_t WGPUBool; +/** + * Nullable value defining a pointer+length view into a UTF-8 encoded string. + * + * Values passed into the API may use the special length value @ref WGPU_STRLEN + * to indicate a null-terminated string. + * Non-null values passed out of the API (for example as callback arguments) + * always provide an explicit length and **may or may not be null-terminated**. + * + * Some inputs to the API accept null values. Those which do not accept null + * values "default" to the empty string when null values are passed. + * + * Values are encoded as follows: + * - `{NULL, WGPU_STRLEN}`: the null value. + * - `{non_null_pointer, WGPU_STRLEN}`: a null-terminated string view. + * - `{any, 0}`: the empty string. + * - `{NULL, non_zero_length}`: not allowed (null dereference). + * - `{non_null_pointer, non_zero_length}`: an explictly-sized string view with + * size `non_zero_length` (in bytes). + * + * For info on how this is used in various places, see \ref Strings. + */ +typedef struct WGPUStringView { + char const * WGPU_NULLABLE data; + size_t length; +} WGPUStringView; + +/** + * Sentinel value used in @ref WGPUStringView to indicate that the pointer + * is to a null-terminated string, rather than an explicitly-sized string. + */ +#define WGPU_STRLEN SIZE_MAX + +#define WGPU_STRING_VIEW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStringView, { \ + /*.data=*/NULL _wgpu_COMMA \ + /*.length=*/WGPU_STRLEN _wgpu_COMMA \ +}) + + +/** @} */ + +/** + * \defgroup Objects + * \brief Opaque, non-dispatchable handles to WebGPU objects. + * + * @{ + */ typedef struct WGPUAdapterImpl* WGPUAdapter WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUBindGroupImpl* WGPUBindGroup WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout WGPU_OBJECT_ATTRIBUTE; @@ -98,12 +161,17 @@ typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder WGPU_OBJECT_ATTR typedef struct WGPURenderPipelineImpl* WGPURenderPipeline WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUSamplerImpl* WGPUSampler WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUShaderModuleImpl* WGPUShaderModule WGPU_OBJECT_ATTRIBUTE; +/** + * An object used to continuously present image data to the user, see @ref Surfaces for more details. + */ typedef struct WGPUSurfaceImpl* WGPUSurface WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE; + +/** @} */ // Structure forward declarations -struct WGPUAdapterProperties; +struct WGPUAdapterInfo; struct WGPUBindGroupEntry; struct WGPUBlendComponent; struct WGPUBufferBindingLayout; @@ -115,41 +183,42 @@ struct WGPUCompilationMessage; struct WGPUComputePassTimestampWrites; struct WGPUConstantEntry; struct WGPUExtent3D; -struct WGPUInstanceDescriptor; +struct WGPUFuture; +struct WGPUInstanceCapabilities; struct WGPULimits; struct WGPUMultisampleState; struct WGPUOrigin3D; struct WGPUPipelineLayoutDescriptor; -struct WGPUPrimitiveDepthClipControl; struct WGPUPrimitiveState; struct WGPUQuerySetDescriptor; struct WGPUQueueDescriptor; struct WGPURenderBundleDescriptor; struct WGPURenderBundleEncoderDescriptor; struct WGPURenderPassDepthStencilAttachment; -struct WGPURenderPassDescriptorMaxDrawCount; +struct WGPURenderPassMaxDrawCount; struct WGPURenderPassTimestampWrites; struct WGPURequestAdapterOptions; struct WGPUSamplerBindingLayout; struct WGPUSamplerDescriptor; -struct WGPUShaderModuleCompilationHint; -struct WGPUShaderModuleSPIRVDescriptor; -struct WGPUShaderModuleWGSLDescriptor; +struct WGPUShaderModuleDescriptor; +struct WGPUShaderSourceSPIRV; +struct WGPUShaderSourceWGSL; struct WGPUStencilFaceState; struct WGPUStorageTextureBindingLayout; +struct WGPUSupportedFeatures; +struct WGPUSupportedWGSLLanguageFeatures; struct WGPUSurfaceCapabilities; struct WGPUSurfaceConfiguration; struct WGPUSurfaceDescriptor; -struct WGPUSurfaceDescriptorFromAndroidNativeWindow; -struct WGPUSurfaceDescriptorFromCanvasHTMLSelector; -struct WGPUSurfaceDescriptorFromMetalLayer; -struct WGPUSurfaceDescriptorFromWaylandSurface; -struct WGPUSurfaceDescriptorFromWindowsHWND; -struct WGPUSurfaceDescriptorFromXcbWindow; -struct WGPUSurfaceDescriptorFromXlibWindow; +struct WGPUSurfaceSourceAndroidNativeWindow; +struct WGPUSurfaceSourceMetalLayer; +struct WGPUSurfaceSourceWaylandSurface; +struct WGPUSurfaceSourceWindowsHWND; +struct WGPUSurfaceSourceXCBWindow; +struct WGPUSurfaceSourceXlibWindow; struct WGPUSurfaceTexture; +struct WGPUTexelCopyBufferLayout; struct WGPUTextureBindingLayout; -struct WGPUTextureDataLayout; struct WGPUTextureViewDescriptor; struct WGPUVertexAttribute; struct WGPUBindGroupDescriptor; @@ -158,40 +227,67 @@ struct WGPUBlendState; struct WGPUCompilationInfo; struct WGPUComputePassDescriptor; struct WGPUDepthStencilState; -struct WGPUImageCopyBuffer; -struct WGPUImageCopyTexture; +struct WGPUDeviceDescriptor; +struct WGPUFutureWaitInfo; +struct WGPUInstanceDescriptor; struct WGPUProgrammableStageDescriptor; struct WGPURenderPassColorAttachment; -struct WGPURequiredLimits; -struct WGPUShaderModuleDescriptor; -struct WGPUSupportedLimits; +struct WGPUTexelCopyBufferInfo; +struct WGPUTexelCopyTextureInfo; struct WGPUTextureDescriptor; struct WGPUVertexBufferLayout; struct WGPUBindGroupLayoutDescriptor; struct WGPUColorTargetState; struct WGPUComputePipelineDescriptor; -struct WGPUDeviceDescriptor; struct WGPURenderPassDescriptor; struct WGPUVertexState; struct WGPUFragmentState; struct WGPURenderPipelineDescriptor; +// Callback info structure forward declarations +struct WGPUBufferMapCallbackInfo; +struct WGPUCompilationInfoCallbackInfo; +struct WGPUCreateComputePipelineAsyncCallbackInfo; +struct WGPUCreateRenderPipelineAsyncCallbackInfo; +struct WGPUDeviceLostCallbackInfo; +struct WGPUPopErrorScopeCallbackInfo; +struct WGPUQueueWorkDoneCallbackInfo; +struct WGPURequestAdapterCallbackInfo; +struct WGPURequestDeviceCallbackInfo; +struct WGPUUncapturedErrorCallbackInfo; + + +/** + * \defgroup Enumerations + * \brief Enums. + * + * @{ + */ typedef enum WGPUAdapterType { - WGPUAdapterType_DiscreteGPU = 0x00000000, - WGPUAdapterType_IntegratedGPU = 0x00000001, - WGPUAdapterType_CPU = 0x00000002, - WGPUAdapterType_Unknown = 0x00000003, + WGPUAdapterType_DiscreteGPU = 0x00000001, + WGPUAdapterType_IntegratedGPU = 0x00000002, + WGPUAdapterType_CPU = 0x00000003, + WGPUAdapterType_Unknown = 0x00000004, WGPUAdapterType_Force32 = 0x7FFFFFFF } WGPUAdapterType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUAddressMode { - WGPUAddressMode_Repeat = 0x00000000, - WGPUAddressMode_MirrorRepeat = 0x00000001, - WGPUAddressMode_ClampToEdge = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUAddressMode_Undefined = 0x00000000, + WGPUAddressMode_ClampToEdge = 0x00000001, + WGPUAddressMode_Repeat = 0x00000002, + WGPUAddressMode_MirrorRepeat = 0x00000003, WGPUAddressMode_Force32 = 0x7FFFFFFF } WGPUAddressMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBackendType { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUBackendType_Undefined = 0x00000000, WGPUBackendType_Null = 0x00000001, WGPUBackendType_WebGPU = 0x00000002, @@ -205,165 +301,277 @@ typedef enum WGPUBackendType { } WGPUBackendType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendFactor { - WGPUBlendFactor_Zero = 0x00000000, - WGPUBlendFactor_One = 0x00000001, - WGPUBlendFactor_Src = 0x00000002, - WGPUBlendFactor_OneMinusSrc = 0x00000003, - WGPUBlendFactor_SrcAlpha = 0x00000004, - WGPUBlendFactor_OneMinusSrcAlpha = 0x00000005, - WGPUBlendFactor_Dst = 0x00000006, - WGPUBlendFactor_OneMinusDst = 0x00000007, - WGPUBlendFactor_DstAlpha = 0x00000008, - WGPUBlendFactor_OneMinusDstAlpha = 0x00000009, - WGPUBlendFactor_SrcAlphaSaturated = 0x0000000A, - WGPUBlendFactor_Constant = 0x0000000B, - WGPUBlendFactor_OneMinusConstant = 0x0000000C, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBlendFactor_Undefined = 0x00000000, + WGPUBlendFactor_Zero = 0x00000001, + WGPUBlendFactor_One = 0x00000002, + WGPUBlendFactor_Src = 0x00000003, + WGPUBlendFactor_OneMinusSrc = 0x00000004, + WGPUBlendFactor_SrcAlpha = 0x00000005, + WGPUBlendFactor_OneMinusSrcAlpha = 0x00000006, + WGPUBlendFactor_Dst = 0x00000007, + WGPUBlendFactor_OneMinusDst = 0x00000008, + WGPUBlendFactor_DstAlpha = 0x00000009, + WGPUBlendFactor_OneMinusDstAlpha = 0x0000000A, + WGPUBlendFactor_SrcAlphaSaturated = 0x0000000B, + WGPUBlendFactor_Constant = 0x0000000C, + WGPUBlendFactor_OneMinusConstant = 0x0000000D, + WGPUBlendFactor_Src1 = 0x0000000E, + WGPUBlendFactor_OneMinusSrc1 = 0x0000000F, + WGPUBlendFactor_Src1Alpha = 0x00000010, + WGPUBlendFactor_OneMinusSrc1Alpha = 0x00000011, WGPUBlendFactor_Force32 = 0x7FFFFFFF } WGPUBlendFactor WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendOperation { - WGPUBlendOperation_Add = 0x00000000, - WGPUBlendOperation_Subtract = 0x00000001, - WGPUBlendOperation_ReverseSubtract = 0x00000002, - WGPUBlendOperation_Min = 0x00000003, - WGPUBlendOperation_Max = 0x00000004, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBlendOperation_Undefined = 0x00000000, + WGPUBlendOperation_Add = 0x00000001, + WGPUBlendOperation_Subtract = 0x00000002, + WGPUBlendOperation_ReverseSubtract = 0x00000003, + WGPUBlendOperation_Min = 0x00000004, + WGPUBlendOperation_Max = 0x00000005, WGPUBlendOperation_Force32 = 0x7FFFFFFF } WGPUBlendOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBufferBindingType { - WGPUBufferBindingType_Undefined = 0x00000000, - WGPUBufferBindingType_Uniform = 0x00000001, - WGPUBufferBindingType_Storage = 0x00000002, - WGPUBufferBindingType_ReadOnlyStorage = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUBufferBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUBufferBindingType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBufferBindingType_Undefined = 0x00000001, + WGPUBufferBindingType_Uniform = 0x00000002, + WGPUBufferBindingType_Storage = 0x00000003, + WGPUBufferBindingType_ReadOnlyStorage = 0x00000004, WGPUBufferBindingType_Force32 = 0x7FFFFFFF } WGPUBufferBindingType WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUBufferMapAsyncStatus { - WGPUBufferMapAsyncStatus_Success = 0x00000000, - WGPUBufferMapAsyncStatus_ValidationError = 0x00000001, - WGPUBufferMapAsyncStatus_Unknown = 0x00000002, - WGPUBufferMapAsyncStatus_DeviceLost = 0x00000003, - WGPUBufferMapAsyncStatus_DestroyedBeforeCallback = 0x00000004, - WGPUBufferMapAsyncStatus_UnmappedBeforeCallback = 0x00000005, - WGPUBufferMapAsyncStatus_MappingAlreadyPending = 0x00000006, - WGPUBufferMapAsyncStatus_OffsetOutOfRange = 0x00000007, - WGPUBufferMapAsyncStatus_SizeOutOfRange = 0x00000008, - WGPUBufferMapAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUBufferMapAsyncStatus WGPU_ENUM_ATTRIBUTE; - typedef enum WGPUBufferMapState { - WGPUBufferMapState_Unmapped = 0x00000000, - WGPUBufferMapState_Pending = 0x00000001, - WGPUBufferMapState_Mapped = 0x00000002, + WGPUBufferMapState_Unmapped = 0x00000001, + WGPUBufferMapState_Pending = 0x00000002, + WGPUBufferMapState_Mapped = 0x00000003, WGPUBufferMapState_Force32 = 0x7FFFFFFF } WGPUBufferMapState WGPU_ENUM_ATTRIBUTE; +/** + * The callback mode controls how a callback for an asynchronous operation may be fired. See @ref Asynchronous-Operations for how these are used. + */ +typedef enum WGPUCallbackMode { + /** + * `0x00000001`. + * Callbacks created with `WGPUCallbackMode_WaitAnyOnly`: + * - fire when the asynchronous operation's future is passed to a call to `::wgpuInstanceWaitAny` + * AND the operation has already completed or it completes inside the call to `::wgpuInstanceWaitAny`. + */ + WGPUCallbackMode_WaitAnyOnly = 0x00000001, + /** + * `0x00000002`. + * Callbacks created with `WGPUCallbackMode_AllowProcessEvents`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_WaitAnyOnly` + * - fire inside a call to `::wgpuInstanceProcessEvents` if the asynchronous operation is complete. + */ + WGPUCallbackMode_AllowProcessEvents = 0x00000002, + /** + * `0x00000003`. + * Callbacks created with `WGPUCallbackMode_AllowSpontaneous`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_AllowProcessEvents` + * - **may** fire spontaneously on an arbitrary or application thread, when the WebGPU implementations discovers that the asynchronous operation is complete. + * + * Implementations _should_ fire spontaneous callbacks as soon as possible. + * + * @note Because spontaneous callbacks may fire at an arbitrary time on an arbitrary thread, applications should take extra care when acquiring locks or mutating state inside the callback. It undefined behavior to re-entrantly call into the webgpu.h API if the callback fires while inside the callstack of another webgpu.h function that is not `wgpuInstanceWaitAny` or `wgpuInstanceProcessEvents`. + */ + WGPUCallbackMode_AllowSpontaneous = 0x00000003, + WGPUCallbackMode_Force32 = 0x7FFFFFFF +} WGPUCallbackMode WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUCompareFunction { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUCompareFunction_Undefined = 0x00000000, WGPUCompareFunction_Never = 0x00000001, WGPUCompareFunction_Less = 0x00000002, - WGPUCompareFunction_LessEqual = 0x00000003, - WGPUCompareFunction_Greater = 0x00000004, - WGPUCompareFunction_GreaterEqual = 0x00000005, - WGPUCompareFunction_Equal = 0x00000006, - WGPUCompareFunction_NotEqual = 0x00000007, + WGPUCompareFunction_Equal = 0x00000003, + WGPUCompareFunction_LessEqual = 0x00000004, + WGPUCompareFunction_Greater = 0x00000005, + WGPUCompareFunction_NotEqual = 0x00000006, + WGPUCompareFunction_GreaterEqual = 0x00000007, WGPUCompareFunction_Always = 0x00000008, WGPUCompareFunction_Force32 = 0x7FFFFFFF } WGPUCompareFunction WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationInfoRequestStatus { - WGPUCompilationInfoRequestStatus_Success = 0x00000000, - WGPUCompilationInfoRequestStatus_Error = 0x00000001, - WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000002, - WGPUCompilationInfoRequestStatus_Unknown = 0x00000003, + WGPUCompilationInfoRequestStatus_Success = 0x00000001, + WGPUCompilationInfoRequestStatus_InstanceDropped = 0x00000002, + WGPUCompilationInfoRequestStatus_Error = 0x00000003, + WGPUCompilationInfoRequestStatus_Unknown = 0x00000004, WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF } WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationMessageType { - WGPUCompilationMessageType_Error = 0x00000000, - WGPUCompilationMessageType_Warning = 0x00000001, - WGPUCompilationMessageType_Info = 0x00000002, + WGPUCompilationMessageType_Error = 0x00000001, + WGPUCompilationMessageType_Warning = 0x00000002, + WGPUCompilationMessageType_Info = 0x00000003, WGPUCompilationMessageType_Force32 = 0x7FFFFFFF } WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE; +/** + * Describes how frames are composited with other contents on the screen when `::wgpuSurfacePresent` is called. + */ typedef enum WGPUCompositeAlphaMode { + /** + * `0x00000000`. + * Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between @ref WGPUCompositeAlphaMode_Opaque or @ref WGPUCompositeAlphaMode_Inherit. + */ WGPUCompositeAlphaMode_Auto = 0x00000000, + /** + * `0x00000001`. + * The alpha component of the image is ignored and teated as if it is always 1.0. + */ WGPUCompositeAlphaMode_Opaque = 0x00000001, + /** + * `0x00000002`. + * The alpha component is respected and non-alpha components are assumed to be already multiplied with the alpha component. For example, (0.5, 0, 0, 0.5) is semi-transparent bright red. + */ WGPUCompositeAlphaMode_Premultiplied = 0x00000002, + /** + * `0x00000003`. + * The alpha component is respected and non-alpha components are assumed to NOT be already multiplied with the alpha component. For example, (1.0, 0, 0, 0.5) is semi-transparent bright red. + */ WGPUCompositeAlphaMode_Unpremultiplied = 0x00000003, + /** + * `0x00000004`. + * The handling of the alpha component is unknown to WebGPU and should be handled by the application using system-specific APIs. This mode may be unavailable (for example on Wasm). + */ WGPUCompositeAlphaMode_Inherit = 0x00000004, WGPUCompositeAlphaMode_Force32 = 0x7FFFFFFF } WGPUCompositeAlphaMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCreatePipelineAsyncStatus { - WGPUCreatePipelineAsyncStatus_Success = 0x00000000, - WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001, - WGPUCreatePipelineAsyncStatus_InternalError = 0x00000002, - WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000003, - WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000004, + WGPUCreatePipelineAsyncStatus_Success = 0x00000001, + WGPUCreatePipelineAsyncStatus_InstanceDropped = 0x00000002, + WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000003, + WGPUCreatePipelineAsyncStatus_InternalError = 0x00000004, WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF } WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCullMode { - WGPUCullMode_None = 0x00000000, - WGPUCullMode_Front = 0x00000001, - WGPUCullMode_Back = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUCullMode_Undefined = 0x00000000, + WGPUCullMode_None = 0x00000001, + WGPUCullMode_Front = 0x00000002, + WGPUCullMode_Back = 0x00000003, WGPUCullMode_Force32 = 0x7FFFFFFF } WGPUCullMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUDeviceLostReason { - WGPUDeviceLostReason_Undefined = 0x00000000, - WGPUDeviceLostReason_Destroyed = 0x00000001, + WGPUDeviceLostReason_Unknown = 0x00000001, + WGPUDeviceLostReason_Destroyed = 0x00000002, + WGPUDeviceLostReason_InstanceDropped = 0x00000003, + WGPUDeviceLostReason_FailedCreation = 0x00000004, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF } WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorFilter { - WGPUErrorFilter_Validation = 0x00000000, - WGPUErrorFilter_OutOfMemory = 0x00000001, - WGPUErrorFilter_Internal = 0x00000002, + WGPUErrorFilter_Validation = 0x00000001, + WGPUErrorFilter_OutOfMemory = 0x00000002, + WGPUErrorFilter_Internal = 0x00000003, WGPUErrorFilter_Force32 = 0x7FFFFFFF } WGPUErrorFilter WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorType { - WGPUErrorType_NoError = 0x00000000, - WGPUErrorType_Validation = 0x00000001, - WGPUErrorType_OutOfMemory = 0x00000002, - WGPUErrorType_Internal = 0x00000003, - WGPUErrorType_Unknown = 0x00000004, - WGPUErrorType_DeviceLost = 0x00000005, + WGPUErrorType_NoError = 0x00000001, + WGPUErrorType_Validation = 0x00000002, + WGPUErrorType_OutOfMemory = 0x00000003, + WGPUErrorType_Internal = 0x00000004, + WGPUErrorType_Unknown = 0x00000005, WGPUErrorType_Force32 = 0x7FFFFFFF } WGPUErrorType WGPU_ENUM_ATTRIBUTE; +/** + * See @ref WGPURequestAdapterOptions::featureLevel. + */ +typedef enum WGPUFeatureLevel { + /** + * `0x00000001`. + * "Compatibility" profile which can be supported on OpenGL ES 3.1. + */ + WGPUFeatureLevel_Compatibility = 0x00000001, + /** + * `0x00000002`. + * "Core" profile which can be supported on Vulkan/Metal/D3D12. + */ + WGPUFeatureLevel_Core = 0x00000002, + WGPUFeatureLevel_Force32 = 0x7FFFFFFF +} WGPUFeatureLevel WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUFeatureName { WGPUFeatureName_Undefined = 0x00000000, WGPUFeatureName_DepthClipControl = 0x00000001, WGPUFeatureName_Depth32FloatStencil8 = 0x00000002, WGPUFeatureName_TimestampQuery = 0x00000003, WGPUFeatureName_TextureCompressionBC = 0x00000004, - WGPUFeatureName_TextureCompressionETC2 = 0x00000005, - WGPUFeatureName_TextureCompressionASTC = 0x00000006, - WGPUFeatureName_IndirectFirstInstance = 0x00000007, - WGPUFeatureName_ShaderF16 = 0x00000008, - WGPUFeatureName_RG11B10UfloatRenderable = 0x00000009, - WGPUFeatureName_BGRA8UnormStorage = 0x0000000A, - WGPUFeatureName_Float32Filterable = 0x0000000B, + WGPUFeatureName_TextureCompressionBCSliced3D = 0x00000005, + WGPUFeatureName_TextureCompressionETC2 = 0x00000006, + WGPUFeatureName_TextureCompressionASTC = 0x00000007, + WGPUFeatureName_TextureCompressionASTCSliced3D = 0x00000008, + WGPUFeatureName_IndirectFirstInstance = 0x00000009, + WGPUFeatureName_ShaderF16 = 0x0000000A, + WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000B, + WGPUFeatureName_BGRA8UnormStorage = 0x0000000C, + WGPUFeatureName_Float32Filterable = 0x0000000D, + WGPUFeatureName_Float32Blendable = 0x0000000E, + WGPUFeatureName_ClipDistances = 0x0000000F, + WGPUFeatureName_DualSourceBlending = 0x00000010, WGPUFeatureName_Force32 = 0x7FFFFFFF } WGPUFeatureName WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFilterMode { - WGPUFilterMode_Nearest = 0x00000000, - WGPUFilterMode_Linear = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFilterMode_Undefined = 0x00000000, + WGPUFilterMode_Nearest = 0x00000001, + WGPUFilterMode_Linear = 0x00000002, WGPUFilterMode_Force32 = 0x7FFFFFFF } WGPUFilterMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFrontFace { - WGPUFrontFace_CCW = 0x00000000, - WGPUFrontFace_CW = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFrontFace_Undefined = 0x00000000, + WGPUFrontFace_CCW = 0x00000001, + WGPUFrontFace_CW = 0x00000002, WGPUFrontFace_Force32 = 0x7FFFFFFF } WGPUFrontFace WGPU_ENUM_ATTRIBUTE; typedef enum WGPUIndexFormat { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUIndexFormat_Undefined = 0x00000000, WGPUIndexFormat_Uint16 = 0x00000001, WGPUIndexFormat_Uint32 = 0x00000002, @@ -371,147 +579,318 @@ typedef enum WGPUIndexFormat { } WGPUIndexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPULoadOp { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPULoadOp_Undefined = 0x00000000, - WGPULoadOp_Clear = 0x00000001, - WGPULoadOp_Load = 0x00000002, + WGPULoadOp_Load = 0x00000001, + WGPULoadOp_Clear = 0x00000002, WGPULoadOp_Force32 = 0x7FFFFFFF } WGPULoadOp WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUMapAsyncStatus { + WGPUMapAsyncStatus_Success = 0x00000001, + WGPUMapAsyncStatus_InstanceDropped = 0x00000002, + WGPUMapAsyncStatus_Error = 0x00000003, + WGPUMapAsyncStatus_Aborted = 0x00000004, + WGPUMapAsyncStatus_Unknown = 0x00000005, + WGPUMapAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUMapAsyncStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUMipmapFilterMode { - WGPUMipmapFilterMode_Nearest = 0x00000000, - WGPUMipmapFilterMode_Linear = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUMipmapFilterMode_Undefined = 0x00000000, + WGPUMipmapFilterMode_Nearest = 0x00000001, + WGPUMipmapFilterMode_Linear = 0x00000002, WGPUMipmapFilterMode_Force32 = 0x7FFFFFFF } WGPUMipmapFilterMode WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUOptionalBool { + WGPUOptionalBool_False = 0x00000000, + WGPUOptionalBool_True = 0x00000001, + WGPUOptionalBool_Undefined = 0x00000002, + WGPUOptionalBool_Force32 = 0x7FFFFFFF +} WGPUOptionalBool WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUPopErrorScopeStatus { + /** + * `0x00000001`. + * The error scope stack was successfully popped and a result was reported. + */ + WGPUPopErrorScopeStatus_Success = 0x00000001, + WGPUPopErrorScopeStatus_InstanceDropped = 0x00000002, + /** + * `0x00000003`. + * The error scope stack could not be popped, because it was empty. + */ + WGPUPopErrorScopeStatus_EmptyStack = 0x00000003, + WGPUPopErrorScopeStatus_Force32 = 0x7FFFFFFF +} WGPUPopErrorScopeStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUPowerPreference { + /** + * `0x00000000`. + * No preference. (See also @ref SentinelValues.) + */ WGPUPowerPreference_Undefined = 0x00000000, WGPUPowerPreference_LowPower = 0x00000001, WGPUPowerPreference_HighPerformance = 0x00000002, WGPUPowerPreference_Force32 = 0x7FFFFFFF } WGPUPowerPreference WGPU_ENUM_ATTRIBUTE; +/** + * Describes when and in which order frames are presented on the screen when `::wgpuSurfacePresent` is called. + */ typedef enum WGPUPresentMode { - WGPUPresentMode_Fifo = 0x00000000, - WGPUPresentMode_FifoRelaxed = 0x00000001, - WGPUPresentMode_Immediate = 0x00000002, - WGPUPresentMode_Mailbox = 0x00000003, + /** + * `0x00000000`. + * Present mode is not specified. Use the default. + */ + WGPUPresentMode_Undefined = 0x00000000, + /** + * `0x00000001`. + * The presentation of the image to the user waits for the next vertical blanking period to update in a first-in, first-out manner. + * Tearing cannot be observed and frame-loop will be limited to the display's refresh rate. + * This is the only mode that's always available. + */ + WGPUPresentMode_Fifo = 0x00000001, + /** + * `0x00000002`. + * The presentation of the image to the user tries to wait for the next vertical blanking period but may decide to not wait if a frame is presented late. + * Tearing can sometimes be observed but late-frame don't produce a full-frame stutter in the presentation. + * This is still a first-in, first-out mechanism so a frame-loop will be limited to the display's refresh rate. + */ + WGPUPresentMode_FifoRelaxed = 0x00000002, + /** + * `0x00000003`. + * The presentation of the image to the user is updated immediately without waiting for a vertical blank. + * Tearing can be observed but latency is minimized. + */ + WGPUPresentMode_Immediate = 0x00000003, + /** + * `0x00000004`. + * The presentation of the image to the user waits for the next vertical blanking period to update to the latest provided image. + * Tearing cannot be observed and a frame-loop is not limited to the display's refresh rate. + */ + WGPUPresentMode_Mailbox = 0x00000004, WGPUPresentMode_Force32 = 0x7FFFFFFF } WGPUPresentMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPrimitiveTopology { - WGPUPrimitiveTopology_PointList = 0x00000000, - WGPUPrimitiveTopology_LineList = 0x00000001, - WGPUPrimitiveTopology_LineStrip = 0x00000002, - WGPUPrimitiveTopology_TriangleList = 0x00000003, - WGPUPrimitiveTopology_TriangleStrip = 0x00000004, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUPrimitiveTopology_Undefined = 0x00000000, + WGPUPrimitiveTopology_PointList = 0x00000001, + WGPUPrimitiveTopology_LineList = 0x00000002, + WGPUPrimitiveTopology_LineStrip = 0x00000003, + WGPUPrimitiveTopology_TriangleList = 0x00000004, + WGPUPrimitiveTopology_TriangleStrip = 0x00000005, WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF } WGPUPrimitiveTopology WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueryType { - WGPUQueryType_Occlusion = 0x00000000, - WGPUQueryType_Timestamp = 0x00000001, + WGPUQueryType_Occlusion = 0x00000001, + WGPUQueryType_Timestamp = 0x00000002, WGPUQueryType_Force32 = 0x7FFFFFFF } WGPUQueryType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueueWorkDoneStatus { - WGPUQueueWorkDoneStatus_Success = 0x00000000, - WGPUQueueWorkDoneStatus_Error = 0x00000001, - WGPUQueueWorkDoneStatus_Unknown = 0x00000002, - WGPUQueueWorkDoneStatus_DeviceLost = 0x00000003, + WGPUQueueWorkDoneStatus_Success = 0x00000001, + WGPUQueueWorkDoneStatus_InstanceDropped = 0x00000002, + WGPUQueueWorkDoneStatus_Error = 0x00000003, + WGPUQueueWorkDoneStatus_Unknown = 0x00000004, WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF } WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestAdapterStatus { - WGPURequestAdapterStatus_Success = 0x00000000, - WGPURequestAdapterStatus_Unavailable = 0x00000001, - WGPURequestAdapterStatus_Error = 0x00000002, - WGPURequestAdapterStatus_Unknown = 0x00000003, + WGPURequestAdapterStatus_Success = 0x00000001, + WGPURequestAdapterStatus_InstanceDropped = 0x00000002, + WGPURequestAdapterStatus_Unavailable = 0x00000003, + WGPURequestAdapterStatus_Error = 0x00000004, + WGPURequestAdapterStatus_Unknown = 0x00000005, WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF } WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestDeviceStatus { - WGPURequestDeviceStatus_Success = 0x00000000, - WGPURequestDeviceStatus_Error = 0x00000001, - WGPURequestDeviceStatus_Unknown = 0x00000002, + WGPURequestDeviceStatus_Success = 0x00000001, + WGPURequestDeviceStatus_InstanceDropped = 0x00000002, + WGPURequestDeviceStatus_Error = 0x00000003, + WGPURequestDeviceStatus_Unknown = 0x00000004, WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF } WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSType { - WGPUSType_Invalid = 0x00000000, - WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, - WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, - WGPUSType_SurfaceDescriptorFromXlibWindow = 0x00000003, - WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004, - WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, - WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, - WGPUSType_PrimitiveDepthClipControl = 0x00000007, - WGPUSType_SurfaceDescriptorFromWaylandSurface = 0x00000008, - WGPUSType_SurfaceDescriptorFromAndroidNativeWindow = 0x00000009, - WGPUSType_SurfaceDescriptorFromXcbWindow = 0x0000000A, - WGPUSType_RenderPassDescriptorMaxDrawCount = 0x0000000F, + WGPUSType_ShaderSourceSPIRV = 0x00000001, + WGPUSType_ShaderSourceWGSL = 0x00000002, + WGPUSType_RenderPassMaxDrawCount = 0x00000003, + WGPUSType_SurfaceSourceMetalLayer = 0x00000004, + WGPUSType_SurfaceSourceWindowsHWND = 0x00000005, + WGPUSType_SurfaceSourceXlibWindow = 0x00000006, + WGPUSType_SurfaceSourceWaylandSurface = 0x00000007, + WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008, + WGPUSType_SurfaceSourceXCBWindow = 0x00000009, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSamplerBindingType { - WGPUSamplerBindingType_Undefined = 0x00000000, - WGPUSamplerBindingType_Filtering = 0x00000001, - WGPUSamplerBindingType_NonFiltering = 0x00000002, - WGPUSamplerBindingType_Comparison = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUSamplerBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUSamplerBindingType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUSamplerBindingType_Undefined = 0x00000001, + WGPUSamplerBindingType_Filtering = 0x00000002, + WGPUSamplerBindingType_NonFiltering = 0x00000003, + WGPUSamplerBindingType_Comparison = 0x00000004, WGPUSamplerBindingType_Force32 = 0x7FFFFFFF } WGPUSamplerBindingType WGPU_ENUM_ATTRIBUTE; +/** + * Status code returned (synchronously) from many operations. Generally + * indicates an invalid input like an unknown enum value or @ref OutStructChainError. + * Read the function's documentation for specific error conditions. + */ +typedef enum WGPUStatus { + WGPUStatus_Success = 0x00000001, + WGPUStatus_Error = 0x00000002, + WGPUStatus_Force32 = 0x7FFFFFFF +} WGPUStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUStencilOperation { - WGPUStencilOperation_Keep = 0x00000000, - WGPUStencilOperation_Zero = 0x00000001, - WGPUStencilOperation_Replace = 0x00000002, - WGPUStencilOperation_Invert = 0x00000003, - WGPUStencilOperation_IncrementClamp = 0x00000004, - WGPUStencilOperation_DecrementClamp = 0x00000005, - WGPUStencilOperation_IncrementWrap = 0x00000006, - WGPUStencilOperation_DecrementWrap = 0x00000007, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUStencilOperation_Undefined = 0x00000000, + WGPUStencilOperation_Keep = 0x00000001, + WGPUStencilOperation_Zero = 0x00000002, + WGPUStencilOperation_Replace = 0x00000003, + WGPUStencilOperation_Invert = 0x00000004, + WGPUStencilOperation_IncrementClamp = 0x00000005, + WGPUStencilOperation_DecrementClamp = 0x00000006, + WGPUStencilOperation_IncrementWrap = 0x00000007, + WGPUStencilOperation_DecrementWrap = 0x00000008, WGPUStencilOperation_Force32 = 0x7FFFFFFF } WGPUStencilOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStorageTextureAccess { - WGPUStorageTextureAccess_Undefined = 0x00000000, - WGPUStorageTextureAccess_WriteOnly = 0x00000001, - WGPUStorageTextureAccess_ReadOnly = 0x00000002, - WGPUStorageTextureAccess_ReadWrite = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUStorageTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUStorageTextureAccess_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUStorageTextureAccess_Undefined = 0x00000001, + WGPUStorageTextureAccess_WriteOnly = 0x00000002, + WGPUStorageTextureAccess_ReadOnly = 0x00000003, + WGPUStorageTextureAccess_ReadWrite = 0x00000004, WGPUStorageTextureAccess_Force32 = 0x7FFFFFFF } WGPUStorageTextureAccess WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStoreOp { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUStoreOp_Undefined = 0x00000000, WGPUStoreOp_Store = 0x00000001, WGPUStoreOp_Discard = 0x00000002, WGPUStoreOp_Force32 = 0x7FFFFFFF } WGPUStoreOp WGPU_ENUM_ATTRIBUTE; +/** + * The status enum for `::wgpuSurfaceGetCurrentTexture`. + */ typedef enum WGPUSurfaceGetCurrentTextureStatus { - WGPUSurfaceGetCurrentTextureStatus_Success = 0x00000000, - WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000001, - WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000002, - WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000003, - WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000004, - WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000005, + /** + * `0x00000001`. + * Yay! Everything is good and we can render this frame. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal = 0x00000001, + /** + * `0x00000002`. + * Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal = 0x00000002, + /** + * `0x00000003`. + * Some operation timed out while trying to acquire the frame. + */ + WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000003, + /** + * `0x00000004`. + * The surface is too different to be used, compared to when it was originally created. + */ + WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000004, + /** + * `0x00000005`. + * The connection to whatever owns the surface was lost. + */ + WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000005, + /** + * `0x00000006`. + * The system ran out of memory. + */ + WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000006, + /** + * `0x00000007`. + * The @ref WGPUDevice configured on the @ref WGPUSurface was lost. + */ + WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000007, + /** + * `0x00000008`. + * The surface is not configured, or there was an @ref OutStructChainError. + */ + WGPUSurfaceGetCurrentTextureStatus_Error = 0x00000008, WGPUSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF } WGPUSurfaceGetCurrentTextureStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureAspect { - WGPUTextureAspect_All = 0x00000000, - WGPUTextureAspect_StencilOnly = 0x00000001, - WGPUTextureAspect_DepthOnly = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureAspect_Undefined = 0x00000000, + WGPUTextureAspect_All = 0x00000001, + WGPUTextureAspect_StencilOnly = 0x00000002, + WGPUTextureAspect_DepthOnly = 0x00000003, WGPUTextureAspect_Force32 = 0x7FFFFFFF } WGPUTextureAspect WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureDimension { - WGPUTextureDimension_1D = 0x00000000, - WGPUTextureDimension_2D = 0x00000001, - WGPUTextureDimension_3D = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureDimension_Undefined = 0x00000000, + WGPUTextureDimension_1D = 0x00000001, + WGPUTextureDimension_2D = 0x00000002, + WGPUTextureDimension_3D = 0x00000003, WGPUTextureDimension_Force32 = 0x7FFFFFFF } WGPUTextureDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureFormat { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUTextureFormat_Undefined = 0x00000000, WGPUTextureFormat_R8Unorm = 0x00000001, WGPUTextureFormat_R8Snorm = 0x00000002, @@ -612,16 +991,31 @@ typedef enum WGPUTextureFormat { } WGPUTextureFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureSampleType { - WGPUTextureSampleType_Undefined = 0x00000000, - WGPUTextureSampleType_Float = 0x00000001, - WGPUTextureSampleType_UnfilterableFloat = 0x00000002, - WGPUTextureSampleType_Depth = 0x00000003, - WGPUTextureSampleType_Sint = 0x00000004, - WGPUTextureSampleType_Uint = 0x00000005, + /** + * `0x00000000`. + * Indicates that this @ref WGPUTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUTextureSampleType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureSampleType_Undefined = 0x00000001, + WGPUTextureSampleType_Float = 0x00000002, + WGPUTextureSampleType_UnfilterableFloat = 0x00000003, + WGPUTextureSampleType_Depth = 0x00000004, + WGPUTextureSampleType_Sint = 0x00000005, + WGPUTextureSampleType_Uint = 0x00000006, WGPUTextureSampleType_Force32 = 0x7FFFFFFF } WGPUTextureSampleType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureViewDimension { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUTextureViewDimension_Undefined = 0x00000000, WGPUTextureViewDimension_1D = 0x00000001, WGPUTextureViewDimension_2D = 0x00000002, @@ -633,112 +1027,243 @@ typedef enum WGPUTextureViewDimension { } WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexFormat { - WGPUVertexFormat_Undefined = 0x00000000, - WGPUVertexFormat_Uint8x2 = 0x00000001, - WGPUVertexFormat_Uint8x4 = 0x00000002, - WGPUVertexFormat_Sint8x2 = 0x00000003, - WGPUVertexFormat_Sint8x4 = 0x00000004, - WGPUVertexFormat_Unorm8x2 = 0x00000005, - WGPUVertexFormat_Unorm8x4 = 0x00000006, - WGPUVertexFormat_Snorm8x2 = 0x00000007, - WGPUVertexFormat_Snorm8x4 = 0x00000008, - WGPUVertexFormat_Uint16x2 = 0x00000009, - WGPUVertexFormat_Uint16x4 = 0x0000000A, - WGPUVertexFormat_Sint16x2 = 0x0000000B, - WGPUVertexFormat_Sint16x4 = 0x0000000C, - WGPUVertexFormat_Unorm16x2 = 0x0000000D, - WGPUVertexFormat_Unorm16x4 = 0x0000000E, - WGPUVertexFormat_Snorm16x2 = 0x0000000F, - WGPUVertexFormat_Snorm16x4 = 0x00000010, - WGPUVertexFormat_Float16x2 = 0x00000011, - WGPUVertexFormat_Float16x4 = 0x00000012, - WGPUVertexFormat_Float32 = 0x00000013, - WGPUVertexFormat_Float32x2 = 0x00000014, - WGPUVertexFormat_Float32x3 = 0x00000015, - WGPUVertexFormat_Float32x4 = 0x00000016, - WGPUVertexFormat_Uint32 = 0x00000017, - WGPUVertexFormat_Uint32x2 = 0x00000018, - WGPUVertexFormat_Uint32x3 = 0x00000019, - WGPUVertexFormat_Uint32x4 = 0x0000001A, - WGPUVertexFormat_Sint32 = 0x0000001B, - WGPUVertexFormat_Sint32x2 = 0x0000001C, - WGPUVertexFormat_Sint32x3 = 0x0000001D, - WGPUVertexFormat_Sint32x4 = 0x0000001E, + WGPUVertexFormat_Uint8 = 0x00000001, + WGPUVertexFormat_Uint8x2 = 0x00000002, + WGPUVertexFormat_Uint8x4 = 0x00000003, + WGPUVertexFormat_Sint8 = 0x00000004, + WGPUVertexFormat_Sint8x2 = 0x00000005, + WGPUVertexFormat_Sint8x4 = 0x00000006, + WGPUVertexFormat_Unorm8 = 0x00000007, + WGPUVertexFormat_Unorm8x2 = 0x00000008, + WGPUVertexFormat_Unorm8x4 = 0x00000009, + WGPUVertexFormat_Snorm8 = 0x0000000A, + WGPUVertexFormat_Snorm8x2 = 0x0000000B, + WGPUVertexFormat_Snorm8x4 = 0x0000000C, + WGPUVertexFormat_Uint16 = 0x0000000D, + WGPUVertexFormat_Uint16x2 = 0x0000000E, + WGPUVertexFormat_Uint16x4 = 0x0000000F, + WGPUVertexFormat_Sint16 = 0x00000010, + WGPUVertexFormat_Sint16x2 = 0x00000011, + WGPUVertexFormat_Sint16x4 = 0x00000012, + WGPUVertexFormat_Unorm16 = 0x00000013, + WGPUVertexFormat_Unorm16x2 = 0x00000014, + WGPUVertexFormat_Unorm16x4 = 0x00000015, + WGPUVertexFormat_Snorm16 = 0x00000016, + WGPUVertexFormat_Snorm16x2 = 0x00000017, + WGPUVertexFormat_Snorm16x4 = 0x00000018, + WGPUVertexFormat_Float16 = 0x00000019, + WGPUVertexFormat_Float16x2 = 0x0000001A, + WGPUVertexFormat_Float16x4 = 0x0000001B, + WGPUVertexFormat_Float32 = 0x0000001C, + WGPUVertexFormat_Float32x2 = 0x0000001D, + WGPUVertexFormat_Float32x3 = 0x0000001E, + WGPUVertexFormat_Float32x4 = 0x0000001F, + WGPUVertexFormat_Uint32 = 0x00000020, + WGPUVertexFormat_Uint32x2 = 0x00000021, + WGPUVertexFormat_Uint32x3 = 0x00000022, + WGPUVertexFormat_Uint32x4 = 0x00000023, + WGPUVertexFormat_Sint32 = 0x00000024, + WGPUVertexFormat_Sint32x2 = 0x00000025, + WGPUVertexFormat_Sint32x3 = 0x00000026, + WGPUVertexFormat_Sint32x4 = 0x00000027, + WGPUVertexFormat_Unorm10_10_10_2 = 0x00000028, + WGPUVertexFormat_Unorm8x4BGRA = 0x00000029, WGPUVertexFormat_Force32 = 0x7FFFFFFF } WGPUVertexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexStepMode { - WGPUVertexStepMode_Vertex = 0x00000000, - WGPUVertexStepMode_Instance = 0x00000001, - WGPUVertexStepMode_VertexBufferNotUsed = 0x00000002, + /** + * `0x00000000`. + * This @ref WGPUVertexBufferLayout is a "hole" in the @ref WGPUVertexState `buffers` array. + * (See also @ref SentinelValues.) + */ + WGPUVertexStepMode_VertexBufferNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUVertexStepMode_Undefined = 0x00000001, + WGPUVertexStepMode_Vertex = 0x00000002, + WGPUVertexStepMode_Instance = 0x00000003, WGPUVertexStepMode_Force32 = 0x7FFFFFFF } WGPUVertexStepMode WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUBufferUsage { - WGPUBufferUsage_None = 0x00000000, - WGPUBufferUsage_MapRead = 0x00000001, - WGPUBufferUsage_MapWrite = 0x00000002, - WGPUBufferUsage_CopySrc = 0x00000004, - WGPUBufferUsage_CopyDst = 0x00000008, - WGPUBufferUsage_Index = 0x00000010, - WGPUBufferUsage_Vertex = 0x00000020, - WGPUBufferUsage_Uniform = 0x00000040, - WGPUBufferUsage_Storage = 0x00000080, - WGPUBufferUsage_Indirect = 0x00000100, - WGPUBufferUsage_QueryResolve = 0x00000200, - WGPUBufferUsage_Force32 = 0x7FFFFFFF -} WGPUBufferUsage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUBufferUsageFlags WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUWGSLLanguageFeatureName { + WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, + WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct = 0x00000002, + WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters = 0x00000003, + WGPUWGSLLanguageFeatureName_PointerCompositeAccess = 0x00000004, + WGPUWGSLLanguageFeatureName_Force32 = 0x7FFFFFFF +} WGPUWGSLLanguageFeatureName WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUColorWriteMask { - WGPUColorWriteMask_None = 0x00000000, - WGPUColorWriteMask_Red = 0x00000001, - WGPUColorWriteMask_Green = 0x00000002, - WGPUColorWriteMask_Blue = 0x00000004, - WGPUColorWriteMask_Alpha = 0x00000008, - WGPUColorWriteMask_All = 0x0000000F, - WGPUColorWriteMask_Force32 = 0x7FFFFFFF -} WGPUColorWriteMask WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUColorWriteMaskFlags WGPU_ENUM_ATTRIBUTE; +/** + * Status returned from a call to ::wgpuInstanceWaitAny. + */ +typedef enum WGPUWaitStatus { + /** + * `0x00000001`. + * At least one WGPUFuture completed successfully. + */ + WGPUWaitStatus_Success = 0x00000001, + /** + * `0x00000002`. + * No WGPUFutures completed within the timeout. + */ + WGPUWaitStatus_TimedOut = 0x00000002, + /** + * `0x00000003`. + * A @ref Timed-Wait was performed when WGPUInstanceFeatures::timedWaitAnyEnable is false. + */ + WGPUWaitStatus_UnsupportedTimeout = 0x00000003, + /** + * `0x00000004`. + * The number of futures waited on in a @ref Timed-Wait is greater than the supported WGPUInstanceFeatures::timedWaitAnyMaxCount. + */ + WGPUWaitStatus_UnsupportedCount = 0x00000004, + /** + * `0x00000005`. + * An invalid wait was performed with @ref Mixed-Sources. + */ + WGPUWaitStatus_UnsupportedMixedSources = 0x00000005, + WGPUWaitStatus_Force32 = 0x7FFFFFFF +} WGPUWaitStatus WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUMapMode { - WGPUMapMode_None = 0x00000000, - WGPUMapMode_Read = 0x00000001, - WGPUMapMode_Write = 0x00000002, - WGPUMapMode_Force32 = 0x7FFFFFFF -} WGPUMapMode WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUMapModeFlags WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUShaderStage { - WGPUShaderStage_None = 0x00000000, - WGPUShaderStage_Vertex = 0x00000001, - WGPUShaderStage_Fragment = 0x00000002, - WGPUShaderStage_Compute = 0x00000004, - WGPUShaderStage_Force32 = 0x7FFFFFFF -} WGPUShaderStage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUShaderStageFlags WGPU_ENUM_ATTRIBUTE; +/** @} */ -typedef enum WGPUTextureUsage { - WGPUTextureUsage_None = 0x00000000, - WGPUTextureUsage_CopySrc = 0x00000001, - WGPUTextureUsage_CopyDst = 0x00000002, - WGPUTextureUsage_TextureBinding = 0x00000004, - WGPUTextureUsage_StorageBinding = 0x00000008, - WGPUTextureUsage_RenderAttachment = 0x00000010, - WGPUTextureUsage_Force32 = 0x7FFFFFFF -} WGPUTextureUsage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUTextureUsageFlags WGPU_ENUM_ATTRIBUTE; +/** + * \defgroup Bitflags + * \brief Type and constant definitions for bitflag types. + * + * @{ + */ +typedef WGPUFlags WGPUBufferUsage; +static const WGPUBufferUsage WGPUBufferUsage_None = 0x0000000000000000; +static const WGPUBufferUsage WGPUBufferUsage_MapRead = 0x0000000000000001; +static const WGPUBufferUsage WGPUBufferUsage_MapWrite = 0x0000000000000002; +static const WGPUBufferUsage WGPUBufferUsage_CopySrc = 0x0000000000000004; +static const WGPUBufferUsage WGPUBufferUsage_CopyDst = 0x0000000000000008; +static const WGPUBufferUsage WGPUBufferUsage_Index = 0x0000000000000010; +static const WGPUBufferUsage WGPUBufferUsage_Vertex = 0x0000000000000020; +static const WGPUBufferUsage WGPUBufferUsage_Uniform = 0x0000000000000040; +static const WGPUBufferUsage WGPUBufferUsage_Storage = 0x0000000000000080; +static const WGPUBufferUsage WGPUBufferUsage_Indirect = 0x0000000000000100; +static const WGPUBufferUsage WGPUBufferUsage_QueryResolve = 0x0000000000000200; -typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFlags WGPUColorWriteMask; +static const WGPUColorWriteMask WGPUColorWriteMask_None = 0x0000000000000000; +static const WGPUColorWriteMask WGPUColorWriteMask_Red = 0x0000000000000001; +static const WGPUColorWriteMask WGPUColorWriteMask_Green = 0x0000000000000002; +static const WGPUColorWriteMask WGPUColorWriteMask_Blue = 0x0000000000000004; +static const WGPUColorWriteMask WGPUColorWriteMask_Alpha = 0x0000000000000008; +static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F /* Red | Green | Blue | Alpha */; + +typedef WGPUFlags WGPUMapMode; +static const WGPUMapMode WGPUMapMode_None = 0x0000000000000000; +static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001; +static const WGPUMapMode WGPUMapMode_Write = 0x0000000000000002; + +typedef WGPUFlags WGPUShaderStage; +static const WGPUShaderStage WGPUShaderStage_None = 0x0000000000000000; +static const WGPUShaderStage WGPUShaderStage_Vertex = 0x0000000000000001; +static const WGPUShaderStage WGPUShaderStage_Fragment = 0x0000000000000002; +static const WGPUShaderStage WGPUShaderStage_Compute = 0x0000000000000004; + +typedef WGPUFlags WGPUTextureUsage; +static const WGPUTextureUsage WGPUTextureUsage_None = 0x0000000000000000; +static const WGPUTextureUsage WGPUTextureUsage_CopySrc = 0x0000000000000001; +static const WGPUTextureUsage WGPUTextureUsage_CopyDst = 0x0000000000000002; +static const WGPUTextureUsage WGPUTextureUsage_TextureBinding = 0x0000000000000004; +static const WGPUTextureUsage WGPUTextureUsage_StorageBinding = 0x0000000000000008; +static const WGPUTextureUsage WGPUTextureUsage_RenderAttachment = 0x0000000000000010; + + +/** @} */ typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup Callbacks + * \brief Callbacks through which asynchronous functions return. + * + * @{ + */ +/** + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUBufferMapCallback)(WGPUMapAsyncStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param compilationInfo + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * Reference to the device which was lost. If, and only if, the `reason` is @ref WGPUDeviceLostReason_FailedCreation, this is a non-null pointer to a null @ref WGPUDevice. + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUDeviceLostCallback)(WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param status + * See @ref WGPUPopErrorScopeStatus. + * + * @param type + * The type of the error caught by the scope, or @ref WGPUErrorType_NoError if there was none. + * If the `status` is not @ref WGPUPopErrorScopeStatus_Success, this is @ref WGPUErrorType_NoError. + * + * @param message + * If the `type` is not @ref WGPUErrorType_NoError, this is a non-empty @ref LocalizableHumanReadableMessageString; + * otherwise, this is an empty string. + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUPopErrorScopeCallback)(WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param adapter + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUUncapturedErrorCallback)(WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ +/** + * \defgroup ChainedStructures Chained Structures + * \brief Structures used to extend descriptors. + * + * @{ + */ typedef struct WGPUChainedStruct { struct WGPUChainedStruct const * next; @@ -750,17 +1275,126 @@ typedef struct WGPUChainedStructOut { WGPUSType sType; } WGPUChainedStructOut WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUAdapterProperties { +/** @} */ + + +/** + * \defgroup Structures + * \brief Descriptors and other transparent structures. + * + * @{ + */ + + /** + * \defgroup WGPUCallbackInfo + * \brief Callback info structures that are used in asynchronous functions. + * + * @{ + */ +typedef struct WGPUBufferMapCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUBufferMapCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUBufferMapCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCompilationInfoCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCompilationInfoCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCompilationInfoCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateComputePipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCreateComputePipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateComputePipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateRenderPipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCreateRenderPipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateRenderPipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUDeviceLostCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUDeviceLostCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUDeviceLostCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUPopErrorScopeCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUPopErrorScopeCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUPopErrorScopeCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUQueueWorkDoneCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUQueueWorkDoneCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUQueueWorkDoneCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestAdapterCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPURequestAdapterCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestAdapterCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestDeviceCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPURequestDeviceCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestDeviceCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUUncapturedErrorCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUUncapturedErrorCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** @} */ + +typedef struct WGPUAdapterInfo { WGPUChainedStructOut * nextInChain; - uint32_t vendorID; - char const * vendorName; - char const * architecture; - uint32_t deviceID; - char const * name; - char const * driverDescription; - WGPUAdapterType adapterType; + /** + * This is an \ref OutputString. + */ + WGPUStringView vendor; + /** + * This is an \ref OutputString. + */ + WGPUStringView architecture; + /** + * This is an \ref OutputString. + */ + WGPUStringView device; + /** + * This is an \ref OutputString. + */ + WGPUStringView description; WGPUBackendType backendType; -} WGPUAdapterProperties WGPU_STRUCTURE_ATTRIBUTE; + WGPUAdapterType adapterType; + uint32_t vendorID; + uint32_t deviceID; +} WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupEntry { WGPUChainedStruct const * nextInChain; @@ -787,8 +1421,11 @@ typedef struct WGPUBufferBindingLayout { typedef struct WGPUBufferDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - WGPUBufferUsageFlags usage; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + WGPUBufferUsage usage; uint64_t size; WGPUBool mappedAtCreation; } WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -802,25 +1439,48 @@ typedef struct WGPUColor { typedef struct WGPUCommandBufferDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUCommandBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCommandEncoderDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUCommandEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCompilationMessage { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * message; + /** + * A @ref LocalizableHumanReadableMessageString. + * + * This is an \ref OutputString. + */ + WGPUStringView message; + /** + * Severity level of the message. + */ WGPUCompilationMessageType type; + /** + * Line number where the message is attached, starting at 1. + */ uint64_t lineNum; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + */ uint64_t linePos; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + */ uint64_t offset; + /** + * Length in UTF-8 code units (bytes) of the span the message corresponds to. + */ uint64_t length; - uint64_t utf16LinePos; - uint64_t utf16Offset; - uint64_t utf16Length; } WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePassTimestampWrites { @@ -831,7 +1491,10 @@ typedef struct WGPUComputePassTimestampWrites { typedef struct WGPUConstantEntry { WGPUChainedStruct const * nextInChain; - char const * key; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView key; double value; } WGPUConstantEntry WGPU_STRUCTURE_ATTRIBUTE; @@ -841,11 +1504,35 @@ typedef struct WGPUExtent3D { uint32_t depthOrArrayLayers; } WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUInstanceDescriptor { - WGPUChainedStruct const * nextInChain; -} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Opaque handle to an asynchronous operation. See @ref Asynchronous-Operations for more information. + */ +typedef struct WGPUFuture { + /** + * Opaque id of the @ref WGPUFuture + */ + uint64_t id; +} WGPUFuture WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Features enabled on the WGPUInstance + */ +typedef struct WGPUInstanceCapabilities { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut * nextInChain; + /** + * Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + WGPUBool timedWaitAnyEnable; + /** + * The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + size_t timedWaitAnyMaxCount; +} WGPUInstanceCapabilities WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPULimits { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut * nextInChain; uint32_t maxTextureDimension1D; uint32_t maxTextureDimension2D; uint32_t maxTextureDimension3D; @@ -868,7 +1555,6 @@ typedef struct WGPULimits { uint64_t maxBufferSize; uint32_t maxVertexAttributes; uint32_t maxVertexBufferArrayStride; - uint32_t maxInterStageShaderComponents; uint32_t maxInterStageShaderVariables; uint32_t maxColorAttachments; uint32_t maxColorAttachmentBytesPerSample; @@ -895,45 +1581,55 @@ typedef struct WGPUOrigin3D { typedef struct WGPUPipelineLayoutDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t bindGroupLayoutCount; WGPUBindGroupLayout const * bindGroupLayouts; } WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUPrimitiveState -typedef struct WGPUPrimitiveDepthClipControl { - WGPUChainedStruct chain; - WGPUBool unclippedDepth; -} WGPUPrimitiveDepthClipControl WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUPrimitiveState { WGPUChainedStruct const * nextInChain; WGPUPrimitiveTopology topology; WGPUIndexFormat stripIndexFormat; WGPUFrontFace frontFace; WGPUCullMode cullMode; + WGPUBool unclippedDepth; } WGPUPrimitiveState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQuerySetDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUQueryType type; uint32_t count; } WGPUQuerySetDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQueueDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUQueueDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPURenderBundleDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleEncoderDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t colorFormatCount; WGPUTextureFormat const * colorFormats; WGPUTextureFormat depthStencilFormat; @@ -954,11 +1650,10 @@ typedef struct WGPURenderPassDepthStencilAttachment { WGPUBool stencilReadOnly; } WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPURenderPassDescriptor -typedef struct WGPURenderPassDescriptorMaxDrawCount { +typedef struct WGPURenderPassMaxDrawCount { WGPUChainedStruct chain; uint64_t maxDrawCount; -} WGPURenderPassDescriptorMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; +} WGPURenderPassMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassTimestampWrites { WGPUQuerySet querySet; @@ -968,10 +1663,28 @@ typedef struct WGPURenderPassTimestampWrites { typedef struct WGPURequestAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE WGPUSurface compatibleSurface; + /** + * "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + * + * Implementations may ignore @ref WGPUFeatureLevel_Compatibility and provide @ref WGPUFeatureLevel_Core instead. @ref WGPUFeatureLevel_Core is the default in the JS API, but in C, this field is **required** (must not be undefined). + */ + WGPUFeatureLevel featureLevel; WGPUPowerPreference powerPreference; - WGPUBackendType backendType; + /** + * If true, requires the adapter to be a "fallback" adapter as defined by the JS spec. + * If this is not possible, the request returns null. + */ WGPUBool forceFallbackAdapter; + /** + * If set, requires the adapter to have a particular backend type. + * If this is not possible, the request returns null. + */ + WGPUBackendType backendType; + /** + * If set, requires the adapter to be able to output to a particular surface. + * If this is not possible, the request returns null. + */ + WGPU_NULLABLE WGPUSurface compatibleSurface; } WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSamplerBindingLayout { @@ -981,7 +1694,10 @@ typedef struct WGPUSamplerBindingLayout { typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUAddressMode addressModeU; WGPUAddressMode addressModeV; WGPUAddressMode addressModeW; @@ -994,24 +1710,27 @@ typedef struct WGPUSamplerDescriptor { uint16_t maxAnisotropy; } WGPUSamplerDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleCompilationHint { +typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; - char const * entryPoint; - WGPUPipelineLayout layout; -} WGPUShaderModuleCompilationHint WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; +} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUShaderModuleDescriptor -typedef struct WGPUShaderModuleSPIRVDescriptor { +typedef struct WGPUShaderSourceSPIRV { WGPUChainedStruct chain; uint32_t codeSize; uint32_t const * code; -} WGPUShaderModuleSPIRVDescriptor WGPU_STRUCTURE_ATTRIBUTE; +} WGPUShaderSourceSPIRV WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUShaderModuleDescriptor -typedef struct WGPUShaderModuleWGSLDescriptor { +typedef struct WGPUShaderSourceWGSL { WGPUChainedStruct chain; - char const * code; -} WGPUShaderModuleWGSLDescriptor WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView code; +} WGPUShaderSourceWGSL WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUStencilFaceState { WGPUCompareFunction compare; @@ -1027,86 +1746,207 @@ typedef struct WGPUStorageTextureBindingLayout { WGPUTextureViewDimension viewDimension; } WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUSupportedFeatures { + size_t featureCount; + WGPUFeatureName const * features; +} WGPUSupportedFeatures WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUSupportedWGSLLanguageFeatures { + size_t featureCount; + WGPUWGSLLanguageFeatureName const * features; +} WGPUSupportedWGSLLanguageFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Filled by `::wgpuSurfaceGetCapabilities` with what's supported for `::wgpuSurfaceConfigure` for a pair of @ref WGPUSurface and @ref WGPUAdapter. + */ typedef struct WGPUSurfaceCapabilities { WGPUChainedStructOut * nextInChain; + /** + * The bit set of supported @ref WGPUTextureUsage bits. + * Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + */ + WGPUTextureUsage usages; + /** + * A list of supported @ref WGPUTextureFormat values, in order of preference. + */ size_t formatCount; - WGPUTextureFormat * formats; + WGPUTextureFormat const * formats; + /** + * A list of supported @ref WGPUPresentMode values. + * Guaranteed to contain @ref WGPUPresentMode_Fifo. + */ size_t presentModeCount; - WGPUPresentMode * presentModes; + WGPUPresentMode const * presentModes; + /** + * A list of supported @ref WGPUCompositeAlphaMode values. + * @ref WGPUCompositeAlphaMode_Auto will be an alias for the first element and will never be present in this array. + */ size_t alphaModeCount; - WGPUCompositeAlphaMode * alphaModes; + WGPUCompositeAlphaMode const * alphaModes; } WGPUSurfaceCapabilities WGPU_STRUCTURE_ATTRIBUTE; +/** + * Options to `::wgpuSurfaceConfigure` for defining how a @ref WGPUSurface will be rendered to and presented to the user. + * See @ref Surface-Configuration for more details. + */ typedef struct WGPUSurfaceConfiguration { WGPUChainedStruct const * nextInChain; + /** + * The @ref WGPUDevice to use to render to surface's textures. + */ WGPUDevice device; + /** + * The @ref WGPUTextureFormat of the surface's textures. + */ WGPUTextureFormat format; - WGPUTextureUsageFlags usage; + /** + * The @ref WGPUTextureUsage of the surface's textures. + */ + WGPUTextureUsage usage; + /** + * The width of the surface's textures. + */ + uint32_t width; + /** + * The height of the surface's textures. + */ + uint32_t height; + /** + * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + */ size_t viewFormatCount; WGPUTextureFormat const * viewFormats; + /** + * How the surface's frames will be composited on the screen. + */ WGPUCompositeAlphaMode alphaMode; - uint32_t width; - uint32_t height; + /** + * When and in which order the surface's frames will be shown on the screen. Defaults to @ref WGPUPresentMode_Fifo. + */ WGPUPresentMode presentMode; } WGPUSurfaceConfiguration WGPU_STRUCTURE_ATTRIBUTE; +/** + * The root descriptor for the creation of an @ref WGPUSurface with `::wgpuInstanceCreateSurface`. + * It isn't sufficient by itself and must have one of the `WGPUSurfaceSource*` in its chain. + * See @ref Surface-Creation for more details. + */ typedef struct WGPUSurfaceDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * Label used to refer to the object. + * + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromAndroidNativeWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). + */ +typedef struct WGPUSurfaceSourceAndroidNativeWindow { WGPUChainedStruct chain; + /** + * The pointer to the [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window) that will be wrapped by the @ref WGPUSurface. + */ void * window; -} WGPUSurfaceDescriptorFromAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromCanvasHTMLSelector { - WGPUChainedStruct chain; - char const * selector; -} WGPUSurfaceDescriptorFromCanvasHTMLSelector WGPU_STRUCTURE_ATTRIBUTE; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromMetalLayer { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). + */ +typedef struct WGPUSurfaceSourceMetalLayer { WGPUChainedStruct chain; + /** + * The pointer to the [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc) that will be wrapped by the @ref WGPUSurface. + */ void * layer; -} WGPUSurfaceDescriptorFromMetalLayer WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceMetalLayer WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromWaylandSurface { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [Wayland](https://wayland.freedesktop.org/) [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface). + */ +typedef struct WGPUSurfaceSourceWaylandSurface { WGPUChainedStruct chain; + /** + * A [`wl_display`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_display) for this Wayland instance. + */ void * display; + /** + * A [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface) that will be wrapped by the @ref WGPUSurface + */ void * surface; -} WGPUSurfaceDescriptorFromWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromWindowsHWND { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a Windows [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd). + */ +typedef struct WGPUSurfaceSourceWindowsHWND { WGPUChainedStruct chain; + /** + * The [`HINSTANCE`](https://learn.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point) for this application. + * Most commonly `GetModuleHandle(nullptr)`. + */ void * hinstance; + /** + * The [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd) that will be wrapped by the @ref WGPUSurface. + */ void * hwnd; -} WGPUSurfaceDescriptorFromWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromXcbWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. + */ +typedef struct WGPUSurfaceSourceXCBWindow { WGPUChainedStruct chain; + /** + * The `xcb_connection_t` for the connection to the X server. + */ void * connection; + /** + * The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + */ uint32_t window; -} WGPUSurfaceDescriptorFromXcbWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceXCBWindow WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromXlibWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. + */ +typedef struct WGPUSurfaceSourceXlibWindow { WGPUChainedStruct chain; + /** + * A pointer to the [`Display`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Opening_the_Display) connected to the X server. + */ void * display; + /** + * The [`Window`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Creating_Windows) that will be wrapped by the @ref WGPUSurface. + */ uint64_t window; -} WGPUSurfaceDescriptorFromXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +/** + * Queried each frame from a @ref WGPUSurface to get a @ref WGPUTexture to render to along with some metadata. + * See @ref Surface-Presenting for more details. + */ typedef struct WGPUSurfaceTexture { + WGPUChainedStructOut * nextInChain; + /** + * The @ref WGPUTexture representing the frame that will be shown on the surface. + * It is @ref ReturnedWithOwnership from @ref wgpuSurfaceGetCurrentTexture. + */ WGPUTexture texture; - WGPUBool suboptimal; + /** + * Whether the call to `::wgpuSurfaceGetCurrentTexture` succeeded and a hint as to why it might not have. + */ WGPUSurfaceGetCurrentTextureStatus status; } WGPUSurfaceTexture WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyBufferLayout { + uint64_t offset; + uint32_t bytesPerRow; + uint32_t rowsPerImage; +} WGPUTexelCopyBufferLayout WGPU_STRUCTURE_ATTRIBUTE; + typedef struct WGPUTextureBindingLayout { WGPUChainedStruct const * nextInChain; WGPUTextureSampleType sampleType; @@ -1114,16 +1954,12 @@ typedef struct WGPUTextureBindingLayout { WGPUBool multisampled; } WGPUTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUTextureDataLayout { - WGPUChainedStruct const * nextInChain; - uint64_t offset; - uint32_t bytesPerRow; - uint32_t rowsPerImage; -} WGPUTextureDataLayout WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUTextureViewDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUTextureFormat format; WGPUTextureViewDimension dimension; uint32_t baseMipLevel; @@ -1131,6 +1967,7 @@ typedef struct WGPUTextureViewDescriptor { uint32_t baseArrayLayer; uint32_t arrayLayerCount; WGPUTextureAspect aspect; + WGPUTextureUsage usage; } WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexAttribute { @@ -1141,7 +1978,10 @@ typedef struct WGPUVertexAttribute { typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUBindGroupLayout layout; size_t entryCount; WGPUBindGroupEntry const * entries; @@ -1150,7 +1990,7 @@ typedef struct WGPUBindGroupDescriptor { typedef struct WGPUBindGroupLayoutEntry { WGPUChainedStruct const * nextInChain; uint32_t binding; - WGPUShaderStageFlags visibility; + WGPUShaderStage visibility; WGPUBufferBindingLayout buffer; WGPUSamplerBindingLayout sampler; WGPUTextureBindingLayout texture; @@ -1170,14 +2010,17 @@ typedef struct WGPUCompilationInfo { typedef struct WGPUComputePassDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUComputePassTimestampWrites const * timestampWrites; } WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUDepthStencilState { WGPUChainedStruct const * nextInChain; WGPUTextureFormat format; - WGPUBool depthWriteEnabled; + WGPUOptionalBool depthWriteEnabled; WGPUCompareFunction depthCompare; WGPUStencilFaceState stencilFront; WGPUStencilFaceState stencilBack; @@ -1188,24 +2031,49 @@ typedef struct WGPUDepthStencilState { float depthBiasClamp; } WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUImageCopyBuffer { +typedef struct WGPUDeviceDescriptor { WGPUChainedStruct const * nextInChain; - WGPUTextureDataLayout layout; - WGPUBuffer buffer; -} WGPUImageCopyBuffer WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + size_t requiredFeatureCount; + WGPUFeatureName const * requiredFeatures; + WGPU_NULLABLE WGPULimits const * requiredLimits; + WGPUQueueDescriptor defaultQueue; + WGPUDeviceLostCallbackInfo deviceLostCallbackInfo; + WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; +} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUImageCopyTexture { +/** + * Struct holding a future to wait on, and a `completed` boolean flag. + */ +typedef struct WGPUFutureWaitInfo { + /** + * The future to wait on. + */ + WGPUFuture future; + /** + * Whether or not the future completed. + */ + WGPUBool completed; +} WGPUFutureWaitInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUInstanceDescriptor { WGPUChainedStruct const * nextInChain; - WGPUTexture texture; - uint32_t mipLevel; - WGPUOrigin3D origin; - WGPUTextureAspect aspect; -} WGPUImageCopyTexture WGPU_STRUCTURE_ATTRIBUTE; + /** + * Instance features to enable + */ + WGPUInstanceCapabilities features; +} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUProgrammableStageDescriptor { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; } WGPUProgrammableStageDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -1213,33 +2081,32 @@ typedef struct WGPUProgrammableStageDescriptor { typedef struct WGPURenderPassColorAttachment { WGPUChainedStruct const * nextInChain; WGPU_NULLABLE WGPUTextureView view; + uint32_t depthSlice; WGPU_NULLABLE WGPUTextureView resolveTarget; WGPULoadOp loadOp; WGPUStoreOp storeOp; WGPUColor clearValue; } WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURequiredLimits { - WGPUChainedStruct const * nextInChain; - WGPULimits limits; -} WGPURequiredLimits WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyBufferInfo { + WGPUTexelCopyBufferLayout layout; + WGPUBuffer buffer; +} WGPUTexelCopyBufferInfo WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleDescriptor { - WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - size_t hintCount; - WGPUShaderModuleCompilationHint const * hints; -} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; - -typedef struct WGPUSupportedLimits { - WGPUChainedStructOut * nextInChain; - WGPULimits limits; -} WGPUSupportedLimits WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyTextureInfo { + WGPUTexture texture; + uint32_t mipLevel; + WGPUOrigin3D origin; + WGPUTextureAspect aspect; +} WGPUTexelCopyTextureInfo WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - WGPUTextureUsageFlags usage; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + WGPUTextureUsage usage; WGPUTextureDimension dimension; WGPUExtent3D size; WGPUTextureFormat format; @@ -1250,47 +2117,55 @@ typedef struct WGPUTextureDescriptor { } WGPUTextureDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexBufferLayout { - uint64_t arrayStride; + /** + * The step mode for the vertex buffer. If @ref WGPUVertexStepMode_VertexBufferNotUsed, + * indicates a "hole" in the parent @ref WGPUVertexState `buffers` array: + * the pipeline does not use a vertex buffer at this `location`. + */ WGPUVertexStepMode stepMode; + uint64_t arrayStride; size_t attributeCount; WGPUVertexAttribute const * attributes; } WGPUVertexBufferLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t entryCount; WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUColorTargetState { WGPUChainedStruct const * nextInChain; + /** + * The texture format of the target. If @ref WGPUTextureFormat_Undefined, + * indicates a "hole" in the parent @ref WGPUFragmentState `targets` array: + * the pipeline does not output a value at this `location`. + */ WGPUTextureFormat format; WGPU_NULLABLE WGPUBlendState const * blend; - WGPUColorWriteMaskFlags writeMask; + WGPUColorWriteMask writeMask; } WGPUColorTargetState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePipelineDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUPipelineLayout layout; WGPUProgrammableStageDescriptor compute; } WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUDeviceDescriptor { - WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - size_t requiredFeatureCount; - WGPUFeatureName const * requiredFeatures; - WGPU_NULLABLE WGPURequiredLimits const * requiredLimits; - WGPUQueueDescriptor defaultQueue; - WGPUDeviceLostCallback deviceLostCallback; - void * deviceLostUserdata; -} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPURenderPassDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t colorAttachmentCount; WGPURenderPassColorAttachment const * colorAttachments; WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; @@ -1301,7 +2176,10 @@ typedef struct WGPURenderPassDescriptor { typedef struct WGPUVertexState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; size_t bufferCount; @@ -1311,7 +2189,10 @@ typedef struct WGPUVertexState { typedef struct WGPUFragmentState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; size_t targetCount; @@ -1320,7 +2201,10 @@ typedef struct WGPUFragmentState { typedef struct WGPURenderPipelineDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUPipelineLayout layout; WGPUVertexState vertex; WGPUPrimitiveState primitive; @@ -1329,401 +2213,1439 @@ typedef struct WGPURenderPipelineDescriptor { WGPU_NULLABLE WGPUFragmentState const * fragment; } WGPURenderPipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** @} */ + #ifdef __cplusplus extern "C" { #endif #if !defined(WGPU_SKIP_PROCS) +/** + * Proc pointer type for @ref wgpuCreateInstance: + * > @copydoc wgpuCreateInstance + */ typedef WGPUInstance (*WGPUProcCreateInstance)(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetInstanceCapabilities: + * > @copydoc wgpuGetInstanceCapabilities + */ +typedef WGPUStatus (*WGPUProcGetInstanceCapabilities)(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetProcAddress: + * > @copydoc wgpuGetProcAddress + */ +typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; // Procs of Adapter -typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetFeatures: + * > @copydoc wgpuAdapterGetFeatures + */ +typedef void (*WGPUProcAdapterGetFeatures)(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetInfo: + * > @copydoc wgpuAdapterGetInfo + */ +typedef WGPUStatus (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetLimits: + * > @copydoc wgpuAdapterGetLimits + */ +typedef WGPUStatus (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterHasFeature: + * > @copydoc wgpuAdapterHasFeature + */ typedef WGPUBool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterReference)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterRequestDevice: + * > @copydoc wgpuAdapterRequestDevice + */ +typedef WGPUFuture (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterAddRef. + * > @copydoc wgpuAdapterAddRef + */ +typedef void (*WGPUProcAdapterAddRef)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterRelease. + * > @copydoc wgpuAdapterRelease + */ typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +// Procs of AdapterInfo +/** + * Proc pointer type for @ref wgpuAdapterInfoFreeMembers: + * > @copydoc wgpuAdapterInfoFreeMembers + */ +typedef void (*WGPUProcAdapterInfoFreeMembers)(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; + // Procs of BindGroup -typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupSetLabel: + * > @copydoc wgpuBindGroupSetLabel + */ +typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupAddRef. + * > @copydoc wgpuBindGroupAddRef + */ +typedef void (*WGPUProcBindGroupAddRef)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupRelease. + * > @copydoc wgpuBindGroupRelease + */ typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroupLayout -typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutSetLabel: + * > @copydoc wgpuBindGroupLayoutSetLabel + */ +typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutAddRef. + * > @copydoc wgpuBindGroupLayoutAddRef + */ +typedef void (*WGPUProcBindGroupLayoutAddRef)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutRelease. + * > @copydoc wgpuBindGroupLayoutRelease + */ typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of Buffer +/** + * Proc pointer type for @ref wgpuBufferDestroy: + * > @copydoc wgpuBufferDestroy + */ typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetConstMappedRange: + * > @copydoc wgpuBufferGetConstMappedRange + */ typedef void const * (*WGPUProcBufferGetConstMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetMapState: + * > @copydoc wgpuBufferGetMapState + */ typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetMappedRange: + * > @copydoc wgpuBufferGetMappedRange + */ typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetSize: + * > @copydoc wgpuBufferGetSize + */ typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBufferUsageFlags (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetUsage: + * > @copydoc wgpuBufferGetUsage + */ +typedef WGPUBufferUsage (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferMapAsync: + * > @copydoc wgpuBufferMapAsync + */ +typedef WGPUFuture (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferSetLabel: + * > @copydoc wgpuBufferSetLabel + */ +typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferUnmap: + * > @copydoc wgpuBufferUnmap + */ typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferAddRef. + * > @copydoc wgpuBufferAddRef + */ +typedef void (*WGPUProcBufferAddRef)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferRelease. + * > @copydoc wgpuBufferRelease + */ typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; // Procs of CommandBuffer -typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandBufferReference)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferSetLabel: + * > @copydoc wgpuCommandBufferSetLabel + */ +typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferAddRef. + * > @copydoc wgpuCommandBufferAddRef + */ +typedef void (*WGPUProcCommandBufferAddRef)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferRelease. + * > @copydoc wgpuCommandBufferRelease + */ typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; // Procs of CommandEncoder +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginComputePass: + * > @copydoc wgpuCommandEncoderBeginComputePass + */ typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginRenderPass: + * > @copydoc wgpuCommandEncoderBeginRenderPass + */ typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderClearBuffer: + * > @copydoc wgpuCommandEncoderClearBuffer + */ typedef void (*WGPUProcCommandEncoderClearBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToBuffer: + * > @copydoc wgpuCommandEncoderCopyBufferToBuffer + */ typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToTexture: + * > @copydoc wgpuCommandEncoderCopyBufferToTexture + */ +typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToBuffer: + * > @copydoc wgpuCommandEncoderCopyTextureToBuffer + */ +typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToTexture: + * > @copydoc wgpuCommandEncoderCopyTextureToTexture + */ +typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderFinish: + * > @copydoc wgpuCommandEncoderFinish + */ typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderInsertDebugMarker: + * > @copydoc wgpuCommandEncoderInsertDebugMarker + */ +typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderPopDebugGroup: + * > @copydoc wgpuCommandEncoderPopDebugGroup + */ typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderPushDebugGroup: + * > @copydoc wgpuCommandEncoderPushDebugGroup + */ +typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderResolveQuerySet: + * > @copydoc wgpuCommandEncoderResolveQuerySet + */ typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderSetLabel: + * > @copydoc wgpuCommandEncoderSetLabel + */ +typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderWriteTimestamp: + * > @copydoc wgpuCommandEncoderWriteTimestamp + */ typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderAddRef. + * > @copydoc wgpuCommandEncoderAddRef + */ +typedef void (*WGPUProcCommandEncoderAddRef)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderRelease. + * > @copydoc wgpuCommandEncoderRelease + */ typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePassEncoder +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroups: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroups + */ typedef void (*WGPUProcComputePassEncoderDispatchWorkgroups)(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroupsIndirect: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroupsIndirect + */ typedef void (*WGPUProcComputePassEncoderDispatchWorkgroupsIndirect)(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderEnd: + * > @copydoc wgpuComputePassEncoderEnd + */ typedef void (*WGPUProcComputePassEncoderEnd)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderInsertDebugMarker: + * > @copydoc wgpuComputePassEncoderInsertDebugMarker + */ +typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderPopDebugGroup: + * > @copydoc wgpuComputePassEncoderPopDebugGroup + */ typedef void (*WGPUProcComputePassEncoderPopDebugGroup)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderPushDebugGroup: + * > @copydoc wgpuComputePassEncoderPushDebugGroup + */ +typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetBindGroup: + * > @copydoc wgpuComputePassEncoderSetBindGroup + */ typedef void (*WGPUProcComputePassEncoderSetBindGroup)(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetLabel: + * > @copydoc wgpuComputePassEncoderSetLabel + */ +typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetPipeline: + * > @copydoc wgpuComputePassEncoderSetPipeline + */ typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderReference)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderAddRef. + * > @copydoc wgpuComputePassEncoderAddRef + */ +typedef void (*WGPUProcComputePassEncoderAddRef)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderRelease. + * > @copydoc wgpuComputePassEncoderRelease + */ typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePipeline +/** + * Proc pointer type for @ref wgpuComputePipelineGetBindGroupLayout: + * > @copydoc wgpuComputePipelineGetBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePipelineReference)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineSetLabel: + * > @copydoc wgpuComputePipelineSetLabel + */ +typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineAddRef. + * > @copydoc wgpuComputePipelineAddRef + */ +typedef void (*WGPUProcComputePipelineAddRef)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineRelease. + * > @copydoc wgpuComputePipelineRelease + */ typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Device +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroup: + * > @copydoc wgpuDeviceCreateBindGroup + */ typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroupLayout: + * > @copydoc wgpuDeviceCreateBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateBuffer: + * > @copydoc wgpuDeviceCreateBuffer + */ typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateCommandEncoder: + * > @copydoc wgpuDeviceCreateCommandEncoder + */ typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipeline: + * > @copydoc wgpuDeviceCreateComputePipeline + */ typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipelineAsync: + * > @copydoc wgpuDeviceCreateComputePipelineAsync + */ +typedef WGPUFuture (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreatePipelineLayout: + * > @copydoc wgpuDeviceCreatePipelineLayout + */ typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateQuerySet: + * > @copydoc wgpuDeviceCreateQuerySet + */ typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderBundleEncoder: + * > @copydoc wgpuDeviceCreateRenderBundleEncoder + */ typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipeline: + * > @copydoc wgpuDeviceCreateRenderPipeline + */ typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipelineAsync: + * > @copydoc wgpuDeviceCreateRenderPipelineAsync + */ +typedef WGPUFuture (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateSampler: + * > @copydoc wgpuDeviceCreateSampler + */ typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateShaderModule: + * > @copydoc wgpuDeviceCreateShaderModule + */ typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateTexture: + * > @copydoc wgpuDeviceCreateTexture + */ typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceDestroy: + * > @copydoc wgpuDeviceDestroy + */ typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetAdapterInfo: + * > @copydoc wgpuDeviceGetAdapterInfo + */ +typedef WGPUAdapterInfo (*WGPUProcDeviceGetAdapterInfo)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetFeatures: + * > @copydoc wgpuDeviceGetFeatures + */ +typedef void (*WGPUProcDeviceGetFeatures)(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetLimits: + * > @copydoc wgpuDeviceGetLimits + */ +typedef WGPUStatus (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetLostFuture: + * > @copydoc wgpuDeviceGetLostFuture + */ +typedef WGPUFuture (*WGPUProcDeviceGetLostFuture)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetQueue: + * > @copydoc wgpuDeviceGetQueue + */ typedef WGPUQueue (*WGPUProcDeviceGetQueue)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceHasFeature: + * > @copydoc wgpuDeviceHasFeature + */ typedef WGPUBool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDevicePopErrorScope: + * > @copydoc wgpuDevicePopErrorScope + */ +typedef WGPUFuture (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDevicePushErrorScope: + * > @copydoc wgpuDevicePushErrorScope + */ typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceSetUncapturedErrorCallback)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceReference)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceSetLabel: + * > @copydoc wgpuDeviceSetLabel + */ +typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceAddRef. + * > @copydoc wgpuDeviceAddRef + */ +typedef void (*WGPUProcDeviceAddRef)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceRelease. + * > @copydoc wgpuDeviceRelease + */ typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; // Procs of Instance +/** + * Proc pointer type for @ref wgpuInstanceCreateSurface: + * > @copydoc wgpuInstanceCreateSurface + */ typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceGetWGSLLanguageFeatures: + * > @copydoc wgpuInstanceGetWGSLLanguageFeatures + */ +typedef WGPUStatus (*WGPUProcInstanceGetWGSLLanguageFeatures)(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceHasWGSLLanguageFeature: + * > @copydoc wgpuInstanceHasWGSLLanguageFeature + */ +typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceProcessEvents: + * > @copydoc wgpuInstanceProcessEvents + */ typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceReference)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceRequestAdapter: + * > @copydoc wgpuInstanceRequestAdapter + */ +typedef WGPUFuture (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceWaitAny: + * > @copydoc wgpuInstanceWaitAny + */ +typedef WGPUWaitStatus (*WGPUProcInstanceWaitAny)(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceAddRef. + * > @copydoc wgpuInstanceAddRef + */ +typedef void (*WGPUProcInstanceAddRef)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceRelease. + * > @copydoc wgpuInstanceRelease + */ typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; // Procs of PipelineLayout -typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutSetLabel: + * > @copydoc wgpuPipelineLayoutSetLabel + */ +typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutAddRef. + * > @copydoc wgpuPipelineLayoutAddRef + */ +typedef void (*WGPUProcPipelineLayoutAddRef)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutRelease. + * > @copydoc wgpuPipelineLayoutRelease + */ typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of QuerySet +/** + * Proc pointer type for @ref wgpuQuerySetDestroy: + * > @copydoc wgpuQuerySetDestroy + */ typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetGetCount: + * > @copydoc wgpuQuerySetGetCount + */ typedef uint32_t (*WGPUProcQuerySetGetCount)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetGetType: + * > @copydoc wgpuQuerySetGetType + */ typedef WGPUQueryType (*WGPUProcQuerySetGetType)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQuerySetReference)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetSetLabel: + * > @copydoc wgpuQuerySetSetLabel + */ +typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetAddRef. + * > @copydoc wgpuQuerySetAddRef + */ +typedef void (*WGPUProcQuerySetAddRef)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetRelease. + * > @copydoc wgpuQuerySetRelease + */ typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Procs of Queue -typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueOnSubmittedWorkDone: + * > @copydoc wgpuQueueOnSubmittedWorkDone + */ +typedef WGPUFuture (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueSetLabel: + * > @copydoc wgpuQueueSetLabel + */ +typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueSubmit: + * > @copydoc wgpuQueueSubmit + */ typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueWriteBuffer: + * > @copydoc wgpuQueueWriteBuffer + */ typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueReference)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueWriteTexture: + * > @copydoc wgpuQueueWriteTexture + */ +typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueAddRef. + * > @copydoc wgpuQueueAddRef + */ +typedef void (*WGPUProcQueueAddRef)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueRelease. + * > @copydoc wgpuQueueRelease + */ typedef void (*WGPUProcQueueRelease)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundle -typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleReference)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleSetLabel: + * > @copydoc wgpuRenderBundleSetLabel + */ +typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleAddRef. + * > @copydoc wgpuRenderBundleAddRef + */ +typedef void (*WGPUProcRenderBundleAddRef)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleRelease. + * > @copydoc wgpuRenderBundleRelease + */ typedef void (*WGPUProcRenderBundleRelease)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundleEncoder +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDraw: + * > @copydoc wgpuRenderBundleEncoderDraw + */ typedef void (*WGPUProcRenderBundleEncoderDraw)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexed: + * > @copydoc wgpuRenderBundleEncoderDrawIndexed + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndexed)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndexedIndirect + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndexedIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndirect + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderFinish: + * > @copydoc wgpuRenderBundleEncoderFinish + */ typedef WGPURenderBundle (*WGPUProcRenderBundleEncoderFinish)(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderInsertDebugMarker: + * > @copydoc wgpuRenderBundleEncoderInsertDebugMarker + */ +typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPopDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPopDebugGroup + */ typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPushDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPushDebugGroup + */ +typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetBindGroup: + * > @copydoc wgpuRenderBundleEncoderSetBindGroup + */ typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetIndexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetIndexBuffer + */ typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetLabel: + * > @copydoc wgpuRenderBundleEncoderSetLabel + */ +typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetPipeline: + * > @copydoc wgpuRenderBundleEncoderSetPipeline + */ typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetVertexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetVertexBuffer + */ typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderAddRef. + * > @copydoc wgpuRenderBundleEncoderAddRef + */ +typedef void (*WGPUProcRenderBundleEncoderAddRef)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderRelease. + * > @copydoc wgpuRenderBundleEncoderRelease + */ typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPassEncoder +/** + * Proc pointer type for @ref wgpuRenderPassEncoderBeginOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderBeginOcclusionQuery + */ typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDraw: + * > @copydoc wgpuRenderPassEncoderDraw + */ typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexed: + * > @copydoc wgpuRenderPassEncoderDrawIndexed + */ typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndexedIndirect + */ typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndirect + */ typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEnd: + * > @copydoc wgpuRenderPassEncoderEnd + */ typedef void (*WGPUProcRenderPassEncoderEnd)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEndOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderEndOcclusionQuery + */ typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderExecuteBundles: + * > @copydoc wgpuRenderPassEncoderExecuteBundles + */ typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderInsertDebugMarker: + * > @copydoc wgpuRenderPassEncoderInsertDebugMarker + */ +typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPopDebugGroup: + * > @copydoc wgpuRenderPassEncoderPopDebugGroup + */ typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPushDebugGroup: + * > @copydoc wgpuRenderPassEncoderPushDebugGroup + */ +typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBindGroup: + * > @copydoc wgpuRenderPassEncoderSetBindGroup + */ typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBlendConstant: + * > @copydoc wgpuRenderPassEncoderSetBlendConstant + */ typedef void (*WGPUProcRenderPassEncoderSetBlendConstant)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetIndexBuffer: + * > @copydoc wgpuRenderPassEncoderSetIndexBuffer + */ typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetLabel: + * > @copydoc wgpuRenderPassEncoderSetLabel + */ +typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetPipeline: + * > @copydoc wgpuRenderPassEncoderSetPipeline + */ typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetScissorRect: + * > @copydoc wgpuRenderPassEncoderSetScissorRect + */ typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetStencilReference: + * > @copydoc wgpuRenderPassEncoderSetStencilReference + */ typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetVertexBuffer: + * > @copydoc wgpuRenderPassEncoderSetVertexBuffer + */ typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetViewport: + * > @copydoc wgpuRenderPassEncoderSetViewport + */ typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderReference)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderAddRef. + * > @copydoc wgpuRenderPassEncoderAddRef + */ +typedef void (*WGPUProcRenderPassEncoderAddRef)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderRelease. + * > @copydoc wgpuRenderPassEncoderRelease + */ typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPipeline +/** + * Proc pointer type for @ref wgpuRenderPipelineGetBindGroupLayout: + * > @copydoc wgpuRenderPipelineGetBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPipelineReference)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineSetLabel: + * > @copydoc wgpuRenderPipelineSetLabel + */ +typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineAddRef. + * > @copydoc wgpuRenderPipelineAddRef + */ +typedef void (*WGPUProcRenderPipelineAddRef)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineRelease. + * > @copydoc wgpuRenderPipelineRelease + */ typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Sampler -typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerSetLabel: + * > @copydoc wgpuSamplerSetLabel + */ +typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerAddRef. + * > @copydoc wgpuSamplerAddRef + */ +typedef void (*WGPUProcSamplerAddRef)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerRelease. + * > @copydoc wgpuSamplerRelease + */ typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Procs of ShaderModule -typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleGetCompilationInfo: + * > @copydoc wgpuShaderModuleGetCompilationInfo + */ +typedef WGPUFuture (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleSetLabel: + * > @copydoc wgpuShaderModuleSetLabel + */ +typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleAddRef. + * > @copydoc wgpuShaderModuleAddRef + */ +typedef void (*WGPUProcShaderModuleAddRef)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleRelease. + * > @copydoc wgpuShaderModuleRelease + */ typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +// Procs of SupportedFeatures +/** + * Proc pointer type for @ref wgpuSupportedFeaturesFreeMembers: + * > @copydoc wgpuSupportedFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedFeaturesFreeMembers)(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; + +// Procs of SupportedWGSLLanguageFeatures +/** + * Proc pointer type for @ref wgpuSupportedWGSLLanguageFeaturesFreeMembers: + * > @copydoc wgpuSupportedWGSLLanguageFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedWGSLLanguageFeaturesFreeMembers)(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; + // Procs of Surface +/** + * Proc pointer type for @ref wgpuSurfaceConfigure: + * > @copydoc wgpuSurfaceConfigure + */ typedef void (*WGPUProcSurfaceConfigure)(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceGetCapabilities: + * > @copydoc wgpuSurfaceGetCapabilities + */ +typedef WGPUStatus (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceGetCurrentTexture: + * > @copydoc wgpuSurfaceGetCurrentTexture + */ typedef void (*WGPUProcSurfaceGetCurrentTexture)(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUTextureFormat (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfacePresent: + * > @copydoc wgpuSurfacePresent + */ +typedef WGPUStatus (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceSetLabel: + * > @copydoc wgpuSurfaceSetLabel + */ +typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceUnconfigure: + * > @copydoc wgpuSurfaceUnconfigure + */ typedef void (*WGPUProcSurfaceUnconfigure)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceAddRef. + * > @copydoc wgpuSurfaceAddRef + */ +typedef void (*WGPUProcSurfaceAddRef)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceRelease. + * > @copydoc wgpuSurfaceRelease + */ typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; // Procs of SurfaceCapabilities -typedef void (*WGPUProcSurfaceCapabilitiesFreeMembers)(WGPUSurfaceCapabilities capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceCapabilitiesFreeMembers: + * > @copydoc wgpuSurfaceCapabilitiesFreeMembers + */ +typedef void (*WGPUProcSurfaceCapabilitiesFreeMembers)(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; // Procs of Texture +/** + * Proc pointer type for @ref wgpuTextureCreateView: + * > @copydoc wgpuTextureCreateView + */ typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureDestroy: + * > @copydoc wgpuTextureDestroy + */ typedef void (*WGPUProcTextureDestroy)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetDepthOrArrayLayers: + * > @copydoc wgpuTextureGetDepthOrArrayLayers + */ typedef uint32_t (*WGPUProcTextureGetDepthOrArrayLayers)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetDimension: + * > @copydoc wgpuTextureGetDimension + */ typedef WGPUTextureDimension (*WGPUProcTextureGetDimension)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetFormat: + * > @copydoc wgpuTextureGetFormat + */ typedef WGPUTextureFormat (*WGPUProcTextureGetFormat)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetHeight: + * > @copydoc wgpuTextureGetHeight + */ typedef uint32_t (*WGPUProcTextureGetHeight)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetMipLevelCount: + * > @copydoc wgpuTextureGetMipLevelCount + */ typedef uint32_t (*WGPUProcTextureGetMipLevelCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetSampleCount: + * > @copydoc wgpuTextureGetSampleCount + */ typedef uint32_t (*WGPUProcTextureGetSampleCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUTextureUsageFlags (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetUsage: + * > @copydoc wgpuTextureGetUsage + */ +typedef WGPUTextureUsage (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetWidth: + * > @copydoc wgpuTextureGetWidth + */ typedef uint32_t (*WGPUProcTextureGetWidth)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureReference)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureSetLabel: + * > @copydoc wgpuTextureSetLabel + */ +typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureAddRef. + * > @copydoc wgpuTextureAddRef + */ +typedef void (*WGPUProcTextureAddRef)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureRelease. + * > @copydoc wgpuTextureRelease + */ typedef void (*WGPUProcTextureRelease)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; // Procs of TextureView -typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureViewReference)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewSetLabel: + * > @copydoc wgpuTextureViewSetLabel + */ +typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewAddRef. + * > @copydoc wgpuTextureViewAddRef + */ +typedef void (*WGPUProcTextureViewAddRef)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewRelease. + * > @copydoc wgpuTextureViewRelease + */ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; #endif // !defined(WGPU_SKIP_PROCS) #if !defined(WGPU_SKIP_DECLARATIONS) - +/** + * \defgroup GlobalFunctions Global Functions + * \brief Functions that are not specific to an object. + * + * @{ + */ +/** + * Create a WGPUInstance + */ WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; +/** + * Query the supported instance capabilities. + * + * @param capabilities + * The supported instance capabilities + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuGetInstanceCapabilities(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns the "procedure address" (function pointer) of the named function. + * The result must be cast to the appropriate proc pointer type. + */ +WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; -// Methods of Adapter -WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup Methods + * \brief Functions that are relative to a specific object. + * + * @{ + */ + +/** + * \defgroup WGPUAdapterMethods WGPUAdapter methods + * \brief Functions whose first argument has type WGPUAdapter. + * + * @{ + */ +/** + * Get the list of @ref WGPUFeatureName values supported by the adapter. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuAdapterGetFeatures(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param info + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuAdapterGetLimits(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterAddRef(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of BindGroup -WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods + * \brief Functions whose first argument has type WGPUAdapterInfo. + * + * @{ + */ +/** + * Frees array members of WGPUAdapterInfo which were allocated by the API. + */ +WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUBindGroupMethods WGPUBindGroup methods + * \brief Functions whose first argument has type WGPUBindGroup. + * + * @{ + */ +WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupAddRef(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of BindGroupLayout -WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUBindGroupLayoutMethods WGPUBindGroupLayout methods + * \brief Functions whose first argument has type WGPUBindGroupLayout. + * + * @{ + */ +WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutAddRef(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Buffer + + +/** + * \defgroup WGPUBufferMethods WGPUBuffer methods + * \brief Functions whose first argument has type WGPUBuffer. + * + * @{ + */ WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. The returned pointer is valid for exactly this many bytes. + * + * @returns + * Returns a const pointer to beginning of the mapped range. + * It must not be written; writing to this range causes undefined behavior. + * Returns `NULL` with @ref ImplementationDefinedLogging if: + * + * - There is any content-timeline error as defined in the WebGPU specification for `getMappedRange()` (alignments, overlaps, etc.) + * **except** for overlaps with other *const* ranges, which are allowed in C. + * (JS does not allow this because const ranges do not exist.) + */ WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. The returned pointer is valid for exactly this many bytes. + * + * @returns + * Returns a mutable pointer to beginning of the mapped range. + * Returns `NULL` with @ref ImplementationDefinedLogging if: + * + * - There is any content-timeline error as defined in the WebGPU specification for `getMappedRange()` (alignments, overlaps, etc.) + * - The buffer is not mapped with @ref WGPUMapMode_Write. + */ WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferAddRef(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of CommandBuffer -WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUCommandBufferMethods WGPUCommandBuffer methods + * \brief Functions whose first argument has type WGPUCommandBuffer. + * + * @{ + */ +WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferAddRef(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of CommandEncoder + + +/** + * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods + * \brief Functions whose first argument has type WGPUCommandEncoder. + * + * @{ + */ WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderAddRef(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of ComputePassEncoder + + +/** + * \defgroup WGPUComputePassEncoderMethods WGPUComputePassEncoder methods + * \brief Functions whose first argument has type WGPUComputePassEncoder. + * + * @{ + */ WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderAddRef(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of ComputePipeline + + +/** + * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods + * \brief Functions whose first argument has type WGPUComputePipeline. + * + * @{ + */ WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineAddRef(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Device + + +/** + * \defgroup WGPUDeviceMethods WGPUDevice methods + * \brief Functions whose first argument has type WGPUDevice. + * + * @{ + */ WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUAdapterInfo wgpuDeviceGetAdapterInfo(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUFeatureName values supported by the device. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuDeviceGetFeatures(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuDeviceGetLimits(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * The @ref WGPUFuture for the device-lost event of the device. + */ +WGPU_EXPORT WGPUFuture wgpuDeviceGetLostFuture(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceAddRef(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Instance + + +/** + * \defgroup WGPUInstanceMethods WGPUInstance methods + * \brief Functions whose first argument has type WGPUInstance. + * + * @{ + */ +/** + * Creates a @ref WGPUSurface, see @ref Surface-Creation for more details. + * + * @param descriptor + * The description of the @ref WGPUSurface to create. + * + * @returns + * A new @ref WGPUSurface for this descriptor (or an error @ref WGPUSurface). + */ WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUWGSLLanguageFeatureName values supported by the instance. + */ +WGPU_EXPORT WGPUStatus wgpuInstanceGetWGSLLanguageFeatures(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with `::WGPUCallbackMode_AllowProcessEvents`. + * + * See @ref Process-Events for more information. + */ WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Wait for at least one WGPUFuture in `futures` to complete, and call callbacks of the respective completed asynchronous operations. + * + * See @ref Wait-Any for more information. + */ +WGPU_EXPORT WGPUWaitStatus wgpuInstanceWaitAny(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceAddRef(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of PipelineLayout -WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUPipelineLayoutMethods WGPUPipelineLayout methods + * \brief Functions whose first argument has type WGPUPipelineLayout. + * + * @{ + */ +WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutAddRef(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of QuerySet + + +/** + * \defgroup WGPUQuerySetMethods WGPUQuerySet methods + * \brief Functions whose first argument has type WGPUQuerySet. + * + * @{ + */ WGPU_EXPORT void wgpuQuerySetDestroy(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetAddRef(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Queue -WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUQueueMethods WGPUQueue methods + * \brief Functions whose first argument has type WGPUQueue. + * + * @{ + */ +WGPU_EXPORT WGPUFuture wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +/** + * Produces a @ref DeviceError both content-timeline (`size` alignment) and device-timeline + * errors defined by the WebGPU specification. + */ WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueAddRef(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of RenderBundle -WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleReference(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPURenderBundleMethods WGPURenderBundle methods + * \brief Functions whose first argument has type WGPURenderBundle. + * + * @{ + */ +WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleAddRef(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of RenderBundleEncoder + + +/** + * \defgroup WGPURenderBundleEncoderMethods WGPURenderBundleEncoder methods + * \brief Functions whose first argument has type WGPURenderBundleEncoder. + * + * @{ + */ WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderAddRef(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of RenderPassEncoder + + +/** + * \defgroup WGPURenderPassEncoderMethods WGPURenderPassEncoder methods + * \brief Functions whose first argument has type WGPURenderPassEncoder. + * + * @{ + */ WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; @@ -1732,52 +3654,181 @@ WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderP WGPU_EXPORT void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderAddRef(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of RenderPipeline + + +/** + * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods + * \brief Functions whose first argument has type WGPURenderPipeline. + * + * @{ + */ WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineAddRef(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Sampler -WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUSamplerMethods WGPUSampler methods + * \brief Functions whose first argument has type WGPUSampler. + * + * @{ + */ +WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerAddRef(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of ShaderModule -WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUShaderModuleMethods WGPUShaderModule methods + * \brief Functions whose first argument has type WGPUShaderModule. + * + * @{ + */ +WGPU_EXPORT WGPUFuture wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleAddRef(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Surface + + +/** + * \defgroup WGPUSupportedFeaturesMethods WGPUSupportedFeatures methods + * \brief Functions whose first argument has type WGPUSupportedFeatures. + * + * @{ + */ +/** + * Frees array members of WGPUSupportedFeatures which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUSupportedWGSLLanguageFeaturesMethods WGPUSupportedWGSLLanguageFeatures methods + * \brief Functions whose first argument has type WGPUSupportedWGSLLanguageFeatures. + * + * @{ + */ +/** + * Frees array members of WGPUSupportedWGSLLanguageFeatures which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedWGSLLanguageFeaturesFreeMembers(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUSurfaceMethods WGPUSurface methods + * \brief Functions whose first argument has type WGPUSurface. + * + * @{ + */ +/** + * Configures parameters for rendering to `surface`. + * Produces a @ref DeviceError for all content-timeline errors defined by the WebGPU specification. + * + * See @ref Surface-Configuration for more details. + * + * @param config + * The new configuration to use. + */ WGPU_EXPORT void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Provides information on how `adapter` is able to use `surface`. + * See @ref Surface-Capabilities for more details. + * + * @param adapter + * The @ref WGPUAdapter to get capabilities for presenting to this @ref WGPUSurface. + * + * @param capabilities + * The structure to fill capabilities in. + * It may contain memory allocations so `::wgpuSurfaceCapabilitiesFreeMembers` must be called to avoid memory leaks. + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns the @ref WGPUTexture to render to `surface` this frame along with metadata on the frame. + * Returns `NULL` and @ref WGPUSurfaceGetCurrentTextureStatus_Error if the surface is not configured. + * + * See @ref Surface-Presenting for more details. + * + * @param surfaceTexture + * The structure to fill the @ref WGPUTexture and metadata in. + */ WGPU_EXPORT void wgpuSurfaceGetCurrentTexture(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Shows `surface`'s current texture to the user. + * See @ref Surface-Presenting for more details. + * + * @returns + * Returns @ref WGPUStatus_Error if the surface doesn't have a current texture. + */ +WGPU_EXPORT WGPUStatus wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Modifies the label used to refer to `surface`. + * + * @param label + * The new label. + */ +WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Removes the configuration for `surface`. + * See @ref Surface-Configuration for more details. + */ WGPU_EXPORT void wgpuSurfaceUnconfigure(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceAddRef(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of SurfaceCapabilities -WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) WGPU_FUNCTION_ATTRIBUTE; -// Methods of Texture + +/** + * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods + * \brief Functions whose first argument has type WGPUSurfaceCapabilities. + * + * @{ + */ +/** + * Frees array members of WGPUSurfaceCapabilities which were allocated by the API. + */ +WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUTextureMethods WGPUTexture methods + * \brief Functions whose first argument has type WGPUTexture. + * + * @{ + */ WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureDestroy(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; @@ -1786,16 +3837,28 @@ WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) WGPU_FUN WGPU_EXPORT uint32_t wgpuTextureGetHeight(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureReference(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureAddRef(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of TextureView -WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureViewReference(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; + + +/** + * \defgroup WGPUTextureViewMethods WGPUTextureView methods + * \brief Functions whose first argument has type WGPUTextureView. + * + * @{ + */ +WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewAddRef(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + +/** @} */ #endif // !defined(WGPU_SKIP_DECLARATIONS) diff --git a/libs/wgpu/include/psemek/wgpu/external/wgpu.h b/libs/wgpu/include/psemek/wgpu/external/wgpu.h index ce9c7589..ec12da35 100644 --- a/libs/wgpu/include/psemek/wgpu/external/wgpu.h +++ b/libs/wgpu/include/psemek/wgpu/external/wgpu.h @@ -6,10 +6,9 @@ typedef enum WGPUNativeSType { // Start at 0003 since that's allocated range for wgpu-native WGPUSType_DeviceExtras = 0x00030001, - WGPUSType_RequiredLimitsExtras = 0x00030002, + WGPUSType_NativeLimits = 0x00030002, WGPUSType_PipelineLayoutExtras = 0x00030003, - WGPUSType_ShaderModuleGLSLDescriptor = 0x00030004, - WGPUSType_SupportedLimitsExtras = 0x00030005, + WGPUSType_ShaderSourceGLSL = 0x00030004, WGPUSType_InstanceExtras = 0x00030006, WGPUSType_BindGroupEntryExtras = 0x00030007, WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, @@ -29,6 +28,33 @@ typedef enum WGPUNativeFeature { WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008, WGPUNativeFeature_StorageResourceBindingArray = 0x00030009, WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, + WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B, + WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C, + WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E, + WGPUNativeFeature_BufferBindingArray = 0x0003000F, + WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010, + // TODO: requires wgpu.h api change + // WGPUNativeFeature_AddressModeClampToZero = 0x00030011, + // WGPUNativeFeature_AddressModeClampToBorder = 0x00030012, + // WGPUNativeFeature_PolygonModeLine = 0x00030013, + // WGPUNativeFeature_PolygonModePoint = 0x00030014, + // WGPUNativeFeature_ConservativeRasterization = 0x00030015, + // WGPUNativeFeature_ClearTexture = 0x00030016, + WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, + // WGPUNativeFeature_Multiview = 0x00030018, + WGPUNativeFeature_VertexAttribute64bit = 0x00030019, + WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, + WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001B, + WGPUNativeFeature_RayQuery = 0x0003001C, + WGPUNativeFeature_ShaderF64 = 0x0003001D, + WGPUNativeFeature_ShaderI16 = 0x0003001E, + WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F, + WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, + WGPUNativeFeature_Subgroup = 0x00030021, + WGPUNativeFeature_SubgroupVertex = 0x00030022, + WGPUNativeFeature_SubgroupBarrier = 0x00030023, + WGPUNativeFeature_TimestampQueryInsideEncoders = 0x00030024, + WGPUNativeFeature_TimestampQueryInsidePasses = 0x00030025, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; @@ -42,30 +68,26 @@ typedef enum WGPULogLevel { WGPULogLevel_Force32 = 0x7FFFFFFF } WGPULogLevel; -typedef enum WGPUInstanceBackend { - WGPUInstanceBackend_All = 0x00000000, - WGPUInstanceBackend_Vulkan = 1 << 0, - WGPUInstanceBackend_GL = 1 << 1, - WGPUInstanceBackend_Metal = 1 << 2, - WGPUInstanceBackend_DX12 = 1 << 3, - WGPUInstanceBackend_DX11 = 1 << 4, - WGPUInstanceBackend_BrowserWebGPU = 1 << 5, - WGPUInstanceBackend_Primary = WGPUInstanceBackend_Vulkan | WGPUInstanceBackend_Metal | - WGPUInstanceBackend_DX12 | - WGPUInstanceBackend_BrowserWebGPU, - WGPUInstanceBackend_Secondary = WGPUInstanceBackend_GL | WGPUInstanceBackend_DX11, - WGPUInstanceBackend_Force32 = 0x7FFFFFFF -} WGPUInstanceBackend; -typedef WGPUFlags WGPUInstanceBackendFlags; +typedef WGPUFlags WGPUInstanceBackend; +static const WGPUInstanceBackend WGPUInstanceBackend_All = 0x00000000; +static const WGPUInstanceBackend WGPUInstanceBackend_Vulkan = 1 << 0; +static const WGPUInstanceBackend WGPUInstanceBackend_GL = 1 << 1; +static const WGPUInstanceBackend WGPUInstanceBackend_Metal = 1 << 2; +static const WGPUInstanceBackend WGPUInstanceBackend_DX12 = 1 << 3; +static const WGPUInstanceBackend WGPUInstanceBackend_DX11 = 1 << 4; +static const WGPUInstanceBackend WGPUInstanceBackend_BrowserWebGPU = 1 << 5; +// Vulkan, Metal, DX12 and BrowserWebGPU +static const WGPUInstanceBackend WGPUInstanceBackend_Primary = (1 << 0) | (1 << 2) | (1 << 3) | (1 << 5); +// GL and DX11 +static const WGPUInstanceBackend WGPUInstanceBackend_Secondary = (1 << 1) | (1 << 4); +static const WGPUInstanceBackend WGPUInstanceBackend_Force32 = 0x7FFFFFFF; -typedef enum WGPUInstanceFlag { - WGPUInstanceFlag_Default = 0x00000000, - WGPUInstanceFlag_Debug = 1 << 0, - WGPUInstanceFlag_Validation = 1 << 1, - WGPUInstanceFlag_DiscardHalLabels = 1 << 2, - WGPUInstanceFlag_Force32 = 0x7FFFFFFF -} WGPUInstanceFlag; -typedef WGPUFlags WGPUInstanceFlags; +typedef WGPUFlags WGPUInstanceFlag; +static const WGPUInstanceFlag WGPUInstanceFlag_Default = 0x00000000; +static const WGPUInstanceFlag WGPUInstanceFlag_Debug = 1 << 0; +static const WGPUInstanceFlag WGPUInstanceFlag_Validation = 1 << 1; +static const WGPUInstanceFlag WGPUInstanceFlag_DiscardHalLabels = 1 << 2; +static const WGPUInstanceFlag WGPUInstanceFlag_Force32 = 0x7FFFFFFF; typedef enum WGPUDx12Compiler { WGPUDx12Compiler_Undefined = 0x00000000, @@ -96,38 +118,50 @@ typedef enum WGPUNativeQueryType { WGPUNativeQueryType_Force32 = 0x7FFFFFFF } WGPUNativeQueryType WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUDxcMaxShaderModel { + WGPUDxcMaxShaderModel_V6_0 = 0x00000000, + WGPUDxcMaxShaderModel_V6_1 = 0x00000001, + WGPUDxcMaxShaderModel_V6_2 = 0x00000002, + WGPUDxcMaxShaderModel_V6_3 = 0x00000003, + WGPUDxcMaxShaderModel_V6_4 = 0x00000004, + WGPUDxcMaxShaderModel_V6_5 = 0x00000005, + WGPUDxcMaxShaderModel_V6_6 = 0x00000006, + WGPUDxcMaxShaderModel_V6_7 = 0x00000007, + WGPUDxcMaxShaderModel_Force32 = 0x7FFFFFFF +} WGPUDxcMaxShaderModel; + +typedef enum WGPUGLFenceBehaviour { + WGPUGLFenceBehaviour_Normal = 0x00000000, + WGPUGLFenceBehaviour_AutoFinish = 0x00000001, + WGPUGLFenceBehaviour_Force32 = 0x7FFFFFFF +} WGPUGLFenceBehaviour; + typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; - WGPUInstanceBackendFlags backends; - WGPUInstanceFlags flags; + WGPUInstanceBackend backends; + WGPUInstanceFlag flags; WGPUDx12Compiler dx12ShaderCompiler; WGPUGles3MinorVersion gles3MinorVersion; - const char * dxilPath; - const char * dxcPath; + WGPUGLFenceBehaviour glFenceBehaviour; + WGPUStringView dxilPath; + WGPUStringView dxcPath; + WGPUDxcMaxShaderModel dxcMaxShaderModel; } WGPUInstanceExtras; typedef struct WGPUDeviceExtras { WGPUChainedStruct chain; - const char * tracePath; + WGPUStringView tracePath; } WGPUDeviceExtras; typedef struct WGPUNativeLimits { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut chain; uint32_t maxPushConstantSize; uint32_t maxNonSamplerBindings; } WGPUNativeLimits; -typedef struct WGPURequiredLimitsExtras { - WGPUChainedStruct chain; - WGPUNativeLimits limits; -} WGPURequiredLimitsExtras; - -typedef struct WGPUSupportedLimitsExtras { - WGPUChainedStructOut chain; - WGPUNativeLimits limits; -} WGPUSupportedLimitsExtras; - typedef struct WGPUPushConstantRange { - WGPUShaderStageFlags stages; + WGPUShaderStage stages; uint32_t start; uint32_t end; } WGPUPushConstantRange; @@ -140,29 +174,29 @@ typedef struct WGPUPipelineLayoutExtras { typedef uint64_t WGPUSubmissionIndex; -typedef struct WGPUWrappedSubmissionIndex { - WGPUQueue queue; - WGPUSubmissionIndex submissionIndex; -} WGPUWrappedSubmissionIndex; - typedef struct WGPUShaderDefine { - char const * name; - char const * value; + WGPUStringView name; + WGPUStringView value; } WGPUShaderDefine; -typedef struct WGPUShaderModuleGLSLDescriptor { +typedef struct WGPUShaderSourceGLSL { WGPUChainedStruct chain; WGPUShaderStage stage; - char const * code; + WGPUStringView code; uint32_t defineCount; WGPUShaderDefine * defines; -} WGPUShaderModuleGLSLDescriptor; +} WGPUShaderSourceGLSL; + +typedef struct WGPUShaderModuleDescriptorSpirV { + WGPUStringView label; + uint32_t sourceSize; + uint32_t const * source; +} WGPUShaderModuleDescriptorSpirV; typedef struct WGPURegistryReport { size_t numAllocated; size_t numKeptFromUser; size_t numReleasedFromUser; - size_t numError; size_t elementSize; } WGPURegistryReport; @@ -178,6 +212,7 @@ typedef struct WGPUHubReport { WGPURegistryReport renderBundles; WGPURegistryReport renderPipelines; WGPURegistryReport computePipelines; + WGPURegistryReport pipelineCaches; WGPURegistryReport querySets; WGPURegistryReport buffers; WGPURegistryReport textures; @@ -187,16 +222,12 @@ typedef struct WGPUHubReport { typedef struct WGPUGlobalReport { WGPURegistryReport surfaces; - WGPUBackendType backendType; - WGPUHubReport vulkan; - WGPUHubReport metal; - WGPUHubReport dx12; - WGPUHubReport gl; + WGPUHubReport hub; } WGPUGlobalReport; typedef struct WGPUInstanceEnumerateAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPUInstanceBackendFlags backends; + WGPUInstanceBackend backends; } WGPUInstanceEnumerateAdapterOptions; typedef struct WGPUBindGroupEntryExtras { @@ -222,10 +253,22 @@ typedef struct WGPUQuerySetDescriptorExtras { typedef struct WGPUSurfaceConfigurationExtras { WGPUChainedStruct chain; - WGPUBool desiredMaximumFrameLatency; + uint32_t desiredMaximumFrameLatency; } WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; -typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata); +typedef void (*WGPULogCallback)(WGPULogLevel level, WGPUStringView message, void * userdata); + +typedef enum WGPUNativeTextureFormat { + // From Features::TEXTURE_FORMAT_16BIT_NORM + WGPUNativeTextureFormat_R16Unorm = 0x00030001, + WGPUNativeTextureFormat_R16Snorm = 0x00030002, + WGPUNativeTextureFormat_Rg16Unorm = 0x00030003, + WGPUNativeTextureFormat_Rg16Snorm = 0x00030004, + WGPUNativeTextureFormat_Rgba16Unorm = 0x00030005, + WGPUNativeTextureFormat_Rgba16Snorm = 0x00030006, + // From Features::TEXTURE_FORMAT_NV12 + WGPUNativeTextureFormat_NV12 = 0x00030007, +} WGPUNativeTextureFormat; #ifdef __cplusplus extern "C" { @@ -237,7 +280,8 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUIn WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex); +WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * submissionIndex); +WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); @@ -245,7 +289,9 @@ void wgpuSetLogLevel(WGPULogLevel level); uint32_t wgpuGetVersion(void); -void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuComputePassEncoderSetPushConstants(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuRenderBundleEncoderSetPushConstants(WGPURenderBundleEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); @@ -258,6 +304,9 @@ void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder com void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); +void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + #ifdef __cplusplus } // extern "C" #endif diff --git a/libs/wgpu/include/psemek/wgpu/image_copy.hpp b/libs/wgpu/include/psemek/wgpu/image_copy.hpp index 58fa0fb1..ae752142 100644 --- a/libs/wgpu/include/psemek/wgpu/image_copy.hpp +++ b/libs/wgpu/include/psemek/wgpu/image_copy.hpp @@ -3,25 +3,28 @@ #include #include #include -#include - -#include namespace psemek::wgpu { - struct image_copy_texture + struct texel_copy_texture_info { - std::vector chain = {}; struct texture texture; std::uint32_t mip_level = 0; math::point origin = {0, 0, 0}; texture::aspect aspect = texture::aspect::all; }; - struct image_copy_buffer { - std::vector chain = {}; - texture::data_layout layout; + struct texel_copy_buffer_layout + { + std::uint64_t offset = 0; + std::uint32_t bytes_per_row; + std::uint32_t rows_per_image; + }; + + struct texel_copy_buffer_info + { + texel_copy_buffer_layout layout; struct buffer buffer; }; diff --git a/libs/wgpu/include/psemek/wgpu/instance.hpp b/libs/wgpu/include/psemek/wgpu/instance.hpp index b5a0bca9..24d13d75 100644 --- a/libs/wgpu/include/psemek/wgpu/instance.hpp +++ b/libs/wgpu/include/psemek/wgpu/instance.hpp @@ -13,6 +13,8 @@ namespace psemek::wgpu { using detail::object::object; + // TODO: add WGPUFuture stuff when it's supported in wgpu-native + struct descriptor { std::vector chain = {}; @@ -22,7 +24,7 @@ namespace psemek::wgpu void process_events(); surface create_surface(surface::descriptor const & desc); - void request_adapter(adapter::request_options const & request_options, adapter::request_callback callback); + void request_adapter(callback_mode mode, adapter::request_options const & request_options, adapter::request_callback callback); static void reference(void * ptr); static void release(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/query_set.hpp b/libs/wgpu/include/psemek/wgpu/query_set.hpp index 0b9a3f69..98fb15fe 100644 --- a/libs/wgpu/include/psemek/wgpu/query_set.hpp +++ b/libs/wgpu/include/psemek/wgpu/query_set.hpp @@ -16,8 +16,8 @@ namespace psemek::wgpu enum class type : std::uint32_t { - occlusion = 0x00000000, - timestamp = 0x00000001, + occlusion = 0x00000001, + timestamp = 0x00000002, }; struct descriptor diff --git a/libs/wgpu/include/psemek/wgpu/queue.hpp b/libs/wgpu/include/psemek/wgpu/queue.hpp index e4738ccd..66951165 100644 --- a/libs/wgpu/include/psemek/wgpu/queue.hpp +++ b/libs/wgpu/include/psemek/wgpu/queue.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -29,18 +30,18 @@ namespace psemek::wgpu enum class work_done_status : std::uint32_t { - success = 0x00000000, - error = 0x00000001, - unknown = 0x00000002, - device_lost = 0x00000003, + success = 0x00000001, + instance_dropped = 0x00000002, + error = 0x00000003, + unknown = 0x00000004, }; using work_done_callback = std::function; void submit(std::vector const & commands); void write_buffer(buffer const & buffer, std::uint64_t offset, util::span data); - void write_texture(image_copy_texture const & dest, util::span data, texture::data_layout const & data_layout, math::vector const & write_size); - void on_submitted_work_done(work_done_callback const & callback); + void write_texture(texel_copy_texture_info const & dest, util::span data, texel_copy_buffer_layout const & data_layout, math::vector const & write_size); + void on_submitted_work_done(callback_mode mode, work_done_callback const & callback); void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/render_bundle_encoder.hpp b/libs/wgpu/include/psemek/wgpu/render_bundle_encoder.hpp index 0d931df7..44b1d2d8 100644 --- a/libs/wgpu/include/psemek/wgpu/render_bundle_encoder.hpp +++ b/libs/wgpu/include/psemek/wgpu/render_bundle_encoder.hpp @@ -38,8 +38,8 @@ namespace psemek::wgpu void draw_indexed(std::uint32_t index_count, std::uint32_t instance_count, std::uint32_t first_index, std::uint32_t base_vertex, std::uint32_t first_instance); void draw_indirect(buffer const & indirect_buffer, std::uint64_t offset); void draw_indexed_indirect(buffer const & indirect_buffer, std::uint64_t offset); - void insert_debug_marker(std::string const & marker_label); - void push_debug_group(std::string const & group_label); + void insert_debug_marker(std::string_view marker_label); + void push_debug_group(std::string_view group_label); void pop_debug_group(); render_bundle finish(render_bundle::descriptor const & desc); void set_label(std::string const & label); diff --git a/libs/wgpu/include/psemek/wgpu/render_pass_encoder.hpp b/libs/wgpu/include/psemek/wgpu/render_pass_encoder.hpp index 37368a24..2bb77c2f 100644 --- a/libs/wgpu/include/psemek/wgpu/render_pass_encoder.hpp +++ b/libs/wgpu/include/psemek/wgpu/render_pass_encoder.hpp @@ -21,15 +21,15 @@ namespace psemek::wgpu enum class load_op : std::uint32_t { undefined = 0x00000000, - clear = 0x00000001, - load = 0x00000002, + load = 0x00000001, + clear = 0x00000002, }; enum class store_op : std::uint32_t { undefined = 0x00000000, - store = 0x00000001, - discard = 0x00000002, + store = 0x00000001, + discard = 0x00000002, }; struct render_pass_encoder @@ -41,6 +41,7 @@ namespace psemek::wgpu { std::vector chain = {}; texture_view view; + std::uint32_t depth_slice = 0; texture_view resolve_target = {}; enum load_op load_op; enum store_op store_op; @@ -97,8 +98,9 @@ namespace psemek::wgpu void execute_bundles(std::vector const & bundles); void begin_occlusion_query(std::uint32_t query_index); void end_occlusion_query(); - void insert_debug_marker(std::string const & marker_label); - void push_debug_group(std::string const & group_label); + void write_timestamp(query_set const & query_set, std::uint32_t query_index); + void insert_debug_marker(std::string_view marker_label); + void push_debug_group(std::string_view group_label); void pop_debug_group(); void end(); void set_label(std::string const & label); diff --git a/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp b/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp index 1b1e998d..e5592074 100644 --- a/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp +++ b/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp @@ -19,44 +19,55 @@ namespace psemek::wgpu enum class vertex_step_mode : std::uint32_t { - vertex = 0x00000000, - instance = 0x00000001, - vertex_buffer_not_used = 0x00000002, + vertex_buffer_not_used = 0x00000000, + undefined = 0x00000001, + vertex = 0x00000002, + instance = 0x00000003, }; enum class vertex_format : std::uint32_t { - 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, + uint8 = 0x00000001, + uint8x2 = 0x00000002, + uint8x4 = 0x00000003, + sint8 = 0x00000004, + sint8x2 = 0x00000005, + sint8x4 = 0x00000006, + unorm8 = 0x00000007, + unorm8x2 = 0x00000008, + unorm8x4 = 0x00000009, + snorm8 = 0x0000000a, + snorm8x2 = 0x0000000b, + snorm8x4 = 0x0000000c, + uint16 = 0x0000000d, + uint16x2 = 0x0000000e, + uint16x4 = 0x0000000f, + sint16 = 0x00000010, + sint16x2 = 0x00000011, + sint16x4 = 0x00000012, + unorm16 = 0x00000013, + unorm16x2 = 0x00000014, + unorm16x4 = 0x00000015, + snorm16 = 0x00000016, + snorm16x2 = 0x00000017, + snorm16x4 = 0x00000018, + float16 = 0x00000019, + float16x2 = 0x0000001a, + float16x4 = 0x0000001b, + float32 = 0x0000001c, + float32x2 = 0x0000001d, + float32x3 = 0x0000001e, + float32x4 = 0x0000001f, + uint32 = 0x00000020, + uint32x2 = 0x00000021, + uint32x3 = 0x00000022, + uint32x4 = 0x00000023, + sint32 = 0x00000024, + sint32x2 = 0x00000025, + sint32x3 = 0x00000026, + sint32x4 = 0x00000027, + unorm10_10_10_2 = 0x00000028, + unorm8x4_bgra = 0x00000029, }; struct vertex_attribute @@ -84,31 +95,34 @@ namespace psemek::wgpu enum class primitive_topology : std::uint32_t { - point_list = 0x00000000, - line_list = 0x00000001, - line_strip = 0x00000002, - triangle_list = 0x00000003, - triangle_strip = 0x00000004, + undefined = 0x00000000, + point_list = 0x00000001, + line_list = 0x00000002, + line_strip = 0x00000003, + triangle_list = 0x00000004, + triangle_strip = 0x00000005, }; enum class index_format : std::uint32_t { undefined = 0x00000000, - uint16 = 0x00000001, - uint32 = 0x00000002, + uint16 = 0x00000001, + uint32 = 0x00000002, }; enum class front_face : std::uint32_t { - ccw = 0x00000000, - cw = 0x00000001, + undefined = 0x00000000, + ccw = 0x00000001, + cw = 0x00000002, }; enum class cull_mode : std::uint32_t { - none = 0x00000000, - front = 0x00000001, - back = 0x00000002, + undefined = 0x00000000, + none = 0x00000001, + front = 0x00000002, + back = 0x00000003, }; struct primitive_state @@ -118,18 +132,20 @@ namespace psemek::wgpu index_format strip_index_format = index_format::undefined; enum front_face front_face; enum cull_mode cull_mode; + bool clip_depth = true; }; enum class stencil_operation : std::uint32_t { - keep = 0x00000000, - zero = 0x00000001, - replace = 0x00000002, - invert = 0x00000003, - increment_clamp = 0x00000004, - decrement_clamp = 0x00000005, - increment_wrap = 0x00000006, - decrement_wrap = 0x00000007, + undefined = 0x00000000, + keep = 0x00000001, + zero = 0x00000002, + replace = 0x00000003, + invert = 0x00000004, + increment_clamp = 0x00000005, + decrement_clamp = 0x00000006, + increment_wrap = 0x00000007, + decrement_wrap = 0x00000008, }; struct stencil_face_state @@ -144,8 +160,8 @@ namespace psemek::wgpu { std::vector chain = {}; texture::format format; - bool depth_write = true; - compare_function depth_compare; + std::optional depth_write = true; + compare_function depth_compare = compare_function::always; stencil_face_state stencil_front = {}; stencil_face_state stencil_back = {}; std::uint32_t stencil_read_mask = 0; @@ -165,28 +181,34 @@ namespace psemek::wgpu enum class blend_operation : std::uint32_t { - add = 0x00000000, - subtract = 0x00000001, - reverse_subtract = 0x00000002, - min = 0x00000003, - max = 0x00000004, + undefined = 0x00000000, + add = 0x00000001, + subtract = 0x00000002, + reverse_subtract = 0x00000003, + min = 0x00000004, + max = 0x00000005, }; enum class blend_factor : std::uint32_t { - 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, + undefined = 0x00000000, + zero = 0x00000001, + one = 0x00000002, + src = 0x00000003, + one_minus_src = 0x00000004, + src_alpha = 0x00000005, + one_minus_src_alpha = 0x00000006, + dst = 0x00000007, + one_minus_dst = 0x00000008, + dst_alpha = 0x00000009, + one_minus_dst_alpha = 0x0000000a, + src_alpha_saturated = 0x0000000b, + constant = 0x0000000c, + one_minus_constant = 0x0000000d, + src1 = 0x0000000e, + one_minus_src1 = 0x0000000f, + src1_alpha = 0x00000010, + one_minus_src1_alpha = 0x00000011, }; struct blend_component @@ -202,14 +224,14 @@ namespace psemek::wgpu blend_component alpha; }; - enum color_write_mask : std::uint32_t + enum color_write_mask : std::uint64_t { - none = 0x00000000, - red = 0x00000001, + none = 0x00000000, + red = 0x00000001, green = 0x00000002, - blue = 0x00000004, + blue = 0x00000004, alpha = 0x00000008, - all = 0x0000000f, + all = 0x0000000f, }; struct color_target_state diff --git a/libs/wgpu/include/psemek/wgpu/sampler.hpp b/libs/wgpu/include/psemek/wgpu/sampler.hpp index ccc67bd4..f14c361a 100644 --- a/libs/wgpu/include/psemek/wgpu/sampler.hpp +++ b/libs/wgpu/include/psemek/wgpu/sampler.hpp @@ -13,34 +13,37 @@ namespace psemek::wgpu enum class address_mode : std::uint32_t { - repeat = 0x00000000, - mirror_repeat = 0x00000001, - clamp_to_edge = 0x00000002, + undefined = 0x00000000, + clamp_to_edge = 0x00000001, + repeat = 0x00000002, + mirror_repeat = 0x00000003, }; enum class filter_mode : std::uint32_t { - nearest = 0x00000000, - linear = 0x00000001, + undefined = 0x00000000, + nearest = 0x00000001, + linear = 0x00000002, }; enum class mipmap_filter_mode : std::uint32_t { - nearest = 0x00000000, - linear = 0x00000001, + undefined = 0x00000000, + nearest = 0x00000001, + linear = 0x00000002, }; enum class compare_function : std::uint32_t { - undefined = 0x00000000, - never = 0x00000001, - less = 0x00000002, - less_equal = 0x00000003, - greater = 0x00000004, - greater_equal = 0x00000005, - equal = 0x00000006, - not_equal = 0x00000007, - always = 0x00000008, + undefined = 0x00000000, + never = 0x00000001, + less = 0x00000002, + equal = 0x00000003, + less_equal = 0x00000004, + greater = 0x00000005, + not_equal = 0x00000006, + greater_equal = 0x00000007, + always = 0x00000008, }; struct sampler diff --git a/libs/wgpu/include/psemek/wgpu/shader_module.hpp b/libs/wgpu/include/psemek/wgpu/shader_module.hpp index 72c4b7ff..64b01467 100644 --- a/libs/wgpu/include/psemek/wgpu/shader_module.hpp +++ b/libs/wgpu/include/psemek/wgpu/shader_module.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -21,17 +22,17 @@ namespace psemek::wgpu enum class compilation_info_request_status : std::uint32_t { - success = 0x00000000, - error = 0x00000001, - device_lost = 0x00000002, - unknown = 0x00000003, + success = 0x00000001, + instance_dropped = 0x00000002, + error = 0x00000003, + unknown = 0x00000004, }; enum class compilation_message_type : std::uint32_t { - error = 0x00000000, - warning = 0x00000001, - info = 0x00000002, + error = 0x00000001, + warning = 0x00000002, + info = 0x00000003, }; struct compilation_message @@ -43,9 +44,6 @@ namespace psemek::wgpu std::uint64_t line_pos; std::uint64_t offset; std::uint64_t length; - std::uint64_t utf16_line_pos; - std::uint64_t utf16_offset; - std::uint64_t utf16_length; }; struct compilation_info @@ -54,24 +52,16 @@ namespace psemek::wgpu std::vector messages = {}; }; - struct compilation_hint - { - std::vector chain = {}; - std::string entry_point; - pipeline_layout layout; - }; - struct define { - char const * name; - char const * value; + std::string_view name; + std::string_view value; }; struct descriptor { std::vector chain = {}; std::string label = {}; - std::vector hints = {}; }; struct spirv_descriptor @@ -81,19 +71,19 @@ namespace psemek::wgpu struct wgsl_descriptor { - char const * code; + std::string_view code; }; struct glsl_descriptor { shader_stage stage; - char const * code; + std::string_view code; std::vector defines = {}; }; using compilation_info_callback = std::function; - void get_compilation_info(compilation_info_callback const & callback); + void get_compilation_info(callback_mode mode, compilation_info_callback const & callback); void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/shader_stage.hpp b/libs/wgpu/include/psemek/wgpu/shader_stage.hpp index e5a38c1d..d5c789ad 100644 --- a/libs/wgpu/include/psemek/wgpu/shader_stage.hpp +++ b/libs/wgpu/include/psemek/wgpu/shader_stage.hpp @@ -5,17 +5,17 @@ namespace psemek::wgpu { - enum class shader_stage : std::uint32_t + enum class shader_stage : std::uint64_t { - none = 0x00000000, - vertex = 0x00000001, + none = 0x00000000, + vertex = 0x00000001, fragment = 0x00000002, - compute = 0x00000004, + compute = 0x00000004, }; inline shader_stage operator | (shader_stage s1, shader_stage s2) { - return static_cast(static_cast(s1) | static_cast(s2)); + return static_cast(static_cast(s1) | static_cast(s2)); } } diff --git a/libs/wgpu/include/psemek/wgpu/surface.hpp b/libs/wgpu/include/psemek/wgpu/surface.hpp index 70c03729..7c35fba5 100644 --- a/libs/wgpu/include/psemek/wgpu/surface.hpp +++ b/libs/wgpu/include/psemek/wgpu/surface.hpp @@ -27,19 +27,20 @@ namespace psemek::wgpu enum class composite_alpha_mode : std::uint32_t { - _auto = 0x00000000, - opaque = 0x00000001, - premultiplied = 0x00000002, + _auto = 0x00000000, + opaque = 0x00000001, + premultiplied = 0x00000002, unpremultiplied = 0x00000003, - inherit = 0x00000004, + inherit = 0x00000004, }; enum class present_mode : std::uint32_t { - fifo = 0x00000000, - fifo_relaxed = 0x00000001, - immediate = 0x00000002, - mailbox = 0x00000003, + undefined = 0x00000000, + fifo = 0x00000001, + fifo_relaxed = 0x00000002, + immediate = 0x00000003, + mailbox = 0x00000004, }; struct configuration @@ -63,6 +64,7 @@ namespace psemek::wgpu struct capabilities { std::vector chain = {}; + texture::usage usage = texture::usage::none; std::vector formats = {}; std::vector present_modes = {}; std::vector alpha_modes = {}; @@ -72,23 +74,23 @@ namespace psemek::wgpu { enum class status : std::uint32_t { - success = 0x00000000, - timeout = 0x00000001, - outdated = 0x00000002, - lost = 0x00000003, - out_of_memory = 0x00000004, - device_lost = 0x00000005, + success_optimal = 0x00000001, + success_suboptimal = 0x00000002, + timeout = 0x00000003, + outdated = 0x00000004, + lost = 0x00000005, + out_of_memory = 0x00000006, + device_lost = 0x00000007, + error = 0x00000008, }; wgpu::texture texture; - bool suboptimal; enum status status; }; void configure(configuration const & conf); capabilities get_capabilities(adapter const & adapter); current_texture get_current_texture(); - wgpu::texture::format get_preferred_format(adapter const & adapter); void present(); void unconfigure(); @@ -97,11 +99,6 @@ namespace psemek::wgpu void * window; }; - struct from_canvas_html_selected - { - std::string selector; - }; - struct from_metal_layer { void * layer; @@ -144,7 +141,6 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(surface::configuration::extras const & value); detail::chained_struct_ptr to_chained_struct(surface::from_android_native_window const & value); - detail::chained_struct_ptr to_chained_struct(surface::from_canvas_html_selected const & value); detail::chained_struct_ptr to_chained_struct(surface::from_metal_layer const & value); detail::chained_struct_ptr to_chained_struct(surface::from_wayland_surface const & value); detail::chained_struct_ptr to_chained_struct(surface::from_windows_hwnd const & value); diff --git a/libs/wgpu/include/psemek/wgpu/texture.hpp b/libs/wgpu/include/psemek/wgpu/texture.hpp index 563162c2..748b9921 100644 --- a/libs/wgpu/include/psemek/wgpu/texture.hpp +++ b/libs/wgpu/include/psemek/wgpu/texture.hpp @@ -19,136 +19,150 @@ namespace psemek::wgpu enum class format : std::uint32_t { - undefined = 0x00000000, - r8unorm = 0x00000001, - r8snorm = 0x00000002, - r8uint = 0x00000003, - r8sint = 0x00000004, - r16uint = 0x00000005, - r16sint = 0x00000006, - r16float = 0x00000007, - rg8unorm = 0x00000008, - rg8snorm = 0x00000009, - rg8uint = 0x0000000a, - rg8sint = 0x0000000b, - r32float = 0x0000000c, - r32uint = 0x0000000d, - r32sint = 0x0000000e, - rg16uint = 0x0000000f, - rg16sint = 0x00000010, - rg16float = 0x00000011, - rgba8unorm = 0x00000012, - rgba8unorm_srgb = 0x00000013, - rgba8snorm = 0x00000014, - rgba8uint = 0x00000015, - rgba8sint = 0x00000016, - bgra8unorm = 0x00000017, - bgra8unorm_srgb = 0x00000018, - rgb10a2uint = 0x00000019, - rgb10a2unorm = 0x0000001a, - rg11b10ufloat = 0x0000001b, - rgb9e5ufloat = 0x0000001c, - rg32float = 0x0000001d, - rg32uint = 0x0000001e, - rg32sint = 0x0000001f, - rgba16uint = 0x00000020, - rgba16sint = 0x00000021, - rgba16float = 0x00000022, - rgba32float = 0x00000023, - rgba32uint = 0x00000024, - rgba32sint = 0x00000025, - stencil8 = 0x00000026, - depth16unorm = 0x00000027, - depth24plus = 0x00000028, - depth24plusstencil8 = 0x00000029, - depth32float = 0x0000002a, + undefined = 0x00000000, + r8unorm = 0x00000001, + r8snorm = 0x00000002, + r8uint = 0x00000003, + r8sint = 0x00000004, + r16uint = 0x00000005, + r16sint = 0x00000006, + r16float = 0x00000007, + rg8unorm = 0x00000008, + rg8snorm = 0x00000009, + rg8uint = 0x0000000a, + rg8sint = 0x0000000b, + r32float = 0x0000000c, + r32uint = 0x0000000d, + r32sint = 0x0000000e, + rg16uint = 0x0000000f, + rg16sint = 0x00000010, + rg16float = 0x00000011, + rgba8unorm = 0x00000012, + rgba8unorm_srgb = 0x00000013, + rgba8snorm = 0x00000014, + rgba8uint = 0x00000015, + rgba8sint = 0x00000016, + bgra8unorm = 0x00000017, + bgra8unorm_srgb = 0x00000018, + rgb10a2uint = 0x00000019, + rgb10a2unorm = 0x0000001a, + rg11b10ufloat = 0x0000001b, + rgb9e5ufloat = 0x0000001c, + rg32float = 0x0000001d, + rg32uint = 0x0000001e, + rg32sint = 0x0000001f, + rgba16uint = 0x00000020, + rgba16sint = 0x00000021, + rgba16float = 0x00000022, + rgba32float = 0x00000023, + rgba32uint = 0x00000024, + rgba32sint = 0x00000025, + stencil8 = 0x00000026, + depth16unorm = 0x00000027, + depth24plus = 0x00000028, + depth24plusstencil8 = 0x00000029, + depth32float = 0x0000002a, depth32floatstencil8 = 0x0000002b, - bc1rgbaunorm = 0x0000002c, - bc1rgbaunorm_srgb = 0x0000002d, - bc2rgbaunorm = 0x0000002e, - bc2rgbaunorm_srgb = 0x0000002f, - bc3rgbaunorm = 0x00000030, - bc3rgbaunorm_srgb = 0x00000031, - bc4runorm = 0x00000032, - bc4rsnorm = 0x00000033, - bc5rgunorm = 0x00000034, - bc5rgsnorm = 0x00000035, - bc6hrgbufloat = 0x00000036, - bc6hrgbfloat = 0x00000037, - bc7rgbaunorm = 0x00000038, - bc7rgbaunorm_srgb = 0x00000039, - etc2rgb8unorm = 0x0000003a, - etc2rgb8unorm_srgb = 0x0000003b, - etc2rgb8a1unorm = 0x0000003c, + bc1rgbaunorm = 0x0000002c, + bc1rgbaunorm_srgb = 0x0000002d, + bc2rgbaunorm = 0x0000002e, + bc2rgbaunorm_srgb = 0x0000002f, + bc3rgbaunorm = 0x00000030, + bc3rgbaunorm_srgb = 0x00000031, + bc4runorm = 0x00000032, + bc4rsnorm = 0x00000033, + bc5rgunorm = 0x00000034, + bc5rgsnorm = 0x00000035, + bc6hrgbufloat = 0x00000036, + bc6hrgbfloat = 0x00000037, + bc7rgbaunorm = 0x00000038, + bc7rgbaunorm_srgb = 0x00000039, + etc2rgb8unorm = 0x0000003a, + etc2rgb8unorm_srgb = 0x0000003b, + etc2rgb8a1unorm = 0x0000003c, etc2rgb8a1unorm_srgb = 0x0000003d, - etc2rgba8unorm = 0x0000003e, - etc2rgba8unorm_srgb = 0x0000003f, - eacr11unorm = 0x00000040, - eacr11snorm = 0x00000041, - eacrg11unorm = 0x00000042, - eacrg11snorm = 0x00000043, - astc4x4unorm = 0x00000044, - astc4x4unorm_srgb = 0x00000045, - astc5x4unorm = 0x00000046, - astc5x4unorm_srgb = 0x00000047, - astc5x5unorm = 0x00000048, - astc5x5unorm_srgb = 0x00000049, - astc6x5unorm = 0x0000004a, - astc6x5unorm_srgb = 0x0000004b, - astc6x6unorm = 0x0000004c, - astc6x6unorm_srgb = 0x0000004d, - astc8x5unorm = 0x0000004e, - astc8x5unorm_srgb = 0x0000004f, - astc8x6unorm = 0x00000050, - astc8x6unorm_srgb = 0x00000051, - astc8x8unorm = 0x00000052, - astc8x8unorm_srgb = 0x00000053, - astc10x5unorm = 0x00000054, - astc10x5unorm_srgb = 0x00000055, - astc10x6unorm = 0x00000056, - astc10x6unorm_srgb = 0x00000057, - astc10x8unorm = 0x00000058, - astc10x8unorm_srgb = 0x00000059, - astc10x10unorm = 0x0000005a, - astc10x10unorm_srgb = 0x0000005b, - astc12x10unorm = 0x0000005c, - astc12x10unorm_srgb = 0x0000005d, - astc12x12unorm = 0x0000005e, - astc12x12unorm_srgb = 0x0000005f, + etc2rgba8unorm = 0x0000003e, + etc2rgba8unorm_srgb = 0x0000003f, + eacr11unorm = 0x00000040, + eacr11snorm = 0x00000041, + eacrg11unorm = 0x00000042, + eacrg11snorm = 0x00000043, + astc4x4unorm = 0x00000044, + astc4x4unorm_srgb = 0x00000045, + astc5x4unorm = 0x00000046, + astc5x4unorm_srgb = 0x00000047, + astc5x5unorm = 0x00000048, + astc5x5unorm_srgb = 0x00000049, + astc6x5unorm = 0x0000004a, + astc6x5unorm_srgb = 0x0000004b, + astc6x6unorm = 0x0000004c, + astc6x6unorm_srgb = 0x0000004d, + astc8x5unorm = 0x0000004e, + astc8x5unorm_srgb = 0x0000004f, + astc8x6unorm = 0x00000050, + astc8x6unorm_srgb = 0x00000051, + astc8x8unorm = 0x00000052, + astc8x8unorm_srgb = 0x00000053, + astc10x5unorm = 0x00000054, + astc10x5unorm_srgb = 0x00000055, + astc10x6unorm = 0x00000056, + astc10x6unorm_srgb = 0x00000057, + astc10x8unorm = 0x00000058, + astc10x8unorm_srgb = 0x00000059, + astc10x10unorm = 0x0000005a, + astc10x10unorm_srgb = 0x0000005b, + astc12x10unorm = 0x0000005c, + astc12x10unorm_srgb = 0x0000005d, + astc12x12unorm = 0x0000005e, + astc12x12unorm_srgb = 0x0000005f, + + // texture_format16bit_norm + r16unorm = 0x00030001, + r16snorm = 0x00030002, + rg16unorm = 0x00030003, + rg16snorm = 0x00030004, + rgba16unorm = 0x00030005, + rgba16snorm = 0x00030006, + + // texture_format_nv12 + nv12 = 0x00030007, }; - enum class usage : std::uint32_t + enum class usage : std::uint64_t { - none = 0x00000000, - copy_src = 0x00000001, - copy_dst = 0x00000002, - texture_binding = 0x00000004, - storage_binding = 0x00000008, + none = 0x00000000, + copy_src = 0x00000001, + copy_dst = 0x00000002, + texture_binding = 0x00000004, + storage_binding = 0x00000008, render_attachment = 0x00000010, }; enum class dimension : std::uint32_t { - _1d = 0x00000000, - _2d = 0x00000001, - _3d = 0x00000002, + undefined = 0x00000000, + _1d = 0x00000001, + _2d = 0x00000002, + _3d = 0x00000003, }; enum class aspect : std::uint32_t { - all = 0x00000000, - stencil_only = 0x00000001, - depth_only = 0x00000002, + undefined = 0x00000000, + all = 0x00000001, + stencil_only = 0x00000002, + depth_only = 0x00000003, }; enum class sample_type : std::uint32_t { - undefined = 0x00000000, - _float = 0x00000001, - unfilterable_float = 0x00000002, - depth = 0x00000003, - sint = 0x00000004, - uint = 0x00000005, + binding_not_used = 0x00000000, + undefined = 0x00000001, + _float = 0x00000002, + unfilterable_float = 0x00000003, + depth = 0x00000004, + sint = 0x00000005, + uint = 0x00000006, }; struct descriptor @@ -164,14 +178,6 @@ namespace psemek::wgpu std::vector view_formats = {}; }; - struct data_layout - { - std::vector chain = {}; - std::uint64_t offset = 0; - std::uint32_t bytes_per_row; - std::uint32_t rows_per_image; - }; - texture_view create_view(texture_view::descriptor const & desc); void destroy(); std::uint32_t get_width(); diff --git a/libs/wgpu/include/psemek/wgpu/texture_view.hpp b/libs/wgpu/include/psemek/wgpu/texture_view.hpp index 23ec5886..48cb3f2c 100644 --- a/libs/wgpu/include/psemek/wgpu/texture_view.hpp +++ b/libs/wgpu/include/psemek/wgpu/texture_view.hpp @@ -15,13 +15,13 @@ namespace psemek::wgpu enum class dimension : std::uint32_t { - undefined = 0x00000000, - _1d = 0x00000001, - _2d = 0x00000002, - _2d_array = 0x00000003, - cube = 0x00000004, + undefined = 0x00000000, + _1d = 0x00000001, + _2d = 0x00000002, + _2d_array = 0x00000003, + cube = 0x00000004, cube_array = 0x00000005, - _3d = 0x00000006, + _3d = 0x00000006, }; // Defined in wgpu/texture.hpp to break circular dependencies diff --git a/libs/wgpu/source/adapter.cpp b/libs/wgpu/source/adapter.cpp index b906b8b5..5476b437 100644 --- a/libs/wgpu/source/adapter.cpp +++ b/libs/wgpu/source/adapter.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -8,37 +10,67 @@ namespace psemek::wgpu std::vector adapter::enumerate_features() { - std::size_t count = wgpuAdapterEnumerateFeatures((WGPUAdapter)get(), nullptr); - std::vector result(count); - wgpuAdapterEnumerateFeatures((WGPUAdapter)get(), (WGPUFeatureName *)result.data()); - return result; + WGPUSupportedFeatures supported_features; + wgpuAdapterGetFeatures((WGPUAdapter)get(), &supported_features); + return std::vector((feature const *)supported_features.features, (feature const *)(supported_features.features) + supported_features.featureCount); } limits adapter::get_limits() { - WGPUSupportedLimits limits = {}; - wgpuAdapterGetLimits((WGPUAdapter)get(), &limits); + WGPULimits limits = {}; + detail::check_status("wgpuAdapterGetLimits", wgpuAdapterGetLimits((WGPUAdapter)get(), &limits)); // TODO: support out chain wgpu::limits result; - static_assert(sizeof(result) == sizeof(limits.limits)); - std::memcpy((char *)&result, (char *)&limits.limits, sizeof(result)); + result.max_texture_dimension_1D = limits.maxTextureDimension1D; + result.max_texture_dimension_2D = limits.maxTextureDimension2D; + result.max_texture_dimension_3D = limits.maxTextureDimension3D; + result.max_texture_array_layers = limits.maxTextureArrayLayers; + result.max_bind_groups = limits.maxBindGroups; + result.max_bind_groups_plus_vertex_buffers = limits.maxBindGroupsPlusVertexBuffers; + result.max_bindings_per_bind_group = limits.maxBindingsPerBindGroup; + result.max_dynamic_uniform_buffers_per_pipeline_layout = limits.maxDynamicUniformBuffersPerPipelineLayout; + result.max_dynamic_storage_buffers_per_pipeline_layout = limits.maxDynamicStorageBuffersPerPipelineLayout; + result.max_sampled_textures_per_shader_stage = limits.maxSampledTexturesPerShaderStage; + result.max_samplers_per_shader_stage = limits.maxSamplersPerShaderStage; + result.max_storage_buffers_per_shader_stage = limits.maxStorageBuffersPerShaderStage; + result.max_storage_textures_per_shader_stage = limits.maxStorageTexturesPerShaderStage; + result.max_uniform_buffers_per_shader_stage = limits.maxUniformBuffersPerShaderStage; + result.max_uniform_buffer_binding_size = limits.maxUniformBufferBindingSize; + result.max_storage_buffer_binding_size = limits.maxStorageBufferBindingSize; + result.min_uniform_buffer_offset_alignment = limits.minUniformBufferOffsetAlignment; + result.min_storage_buffer_offset_alignment = limits.minStorageBufferOffsetAlignment; + result.max_vertex_buffers = limits.maxVertexBuffers; + result.max_buffer_size = limits.maxBufferSize; + result.max_vertex_attributes = limits.maxVertexAttributes; + result.max_vertex_buffer_array_stride = limits.maxVertexBufferArrayStride; + result.max_inter_stage_shader_variables = limits.maxInterStageShaderVariables; + result.max_color_attachments = limits.maxColorAttachments; + result.max_color_attachment_bytes_per_sample = limits.maxColorAttachmentBytesPerSample; + result.max_compute_workgroup_storage_size = limits.maxComputeWorkgroupStorageSize; + result.max_compute_invocations_per_workgroup = limits.maxComputeInvocationsPerWorkgroup; + result.max_compute_workgroup_size_x = limits.maxComputeWorkgroupSizeX; + result.max_compute_workgroup_size_y = limits.maxComputeWorkgroupSizeY; + result.max_compute_workgroup_size_z = limits.maxComputeWorkgroupSizeZ; + result.max_compute_workgroups_per_dimension = limits.maxComputeWorkgroupsPerDimension; + return result; } - adapter::properties adapter::get_properties() + adapter::info adapter::get_info() { - WGPUAdapterProperties props; - wgpuAdapterGetProperties((WGPUAdapter)get(), &props); + WGPUAdapterInfo info; + detail::check_status("wgpuAdapterGetInfo", wgpuAdapterGetInfo((WGPUAdapter)get(), &info)); + return { - .vendor_id = props.vendorID, - .vendor_name = props.vendorName, - .architecture = props.architecture, - .device_id = props.deviceID, - .name = props.name, - .driver_description = props.driverDescription, - .adapter_type = (adapter::type)props.adapterType, - .backend_type = (backend_type)props.backendType, + .vendor = std::string_view(info.vendor.data, info.vendor.length), + .architecture = std::string_view(info.architecture.data, info.architecture.length), + .device = std::string_view(info.device.data, info.device.length), + .description = std::string_view(info.description.data, info.description.length), + .backend_type = (backend_type)info.backendType, + .adapter_type = (type)info.adapterType, + .vendor_id = info.vendorID, + .device_id = info.deviceID, }; } @@ -47,49 +79,83 @@ namespace psemek::wgpu return wgpuAdapterHasFeature((WGPUAdapter)get(), (WGPUFeatureName)feature); } - void adapter::request_device(device::descriptor const & descriptor, device::request_callback const & callback) + void adapter::request_device(callback_mode mode, device::descriptor const & descriptor, device::request_callback const & callback) { - WGPURequiredLimits limits = {}; + WGPULimits limits = {}; if (descriptor.required_limits) { - static_assert(sizeof(limits.limits) == sizeof(descriptor.required_limits->limits)); - limits.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(descriptor.required_limits->chain); - std::memcpy(&limits.limits, &descriptor.required_limits->limits, sizeof(limits.limits)); + limits.nextInChain = (WGPUChainedStructOut *)detail::fill_chain_out(descriptor.required_limits->chain); + + limits.maxTextureDimension1D = descriptor.required_limits->limits.max_texture_dimension_1D; + limits.maxTextureDimension2D = descriptor.required_limits->limits.max_texture_dimension_2D; + limits.maxTextureDimension3D = descriptor.required_limits->limits.max_texture_dimension_3D; + limits.maxTextureArrayLayers = descriptor.required_limits->limits.max_texture_array_layers; + limits.maxBindGroups = descriptor.required_limits->limits.max_bind_groups; + limits.maxBindGroupsPlusVertexBuffers = descriptor.required_limits->limits.max_bind_groups_plus_vertex_buffers; + limits.maxBindingsPerBindGroup = descriptor.required_limits->limits.max_bindings_per_bind_group; + limits.maxDynamicUniformBuffersPerPipelineLayout = descriptor.required_limits->limits.max_dynamic_uniform_buffers_per_pipeline_layout; + limits.maxDynamicStorageBuffersPerPipelineLayout = descriptor.required_limits->limits.max_dynamic_storage_buffers_per_pipeline_layout; + limits.maxSampledTexturesPerShaderStage = descriptor.required_limits->limits.max_sampled_textures_per_shader_stage; + limits.maxSamplersPerShaderStage = descriptor.required_limits->limits.max_samplers_per_shader_stage; + limits.maxStorageBuffersPerShaderStage = descriptor.required_limits->limits.max_storage_buffers_per_shader_stage; + limits.maxStorageTexturesPerShaderStage = descriptor.required_limits->limits.max_storage_textures_per_shader_stage; + limits.maxUniformBuffersPerShaderStage = descriptor.required_limits->limits.max_uniform_buffers_per_shader_stage; + limits.maxUniformBufferBindingSize = descriptor.required_limits->limits.max_uniform_buffer_binding_size; + limits.maxStorageBufferBindingSize = descriptor.required_limits->limits.max_storage_buffer_binding_size; + limits.minUniformBufferOffsetAlignment = descriptor.required_limits->limits.min_uniform_buffer_offset_alignment; + limits.minStorageBufferOffsetAlignment = descriptor.required_limits->limits.min_storage_buffer_offset_alignment; + limits.maxVertexBuffers = descriptor.required_limits->limits.max_vertex_buffers; + limits.maxBufferSize = descriptor.required_limits->limits.max_buffer_size; + limits.maxVertexAttributes = descriptor.required_limits->limits.max_vertex_attributes; + limits.maxVertexBufferArrayStride = descriptor.required_limits->limits.max_vertex_buffer_array_stride; + limits.maxInterStageShaderVariables = descriptor.required_limits->limits.max_inter_stage_shader_variables; + limits.maxColorAttachments = descriptor.required_limits->limits.max_color_attachments; + limits.maxColorAttachmentBytesPerSample = descriptor.required_limits->limits.max_color_attachment_bytes_per_sample; + limits.maxComputeWorkgroupStorageSize = descriptor.required_limits->limits.max_compute_workgroup_storage_size; + limits.maxComputeInvocationsPerWorkgroup = descriptor.required_limits->limits.max_compute_invocations_per_workgroup; + limits.maxComputeWorkgroupSizeX = descriptor.required_limits->limits.max_compute_workgroup_size_x; + limits.maxComputeWorkgroupSizeY = descriptor.required_limits->limits.max_compute_workgroup_size_y; + limits.maxComputeWorkgroupSizeZ = descriptor.required_limits->limits.max_compute_workgroup_size_z; + limits.maxComputeWorkgroupsPerDimension = descriptor.required_limits->limits.max_compute_workgroups_per_dimension; } - auto device_lost_userdata = new device::lost_callback(descriptor.lost_callback); - - auto device_lost_real_callback = [](WGPUDeviceLostReason reason, char const * message, void * userdata) - { - std::unique_ptr callback((device::lost_callback *)userdata); - if (*callback) (*callback)((device::lost_reason)reason, message ? message : ""); - }; - WGPUDeviceDescriptor device_desc = {}; device_desc.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(descriptor.chain); - device_desc.label = descriptor.label.data(); + device_desc.label = detail::to_string_view(descriptor.label); device_desc.requiredFeatureCount = descriptor.required_features.size(); device_desc.requiredFeatures = (WGPUFeatureName const *)descriptor.required_features.data(); device_desc.requiredLimits = descriptor.required_limits ? &limits : nullptr; device_desc.defaultQueue.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(descriptor.default_queue.chain); - device_desc.defaultQueue.label = descriptor.default_queue.label.data(); - device_desc.deviceLostCallback = device_lost_real_callback; - device_desc.deviceLostUserdata = device_lost_userdata; + device_desc.defaultQueue.label = detail::to_string_view(descriptor.default_queue.label); + device_desc.deviceLostCallbackInfo.mode = (WGPUCallbackMode)descriptor.lost_callback_mode; + device_desc.deviceLostCallbackInfo.callback = [](WGPUDevice const *, WGPUDeviceLostReason reason, WGPUStringView message, void * userdata, void *) + { + std::unique_ptr callback{(device::lost_callback *)userdata}; + if (*callback) (*callback)((device::lost_reason)reason, std::string(message.data, message.length)); + }; + device_desc.deviceLostCallbackInfo.userdata1 = new device::lost_callback(descriptor.lost_callback); + device_desc.uncapturedErrorCallbackInfo.callback = [](WGPUDevice const *, WGPUErrorType type, WGPUStringView message, void * userdata, void *) + { + auto callback = (device::uncaptured_error_callback *)userdata; + if (*callback) (*callback)((error_type)type, std::string(message.data, message.length)); + }; + device_desc.uncapturedErrorCallbackInfo.userdata1 = new device::uncaptured_error_callback(descriptor.uncaptured_error_callback); - auto userdata = new device::request_callback(callback); - - auto real_callback = [](WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata) + WGPURequestDeviceCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, void * userdata, void *) { std::unique_ptr callback{(device::request_callback *)userdata}; - if (*callback) (*callback)((device::request_status)status, wgpu::device(device), message ? message : ""); + if (*callback) (*callback)((device::request_status)status, wgpu::device(device), std::string(message.data, message.length)); }; + callback_info.userdata1 = new device::request_callback(callback); - wgpuAdapterRequestDevice((WGPUAdapter)get(), &device_desc, real_callback, userdata); + wgpuAdapterRequestDevice((WGPUAdapter)get(), &device_desc, callback_info); } void adapter::reference(void * ptr) { - wgpuAdapterReference((WGPUAdapter)ptr); + wgpuAdapterAddRef((WGPUAdapter)ptr); } void adapter::release(void * ptr) diff --git a/libs/wgpu/source/bind_group.cpp b/libs/wgpu/source/bind_group.cpp index 0e51baf5..c4901186 100644 --- a/libs/wgpu/source/bind_group.cpp +++ b/libs/wgpu/source/bind_group.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -6,12 +7,12 @@ namespace psemek::wgpu void bind_group::set_label(std::string const & label) { - wgpuBindGroupSetLabel((WGPUBindGroup)get(), label.data()); + wgpuBindGroupSetLabel((WGPUBindGroup)get(), detail::to_string_view(label)); } void bind_group::reference(void * ptr) { - wgpuBindGroupReference((WGPUBindGroup)ptr); + wgpuBindGroupAddRef((WGPUBindGroup)ptr); } void bind_group::release(void * ptr) diff --git a/libs/wgpu/source/bind_group_layout.cpp b/libs/wgpu/source/bind_group_layout.cpp index a32e18e5..e640837c 100644 --- a/libs/wgpu/source/bind_group_layout.cpp +++ b/libs/wgpu/source/bind_group_layout.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -6,12 +7,12 @@ namespace psemek::wgpu void bind_group_layout::set_label(std::string const & label) { - wgpuBindGroupLayoutSetLabel((WGPUBindGroupLayout)get(), label.data()); + wgpuBindGroupLayoutSetLabel((WGPUBindGroupLayout)get(), detail::to_string_view(label)); } void bind_group_layout::reference(void * ptr) { - wgpuBindGroupLayoutReference((WGPUBindGroupLayout)ptr); + wgpuBindGroupLayoutAddRef((WGPUBindGroupLayout)ptr); } void bind_group_layout::release(void * ptr) diff --git a/libs/wgpu/source/buffer.cpp b/libs/wgpu/source/buffer.cpp index f0bab4e1..ff6ec097 100644 --- a/libs/wgpu/source/buffer.cpp +++ b/libs/wgpu/source/buffer.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -36,17 +37,18 @@ namespace psemek::wgpu return wgpuBufferGetMappedRange((WGPUBuffer)get(), offset, size); } - void buffer::map_async(map_mode flags, std::size_t offset, std::size_t size, map_callback const & callback) + void buffer::map_async(callback_mode mode, map_mode flags, std::size_t offset, std::size_t size, map_callback const & callback) { - auto userdata = new map_callback(callback); - - auto real_callback = [](WGPUBufferMapAsyncStatus status, void * userdata) + WGPUBufferMapCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPUMapAsyncStatus status, WGPUStringView message, void * userdata, void *) { std::unique_ptr callback((map_callback *)userdata); - if (*callback) (*callback)((map_async_status)status); + if (*callback) (*callback)((map_async_status)status, std::string_view(message.data, message.length)); }; + callback_info.userdata1 = new map_callback(callback); - wgpuBufferMapAsync((WGPUBuffer)get(), (WGPUMapModeFlags)flags, offset, size, real_callback, userdata); + wgpuBufferMapAsync((WGPUBuffer)get(), (WGPUMapMode)flags, offset, size, callback_info); } void buffer::unmap() @@ -56,12 +58,12 @@ namespace psemek::wgpu void buffer::set_label(std::string const & label) { - wgpuBufferSetLabel((WGPUBuffer)get(), label.data()); + wgpuBufferSetLabel((WGPUBuffer)get(), detail::to_string_view(label)); } void buffer::reference(void * ptr) { - wgpuBufferReference((WGPUBuffer)ptr); + wgpuBufferAddRef((WGPUBuffer)ptr); } void buffer::release(void * ptr) diff --git a/libs/wgpu/source/chained_struct.cpp b/libs/wgpu/source/chained_struct.cpp index 5090add2..8a1c3d02 100644 --- a/libs/wgpu/source/chained_struct.cpp +++ b/libs/wgpu/source/chained_struct.cpp @@ -30,4 +30,30 @@ namespace psemek::wgpu::detail return first; } + void * fill_chain_out(std::vector const & chain) + { + WGPUChainedStructOut * first = nullptr; + WGPUChainedStructOut * current = nullptr; + + for (auto const & s : chain) + { + auto p = (WGPUChainedStructOut *)s.ptr(); + if (!first) + { + first = p; + current = p; + } + else + { + current->next = p; + current = p; + } + } + + if (current) + current->next = nullptr; + + return first; + } + } diff --git a/libs/wgpu/source/command_buffer.cpp b/libs/wgpu/source/command_buffer.cpp index 9a2c43d2..b27f781b 100644 --- a/libs/wgpu/source/command_buffer.cpp +++ b/libs/wgpu/source/command_buffer.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -6,12 +7,12 @@ namespace psemek::wgpu void command_buffer::set_label(std::string const & label) { - wgpuCommandBufferSetLabel((WGPUCommandBuffer)get(), label.data()); + wgpuCommandBufferSetLabel((WGPUCommandBuffer)get(), detail::to_string_view(label)); } void command_buffer::reference(void * ptr) { - wgpuCommandBufferReference((WGPUCommandBuffer)ptr); + wgpuCommandBufferAddRef((WGPUCommandBuffer)ptr); } void command_buffer::release(void * ptr) diff --git a/libs/wgpu/source/command_encoder.cpp b/libs/wgpu/source/command_encoder.cpp index 9a8b63b6..e9dfbe4f 100644 --- a/libs/wgpu/source/command_encoder.cpp +++ b/libs/wgpu/source/command_encoder.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -16,7 +17,7 @@ namespace psemek::wgpu WGPUComputePassDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.timestampWrites = desc.timestamp_writes ? ×tamp_writes : nullptr; return compute_pass_encoder(wgpuCommandEncoderBeginComputePass((WGPUCommandEncoder)get(), &descriptor)); @@ -30,6 +31,7 @@ namespace psemek::wgpu auto & dst = color_attachments.emplace_back(); dst.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(src.chain); dst.view = (WGPUTextureView)src.view.get(); + dst.depthSlice = src.depth_slice; dst.resolveTarget = (WGPUTextureView)src.resolve_target.get(); dst.loadOp = (WGPULoadOp)src.load_op; dst.storeOp = (WGPUStoreOp)src.store_op; @@ -43,11 +45,11 @@ namespace psemek::wgpu depth_stencil_attachment.depthLoadOp = (WGPULoadOp)desc.depth_stencil_attachment->depth_load_op; depth_stencil_attachment.depthStoreOp = (WGPUStoreOp)desc.depth_stencil_attachment->depth_store_op; depth_stencil_attachment.depthClearValue = desc.depth_stencil_attachment->depth_clear_value; - depth_stencil_attachment.depthReadOnly = desc.depth_stencil_attachment->depth_read_only; + depth_stencil_attachment.depthReadOnly = desc.depth_stencil_attachment->depth_read_only ? 1 : 0; depth_stencil_attachment.stencilLoadOp = (WGPULoadOp)desc.depth_stencil_attachment->stencil_load_op; depth_stencil_attachment.stencilStoreOp = (WGPUStoreOp)desc.depth_stencil_attachment->stencil_store_op; depth_stencil_attachment.stencilClearValue = desc.depth_stencil_attachment->stencil_clear_value; - depth_stencil_attachment.stencilReadOnly = desc.depth_stencil_attachment->stencil_clear_value; + depth_stencil_attachment.stencilReadOnly = desc.depth_stencil_attachment->stencil_read_only ? 1 : 0; } WGPURenderPassTimestampWrites timestamp_writes = {}; @@ -60,7 +62,7 @@ namespace psemek::wgpu WGPURenderPassDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.colorAttachmentCount = color_attachments.size(); descriptor.colorAttachments = color_attachments.data(); descriptor.depthStencilAttachment = desc.depth_stencil_attachment ? &depth_stencil_attachment : nullptr; @@ -80,73 +82,65 @@ namespace psemek::wgpu wgpuCommandEncoderCopyBufferToBuffer((WGPUCommandEncoder)get(), (WGPUBuffer)source.get(), source_offset, (WGPUBuffer)destination.get(), destination_offset, size); } - void command_encoder::copy_buffer_to_texture(image_copy_buffer const & source, image_copy_texture const & destination, math::vector const & extent) + void command_encoder::copy_buffer_to_texture(texel_copy_buffer_info const & source, texel_copy_texture_info const & destination, math::vector const & extent) { - WGPUImageCopyBuffer image_copy_src = {}; - image_copy_src.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(source.chain); - image_copy_src.layout.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(source.layout.chain); - image_copy_src.layout.offset = source.layout.offset; - image_copy_src.layout.bytesPerRow = source.layout.bytes_per_row; - image_copy_src.layout.rowsPerImage = source.layout.rows_per_image; - image_copy_src.buffer = (WGPUBuffer)source.buffer.get(); + WGPUTexelCopyBufferInfo texel_copy_buffer_info_src = {}; + texel_copy_buffer_info_src.layout.offset = source.layout.offset; + texel_copy_buffer_info_src.layout.bytesPerRow = source.layout.bytes_per_row; + texel_copy_buffer_info_src.layout.rowsPerImage = source.layout.rows_per_image; + texel_copy_buffer_info_src.buffer = (WGPUBuffer)source.buffer.get(); - WGPUImageCopyTexture image_copy_dst = {}; - image_copy_dst.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(destination.chain); - image_copy_dst.texture = (WGPUTexture)destination.texture.get(); - image_copy_dst.mipLevel = destination.mip_level; - image_copy_dst.origin = {destination.origin[0], destination.origin[1], destination.origin[2]}; - image_copy_dst.aspect = (WGPUTextureAspect)destination.aspect; + WGPUTexelCopyTextureInfo texel_copy_texture_info_src_dst = {}; + texel_copy_texture_info_src_dst.texture = (WGPUTexture)destination.texture.get(); + texel_copy_texture_info_src_dst.mipLevel = destination.mip_level; + texel_copy_texture_info_src_dst.origin = {destination.origin[0], destination.origin[1], destination.origin[2]}; + texel_copy_texture_info_src_dst.aspect = (WGPUTextureAspect)destination.aspect; - wgpuCommandEncoderCopyBufferToTexture((WGPUCommandEncoder)get(), &image_copy_src, &image_copy_dst, (WGPUExtent3D const *)(&extent)); + wgpuCommandEncoderCopyBufferToTexture((WGPUCommandEncoder)get(), &texel_copy_buffer_info_src, &texel_copy_texture_info_src_dst, (WGPUExtent3D const *)(&extent)); } - void command_encoder::copy_texture_to_buffer(image_copy_texture const & source, image_copy_buffer const & destination, math::vector const & extent) + void command_encoder::copy_texture_to_buffer(texel_copy_texture_info const & source, texel_copy_buffer_info const & destination, math::vector const & extent) { - WGPUImageCopyTexture image_copy_src = {}; - image_copy_src.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(source.chain); - image_copy_src.texture = (WGPUTexture)source.texture.get(); - image_copy_src.mipLevel = source.mip_level; - image_copy_src.origin = {source.origin[0], source.origin[1], source.origin[2]}; - image_copy_src.aspect = (WGPUTextureAspect)source.aspect; + WGPUTexelCopyTextureInfo texel_copy_texture_info_src = {}; + texel_copy_texture_info_src.texture = (WGPUTexture)source.texture.get(); + texel_copy_texture_info_src.mipLevel = source.mip_level; + texel_copy_texture_info_src.origin = {source.origin[0], source.origin[1], source.origin[2]}; + texel_copy_texture_info_src.aspect = (WGPUTextureAspect)source.aspect; - WGPUImageCopyBuffer image_copy_dst = {}; - image_copy_dst.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(destination.chain); - image_copy_dst.layout.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(destination.layout.chain); - image_copy_dst.layout.offset = destination.layout.offset; - image_copy_dst.layout.bytesPerRow = destination.layout.bytes_per_row; - image_copy_dst.layout.rowsPerImage = destination.layout.rows_per_image; - image_copy_dst.buffer = (WGPUBuffer)destination.buffer.get(); + WGPUTexelCopyBufferInfo texel_copy_buffer_info_dst = {}; + texel_copy_buffer_info_dst.layout.offset = destination.layout.offset; + texel_copy_buffer_info_dst.layout.bytesPerRow = destination.layout.bytes_per_row; + texel_copy_buffer_info_dst.layout.rowsPerImage = destination.layout.rows_per_image; + texel_copy_buffer_info_dst.buffer = (WGPUBuffer)destination.buffer.get(); - wgpuCommandEncoderCopyTextureToBuffer((WGPUCommandEncoder)get(), &image_copy_src, &image_copy_dst, (WGPUExtent3D const *)(&extent)); + wgpuCommandEncoderCopyTextureToBuffer((WGPUCommandEncoder)get(), &texel_copy_texture_info_src, &texel_copy_buffer_info_dst, (WGPUExtent3D const *)(&extent)); } - void command_encoder::copy_texture_to_texture(image_copy_texture const & source, image_copy_texture const & destination, math::vector const & extent) + void command_encoder::copy_texture_to_texture(texel_copy_texture_info const & source, texel_copy_texture_info const & destination, math::vector const & extent) { - WGPUImageCopyTexture image_copy_src = {}; - image_copy_src.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(source.chain); - image_copy_src.texture = (WGPUTexture)source.texture.get(); - image_copy_src.mipLevel = source.mip_level; - image_copy_src.origin = {source.origin[0], source.origin[1], source.origin[2]}; - image_copy_src.aspect = (WGPUTextureAspect)source.aspect; + WGPUTexelCopyTextureInfo texel_copy_texture_info_src = {}; + texel_copy_texture_info_src.texture = (WGPUTexture)source.texture.get(); + texel_copy_texture_info_src.mipLevel = source.mip_level; + texel_copy_texture_info_src.origin = {source.origin[0], source.origin[1], source.origin[2]}; + texel_copy_texture_info_src.aspect = (WGPUTextureAspect)source.aspect; - WGPUImageCopyTexture image_copy_dst = {}; - image_copy_dst.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(destination.chain); - image_copy_dst.texture = (WGPUTexture)destination.texture.get(); - image_copy_dst.mipLevel = destination.mip_level; - image_copy_dst.origin = {destination.origin[0], destination.origin[1], destination.origin[2]}; - image_copy_dst.aspect = (WGPUTextureAspect)destination.aspect; + WGPUTexelCopyTextureInfo texel_copy_texture_info_dst = {}; + texel_copy_texture_info_dst.texture = (WGPUTexture)destination.texture.get(); + texel_copy_texture_info_dst.mipLevel = destination.mip_level; + texel_copy_texture_info_dst.origin = {destination.origin[0], destination.origin[1], destination.origin[2]}; + texel_copy_texture_info_dst.aspect = (WGPUTextureAspect)destination.aspect; - wgpuCommandEncoderCopyTextureToTexture((WGPUCommandEncoder)get(), &image_copy_src, &image_copy_dst, (WGPUExtent3D const *)(&extent)); + wgpuCommandEncoderCopyTextureToTexture((WGPUCommandEncoder)get(), &texel_copy_texture_info_src, &texel_copy_texture_info_dst, (WGPUExtent3D const *)(&extent)); } void command_encoder::insert_debug_marker(std::string const & marker_label) { - wgpuCommandEncoderInsertDebugMarker((WGPUCommandEncoder)get(), marker_label.data()); + wgpuCommandEncoderInsertDebugMarker((WGPUCommandEncoder)get(), detail::to_string_view(marker_label)); } void command_encoder::push_debug_group(std::string const & group_label) { - wgpuCommandEncoderPushDebugGroup((WGPUCommandEncoder)get(), group_label.data()); + wgpuCommandEncoderPushDebugGroup((WGPUCommandEncoder)get(), detail::to_string_view(group_label)); } void command_encoder::pop_debug_group() @@ -168,18 +162,18 @@ namespace psemek::wgpu { WGPUCommandBufferDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); return command_buffer(wgpuCommandEncoderFinish((WGPUCommandEncoder)get(), &descriptor)); } void command_encoder::set_label(std::string const & label) { - wgpuCommandEncoderSetLabel((WGPUCommandEncoder)get(), label.data()); + wgpuCommandEncoderSetLabel((WGPUCommandEncoder)get(), detail::to_string_view(label)); } void command_encoder::reference(void * ptr) { - wgpuCommandEncoderReference((WGPUCommandEncoder)ptr); + wgpuCommandEncoderAddRef((WGPUCommandEncoder)ptr); } void command_encoder::release(void * ptr) diff --git a/libs/wgpu/source/compute_pass_encoder.cpp b/libs/wgpu/source/compute_pass_encoder.cpp index 49d1de33..f3ee8b53 100644 --- a/libs/wgpu/source/compute_pass_encoder.cpp +++ b/libs/wgpu/source/compute_pass_encoder.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include namespace psemek::wgpu { @@ -24,14 +26,24 @@ namespace psemek::wgpu wgpuComputePassEncoderDispatchWorkgroupsIndirect((WGPUComputePassEncoder)get(), (WGPUBuffer)indirect_buffer.get(), offset); } + void compute_pass_encoder::set_push_constants(std::uint32_t offset, util::span data) + { + wgpuComputePassEncoderSetPushConstants((WGPUComputePassEncoder)get(), offset, data.size(), data.data()); + } + + void compute_pass_encoder::write_timestamp(query_set const & query_set, std::uint32_t query_index) + { + wgpuComputePassEncoderWriteTimestamp((WGPUComputePassEncoder)get(), (WGPUQuerySet)query_set.get(), query_index); + } + void compute_pass_encoder::insert_debug_marker(std::string const & marker_label) { - wgpuComputePassEncoderInsertDebugMarker((WGPUComputePassEncoder)get(), marker_label.data()); + wgpuComputePassEncoderInsertDebugMarker((WGPUComputePassEncoder)get(), detail::to_string_view(marker_label)); } void compute_pass_encoder::push_debug_group(std::string const & group_label) { - wgpuComputePassEncoderPushDebugGroup((WGPUComputePassEncoder)get(), group_label.data()); + wgpuComputePassEncoderPushDebugGroup((WGPUComputePassEncoder)get(), detail::to_string_view(group_label)); } void compute_pass_encoder::pop_debug_group() @@ -46,12 +58,12 @@ namespace psemek::wgpu void compute_pass_encoder::set_label(std::string const & label) { - wgpuComputePassEncoderSetLabel((WGPUComputePassEncoder)get(), label.data()); + wgpuComputePassEncoderSetLabel((WGPUComputePassEncoder)get(), detail::to_string_view(label)); } void compute_pass_encoder::reference(void * ptr) { - wgpuComputePassEncoderReference((WGPUComputePassEncoder)ptr); + wgpuComputePassEncoderAddRef((WGPUComputePassEncoder)ptr); } void compute_pass_encoder::release(void * ptr) diff --git a/libs/wgpu/source/compute_pipeline.cpp b/libs/wgpu/source/compute_pipeline.cpp index 7058efc3..178723ad 100644 --- a/libs/wgpu/source/compute_pipeline.cpp +++ b/libs/wgpu/source/compute_pipeline.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -11,12 +12,12 @@ namespace psemek::wgpu void compute_pipeline::set_label(std::string const & label) { - wgpuComputePipelineSetLabel((WGPUComputePipeline)get(), label.data()); + wgpuComputePipelineSetLabel((WGPUComputePipeline)get(), detail::to_string_view(label)); } void compute_pipeline::reference(void * ptr) { - wgpuComputePipelineReference((WGPUComputePipeline)ptr); + wgpuComputePipelineAddRef((WGPUComputePipeline)ptr); } void compute_pipeline::release(void * ptr) diff --git a/libs/wgpu/source/device.cpp b/libs/wgpu/source/device.cpp index 6dced1f7..cf581e1f 100644 --- a/libs/wgpu/source/device.cpp +++ b/libs/wgpu/source/device.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -29,7 +31,7 @@ namespace psemek::wgpu WGPUBindGroupDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.layout = (WGPUBindGroupLayout)desc.layout.get(); descriptor.entryCount = entries.size(); descriptor.entries = entries.data(); @@ -45,7 +47,7 @@ namespace psemek::wgpu auto & entry_out = entries.emplace_back(); entry_out.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(entry_in.chain); entry_out.binding = entry_in.binding; - entry_out.visibility = (WGPUShaderStageFlags)entry_in.visibility; + entry_out.visibility = (WGPUShaderStage)entry_in.visibility; entry_out.buffer.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(entry_in.buffer.chain); entry_out.buffer.type = (WGPUBufferBindingType)entry_in.buffer.type; entry_out.buffer.hasDynamicOffset = entry_in.buffer.has_dynamic_offset; @@ -64,7 +66,7 @@ namespace psemek::wgpu WGPUBindGroupLayoutDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.entryCount = entries.size(); descriptor.entries = entries.data(); @@ -75,8 +77,8 @@ namespace psemek::wgpu { WGPUBufferDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); - descriptor.usage = (WGPUBufferUsageFlags)desc.usage; + descriptor.label = detail::to_string_view(desc.label); + descriptor.usage = (WGPUBufferUsage)desc.usage; descriptor.size = desc.size; descriptor.mappedAtCreation = desc.mapped_at_creation; return buffer(wgpuDeviceCreateBuffer((WGPUDevice)get(), &descriptor)); @@ -86,7 +88,7 @@ namespace psemek::wgpu { WGPUCommandEncoderDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); return command_encoder(wgpuDeviceCreateCommandEncoder((WGPUDevice)get(), &descriptor)); } @@ -99,16 +101,16 @@ namespace psemek::wgpu { auto & constant_out = constants.emplace_back(); constant_out.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(constant_in.chain); - constant_out.key = constant_in.key.data(); + constant_out.key = detail::to_string_view(constant_in.key); constant_out.value = constant_in.value; } descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.layout = (WGPUPipelineLayout)desc.layout.get(); descriptor.compute.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.compute.chain); descriptor.compute.module = (WGPUShaderModule)desc.compute.module.get(); - descriptor.compute.entryPoint = desc.compute.entry_point.data(); + descriptor.compute.entryPoint = detail::to_string_view(desc.compute.entry_point); descriptor.compute.constantCount = constants.size(); descriptor.compute.constants = constants.data(); } @@ -124,28 +126,29 @@ namespace psemek::wgpu return compute_pipeline(wgpuDeviceCreateComputePipeline((WGPUDevice)get(), &descriptor)); } - void device::create_compute_pipeline_async(compute_pipeline::descriptor const & desc, create_compute_pipeline_async_callback const & callback) + void device::create_compute_pipeline_async(callback_mode mode, compute_pipeline::descriptor const & desc, create_compute_pipeline_async_callback const & callback) { std::vector constants; WGPUComputePipelineDescriptor descriptor = {}; fill_compute_pipeline_descriptor(desc, constants, descriptor); - auto userdata = new create_compute_pipeline_async_callback(callback); - - auto real_callback = [](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata) + WGPUCreateComputePipelineAsyncCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, WGPUStringView message, void * userdata, void *) { std::unique_ptr callback((create_compute_pipeline_async_callback *)userdata); - if (*callback) (*callback)((create_pipeline_async_status)status, compute_pipeline(pipeline), std::string(message ? message : "")); + if (*callback) (*callback)((create_pipeline_async_status)status, compute_pipeline(pipeline), std::string_view(message.data, message.length)); }; + callback_info.userdata1 = new create_compute_pipeline_async_callback(callback); - wgpuDeviceCreateComputePipelineAsync((WGPUDevice)get(), &descriptor, real_callback, userdata); + wgpuDeviceCreateComputePipelineAsync((WGPUDevice)get(), &descriptor, callback_info); } pipeline_layout device::create_pipeline_layout(pipeline_layout::descriptor const & desc) { WGPUPipelineLayoutDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.bindGroupLayoutCount = desc.layouts.size(); static_assert(sizeof(WGPUBindGroupLayout) == sizeof(bind_group_layout)); descriptor.bindGroupLayouts = (WGPUBindGroupLayout const *)desc.layouts.data(); @@ -156,7 +159,7 @@ namespace psemek::wgpu { WGPUQuerySetDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.type = (WGPUQueryType)desc.type; descriptor.count = desc.count; return query_set(wgpuDeviceCreateQuerySet((WGPUDevice)get(), &descriptor)); @@ -165,6 +168,11 @@ namespace psemek::wgpu namespace { + WGPUOptionalBool to_optional_bool(std::optional value) + { + return value ? (*value ? WGPUOptionalBool_True : WGPUOptionalBool_False) : WGPUOptionalBool_Undefined; + } + void fill_render_pipeline_descriptor(render_pipeline::descriptor const & desc, WGPURenderPipelineDescriptor & descriptor, std::vector & vertex_constants, @@ -175,14 +183,14 @@ namespace psemek::wgpu std::vector & color_targets) { descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.layout = (WGPUPipelineLayout)desc.layout.get(); for (auto const & constant_in : desc.vertex.constants) { auto & constant_out = vertex_constants.emplace_back(); constant_out.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(constant_in.chain); - constant_out.key = constant_in.key.data(); + constant_out.key = detail::to_string_view(constant_in.key); constant_out.value = constant_in.value; } @@ -198,7 +206,7 @@ namespace psemek::wgpu descriptor.vertex.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.vertex.chain); descriptor.vertex.module = (WGPUShaderModule)desc.vertex.module.get(); - descriptor.vertex.entryPoint = desc.vertex.entry_point.data(); + descriptor.vertex.entryPoint = detail::to_string_view(desc.vertex.entry_point); descriptor.vertex.constantCount = vertex_constants.size(); descriptor.vertex.constants = vertex_constants.data(); descriptor.vertex.bufferCount = vertex_buffers.size(); @@ -209,12 +217,13 @@ namespace psemek::wgpu descriptor.primitive.stripIndexFormat = (WGPUIndexFormat)desc.primitive.strip_index_format; descriptor.primitive.frontFace = (WGPUFrontFace)desc.primitive.front_face; descriptor.primitive.cullMode = (WGPUCullMode)desc.primitive.cull_mode; + descriptor.primitive.unclippedDepth = desc.primitive.clip_depth ? 0 : 1; if (desc.depth_stencil) { depth_stencil_state.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.depth_stencil->chain); depth_stencil_state.format = (WGPUTextureFormat)desc.depth_stencil->format; - depth_stencil_state.depthWriteEnabled = desc.depth_stencil->depth_write; + depth_stencil_state.depthWriteEnabled = to_optional_bool(desc.depth_stencil->depth_write); depth_stencil_state.depthCompare = (WGPUCompareFunction)desc.depth_stencil->depth_compare; depth_stencil_state.stencilFront.compare = (WGPUCompareFunction)desc.depth_stencil->stencil_front.compare; depth_stencil_state.stencilFront.failOp = (WGPUStencilOperation)desc.depth_stencil->stencil_front.fail_op; @@ -244,7 +253,7 @@ namespace psemek::wgpu { auto & constant_out = fragment_constants.emplace_back(); constant_out.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(constant_in.chain); - constant_out.key = constant_in.key.data(); + constant_out.key = detail::to_string_view(constant_in.key); constant_out.value = constant_in.value; } @@ -255,12 +264,12 @@ namespace psemek::wgpu target_out.format = (WGPUTextureFormat)target_in.format; static_assert(sizeof(WGPUBlendState) == sizeof(blend_state)); target_out.blend = (WGPUBlendState *)(target_in.blend ? &(*target_in.blend) : nullptr); - target_out.writeMask = (WGPUColorWriteMaskFlags)target_in.write_mask; + target_out.writeMask = (WGPUColorWriteMask)target_in.write_mask; } fragment_state.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.fragment->chain); fragment_state.module = (WGPUShaderModule)desc.fragment->module.get(); - fragment_state.entryPoint = desc.fragment->entry_point.data(); + fragment_state.entryPoint = detail::to_string_view(desc.fragment->entry_point); fragment_state.constantCount = fragment_constants.size(); fragment_state.constants = fragment_constants.data(); fragment_state.targetCount = color_targets.size(); @@ -287,7 +296,7 @@ namespace psemek::wgpu return render_pipeline(wgpuDeviceCreateRenderPipeline((WGPUDevice)get(), &descriptor)); } - void device::create_render_pipeline_async(render_pipeline::descriptor const & desc, create_render_pipeline_async_callback const & callback) + void device::create_render_pipeline_async(callback_mode mode, render_pipeline::descriptor const & desc, create_render_pipeline_async_callback const & callback) { WGPURenderPipelineDescriptor descriptor = {}; std::vector vertex_constants; @@ -299,22 +308,23 @@ namespace psemek::wgpu fill_render_pipeline_descriptor(desc, descriptor, vertex_constants, vertex_buffers, depth_stencil_state, fragment_state, fragment_constants, color_targets); - auto userdata = new create_render_pipeline_async_callback(callback); - - auto real_callback = [](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata) + WGPUCreateRenderPipelineAsyncCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, WGPUStringView message, void * userdata, void *) { std::unique_ptr callback((create_render_pipeline_async_callback *)userdata); - if (*callback) (*callback)((create_pipeline_async_status)status, render_pipeline(pipeline), std::string(message ? message : "")); + if (*callback) (*callback)((create_pipeline_async_status)status, render_pipeline(pipeline), std::string_view(message.data, message.length)); }; + callback_info.userdata1 = new create_render_pipeline_async_callback(callback); - wgpuDeviceCreateRenderPipelineAsync((WGPUDevice)get(), &descriptor, real_callback, userdata); + wgpuDeviceCreateRenderPipelineAsync((WGPUDevice)get(), &descriptor, callback_info); } render_bundle_encoder device::create_render_bundle_encoder(render_bundle_encoder::descriptor const & desc) { WGPURenderBundleEncoderDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.colorFormatCount = desc.color_formats.size(); descriptor.colorFormats = (WGPUTextureFormat const *)desc.color_formats.data(); descriptor.depthStencilFormat = (WGPUTextureFormat)desc.depth_stencil_format; @@ -328,7 +338,7 @@ namespace psemek::wgpu { WGPUSamplerDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.addressModeU = (WGPUAddressMode)desc.address_mode_u; descriptor.addressModeV = (WGPUAddressMode)desc.address_mode_v; descriptor.addressModeW = (WGPUAddressMode)desc.address_mode_w; @@ -344,20 +354,9 @@ namespace psemek::wgpu shader_module device::create_shader_module(shader_module::descriptor const & desc) { - std::vector hints; - for (auto const & hint_in : desc.hints) - { - auto & hint = hints.emplace_back(); - hint.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(hint_in.chain); - hint.entryPoint = hint_in.entry_point.data(); - hint.layout = (WGPUPipelineLayout)hint_in.layout.get(); - } - WGPUShaderModuleDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); - descriptor.hintCount = hints.size(); - descriptor.hints = hints.data(); + descriptor.label = detail::to_string_view(desc.label); return shader_module(wgpuDeviceCreateShaderModule((WGPUDevice)get(), &descriptor)); } @@ -365,8 +364,8 @@ namespace psemek::wgpu { WGPUTextureDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); - descriptor.usage = (WGPUTextureUsageFlags)desc.usage; + descriptor.label = detail::to_string_view(desc.label); + descriptor.usage = (WGPUTextureUsage)desc.usage; descriptor.dimension = (WGPUTextureDimension)desc.dimension; descriptor.size = {desc.size[0], desc.size[1], desc.size[2]}; descriptor.format = (WGPUTextureFormat)desc.format; @@ -384,21 +383,53 @@ namespace psemek::wgpu std::vector device::enumerate_features() { - std::size_t count = wgpuDeviceEnumerateFeatures((WGPUDevice)get(), nullptr); - std::vector result(count); - wgpuDeviceEnumerateFeatures((WGPUDevice)get(), (WGPUFeatureName *)result.data()); + WGPUSupportedFeatures supported_features; + wgpuDeviceGetFeatures((WGPUDevice)get(), &supported_features); + + std::vector result((feature const *)supported_features.features, (feature const *)(supported_features.features + supported_features.featureCount)); + wgpuSupportedFeaturesFreeMembers(supported_features); return result; } limits device::get_limits() { - WGPUSupportedLimits limits = {}; - wgpuDeviceGetLimits((WGPUDevice)get(), &limits); + WGPULimits limits = {}; + detail::check_status("wgpuDeviceGetLimits", wgpuDeviceGetLimits((WGPUDevice)get(), &limits)); // TODO: support out chain wgpu::limits result; - static_assert(sizeof(result) == sizeof(limits.limits)); - std::memcpy((char *)&result, (char *)&limits.limits, sizeof(result)); + result.max_texture_dimension_1D = limits.maxTextureDimension1D; + result.max_texture_dimension_2D = limits.maxTextureDimension2D; + result.max_texture_dimension_3D = limits.maxTextureDimension3D; + result.max_texture_array_layers = limits.maxTextureArrayLayers; + result.max_bind_groups = limits.maxBindGroups; + result.max_bind_groups_plus_vertex_buffers = limits.maxBindGroupsPlusVertexBuffers; + result.max_bindings_per_bind_group = limits.maxBindingsPerBindGroup; + result.max_dynamic_uniform_buffers_per_pipeline_layout = limits.maxDynamicUniformBuffersPerPipelineLayout; + result.max_dynamic_storage_buffers_per_pipeline_layout = limits.maxDynamicStorageBuffersPerPipelineLayout; + result.max_sampled_textures_per_shader_stage = limits.maxSampledTexturesPerShaderStage; + result.max_samplers_per_shader_stage = limits.maxSamplersPerShaderStage; + result.max_storage_buffers_per_shader_stage = limits.maxStorageBuffersPerShaderStage; + result.max_storage_textures_per_shader_stage = limits.maxStorageTexturesPerShaderStage; + result.max_uniform_buffers_per_shader_stage = limits.maxUniformBuffersPerShaderStage; + result.max_uniform_buffer_binding_size = limits.maxUniformBufferBindingSize; + result.max_storage_buffer_binding_size = limits.maxStorageBufferBindingSize; + result.min_uniform_buffer_offset_alignment = limits.minUniformBufferOffsetAlignment; + result.min_storage_buffer_offset_alignment = limits.minStorageBufferOffsetAlignment; + result.max_vertex_buffers = limits.maxVertexBuffers; + result.max_buffer_size = limits.maxBufferSize; + result.max_vertex_attributes = limits.maxVertexAttributes; + result.max_vertex_buffer_array_stride = limits.maxVertexBufferArrayStride; + result.max_inter_stage_shader_variables = limits.maxInterStageShaderVariables; + result.max_color_attachments = limits.maxColorAttachments; + result.max_color_attachment_bytes_per_sample = limits.maxColorAttachmentBytesPerSample; + result.max_compute_workgroup_storage_size = limits.maxComputeWorkgroupStorageSize; + result.max_compute_invocations_per_workgroup = limits.maxComputeInvocationsPerWorkgroup; + result.max_compute_workgroup_size_x = limits.maxComputeWorkgroupSizeX; + result.max_compute_workgroup_size_y = limits.maxComputeWorkgroupSizeY; + result.max_compute_workgroup_size_z = limits.maxComputeWorkgroupSizeZ; + result.max_compute_workgroups_per_dimension = limits.maxComputeWorkgroupsPerDimension; + return result; } @@ -412,40 +443,28 @@ namespace psemek::wgpu wgpuDevicePushErrorScope((WGPUDevice)get(), (WGPUErrorFilter)filter); } - void device::pop_error_scope(error_callback const & callback) + void device::pop_error_scope(callback_mode mode, pop_error_callback const & callback) { - auto userdata = new error_callback(callback); - - auto real_callback = [](WGPUErrorType type, char const * message, void * userdata) + WGPUPopErrorScopeCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void *) { - std::unique_ptr callback((error_callback *)userdata); - if (*callback) (*callback)((error_type)type, message ? message : ""); + std::unique_ptr callback((pop_error_callback *)userdata); + if (*callback) (*callback)((pop_error_scope_status)status, (error_type)type, std::string_view(message.data, message.length)); }; + callback_info.userdata1 = new pop_error_callback(callback); - wgpuDevicePopErrorScope((WGPUDevice)get(), real_callback, userdata); - } - - void device::set_uncaptured_error_callback(error_callback const & callback) - { - auto userdata = new error_callback(callback); - - auto real_callback = [](WGPUErrorType type, char const * message, void * userdata) - { - std::unique_ptr callback((error_callback *)userdata); - if (*callback) (*callback)((error_type)type, message ? message : ""); - }; - - wgpuDeviceSetUncapturedErrorCallback((WGPUDevice)get(), real_callback, userdata); + wgpuDevicePopErrorScope((WGPUDevice)get(), callback_info); } void device::set_label(std::string const & label) { - wgpuDeviceSetLabel((WGPUDevice)get(), label.data()); + wgpuDeviceSetLabel((WGPUDevice)get(), detail::to_string_view(label)); } void device::reference(void * ptr) { - wgpuDeviceReference((WGPUDevice)ptr); + wgpuDeviceAddRef((WGPUDevice)ptr); } void device::release(void * ptr) @@ -455,10 +474,10 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(native_limits && value) { - WGPURequiredLimitsExtras chained = {}; - chained.chain.sType = (WGPUSType)WGPUSType_RequiredLimitsExtras; - static_assert(sizeof(WGPUNativeLimits) == sizeof(native_limits)); - std::memcpy(&chained.limits, &value, sizeof(value)); + WGPUNativeLimits chained = {}; + chained.chain.sType = (WGPUSType)WGPUSType_NativeLimits; + chained.maxPushConstantSize = value.max_push_constant_size; + chained.maxNonSamplerBindings = value.max_non_sampler_bindings; return detail::make_chained_struct(chained); } diff --git a/libs/wgpu/source/instance.cpp b/libs/wgpu/source/instance.cpp index 6d6233f1..644107a2 100644 --- a/libs/wgpu/source/instance.cpp +++ b/libs/wgpu/source/instance.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -40,33 +41,35 @@ namespace psemek::wgpu { WGPUSurfaceDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); return surface{wgpuInstanceCreateSurface((WGPUInstance)get(), &descriptor)}; } - void instance::request_adapter(adapter::request_options const & request_options, adapter::request_callback callback) + void instance::request_adapter(callback_mode mode, adapter::request_options const & request_options, adapter::request_callback callback) { - WGPURequestAdapterOptions options; + WGPURequestAdapterOptions options = {}; options.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(request_options.chain); - options.compatibleSurface = (WGPUSurface)request_options.compatible_surface.get(); + options.featureLevel = (WGPUFeatureLevel)request_options.feature_level; options.powerPreference = (WGPUPowerPreference)request_options.power_preference; - options.backendType = (WGPUBackendType)request_options.backend_type; options.forceFallbackAdapter = request_options.force_fallback_adapter; + options.backendType = (WGPUBackendType)request_options.backend_type; + options.compatibleSurface = (WGPUSurface)request_options.compatible_surface.get(); - auto userdata = new adapter::request_callback(callback); - - auto real_callback = [](WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata) + WGPURequestAdapterCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, void * userdata, void *) { std::unique_ptr callback{(adapter::request_callback *)userdata}; - if (*callback) (*callback)(adapter::request_status{status}, wgpu::adapter(adapter), message ? message : ""); + if (*callback) (*callback)(adapter::request_status{status}, wgpu::adapter(adapter), std::string_view(message.data, message.length)); }; + callback_info.userdata1 = new adapter::request_callback(callback); - wgpuInstanceRequestAdapter((WGPUInstance)get(), &options, real_callback, userdata); + wgpuInstanceRequestAdapter((WGPUInstance)get(), &options, callback_info); } void instance::reference(void * ptr) { - wgpuInstanceReference((WGPUInstance)ptr); + wgpuInstanceAddRef((WGPUInstance)ptr); } void instance::release(void * ptr) diff --git a/libs/wgpu/source/logging.cpp b/libs/wgpu/source/logging.cpp index 265197c2..e8d771d6 100644 --- a/libs/wgpu/source/logging.cpp +++ b/libs/wgpu/source/logging.cpp @@ -40,8 +40,8 @@ namespace psemek::wgpu void setup_logging(log::level level) { wgpuSetLogLevel(to_wgpu_log_level(level)); - wgpuSetLogCallback([](WGPULogLevel level, char const * message, void * /* userdata */){ - log::log(to_psemek_log_level(level)) << "WebGPU: " << message; + wgpuSetLogCallback([](WGPULogLevel level, WGPUStringView message, void * /* userdata */){ + log::log(to_psemek_log_level(level)) << "WebGPU: " << std::string_view(message.data, message.length); }, nullptr); } diff --git a/libs/wgpu/source/pipeline_layout.cpp b/libs/wgpu/source/pipeline_layout.cpp index 0ed0ea5e..7994751d 100644 --- a/libs/wgpu/source/pipeline_layout.cpp +++ b/libs/wgpu/source/pipeline_layout.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -7,12 +8,12 @@ namespace psemek::wgpu void pipeline_layout::set_label(std::string const & label) { - wgpuPipelineLayoutSetLabel((WGPUPipelineLayout)get(), label.data()); + wgpuPipelineLayoutSetLabel((WGPUPipelineLayout)get(), detail::to_string_view(label)); } void pipeline_layout::reference(void * ptr) { - wgpuPipelineLayoutReference((WGPUPipelineLayout)ptr); + wgpuPipelineLayoutAddRef((WGPUPipelineLayout)ptr); } void pipeline_layout::release(void * ptr) diff --git a/libs/wgpu/source/query_set.cpp b/libs/wgpu/source/query_set.cpp index 3dab9410..f778ddc6 100644 --- a/libs/wgpu/source/query_set.cpp +++ b/libs/wgpu/source/query_set.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -21,12 +22,12 @@ namespace psemek::wgpu void query_set::set_label(std::string const & label) { - wgpuQuerySetSetLabel((WGPUQuerySet)get(), label.data()); + wgpuQuerySetSetLabel((WGPUQuerySet)get(), detail::to_string_view(label)); } void query_set::reference(void * ptr) { - wgpuQuerySetReference((WGPUQuerySet)ptr); + wgpuQuerySetAddRef((WGPUQuerySet)ptr); } void query_set::release(void * ptr) diff --git a/libs/wgpu/source/queue.cpp b/libs/wgpu/source/queue.cpp index cd1a665b..2cba63fc 100644 --- a/libs/wgpu/source/queue.cpp +++ b/libs/wgpu/source/queue.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -15,47 +16,46 @@ namespace psemek::wgpu wgpuQueueWriteBuffer((WGPUQueue)get(), (WGPUBuffer)buffer.get(), offset, data.data(), data.size()); } - void queue::write_texture(image_copy_texture const & dest, util::span data, texture::data_layout const & data_layout, math::vector const & write_size) + void queue::write_texture(texel_copy_texture_info const & dest, util::span data, texel_copy_buffer_layout const & data_layout, math::vector const & write_size) { - WGPUImageCopyTexture image_copy_texture = {}; - image_copy_texture.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(dest.chain); - image_copy_texture.texture = (WGPUTexture)dest.texture.get(); - image_copy_texture.mipLevel = dest.mip_level; - image_copy_texture.origin = {dest.origin[0], dest.origin[1], dest.origin[2]}; - image_copy_texture.aspect = (WGPUTextureAspect)dest.aspect; + WGPUTexelCopyTextureInfo texel_copy_texture_info = {}; + texel_copy_texture_info.texture = (WGPUTexture)dest.texture.get(); + texel_copy_texture_info.mipLevel = dest.mip_level; + texel_copy_texture_info.origin = {dest.origin[0], dest.origin[1], dest.origin[2]}; + texel_copy_texture_info.aspect = (WGPUTextureAspect)dest.aspect; - WGPUTextureDataLayout texture_data_layout = {}; - texture_data_layout.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(data_layout.chain); - texture_data_layout.offset = data_layout.offset; - texture_data_layout.bytesPerRow = data_layout.bytes_per_row; - texture_data_layout.rowsPerImage = data_layout.rows_per_image; + WGPUTexelCopyBufferLayout texel_copy_buffer_layout = {}; + texel_copy_buffer_layout.offset = data_layout.offset; + texel_copy_buffer_layout.bytesPerRow = data_layout.bytes_per_row; + texel_copy_buffer_layout.rowsPerImage = data_layout.rows_per_image; WGPUExtent3D extent = {write_size[0], write_size[1], write_size[2]}; - wgpuQueueWriteTexture((WGPUQueue)get(), &image_copy_texture, data.data(), data.size(), &texture_data_layout, &extent); + wgpuQueueWriteTexture((WGPUQueue)get(), &texel_copy_texture_info, data.data(), data.size(), &texel_copy_buffer_layout, &extent); } - void queue::on_submitted_work_done(work_done_callback const & callback) + void queue::on_submitted_work_done(callback_mode mode, work_done_callback const & callback) { - auto userdata = new work_done_callback(callback); - - auto real_callback = [](WGPUQueueWorkDoneStatus status, void * userdata) + WGPUQueueWorkDoneCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPUQueueWorkDoneStatus status, void * userdata, void *) { std::unique_ptr callback((work_done_callback*)userdata); if (*callback) (*callback)((work_done_status)status); }; + callback_info.userdata1 = new work_done_callback(callback); - wgpuQueueOnSubmittedWorkDone((WGPUQueue)get(), real_callback, userdata); + wgpuQueueOnSubmittedWorkDone((WGPUQueue)get(), callback_info); } void queue::set_label(std::string const & label) { - wgpuQueueSetLabel((WGPUQueue)get(), label.data()); + wgpuQueueSetLabel((WGPUQueue)get(), detail::to_string_view(label)); } void queue::reference(void * ptr) { - wgpuQueueReference((WGPUQueue)ptr); + wgpuQueueAddRef((WGPUQueue)ptr); } void queue::release(void * ptr) diff --git a/libs/wgpu/source/render_bundle.cpp b/libs/wgpu/source/render_bundle.cpp index 6aeed09b..72309274 100644 --- a/libs/wgpu/source/render_bundle.cpp +++ b/libs/wgpu/source/render_bundle.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -6,12 +7,12 @@ namespace psemek::wgpu void render_bundle::set_label(std::string const & label) { - wgpuRenderBundleSetLabel((WGPURenderBundle)get(), label.data()); + wgpuRenderBundleSetLabel((WGPURenderBundle)get(), detail::to_string_view(label)); } void render_bundle::reference(void * ptr) { - wgpuRenderBundleReference((WGPURenderBundle)ptr); + wgpuRenderBundleAddRef((WGPURenderBundle)ptr); } void render_bundle::release(void * ptr) diff --git a/libs/wgpu/source/render_bundle_encoder.cpp b/libs/wgpu/source/render_bundle_encoder.cpp index b0c2b275..83f4be86 100644 --- a/libs/wgpu/source/render_bundle_encoder.cpp +++ b/libs/wgpu/source/render_bundle_encoder.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -44,14 +45,14 @@ namespace psemek::wgpu wgpuRenderBundleEncoderDrawIndexedIndirect((WGPURenderBundleEncoder)get(), (WGPUBuffer)indirect_buffer.get(), offset); } - void render_bundle_encoder::insert_debug_marker(std::string const & marker_label) + void render_bundle_encoder::insert_debug_marker(std::string_view marker_label) { - wgpuRenderBundleEncoderInsertDebugMarker((WGPURenderBundleEncoder)get(), marker_label.data()); + wgpuRenderBundleEncoderInsertDebugMarker((WGPURenderBundleEncoder)get(), detail::to_string_view(marker_label)); } - void render_bundle_encoder::push_debug_group(std::string const & group_label) + void render_bundle_encoder::push_debug_group(std::string_view group_label) { - wgpuRenderBundleEncoderPushDebugGroup((WGPURenderBundleEncoder)get(), group_label.data()); + wgpuRenderBundleEncoderPushDebugGroup((WGPURenderBundleEncoder)get(), detail::to_string_view(group_label)); } void render_bundle_encoder::pop_debug_group() @@ -63,18 +64,18 @@ namespace psemek::wgpu { WGPURenderBundleDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); return render_bundle(wgpuRenderBundleEncoderFinish((WGPURenderBundleEncoder)get(), &descriptor)); } void render_bundle_encoder::set_label(std::string const & label) { - wgpuRenderBundleEncoderSetLabel((WGPURenderBundleEncoder)get(), label.data()); + wgpuRenderBundleEncoderSetLabel((WGPURenderBundleEncoder)get(), detail::to_string_view(label)); } void render_bundle_encoder::reference(void * ptr) { - wgpuRenderBundleEncoderReference((WGPURenderBundleEncoder)ptr); + wgpuRenderBundleEncoderAddRef((WGPURenderBundleEncoder)ptr); } void render_bundle_encoder::release(void * ptr) diff --git a/libs/wgpu/source/render_pass_encoder.cpp b/libs/wgpu/source/render_pass_encoder.cpp index 422f486e..5122bbe9 100644 --- a/libs/wgpu/source/render_pass_encoder.cpp +++ b/libs/wgpu/source/render_pass_encoder.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -48,7 +49,7 @@ namespace psemek::wgpu void render_pass_encoder::set_push_constants(shader_stage stages, std::uint32_t offset, util::span data) { - wgpuRenderPassEncoderSetPushConstants((WGPURenderPassEncoder)get(), (WGPUShaderStageFlags)stages, offset, data.size(), data.data()); + wgpuRenderPassEncoderSetPushConstants((WGPURenderPassEncoder)get(), (WGPUShaderStage)stages, offset, data.size(), data.data()); } void render_pass_encoder::draw(std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance) @@ -107,14 +108,19 @@ namespace psemek::wgpu wgpuRenderPassEncoderEndOcclusionQuery((WGPURenderPassEncoder)get()); } - void render_pass_encoder::insert_debug_marker(std::string const & marker_label) + void render_pass_encoder::write_timestamp(query_set const & query_set, std::uint32_t query_index) { - wgpuRenderPassEncoderInsertDebugMarker((WGPURenderPassEncoder)get(), marker_label.data()); + wgpuRenderPassEncoderWriteTimestamp((WGPURenderPassEncoder)get(), (WGPUQuerySet)query_set.get(), query_index); } - void render_pass_encoder::push_debug_group(std::string const & group_label) + void render_pass_encoder::insert_debug_marker(std::string_view marker_label) { - wgpuRenderPassEncoderPushDebugGroup((WGPURenderPassEncoder)get(), group_label.data()); + wgpuRenderPassEncoderInsertDebugMarker((WGPURenderPassEncoder)get(), detail::to_string_view(marker_label)); + } + + void render_pass_encoder::push_debug_group(std::string_view group_label) + { + wgpuRenderPassEncoderPushDebugGroup((WGPURenderPassEncoder)get(), detail::to_string_view(group_label)); } void render_pass_encoder::pop_debug_group() @@ -129,12 +135,12 @@ namespace psemek::wgpu void render_pass_encoder::set_label(std::string const & label) { - wgpuRenderPassEncoderSetLabel((WGPURenderPassEncoder)get(), label.data()); + wgpuRenderPassEncoderSetLabel((WGPURenderPassEncoder)get(), detail::to_string_view(label)); } void render_pass_encoder::reference(void * ptr) { - wgpuRenderPassEncoderReference((WGPURenderPassEncoder)ptr); + wgpuRenderPassEncoderAddRef((WGPURenderPassEncoder)ptr); } void render_pass_encoder::release(void * ptr) diff --git a/libs/wgpu/source/render_pipeline.cpp b/libs/wgpu/source/render_pipeline.cpp index d721c396..84749f43 100644 --- a/libs/wgpu/source/render_pipeline.cpp +++ b/libs/wgpu/source/render_pipeline.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -11,12 +12,12 @@ namespace psemek::wgpu void render_pipeline::set_label(std::string const & label) { - wgpuRenderPipelineSetLabel((WGPURenderPipeline)get(), label.data()); + wgpuRenderPipelineSetLabel((WGPURenderPipeline)get(), detail::to_string_view(label)); } void render_pipeline::reference(void * ptr) { - wgpuRenderPipelineReference((WGPURenderPipeline)ptr); + wgpuRenderPipelineAddRef((WGPURenderPipeline)ptr); } void render_pipeline::release(void * ptr) diff --git a/libs/wgpu/source/sampler.cpp b/libs/wgpu/source/sampler.cpp index f8fc0870..bde0d1f8 100644 --- a/libs/wgpu/source/sampler.cpp +++ b/libs/wgpu/source/sampler.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -6,12 +7,12 @@ namespace psemek::wgpu void sampler::set_label(std::string const & label) { - wgpuSamplerSetLabel((WGPUSampler)get(), label.data()); + wgpuSamplerSetLabel((WGPUSampler)get(), detail::to_string_view(label)); } void sampler::reference(void * ptr) { - wgpuSamplerReference((WGPUSampler)ptr); + wgpuSamplerAddRef((WGPUSampler)ptr); } void sampler::release(void * ptr) diff --git a/libs/wgpu/source/shader_module.cpp b/libs/wgpu/source/shader_module.cpp index f1d434aa..8dcceee1 100644 --- a/libs/wgpu/source/shader_module.cpp +++ b/libs/wgpu/source/shader_module.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -7,11 +8,11 @@ namespace psemek::wgpu { - void shader_module::get_compilation_info(compilation_info_callback const & callback) + void shader_module::get_compilation_info(callback_mode mode, compilation_info_callback const & callback) { - auto userdata = new compilation_info_callback(callback); - - auto real_callback = [](WGPUCompilationInfoRequestStatus status, WGPUCompilationInfo const * info, void * userdata) + WGPUCompilationInfoCallbackInfo callback_info = {}; + callback_info.mode = (WGPUCallbackMode)mode; + callback_info.callback = [](WGPUCompilationInfoRequestStatus status, WGPUCompilationInfo const * info, void * userdata, void *) { std::unique_ptr callback((compilation_info_callback *)userdata); @@ -24,32 +25,30 @@ namespace psemek::wgpu auto & message = cinfo.messages.emplace_back(); auto & message_in = info->messages[i]; - message.message = message_in.message; + message.message.assign(message_in.message.data, message_in.message.length); message.type = (compilation_message_type)message_in.type; message.line_num = message_in.lineNum; message.line_pos = message_in.linePos; message.offset = message_in.offset; message.length = message_in.length; - message.utf16_line_pos = message_in.utf16LinePos; - message.utf16_offset = message_in.utf16Offset; - message.utf16_length = message_in.utf16Length; } } if (*callback) (*callback)((compilation_info_request_status)status, cinfo); }; + callback_info.userdata1 = new compilation_info_callback(callback); - wgpuShaderModuleGetCompilationInfo((WGPUShaderModule)get(), real_callback, userdata); + wgpuShaderModuleGetCompilationInfo((WGPUShaderModule)get(), callback_info); } void shader_module::set_label(std::string const & label) { - wgpuShaderModuleSetLabel((WGPUShaderModule)get(), label.data()); + wgpuShaderModuleSetLabel((WGPUShaderModule)get(), detail::to_string_view(label)); } void shader_module::reference(void * ptr) { - wgpuShaderModuleReference((WGPUShaderModule)ptr); + wgpuShaderModuleAddRef((WGPUShaderModule)ptr); } void shader_module::release(void * ptr) @@ -59,8 +58,8 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(shader_module::spirv_descriptor const & value) { - WGPUShaderModuleSPIRVDescriptor chained = {}; - chained.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor; + WGPUShaderSourceSPIRV chained = {}; + chained.chain.sType = WGPUSType_ShaderSourceSPIRV; chained.codeSize = value.code.size(); // TODO: is it in bytes or in words? chained.code = value.code.data(); return detail::make_chained_struct(chained); @@ -68,22 +67,34 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(shader_module::wgsl_descriptor const & value) { - WGPUShaderModuleWGSLDescriptor chained = {}; - chained.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor; - chained.code = value.code; + WGPUShaderSourceWGSL chained = {}; + chained.chain.sType = WGPUSType_ShaderSourceWGSL; + chained.code = detail::to_string_view(value.code); return detail::make_chained_struct(chained); } detail::chained_struct_ptr to_chained_struct(shader_module::glsl_descriptor && value) { - WGPUShaderModuleGLSLDescriptor chained = {}; - chained.chain.sType = (WGPUSType)WGPUSType_ShaderModuleGLSLDescriptor; + struct chained_storage + { + std::vector defines; + }; + + chained_storage storage; + storage.defines.resize(value.defines.size()); + for (int i = 0; i < value.defines.size(); ++i) + { + storage.defines[i].name = detail::to_string_view(value.defines[i].name); + storage.defines[i].value = detail::to_string_view(value.defines[i].value); + } + + WGPUShaderSourceGLSL chained = {}; + chained.chain.sType = (WGPUSType)WGPUSType_ShaderSourceGLSL; chained.stage = (WGPUShaderStage)value.stage; - chained.code = value.code; - chained.defineCount = value.defines.size(); - static_assert(sizeof(WGPUShaderDefine) == sizeof(shader_module::define)); - chained.defines = (WGPUShaderDefine *)value.defines.data(); - return detail::make_chained_struct(chained, std::move(value)); + chained.code = detail::to_string_view(value.code); + chained.defineCount = storage.defines.size(); + chained.defines = storage.defines.data(); + return detail::make_chained_struct(chained, std::move(storage)); } } diff --git a/libs/wgpu/source/surface.cpp b/libs/wgpu/source/surface.cpp index 091d7a08..da24425c 100644 --- a/libs/wgpu/source/surface.cpp +++ b/libs/wgpu/source/surface.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include #include @@ -13,7 +15,7 @@ namespace psemek::wgpu config.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(conf.chain); config.device = (WGPUDevice)conf.device.get(); config.format = (WGPUTextureFormat)conf.format; - config.usage = (WGPUTextureUsageFlags)conf.usage; + config.usage = (WGPUTextureUsage)conf.usage; config.viewFormatCount = conf.view_formats.size(); config.viewFormats = (WGPUTextureFormat const *)conf.view_formats.data(); config.alphaMode = (WGPUCompositeAlphaMode)conf.alpha_mode; @@ -26,13 +28,17 @@ namespace psemek::wgpu surface::capabilities surface::get_capabilities(adapter const & adapter) { WGPUSurfaceCapabilities caps = {}; - wgpuSurfaceGetCapabilities((WGPUSurface)get(), (WGPUAdapter)adapter.get(), &caps); + detail::check_status("wgpuSurfaceGetCapabilities", wgpuSurfaceGetCapabilities((WGPUSurface)get(), (WGPUAdapter)adapter.get(), &caps)); capabilities result; // TODO: support out chain + result.usage = (texture::usage)caps.usages; result.formats.assign((wgpu::texture::format *)(caps.formats), (wgpu::texture::format *)(caps.formats) + caps.formatCount); result.present_modes.assign((present_mode *)(caps.presentModes), (present_mode *)(caps.presentModes) + caps.presentModeCount); result.alpha_modes.assign((composite_alpha_mode *)(caps.alphaModes), (composite_alpha_mode *)(caps.alphaModes) + caps.alphaModeCount); + + wgpuSurfaceCapabilitiesFreeMembers(caps); + return result; } @@ -43,19 +49,13 @@ namespace psemek::wgpu return { .texture = wgpu::texture(tex.texture), - .suboptimal = tex.suboptimal, .status = (enum current_texture::status)tex.status, }; } - wgpu::texture::format surface::get_preferred_format(adapter const & adapter) - { - return (wgpu::texture::format)wgpuSurfaceGetPreferredFormat((WGPUSurface)get(), (WGPUAdapter)adapter.get()); - } - void surface::present() { - wgpuSurfacePresent((WGPUSurface)get()); + detail::check_status("wgpuSurfacePresent", wgpuSurfacePresent((WGPUSurface)get())); } void surface::unconfigure() @@ -65,7 +65,7 @@ namespace psemek::wgpu void surface::reference(void * ptr) { - wgpuSurfaceReference((WGPUSurface)ptr); + wgpuSurfaceAddRef((WGPUSurface)ptr); } void surface::release(void * ptr) @@ -83,32 +83,24 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(surface::from_android_native_window const & value) { - WGPUSurfaceDescriptorFromAndroidNativeWindow chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromAndroidNativeWindow; + WGPUSurfaceSourceAndroidNativeWindow chained = {}; + chained.chain.sType = WGPUSType_SurfaceSourceAndroidNativeWindow; chained.window = value.window; return detail::make_chained_struct(chained); } - detail::chained_struct_ptr to_chained_struct(surface::from_canvas_html_selected const & value) - { - WGPUSurfaceDescriptorFromCanvasHTMLSelector chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector; - chained.selector = value.selector.data(); - return detail::make_chained_struct(chained); - } - detail::chained_struct_ptr to_chained_struct(surface::from_metal_layer const & value) { - WGPUSurfaceDescriptorFromMetalLayer chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromMetalLayer; + WGPUSurfaceSourceMetalLayer chained = {}; + chained.chain.sType = WGPUSType_SurfaceSourceMetalLayer; chained.layer = value.layer; return detail::make_chained_struct(chained); } detail::chained_struct_ptr to_chained_struct(surface::from_wayland_surface const & value) { - WGPUSurfaceDescriptorFromWaylandSurface chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromWaylandSurface; + WGPUSurfaceSourceWaylandSurface chained = {}; + chained.chain.sType = WGPUSType_SurfaceSourceWaylandSurface; chained.display = value.display; chained.surface = value.surface; return detail::make_chained_struct(chained); @@ -116,8 +108,8 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(surface::from_windows_hwnd const & value) { - WGPUSurfaceDescriptorFromWindowsHWND chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromWindowsHWND; + WGPUSurfaceSourceWindowsHWND chained = {}; + chained.chain.sType = WGPUSType_SurfaceSourceWindowsHWND; chained.hinstance = value.hinstance; chained.hwnd = value.hwnd; return detail::make_chained_struct(chained); @@ -125,8 +117,8 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(surface::from_xcb_window const & value) { - WGPUSurfaceDescriptorFromXcbWindow chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromXcbWindow; + WGPUSurfaceSourceXCBWindow chained = {}; + chained.chain.sType = WGPUSType_SurfaceSourceXCBWindow; chained.connection = value.connection; chained.window = value.window; return detail::make_chained_struct(chained); @@ -134,8 +126,8 @@ namespace psemek::wgpu detail::chained_struct_ptr to_chained_struct(surface::from_xlib_window const & value) { - WGPUSurfaceDescriptorFromXlibWindow chained = {}; - chained.chain.sType = WGPUSType_SurfaceDescriptorFromXlibWindow; + WGPUSurfaceSourceXlibWindow chained = {}; + chained.chain.sType = WGPUSType_SurfaceSourceXlibWindow; chained.display = value.display; chained.window = value.window; return detail::make_chained_struct(chained); diff --git a/libs/wgpu/source/texture.cpp b/libs/wgpu/source/texture.cpp index ed8b08d1..6186fa56 100644 --- a/libs/wgpu/source/texture.cpp +++ b/libs/wgpu/source/texture.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -8,7 +9,7 @@ namespace psemek::wgpu { WGPUTextureViewDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); - descriptor.label = desc.label.data(); + descriptor.label = detail::to_string_view(desc.label); descriptor.format = (WGPUTextureFormat)desc.format; descriptor.dimension = (WGPUTextureViewDimension)desc.dimension; descriptor.baseMipLevel = desc.base_mip_level; @@ -62,12 +63,12 @@ namespace psemek::wgpu void texture::set_label(std::string const & label) { - wgpuTextureSetLabel((WGPUTexture)get(), label.data()); + wgpuTextureSetLabel((WGPUTexture)get(), detail::to_string_view(label)); } void texture::reference(void * ptr) { - wgpuTextureReference((WGPUTexture)ptr); + wgpuTextureAddRef((WGPUTexture)ptr); } void texture::release(void * ptr) diff --git a/libs/wgpu/source/texture_view.cpp b/libs/wgpu/source/texture_view.cpp index 60ebc094..7d12fc8d 100644 --- a/libs/wgpu/source/texture_view.cpp +++ b/libs/wgpu/source/texture_view.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace psemek::wgpu @@ -6,12 +7,12 @@ namespace psemek::wgpu void texture_view::set_label(std::string const & label) { - wgpuTextureViewSetLabel((WGPUTextureView)get(), label.data()); + wgpuTextureViewSetLabel((WGPUTextureView)get(), detail::to_string_view(label)); } void texture_view::reference(void * ptr) { - wgpuTextureViewReference((WGPUTextureView)ptr); + wgpuTextureViewAddRef((WGPUTextureView)ptr); } void texture_view::release(void * ptr)