commit 532e8c189727ef1ab01650f2b91530b4db05adce Author: adrien Date: Tue Apr 28 10:22:22 2026 +0200 Basic working matrix addition diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8c8979 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.zig-cache +zig-out diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..54033bd --- /dev/null +++ b/build.zig @@ -0,0 +1,56 @@ +// build.zig +// zig build run +// +// Expects wgpu-native pre-built in libs/wgpu-native/: +// include/wgpu.h +// lib/libwgpu_native.a (or .so / .dylib / .dll) +// +// Download release: https://github.com/gfx-rs/wgpu-native/releases +// Pick the archive matching your OS/arch, e.g.: +// wgpu-linux-x86_64-release.zip → libwgpu_native.a + wgpu.h +// wgpu-macos-aarch64-release.zip +// wgpu-windows-x86_64-msvc-release.zip + +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const exe = b.addExecutable(.{ + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .link_libc = true, + .target = target, + .optimize = optimize, + }), + .name = "gpu_matrix_add", + }); + + // wgpu-native headers + pre-built static library + exe.root_module.addIncludePath(b.path("libs/wgpu-native/include")); + exe.root_module.addLibraryPath(b.path("libs/wgpu-native/lib")); + exe.root_module.addObjectFile(b.path("libs/wgpu-native/lib/libwgpu_native.a")); + + // Platform-specific system frameworks needed by wgpu-native + const t = target.result; + if (t.os.tag == .macos) { + exe.root_module.linkFramework("Metal", .{}); + exe.root_module.linkFramework("QuartzCore", .{}); + exe.root_module.linkFramework("Foundation", .{}); + exe.root_module.linkFramework("CoreGraphics", .{}); + } else if (t.os.tag == .windows) { + exe.root_module.linkSystemLibrary("d3d12", .{}); + exe.root_module.linkSystemLibrary("dxgi", .{}); + exe.root_module.linkSystemLibrary("user32", .{}); + } else { + exe.root_module.linkSystemLibrary("vulkan", .{}); + exe.root_module.linkSystemLibrary("gcc_s", .{}); + } + + b.installArtifact(exe); + + const run = b.addRunArtifact(exe); + run.step.dependOn(b.getInstallStep()); + b.step("run", "Build and run").dependOn(&run.step); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..14a8524 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,81 @@ +.{ + // This is the default name used by packages depending on this one. For + // example, when a user runs `zig fetch --save `, this field is used + // as the key in the `dependencies` table. Although the user can choose a + // different name, most users will stick with this provided value. + // + // It is redundant to include "zig" in this name because it is already + // within the Zig package namespace. + .name = .zig_wgpu, + // This is a [Semantic Version](https://semver.org/). + // In a future version of Zig it will be used for package deduplication. + .version = "0.0.0", + // Together with name, this represents a globally unique package + // identifier. This field is generated by the Zig toolchain when the + // package is first created, and then *never changes*. This allows + // unambiguous detection of one package being an updated version of + // another. + // + // When forking a Zig project, this id should be regenerated (delete the + // field and run `zig build`) if the upstream project is still maintained. + // Otherwise, the fork is *hostile*, attempting to take control over the + // original project's identity. Thus it is recommended to leave the comment + // on the following line intact, so that it shows up in code reviews that + // modify the field. + .fingerprint = 0x5d0e853acbc0c2c6, // Changing this has security and trust implications. + // Tracks the earliest Zig version that the package considers to be a + // supported use case. + .minimum_zig_version = "0.16.0", + // This field is optional. + // Each dependency must either provide a `url` and `hash`, or a `path`. + // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. + // Once all dependencies are fetched, `zig build` no longer requires + // internet connectivity. + .dependencies = .{ + // See `zig fetch --save ` for a command-line interface for adding dependencies. + //.example = .{ + // // When updating this field to a new URL, be sure to delete the corresponding + // // `hash`, otherwise you are communicating that you expect to find the old hash at + // // the new URL. If the contents of a URL change this will result in a hash mismatch + // // which will prevent zig from using it. + // .url = "https://example.com/foo.tar.gz", + // + // // This is computed from the file contents of the directory of files that is + // // obtained after fetching `url` and applying the inclusion rules given by + // // `paths`. + // // + // // This field is the source of truth; packages do not come from a `url`; they + // // come from a `hash`. `url` is just one of many possible mirrors for how to + // // obtain a package matching this `hash`. + // // + // // Uses the [multihash](https://multiformats.io/multihash/) format. + // .hash = "...", + // + // // When this is provided, the package is found in a directory relative to the + // // build root. In this case the package's hash is irrelevant and therefore not + // // computed. This field and `url` are mutually exclusive. + // .path = "foo", + // + // // When this is set to `true`, a package is declared to be lazily + // // fetched. This makes the dependency only get fetched if it is + // // actually used. + // .lazy = false, + //}, + }, + // Specifies the set of files and directories that are included in this package. + // Only files and directories listed here are included in the `hash` that + // is computed for this package. Only files listed here will remain on disk + // when using the zig package manager. As a rule of thumb, one should list + // files required for compilation plus any license(s). + // Paths are relative to the build root. Use the empty string (`""`) to refer to + // the build root itself. + // A directory listed here means that all files within, recursively, are included. + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + // For example... + //"LICENSE", + //"README.md", + }, +} diff --git a/libs/wgpu-native/include/webgpu.h b/libs/wgpu-native/include/webgpu.h new file mode 100644 index 0000000..4223519 --- /dev/null +++ b/libs/wgpu-native/include/webgpu.h @@ -0,0 +1,6747 @@ +/** + * 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. + * + * For all details where behavior is not otherwise specified, `webgpu.h` has + * the same behavior as the WebGPU specification for JavaScript on the Web. + * The WebIDL-based Web specification is mapped into C as faithfully (and + * bidirectionally) as practical/possible. + * The working draft of WebGPU can be found at . + * + * The standard include directive for this header is `#include ` + * (if it is provided in a system-wide or toolchain-wide include directory). + */ + +#ifndef WEBGPU_H_ +#define WEBGPU_H_ + +#if defined(WGPU_SHARED_LIBRARY) +# if defined(_WIN32) +# if defined(WGPU_IMPLEMENTATION) +# define WGPU_EXPORT __declspec(dllexport) +# else +# define WGPU_EXPORT __declspec(dllimport) +# endif +# else // defined(_WIN32) +# if defined(WGPU_IMPLEMENTATION) +# define WGPU_EXPORT __attribute__((visibility("default"))) +# else +# define WGPU_EXPORT +# endif +# endif // defined(_WIN32) +#else // defined(WGPU_SHARED_LIBRARY) +# define WGPU_EXPORT +#endif // defined(WGPU_SHARED_LIBRARY) + +#if !defined(WGPU_OBJECT_ATTRIBUTE) +#define WGPU_OBJECT_ATTRIBUTE +#endif +#if !defined(WGPU_ENUM_ATTRIBUTE) +#define WGPU_ENUM_ATTRIBUTE +#endif +#if !defined(WGPU_STRUCTURE_ATTRIBUTE) +#define WGPU_STRUCTURE_ATTRIBUTE +#endif +#if !defined(WGPU_FUNCTION_ATTRIBUTE) +#define WGPU_FUNCTION_ATTRIBUTE +#endif +#if !defined(WGPU_NULLABLE) +#define WGPU_NULLABLE +#endif + +#include +#include +#include + +#define _wgpu_COMMA , +#if defined(__cplusplus) +# define _wgpu_ENUM_ZERO_INIT(type) type(0) +# define _wgpu_STRUCT_ZERO_INIT {} +# if __cplusplus >= 201103L +# define _wgpu_MAKE_INIT_STRUCT(type, value) (type value) +# else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +# endif +#else +# define _wgpu_ENUM_ZERO_INIT(type) (type)0 +# define _wgpu_STRUCT_ZERO_INIT {0} +# if 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 +#endif + +/** + * \defgroup Constants Constants + * \brief Constants. + * + * @{ + */ + +/** + * 'True' value of @ref WGPUBool. + * + * @remark It's not usually necessary to use this, as `true` (from + * `stdbool.h` or C++) casts to the same value. + */ +#define WGPU_TRUE (UINT32_C(1)) +/** + * 'False' value of @ref WGPUBool. + * + * @remark It's not usually necessary to use this, as `false` (from + * `stdbool.h` or C++) casts to the same value. + */ +#define WGPU_FALSE (UINT32_C(0)) +/** + * Indicates no array layer count is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX) +/** + * Indicates no copy stride is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX) +/** + * Indicates no depth clear value is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_DEPTH_CLEAR_VALUE_UNDEFINED (NAN) +/** + * Indicates no depth slice is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) +/** + * For `uint32_t` limits, indicates no limit value is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) +/** + * For `uint64_t` limits, indicates no limit value is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX) +/** + * Indicates no mip level count is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX) +/** + * Indicates no query set index is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX) +/** + * 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) +/** + * Indicates a size extending to the end of the buffer. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) +/** + * Indicates a size extending to the end of the buffer. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_WHOLE_SIZE (UINT64_MAX) + +/** @} */ + +/** + * \defgroup UtilityTypes Utility Types + * + * @{ + */ + +/** + * 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 { + WGPU_NULLABLE char const * data; + size_t length; +} WGPUStringView WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUStringView. + */ +#define WGPU_STRING_VIEW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStringView, { \ + /*.data=*/NULL _wgpu_COMMA \ + /*.length=*/WGPU_STRLEN _wgpu_COMMA \ +}) + +typedef uint64_t WGPUFlags; +typedef uint32_t WGPUBool; + +/** @} */ + +/** + * \defgroup Objects 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; +typedef struct WGPUBufferImpl* WGPUBuffer WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUCommandBufferImpl* WGPUCommandBuffer WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUCommandEncoderImpl* WGPUCommandEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUComputePassEncoderImpl* WGPUComputePassEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUComputePipelineImpl* WGPUComputePipeline WGPU_OBJECT_ATTRIBUTE; +/** + * TODO + * + * Releasing the last ref to a `WGPUDevice` also calls @ref wgpuDeviceDestroy. + * For more info, see @ref DeviceRelease. + */ +typedef struct WGPUDeviceImpl* WGPUDevice WGPU_OBJECT_ATTRIBUTE; +/** + * A sampleable 2D texture that may perform 0-copy YUV sampling internally. Creation of @ref WGPUExternalTexture is extremely implementation-dependent and not defined in this header. + */ +typedef struct WGPUExternalTextureImpl* WGPUExternalTexture WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUInstanceImpl* WGPUInstance WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUQuerySetImpl* WGPUQuerySet WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUQueueImpl* WGPUQueue WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderBundleImpl* WGPURenderBundle WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder WGPU_OBJECT_ATTRIBUTE; +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 WGPUAdapterInfo; +struct WGPUBlendComponent; +struct WGPUBufferBindingLayout; +struct WGPUBufferDescriptor; +struct WGPUColor; +struct WGPUCommandBufferDescriptor; +struct WGPUCommandEncoderDescriptor; +struct WGPUCompatibilityModeLimits; +struct WGPUCompilationMessage; +struct WGPUConstantEntry; +struct WGPUExtent3D; +struct WGPUExternalTextureBindingEntry; +struct WGPUExternalTextureBindingLayout; +struct WGPUFuture; +struct WGPUInstanceLimits; +struct WGPUMultisampleState; +struct WGPUOrigin3D; +struct WGPUPassTimestampWrites; +struct WGPUPipelineLayoutDescriptor; +struct WGPUPrimitiveState; +struct WGPUQuerySetDescriptor; +struct WGPUQueueDescriptor; +struct WGPURenderBundleDescriptor; +struct WGPURenderBundleEncoderDescriptor; +struct WGPURenderPassDepthStencilAttachment; +struct WGPURenderPassMaxDrawCount; +struct WGPURequestAdapterWebXROptions; +struct WGPUSamplerBindingLayout; +struct WGPUSamplerDescriptor; +struct WGPUShaderSourceSPIRV; +struct WGPUShaderSourceWGSL; +struct WGPUStencilFaceState; +struct WGPUStorageTextureBindingLayout; +struct WGPUSupportedFeatures; +struct WGPUSupportedInstanceFeatures; +struct WGPUSupportedWGSLLanguageFeatures; +struct WGPUSurfaceCapabilities; +struct WGPUSurfaceColorManagement; +struct WGPUSurfaceConfiguration; +struct WGPUSurfaceSourceAndroidNativeWindow; +struct WGPUSurfaceSourceMetalLayer; +struct WGPUSurfaceSourceWaylandSurface; +struct WGPUSurfaceSourceWindowsHWND; +struct WGPUSurfaceSourceXCBWindow; +struct WGPUSurfaceSourceXlibWindow; +struct WGPUSurfaceTexture; +struct WGPUTexelCopyBufferLayout; +struct WGPUTextureBindingLayout; +struct WGPUTextureBindingViewDimension; +struct WGPUTextureComponentSwizzle; +struct WGPUVertexAttribute; +struct WGPUBindGroupEntry; +struct WGPUBindGroupLayoutEntry; +struct WGPUBlendState; +struct WGPUCompilationInfo; +struct WGPUComputePassDescriptor; +struct WGPUComputeState; +struct WGPUDepthStencilState; +struct WGPUFutureWaitInfo; +struct WGPUInstanceDescriptor; +struct WGPULimits; +struct WGPURenderPassColorAttachment; +struct WGPURequestAdapterOptions; +struct WGPUShaderModuleDescriptor; +struct WGPUSurfaceDescriptor; +struct WGPUTexelCopyBufferInfo; +struct WGPUTexelCopyTextureInfo; +struct WGPUTextureComponentSwizzleDescriptor; +struct WGPUTextureDescriptor; +struct WGPUVertexBufferLayout; +struct WGPUBindGroupDescriptor; +struct WGPUBindGroupLayoutDescriptor; +struct WGPUColorTargetState; +struct WGPUComputePipelineDescriptor; +struct WGPUDeviceDescriptor; +struct WGPURenderPassDescriptor; +struct WGPUTextureViewDescriptor; +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 Enumerations + * \brief Enums. + * + * @{ + */ + +typedef enum WGPUAdapterType { + WGPUAdapterType_DiscreteGPU = 0x00000001, + WGPUAdapterType_IntegratedGPU = 0x00000002, + WGPUAdapterType_CPU = 0x00000003, + WGPUAdapterType_Unknown = 0x00000004, + WGPUAdapterType_Force32 = 0x7FFFFFFF +} WGPUAdapterType WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUAddressMode { + /** + * `0`. 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBackendType_Undefined = 0x00000000, + WGPUBackendType_Null = 0x00000001, + WGPUBackendType_WebGPU = 0x00000002, + WGPUBackendType_D3D11 = 0x00000003, + WGPUBackendType_D3D12 = 0x00000004, + WGPUBackendType_Metal = 0x00000005, + WGPUBackendType_Vulkan = 0x00000006, + WGPUBackendType_OpenGL = 0x00000007, + WGPUBackendType_OpenGLES = 0x00000008, + WGPUBackendType_Force32 = 0x7FFFFFFF +} WGPUBackendType WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUBlendFactor { + /** + * `0`. 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 { + /** + * `0`. 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 { + /** + * `0`. Indicates that this @ref WGPUBufferBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUBufferBindingType_BindingNotUsed = 0x00000000, + /** + * `1`. 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 WGPUBufferMapState { + 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 { + /** + * Callbacks created with `WGPUCallbackMode_WaitAnyOnly`: + * - fire when the asynchronous operation's future is passed to a call to @ref wgpuInstanceWaitAny + * AND the operation has already completed or it completes inside the call to @ref wgpuInstanceWaitAny. + */ + WGPUCallbackMode_WaitAnyOnly = 0x00000001, + /** + * Callbacks created with `WGPUCallbackMode_AllowProcessEvents`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_WaitAnyOnly` + * - fire inside a call to @ref wgpuInstanceProcessEvents if the asynchronous operation is complete. + */ + WGPUCallbackMode_AllowProcessEvents = 0x00000002, + /** + * 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUCompareFunction_Undefined = 0x00000000, + WGPUCompareFunction_Never = 0x00000001, + WGPUCompareFunction_Less = 0x00000002, + 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 = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPUCompilationInfoRequestStatus_CallbackCancelled = 0x00000002, + WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF +} WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUCompilationMessageType { + WGPUCompilationMessageType_Error = 0x00000001, + WGPUCompilationMessageType_Warning = 0x00000002, + WGPUCompilationMessageType_Info = 0x00000003, + WGPUCompilationMessageType_Force32 = 0x7FFFFFFF +} WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUComponentSwizzle { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUComponentSwizzle_Undefined = 0x00000000, + /** + * Force its value to 0. + */ + WGPUComponentSwizzle_Zero = 0x00000001, + /** + * Force its value to 1. + */ + WGPUComponentSwizzle_One = 0x00000002, + /** + * Take its value from the red channel of the texture. + */ + WGPUComponentSwizzle_R = 0x00000003, + /** + * Take its value from the green channel of the texture. + */ + WGPUComponentSwizzle_G = 0x00000004, + /** + * Take its value from the blue channel of the texture. + */ + WGPUComponentSwizzle_B = 0x00000005, + /** + * Take its value from the alpha channel of the texture. + */ + WGPUComponentSwizzle_A = 0x00000006, + WGPUComponentSwizzle_Force32 = 0x7FFFFFFF +} WGPUComponentSwizzle WGPU_ENUM_ATTRIBUTE; + +/** + * Describes how frames are composited with other contents on the screen when @ref wgpuSurfacePresent is called. + */ +typedef enum WGPUCompositeAlphaMode { + /** + * `0`. 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, + /** + * The alpha component of the image is ignored and teated as if it is always 1.0. + */ + WGPUCompositeAlphaMode_Opaque = 0x00000001, + /** + * 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, + /** + * 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, + /** + * 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 = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPUCreatePipelineAsyncStatus_CallbackCancelled = 0x00000002, + WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000003, + WGPUCreatePipelineAsyncStatus_InternalError = 0x00000004, + WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUCullMode { + /** + * `0`. 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_Unknown = 0x00000001, + WGPUDeviceLostReason_Destroyed = 0x00000002, + /** + * See @ref CallbackStatuses. + */ + WGPUDeviceLostReason_CallbackCancelled = 0x00000003, + WGPUDeviceLostReason_FailedCreation = 0x00000004, + WGPUDeviceLostReason_Force32 = 0x7FFFFFFF +} WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUErrorFilter { + WGPUErrorFilter_Validation = 0x00000001, + WGPUErrorFilter_OutOfMemory = 0x00000002, + WGPUErrorFilter_Internal = 0x00000003, + WGPUErrorFilter_Force32 = 0x7FFFFFFF +} WGPUErrorFilter WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUErrorType { + 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFeatureLevel_Undefined = 0x00000000, + /** + * "Compatibility" profile which can be supported on OpenGL ES 3.1 and D3D11. + */ + WGPUFeatureLevel_Compatibility = 0x00000001, + /** + * "Core" profile which can be supported on Vulkan/Metal/D3D12 (at least). + */ + WGPUFeatureLevel_Core = 0x00000002, + WGPUFeatureLevel_Force32 = 0x7FFFFFFF +} WGPUFeatureLevel WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUFeatureName { + WGPUFeatureName_CoreFeaturesAndLimits = 0x00000001, + WGPUFeatureName_DepthClipControl = 0x00000002, + WGPUFeatureName_Depth32FloatStencil8 = 0x00000003, + WGPUFeatureName_TextureCompressionBC = 0x00000004, + WGPUFeatureName_TextureCompressionBCSliced3D = 0x00000005, + WGPUFeatureName_TextureCompressionETC2 = 0x00000006, + WGPUFeatureName_TextureCompressionASTC = 0x00000007, + WGPUFeatureName_TextureCompressionASTCSliced3D = 0x00000008, + WGPUFeatureName_TimestampQuery = 0x00000009, + WGPUFeatureName_IndirectFirstInstance = 0x0000000A, + WGPUFeatureName_ShaderF16 = 0x0000000B, + WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000C, + WGPUFeatureName_BGRA8UnormStorage = 0x0000000D, + WGPUFeatureName_Float32Filterable = 0x0000000E, + WGPUFeatureName_Float32Blendable = 0x0000000F, + WGPUFeatureName_ClipDistances = 0x00000010, + WGPUFeatureName_DualSourceBlending = 0x00000011, + WGPUFeatureName_Subgroups = 0x00000012, + WGPUFeatureName_TextureFormatsTier1 = 0x00000013, + WGPUFeatureName_TextureFormatsTier2 = 0x00000014, + WGPUFeatureName_PrimitiveIndex = 0x00000015, + WGPUFeatureName_TextureComponentSwizzle = 0x00000016, + WGPUFeatureName_Force32 = 0x7FFFFFFF +} WGPUFeatureName WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUFilterMode { + /** + * `0`. 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 { + /** + * `0`. 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUIndexFormat_Undefined = 0x00000000, + WGPUIndexFormat_Uint16 = 0x00000001, + WGPUIndexFormat_Uint32 = 0x00000002, + WGPUIndexFormat_Force32 = 0x7FFFFFFF +} WGPUIndexFormat WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUInstanceFeatureName { + /** + * Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + WGPUInstanceFeatureName_TimedWaitAny = 0x00000001, + /** + * Enable passing SPIR-V shaders to @ref wgpuDeviceCreateShaderModule, + * via @ref WGPUShaderSourceSPIRV. + */ + WGPUInstanceFeatureName_ShaderSourceSPIRV = 0x00000002, + /** + * Normally, a @ref WGPUAdapter can only create a single device. If this is + * available and enabled, then adapters won't immediately expire when they + * create a device, so can be reused to make multiple devices. They may + * still expire for other reasons. + */ + WGPUInstanceFeatureName_MultipleDevicesPerAdapter = 0x00000003, + WGPUInstanceFeatureName_Force32 = 0x7FFFFFFF +} WGPUInstanceFeatureName WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPULoadOp { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPULoadOp_Undefined = 0x00000000, + WGPULoadOp_Load = 0x00000001, + WGPULoadOp_Clear = 0x00000002, + WGPULoadOp_Force32 = 0x7FFFFFFF +} WGPULoadOp WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUMapAsyncStatus { + WGPUMapAsyncStatus_Success = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPUMapAsyncStatus_CallbackCancelled = 0x00000002, + WGPUMapAsyncStatus_Error = 0x00000003, + WGPUMapAsyncStatus_Aborted = 0x00000004, + WGPUMapAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUMapAsyncStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUMipmapFilterMode { + /** + * `0`. 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 { + /** + * `0`. + */ + WGPUOptionalBool_False = 0x00000000, + WGPUOptionalBool_True = 0x00000001, + WGPUOptionalBool_Undefined = 0x00000002, + WGPUOptionalBool_Force32 = 0x7FFFFFFF +} WGPUOptionalBool WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUPopErrorScopeStatus { + /** + * The error scope stack was successfully popped and a result was reported. + */ + WGPUPopErrorScopeStatus_Success = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPUPopErrorScopeStatus_CallbackCancelled = 0x00000002, + /** + * The error scope stack could not be popped, because it was empty. + */ + WGPUPopErrorScopeStatus_Error = 0x00000003, + WGPUPopErrorScopeStatus_Force32 = 0x7FFFFFFF +} WGPUPopErrorScopeStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUPowerPreference { + /** + * `0`. No preference. (See also @ref SentinelValues.) + */ + WGPUPowerPreference_Undefined = 0x00000000, + WGPUPowerPreference_LowPower = 0x00000001, + WGPUPowerPreference_HighPerformance = 0x00000002, + WGPUPowerPreference_Force32 = 0x7FFFFFFF +} WGPUPowerPreference WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUPredefinedColorSpace { + WGPUPredefinedColorSpace_SRGB = 0x00000001, + WGPUPredefinedColorSpace_DisplayP3 = 0x00000002, + WGPUPredefinedColorSpace_Force32 = 0x7FFFFFFF +} WGPUPredefinedColorSpace WGPU_ENUM_ATTRIBUTE; + +/** + * Describes when and in which order frames are presented on the screen when @ref wgpuSurfacePresent is called. + */ +typedef enum WGPUPresentMode { + /** + * `0`. Present mode is not specified. Use the default. + */ + WGPUPresentMode_Undefined = 0x00000000, + /** + * 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, + /** + * 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, + /** + * 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, + /** + * 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 { + /** + * `0`. 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 = 0x00000001, + WGPUQueryType_Timestamp = 0x00000002, + WGPUQueryType_Force32 = 0x7FFFFFFF +} WGPUQueryType WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUQueueWorkDoneStatus { + WGPUQueueWorkDoneStatus_Success = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPUQueueWorkDoneStatus_CallbackCancelled = 0x00000002, + /** + * There was some deterministic error. (Note this is currently never used, + * but it will be relevant when it's possible to create a queue object.) + */ + WGPUQueueWorkDoneStatus_Error = 0x00000003, + WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF +} WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPURequestAdapterStatus { + WGPURequestAdapterStatus_Success = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPURequestAdapterStatus_CallbackCancelled = 0x00000002, + WGPURequestAdapterStatus_Unavailable = 0x00000003, + WGPURequestAdapterStatus_Error = 0x00000004, + WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF +} WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPURequestDeviceStatus { + WGPURequestDeviceStatus_Success = 0x00000001, + /** + * See @ref CallbackStatuses. + */ + WGPURequestDeviceStatus_CallbackCancelled = 0x00000002, + WGPURequestDeviceStatus_Error = 0x00000003, + WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF +} WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUSamplerBindingType { + /** + * `0`. Indicates that this @ref WGPUSamplerBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUSamplerBindingType_BindingNotUsed = 0x00000000, + /** + * `1`. 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 { + /** + * `0`. 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 { + /** + * `0`. Indicates that this @ref WGPUStorageTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUStorageTextureAccess_BindingNotUsed = 0x00000000, + /** + * `1`. 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 { + /** + * `0`. 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; + +typedef enum WGPUSType { + 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_SurfaceColorManagement = 0x0000000A, + WGPUSType_RequestAdapterWebXROptions = 0x0000000B, + WGPUSType_TextureComponentSwizzleDescriptor = 0x0000000C, + WGPUSType_ExternalTextureBindingLayout = 0x0000000D, + WGPUSType_ExternalTextureBindingEntry = 0x0000000E, + WGPUSType_CompatibilityModeLimits = 0x0000000F, + WGPUSType_TextureBindingViewDimension = 0x00000010, + WGPUSType_Force32 = 0x7FFFFFFF +} WGPUSType WGPU_ENUM_ATTRIBUTE; + +/** + * The status enum for @ref wgpuSurfaceGetCurrentTexture. + */ +typedef enum WGPUSurfaceGetCurrentTextureStatus { + /** + * Yay! Everything is good and we can render this frame. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal = 0x00000001, + /** + * Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal = 0x00000002, + /** + * Some operation timed out while trying to acquire the frame. + */ + WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000003, + /** + * The surface is too different to be used, compared to when it was originally created. + */ + WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000004, + /** + * The connection to whatever owns the surface was lost, or generally needs to be fully reinitialized. + */ + WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000005, + /** + * There was some deterministic error (for example, the surface is not configured, or there was an @ref OutStructChainError). Should produce @ref ImplementationDefinedLogging containing details. + */ + WGPUSurfaceGetCurrentTextureStatus_Error = 0x00000006, + WGPUSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF +} WGPUSurfaceGetCurrentTextureStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUTextureAspect { + /** + * `0`. 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 { + /** + * `0`. 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureFormat_Undefined = 0x00000000, + WGPUTextureFormat_R8Unorm = 0x00000001, + WGPUTextureFormat_R8Snorm = 0x00000002, + WGPUTextureFormat_R8Uint = 0x00000003, + WGPUTextureFormat_R8Sint = 0x00000004, + WGPUTextureFormat_R16Unorm = 0x00000005, + WGPUTextureFormat_R16Snorm = 0x00000006, + WGPUTextureFormat_R16Uint = 0x00000007, + WGPUTextureFormat_R16Sint = 0x00000008, + WGPUTextureFormat_R16Float = 0x00000009, + WGPUTextureFormat_RG8Unorm = 0x0000000A, + WGPUTextureFormat_RG8Snorm = 0x0000000B, + WGPUTextureFormat_RG8Uint = 0x0000000C, + WGPUTextureFormat_RG8Sint = 0x0000000D, + WGPUTextureFormat_R32Float = 0x0000000E, + WGPUTextureFormat_R32Uint = 0x0000000F, + WGPUTextureFormat_R32Sint = 0x00000010, + WGPUTextureFormat_RG16Unorm = 0x00000011, + WGPUTextureFormat_RG16Snorm = 0x00000012, + WGPUTextureFormat_RG16Uint = 0x00000013, + WGPUTextureFormat_RG16Sint = 0x00000014, + WGPUTextureFormat_RG16Float = 0x00000015, + WGPUTextureFormat_RGBA8Unorm = 0x00000016, + WGPUTextureFormat_RGBA8UnormSrgb = 0x00000017, + WGPUTextureFormat_RGBA8Snorm = 0x00000018, + WGPUTextureFormat_RGBA8Uint = 0x00000019, + WGPUTextureFormat_RGBA8Sint = 0x0000001A, + WGPUTextureFormat_BGRA8Unorm = 0x0000001B, + WGPUTextureFormat_BGRA8UnormSrgb = 0x0000001C, + WGPUTextureFormat_RGB10A2Uint = 0x0000001D, + WGPUTextureFormat_RGB10A2Unorm = 0x0000001E, + WGPUTextureFormat_RG11B10Ufloat = 0x0000001F, + WGPUTextureFormat_RGB9E5Ufloat = 0x00000020, + WGPUTextureFormat_RG32Float = 0x00000021, + WGPUTextureFormat_RG32Uint = 0x00000022, + WGPUTextureFormat_RG32Sint = 0x00000023, + WGPUTextureFormat_RGBA16Unorm = 0x00000024, + WGPUTextureFormat_RGBA16Snorm = 0x00000025, + WGPUTextureFormat_RGBA16Uint = 0x00000026, + WGPUTextureFormat_RGBA16Sint = 0x00000027, + WGPUTextureFormat_RGBA16Float = 0x00000028, + WGPUTextureFormat_RGBA32Float = 0x00000029, + WGPUTextureFormat_RGBA32Uint = 0x0000002A, + WGPUTextureFormat_RGBA32Sint = 0x0000002B, + WGPUTextureFormat_Stencil8 = 0x0000002C, + WGPUTextureFormat_Depth16Unorm = 0x0000002D, + WGPUTextureFormat_Depth24Plus = 0x0000002E, + WGPUTextureFormat_Depth24PlusStencil8 = 0x0000002F, + WGPUTextureFormat_Depth32Float = 0x00000030, + WGPUTextureFormat_Depth32FloatStencil8 = 0x00000031, + WGPUTextureFormat_BC1RGBAUnorm = 0x00000032, + WGPUTextureFormat_BC1RGBAUnormSrgb = 0x00000033, + WGPUTextureFormat_BC2RGBAUnorm = 0x00000034, + WGPUTextureFormat_BC2RGBAUnormSrgb = 0x00000035, + WGPUTextureFormat_BC3RGBAUnorm = 0x00000036, + WGPUTextureFormat_BC3RGBAUnormSrgb = 0x00000037, + WGPUTextureFormat_BC4RUnorm = 0x00000038, + WGPUTextureFormat_BC4RSnorm = 0x00000039, + WGPUTextureFormat_BC5RGUnorm = 0x0000003A, + WGPUTextureFormat_BC5RGSnorm = 0x0000003B, + WGPUTextureFormat_BC6HRGBUfloat = 0x0000003C, + WGPUTextureFormat_BC6HRGBFloat = 0x0000003D, + WGPUTextureFormat_BC7RGBAUnorm = 0x0000003E, + WGPUTextureFormat_BC7RGBAUnormSrgb = 0x0000003F, + WGPUTextureFormat_ETC2RGB8Unorm = 0x00000040, + WGPUTextureFormat_ETC2RGB8UnormSrgb = 0x00000041, + WGPUTextureFormat_ETC2RGB8A1Unorm = 0x00000042, + WGPUTextureFormat_ETC2RGB8A1UnormSrgb = 0x00000043, + WGPUTextureFormat_ETC2RGBA8Unorm = 0x00000044, + WGPUTextureFormat_ETC2RGBA8UnormSrgb = 0x00000045, + WGPUTextureFormat_EACR11Unorm = 0x00000046, + WGPUTextureFormat_EACR11Snorm = 0x00000047, + WGPUTextureFormat_EACRG11Unorm = 0x00000048, + WGPUTextureFormat_EACRG11Snorm = 0x00000049, + WGPUTextureFormat_ASTC4x4Unorm = 0x0000004A, + WGPUTextureFormat_ASTC4x4UnormSrgb = 0x0000004B, + WGPUTextureFormat_ASTC5x4Unorm = 0x0000004C, + WGPUTextureFormat_ASTC5x4UnormSrgb = 0x0000004D, + WGPUTextureFormat_ASTC5x5Unorm = 0x0000004E, + WGPUTextureFormat_ASTC5x5UnormSrgb = 0x0000004F, + WGPUTextureFormat_ASTC6x5Unorm = 0x00000050, + WGPUTextureFormat_ASTC6x5UnormSrgb = 0x00000051, + WGPUTextureFormat_ASTC6x6Unorm = 0x00000052, + WGPUTextureFormat_ASTC6x6UnormSrgb = 0x00000053, + WGPUTextureFormat_ASTC8x5Unorm = 0x00000054, + WGPUTextureFormat_ASTC8x5UnormSrgb = 0x00000055, + WGPUTextureFormat_ASTC8x6Unorm = 0x00000056, + WGPUTextureFormat_ASTC8x6UnormSrgb = 0x00000057, + WGPUTextureFormat_ASTC8x8Unorm = 0x00000058, + WGPUTextureFormat_ASTC8x8UnormSrgb = 0x00000059, + WGPUTextureFormat_ASTC10x5Unorm = 0x0000005A, + WGPUTextureFormat_ASTC10x5UnormSrgb = 0x0000005B, + WGPUTextureFormat_ASTC10x6Unorm = 0x0000005C, + WGPUTextureFormat_ASTC10x6UnormSrgb = 0x0000005D, + WGPUTextureFormat_ASTC10x8Unorm = 0x0000005E, + WGPUTextureFormat_ASTC10x8UnormSrgb = 0x0000005F, + WGPUTextureFormat_ASTC10x10Unorm = 0x00000060, + WGPUTextureFormat_ASTC10x10UnormSrgb = 0x00000061, + WGPUTextureFormat_ASTC12x10Unorm = 0x00000062, + WGPUTextureFormat_ASTC12x10UnormSrgb = 0x00000063, + WGPUTextureFormat_ASTC12x12Unorm = 0x00000064, + WGPUTextureFormat_ASTC12x12UnormSrgb = 0x00000065, + WGPUTextureFormat_Force32 = 0x7FFFFFFF +} WGPUTextureFormat WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUTextureSampleType { + /** + * `0`. Indicates that this @ref WGPUTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUTextureSampleType_BindingNotUsed = 0x00000000, + /** + * `1`. 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureViewDimension_Undefined = 0x00000000, + WGPUTextureViewDimension_1D = 0x00000001, + WGPUTextureViewDimension_2D = 0x00000002, + WGPUTextureViewDimension_2DArray = 0x00000003, + WGPUTextureViewDimension_Cube = 0x00000004, + WGPUTextureViewDimension_CubeArray = 0x00000005, + WGPUTextureViewDimension_3D = 0x00000006, + WGPUTextureViewDimension_Force32 = 0x7FFFFFFF +} WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUToneMappingMode { + WGPUToneMappingMode_Standard = 0x00000001, + WGPUToneMappingMode_Extended = 0x00000002, + WGPUToneMappingMode_Force32 = 0x7FFFFFFF +} WGPUToneMappingMode WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUVertexFormat { + 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 { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUVertexStepMode_Undefined = 0x00000000, + WGPUVertexStepMode_Vertex = 0x00000001, + WGPUVertexStepMode_Instance = 0x00000002, + WGPUVertexStepMode_Force32 = 0x7FFFFFFF +} WGPUVertexStepMode WGPU_ENUM_ATTRIBUTE; + +/** + * Status returned from a call to ::wgpuInstanceWaitAny. + */ +typedef enum WGPUWaitStatus { + /** + * At least one WGPUFuture completed successfully. + */ + WGPUWaitStatus_Success = 0x00000001, + /** + * The wait operation succeeded, but no WGPUFutures completed within the timeout. + */ + WGPUWaitStatus_TimedOut = 0x00000002, + /** + * The call was invalid for some reason (see @ref Wait-Any). + * Should produce @ref ImplementationDefinedLogging containing details. + */ + WGPUWaitStatus_Error = 0x00000003, + WGPUWaitStatus_Force32 = 0x7FFFFFFF +} WGPUWaitStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUWGSLLanguageFeatureName { + WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, + WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct = 0x00000002, + WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters = 0x00000003, + WGPUWGSLLanguageFeatureName_PointerCompositeAccess = 0x00000004, + WGPUWGSLLanguageFeatureName_UniformBufferStandardLayout = 0x00000005, + WGPUWGSLLanguageFeatureName_SubgroupId = 0x00000006, + WGPUWGSLLanguageFeatureName_TextureAndSamplerLet = 0x00000007, + WGPUWGSLLanguageFeatureName_SubgroupUniformity = 0x00000008, + WGPUWGSLLanguageFeatureName_TextureFormatsTier1 = 0x00000009, + WGPUWGSLLanguageFeatureName_Force32 = 0x7FFFFFFF +} WGPUWGSLLanguageFeatureName WGPU_ENUM_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup Bitflags Bitflags + * \brief Type and constant definitions for bitflag types. + * + * @{ + */ + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +typedef WGPUFlags WGPUBufferUsage; +/** + * `0`. + */ +static const WGPUBufferUsage WGPUBufferUsage_None = 0x0000000000000000; +/** + * The buffer can be *mapped* on the CPU side in *read* mode (using @ref WGPUMapMode_Read). + */ +static const WGPUBufferUsage WGPUBufferUsage_MapRead = 0x0000000000000001; +/** + * The buffer can be *mapped* on the CPU side in *write* mode (using @ref WGPUMapMode_Write). + * + * @note This usage is **not** required to set `mappedAtCreation` to `true` in @ref WGPUBufferDescriptor. + */ +static const WGPUBufferUsage WGPUBufferUsage_MapWrite = 0x0000000000000002; +/** + * The buffer can be used as the *source* of a GPU-side copy operation. + */ +static const WGPUBufferUsage WGPUBufferUsage_CopySrc = 0x0000000000000004; +/** + * The buffer can be used as the *destination* of a GPU-side copy operation. + */ +static const WGPUBufferUsage WGPUBufferUsage_CopyDst = 0x0000000000000008; +/** + * The buffer can be used as an Index buffer when doing indexed drawing in a render pipeline. + */ +static const WGPUBufferUsage WGPUBufferUsage_Index = 0x0000000000000010; +/** + * The buffer can be used as a Vertex buffer when using a render pipeline. + */ +static const WGPUBufferUsage WGPUBufferUsage_Vertex = 0x0000000000000020; +/** + * The buffer can be bound to a shader as a uniform buffer. + */ +static const WGPUBufferUsage WGPUBufferUsage_Uniform = 0x0000000000000040; +/** + * The buffer can be bound to a shader as a storage buffer. + */ +static const WGPUBufferUsage WGPUBufferUsage_Storage = 0x0000000000000080; +/** + * The buffer can store arguments for an indirect draw call. + */ +static const WGPUBufferUsage WGPUBufferUsage_Indirect = 0x0000000000000100; +/** + * The buffer can store the result of a timestamp or occlusion query. + */ +static const WGPUBufferUsage WGPUBufferUsage_QueryResolve = 0x0000000000000200; + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +typedef WGPUFlags WGPUColorWriteMask; +/** + * `0`. + */ +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; +/** + * `Red | Green | Blue | Alpha`. + */ +static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F; + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +typedef WGPUFlags WGPUMapMode; +/** + * `0`. + */ +static const WGPUMapMode WGPUMapMode_None = 0x0000000000000000; +static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001; +static const WGPUMapMode WGPUMapMode_Write = 0x0000000000000002; + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +typedef WGPUFlags WGPUShaderStage; +/** + * `0`. + */ +static const WGPUShaderStage WGPUShaderStage_None = 0x0000000000000000; +static const WGPUShaderStage WGPUShaderStage_Vertex = 0x0000000000000001; +static const WGPUShaderStage WGPUShaderStage_Fragment = 0x0000000000000002; +static const WGPUShaderStage WGPUShaderStage_Compute = 0x0000000000000004; + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +typedef WGPUFlags WGPUTextureUsage; +/** + * `0`. + */ +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; +static const WGPUTextureUsage WGPUTextureUsage_TransientAttachment = 0x0000000000000020; + +/** @} */ + +typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; + +/** + * \defgroup Callbacks Callbacks + * \brief Callbacks through which asynchronous functions return. + * + * @{ + */ + +/** + * See also @ref CallbackError. + * + * @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; + +/** + * See also @ref CallbackError. + * + * @param compilationInfo + * This argument contains multiple @ref ImplementationAllocatedStructChain roots. + * Arbitrary chains must be handled gracefully by the application! + * 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; + +/** + * See also @ref CallbackError. + * + * @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; + +/** + * See also @ref CallbackError. + * + * @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; + +/** + * See also @ref CallbackError. + * + * @param device + * Pointer to the device which was lost. This is always a non-null pointer. + * The pointed-to @ref WGPUDevice will be null if, and only if, either: + * (1) The `reason` is @ref WGPUDeviceLostReason_FailedCreation. + * (2) The last ref of the device has been (or is being) released: see @ref DeviceRelease. + * This parameter is @ref PassedWithoutOwnership. + * + * @param reason + * An error code explaining why the device was lost. + * + * @param message + * A @ref LocalizableHumanReadableMessageString describing why the device was lost. + * 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; + +/** + * See also @ref CallbackError. + * + * @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 `status` is not @ref WGPUPopErrorScopeStatus_Success **or** + * 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; + +/** + * See also @ref CallbackError. + * + * @param status + * See @ref WGPUQueueWorkDoneStatus. + * + * @param message + * If the `status` is not @ref WGPUQueueWorkDoneStatus_Success, + * this is a non-empty @ref LocalizableHumanReadableMessageString; + * otherwise, this is an empty string. + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** + * See also @ref CallbackError. + * + * @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; + +/** + * See also @ref CallbackError. + * + * @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; + +/** + * See also @ref CallbackError. + * + * @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 * next; + WGPUSType sType; +} WGPUChainedStruct WGPU_STRUCTURE_ATTRIBUTE; + +/** @} */ + + +/** + * \defgroup Structures Structures + * \brief Descriptors and other transparent structures. + * + * @{ + */ + +/** + * \defgroup CallbackInfoStructs Callback Info Structs + * \brief Callback info structures that are used in asynchronous functions. + * + * @{ + */ + +typedef struct WGPUBufferMapCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUBufferMapCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUBufferMapCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBufferMapCallbackInfo. + */ +#define WGPU_BUFFER_MAP_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBufferMapCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUCompilationInfoCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUCompilationInfoCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCompilationInfoCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCompilationInfoCallbackInfo. + */ +#define WGPU_COMPILATION_INFO_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompilationInfoCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUCreateComputePipelineAsyncCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUCreateComputePipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateComputePipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCreateComputePipelineAsyncCallbackInfo. + */ +#define WGPU_CREATE_COMPUTE_PIPELINE_ASYNC_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCreateComputePipelineAsyncCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUCreateRenderPipelineAsyncCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUCreateRenderPipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateRenderPipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCreateRenderPipelineAsyncCallbackInfo. + */ +#define WGPU_CREATE_RENDER_PIPELINE_ASYNC_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCreateRenderPipelineAsyncCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUDeviceLostCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUDeviceLostCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUDeviceLostCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUDeviceLostCallbackInfo. + */ +#define WGPU_DEVICE_LOST_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUDeviceLostCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUPopErrorScopeCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUPopErrorScopeCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUPopErrorScopeCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUPopErrorScopeCallbackInfo. + */ +#define WGPU_POP_ERROR_SCOPE_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPopErrorScopeCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUQueueWorkDoneCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPUQueueWorkDoneCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUQueueWorkDoneCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUQueueWorkDoneCallbackInfo. + */ +#define WGPU_QUEUE_WORK_DONE_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUQueueWorkDoneCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPURequestAdapterCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPURequestAdapterCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestAdapterCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURequestAdapterCallbackInfo. + */ +#define WGPU_REQUEST_ADAPTER_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestAdapterCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPURequestDeviceCallbackInfo { + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + WGPUCallbackMode mode; + WGPURequestDeviceCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestDeviceCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURequestDeviceCallbackInfo. + */ +#define WGPU_REQUEST_DEVICE_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestDeviceCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +typedef struct WGPUUncapturedErrorCallbackInfo { + WGPUChainedStruct * nextInChain; + WGPUUncapturedErrorCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUUncapturedErrorCallbackInfo. + */ +#define WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUUncapturedErrorCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + +/** @} */ + +/** + * Default values can be set using @ref WGPU_ADAPTER_INFO_INIT as initializer. + */ +typedef struct WGPUAdapterInfo { + WGPUChainedStruct * nextInChain; + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView vendor; + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView architecture; + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView device; + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView description; + /** + * The `INIT` macro sets this to @ref WGPUBackendType_Undefined. + */ + WGPUBackendType backendType; + /** + * The `INIT` macro sets this to (@ref WGPUAdapterType)0. + */ + WGPUAdapterType adapterType; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t vendorID; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t deviceID; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t subgroupMinSize; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t subgroupMaxSize; +} WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUAdapterInfo. + */ +#define WGPU_ADAPTER_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUAdapterInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.vendor=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.architecture=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.device=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.description=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.backendType=*/WGPUBackendType_Undefined _wgpu_COMMA \ + /*.adapterType=*/_wgpu_ENUM_ZERO_INIT(WGPUAdapterType) _wgpu_COMMA \ + /*.vendorID=*/0 _wgpu_COMMA \ + /*.deviceID=*/0 _wgpu_COMMA \ + /*.subgroupMinSize=*/0 _wgpu_COMMA \ + /*.subgroupMaxSize=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BLEND_COMPONENT_INIT as initializer. + */ +typedef struct WGPUBlendComponent { + /** + * If set to @ref WGPUBlendOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendOperation_Add. + * + * The `INIT` macro sets this to @ref WGPUBlendOperation_Undefined. + */ + WGPUBlendOperation operation; + /** + * If set to @ref WGPUBlendFactor_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_One. + * + * The `INIT` macro sets this to @ref WGPUBlendFactor_Undefined. + */ + WGPUBlendFactor srcFactor; + /** + * If set to @ref WGPUBlendFactor_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_Zero. + * + * The `INIT` macro sets this to @ref WGPUBlendFactor_Undefined. + */ + WGPUBlendFactor dstFactor; +} WGPUBlendComponent WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBlendComponent. + */ +#define WGPU_BLEND_COMPONENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBlendComponent, { \ + /*.operation=*/WGPUBlendOperation_Undefined _wgpu_COMMA \ + /*.srcFactor=*/WGPUBlendFactor_Undefined _wgpu_COMMA \ + /*.dstFactor=*/WGPUBlendFactor_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BUFFER_BINDING_LAYOUT_INIT as initializer. + */ +typedef struct WGPUBufferBindingLayout { + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUBufferBindingType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBufferBindingType_Uniform. + * + * The `INIT` macro sets this to @ref WGPUBufferBindingType_Undefined. + */ + WGPUBufferBindingType type; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool hasDynamicOffset; + /** + * The `INIT` macro sets this to `0`. + */ + uint64_t minBindingSize; +} WGPUBufferBindingLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBufferBindingLayout. + */ +#define WGPU_BUFFER_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBufferBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.type=*/WGPUBufferBindingType_Undefined _wgpu_COMMA \ + /*.hasDynamicOffset=*/WGPU_FALSE _wgpu_COMMA \ + /*.minBindingSize=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BUFFER_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUBufferDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to @ref WGPUBufferUsage_None. + */ + WGPUBufferUsage usage; + /** + * The `INIT` macro sets this to `0`. + */ + uint64_t size; + /** + * When true, the buffer is mapped in write mode at creation. It should thus be unmapped once its initial data has been written. + * + * @note Mapping at creation does **not** require the usage @ref WGPUBufferUsage_MapWrite. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool mappedAtCreation; +} WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBufferDescriptor. + */ +#define WGPU_BUFFER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBufferDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.usage=*/WGPUBufferUsage_None _wgpu_COMMA \ + /*.size=*/0 _wgpu_COMMA \ + /*.mappedAtCreation=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * An RGBA color. Represents a `f32`, `i32`, or `u32` color using @ref DoubleAsSupertype. + * + * If any channel is non-finite, produces a @ref NonFiniteFloatValueError. + * + * Default values can be set using @ref WGPU_COLOR_INIT as initializer. + */ +typedef struct WGPUColor { + /** + * The `INIT` macro sets this to `0.`. + */ + double r; + /** + * The `INIT` macro sets this to `0.`. + */ + double g; + /** + * The `INIT` macro sets this to `0.`. + */ + double b; + /** + * The `INIT` macro sets this to `0.`. + */ + double a; +} WGPUColor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUColor. + */ +#define WGPU_COLOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUColor, { \ + /*.r=*/0. _wgpu_COMMA \ + /*.g=*/0. _wgpu_COMMA \ + /*.b=*/0. _wgpu_COMMA \ + /*.a=*/0. _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMMAND_BUFFER_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUCommandBufferDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUCommandBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCommandBufferDescriptor. + */ +#define WGPU_COMMAND_BUFFER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCommandBufferDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMMAND_ENCODER_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUCommandEncoderDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUCommandEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCommandEncoderDescriptor. + */ +#define WGPU_COMMAND_ENCODER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCommandEncoderDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Note: While Compatibility Mode is optional to implement, this extension struct + * is required to be supported (for both queries and requests) and behave as + * defined in the WebGPU spec. + * + * Default values can be set using @ref WGPU_COMPATIBILITY_MODE_LIMITS_INIT as initializer. + */ +typedef struct WGPUCompatibilityModeLimits { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageBuffersInVertexStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageTexturesInVertexStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageBuffersInFragmentStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageTexturesInFragmentStage; +} WGPUCompatibilityModeLimits WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCompatibilityModeLimits. + */ +#define WGPU_COMPATIBILITY_MODE_LIMITS_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompatibilityModeLimits, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_CompatibilityModeLimits _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.maxStorageBuffersInVertexStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageTexturesInVertexStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageBuffersInFragmentStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageTexturesInFragmentStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ +}) + +/** + * This is an @ref ImplementationAllocatedStructChain root. + * Arbitrary chains must be handled gracefully by the application! + * + * Default values can be set using @ref WGPU_COMPILATION_MESSAGE_INIT as initializer. + */ +typedef struct WGPUCompilationMessage { + WGPUChainedStruct * nextInChain; + /** + * A @ref LocalizableHumanReadableMessageString. + * + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView message; + /** + * Severity level of the message. + * + * The `INIT` macro sets this to (@ref WGPUCompilationMessageType)0. + */ + WGPUCompilationMessageType type; + /** + * Line number where the message is attached, starting at 1. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t lineNum; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t linePos; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t offset; + /** + * Length in UTF-8 code units (bytes) of the span the message corresponds to. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t length; +} WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCompilationMessage. + */ +#define WGPU_COMPILATION_MESSAGE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompilationMessage, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.message=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.type=*/_wgpu_ENUM_ZERO_INIT(WGPUCompilationMessageType) _wgpu_COMMA \ + /*.lineNum=*/0 _wgpu_COMMA \ + /*.linePos=*/0 _wgpu_COMMA \ + /*.offset=*/0 _wgpu_COMMA \ + /*.length=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_CONSTANT_ENTRY_INIT as initializer. + */ +typedef struct WGPUConstantEntry { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView key; + /** + * Represents a WGSL numeric or boolean value using @ref DoubleAsSupertype. + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.`. + */ + double value; +} WGPUConstantEntry WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUConstantEntry. + */ +#define WGPU_CONSTANT_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUConstantEntry, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.key=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.value=*/0. _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_EXTENT_3D_INIT as initializer. + */ +typedef struct WGPUExtent3D { + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t width; + /** + * The `INIT` macro sets this to `1`. + */ + uint32_t height; + /** + * The `INIT` macro sets this to `1`. + */ + uint32_t depthOrArrayLayers; +} WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUExtent3D. + */ +#define WGPU_EXTENT_3D_INIT _wgpu_MAKE_INIT_STRUCT(WGPUExtent3D, { \ + /*.width=*/0 _wgpu_COMMA \ + /*.height=*/1 _wgpu_COMMA \ + /*.depthOrArrayLayers=*/1 _wgpu_COMMA \ +}) + +/** + * Chained in an @ref WGPUBindGroupEntry to set it to an @ref WGPUExternalTexture. This must have a corresponding @ref WGPUExternalTextureBindingLayout in the @ref WGPUBindGroupLayout. + * + * Default values can be set using @ref WGPU_EXTERNAL_TEXTURE_BINDING_ENTRY_INIT as initializer. + */ +typedef struct WGPUExternalTextureBindingEntry { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUExternalTexture externalTexture; +} WGPUExternalTextureBindingEntry WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUExternalTextureBindingEntry. + */ +#define WGPU_EXTERNAL_TEXTURE_BINDING_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUExternalTextureBindingEntry, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ExternalTextureBindingEntry _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.externalTexture=*/NULL _wgpu_COMMA \ +}) + +/** + * Chained in @ref WGPUBindGroupLayoutEntry to specify that the corresponding entries in an @ref WGPUBindGroup will contain an @ref WGPUExternalTexture. + * + * Default values can be set using @ref WGPU_EXTERNAL_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ +typedef struct WGPUExternalTextureBindingLayout { + WGPUChainedStruct chain; +} WGPUExternalTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUExternalTextureBindingLayout. + */ +#define WGPU_EXTERNAL_TEXTURE_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUExternalTextureBindingLayout, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ExternalTextureBindingLayout _wgpu_COMMA \ + }) _wgpu_COMMA \ +}) + +/** + * Opaque handle to an asynchronous operation. See @ref Asynchronous-Operations for more information. + * + * Default values can be set using @ref WGPU_FUTURE_INIT as initializer. + */ +typedef struct WGPUFuture { + /** + * Opaque id of the @ref WGPUFuture + * + * The `INIT` macro sets this to `0`. + */ + uint64_t id; +} WGPUFuture WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUFuture. + */ +#define WGPU_FUTURE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUFuture, { \ + /*.id=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_INSTANCE_LIMITS_INIT as initializer. + */ +typedef struct WGPUInstanceLimits { + WGPUChainedStruct * nextInChain; + /** + * The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + * + * The `INIT` macro sets this to `0`. + */ + size_t timedWaitAnyMaxCount; +} WGPUInstanceLimits WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUInstanceLimits. + */ +#define WGPU_INSTANCE_LIMITS_INIT _wgpu_MAKE_INIT_STRUCT(WGPUInstanceLimits, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.timedWaitAnyMaxCount=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_MULTISAMPLE_STATE_INIT as initializer. + */ +typedef struct WGPUMultisampleState { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `1`. + */ + uint32_t count; + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ + uint32_t mask; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool alphaToCoverageEnabled; +} WGPUMultisampleState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUMultisampleState. + */ +#define WGPU_MULTISAMPLE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUMultisampleState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.count=*/1 _wgpu_COMMA \ + /*.mask=*/0xFFFFFFFF _wgpu_COMMA \ + /*.alphaToCoverageEnabled=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_ORIGIN_3D_INIT as initializer. + */ +typedef struct WGPUOrigin3D { + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t x; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t y; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t z; +} WGPUOrigin3D WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUOrigin3D. + */ +#define WGPU_ORIGIN_3D_INIT _wgpu_MAKE_INIT_STRUCT(WGPUOrigin3D, { \ + /*.x=*/0 _wgpu_COMMA \ + /*.y=*/0 _wgpu_COMMA \ + /*.z=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_PASS_TIMESTAMP_WRITES_INIT as initializer. + */ +typedef struct WGPUPassTimestampWrites { + WGPUChainedStruct * nextInChain; + /** + * Query set to write timestamps to. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUQuerySet querySet; + /** + * The `INIT` macro sets this to @ref WGPU_QUERY_SET_INDEX_UNDEFINED. + */ + uint32_t beginningOfPassWriteIndex; + /** + * The `INIT` macro sets this to @ref WGPU_QUERY_SET_INDEX_UNDEFINED. + */ + uint32_t endOfPassWriteIndex; +} WGPUPassTimestampWrites WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUPassTimestampWrites. + */ +#define WGPU_PASS_TIMESTAMP_WRITES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPassTimestampWrites, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.querySet=*/NULL _wgpu_COMMA \ + /*.beginningOfPassWriteIndex=*/WGPU_QUERY_SET_INDEX_UNDEFINED _wgpu_COMMA \ + /*.endOfPassWriteIndex=*/WGPU_QUERY_SET_INDEX_UNDEFINED _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_PIPELINE_LAYOUT_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUPipelineLayoutDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `bindGroupLayouts`. The `INIT` macro sets this to 0. + */ + size_t bindGroupLayoutCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBindGroupLayout const * bindGroupLayouts; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t immediateSize; +} WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUPipelineLayoutDescriptor. + */ +#define WGPU_PIPELINE_LAYOUT_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPipelineLayoutDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.bindGroupLayoutCount=*/0 _wgpu_COMMA \ + /*.bindGroupLayouts=*/NULL _wgpu_COMMA \ + /*.immediateSize=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_PRIMITIVE_STATE_INIT as initializer. + */ +typedef struct WGPUPrimitiveState { + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUPrimitiveTopology_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUPrimitiveTopology_TriangleList. + * + * The `INIT` macro sets this to @ref WGPUPrimitiveTopology_Undefined. + */ + WGPUPrimitiveTopology topology; + /** + * The `INIT` macro sets this to @ref WGPUIndexFormat_Undefined. + */ + WGPUIndexFormat stripIndexFormat; + /** + * If set to @ref WGPUFrontFace_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFrontFace_CCW. + * + * The `INIT` macro sets this to @ref WGPUFrontFace_Undefined. + */ + WGPUFrontFace frontFace; + /** + * If set to @ref WGPUCullMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUCullMode_None. + * + * The `INIT` macro sets this to @ref WGPUCullMode_Undefined. + */ + WGPUCullMode cullMode; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool unclippedDepth; +} WGPUPrimitiveState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUPrimitiveState. + */ +#define WGPU_PRIMITIVE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPrimitiveState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.topology=*/WGPUPrimitiveTopology_Undefined _wgpu_COMMA \ + /*.stripIndexFormat=*/WGPUIndexFormat_Undefined _wgpu_COMMA \ + /*.frontFace=*/WGPUFrontFace_Undefined _wgpu_COMMA \ + /*.cullMode=*/WGPUCullMode_Undefined _wgpu_COMMA \ + /*.unclippedDepth=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_QUERY_SET_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUQuerySetDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to (@ref WGPUQueryType)0. + */ + WGPUQueryType type; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t count; +} WGPUQuerySetDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUQuerySetDescriptor. + */ +#define WGPU_QUERY_SET_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUQuerySetDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.type=*/_wgpu_ENUM_ZERO_INIT(WGPUQueryType) _wgpu_COMMA \ + /*.count=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_QUEUE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUQueueDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUQueueDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUQueueDescriptor. + */ +#define WGPU_QUEUE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUQueueDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_BUNDLE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPURenderBundleDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPURenderBundleDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderBundleDescriptor. + */ +#define WGPU_RENDER_BUNDLE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderBundleDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_BUNDLE_ENCODER_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPURenderBundleEncoderDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `colorFormats`. The `INIT` macro sets this to 0. + */ + size_t colorFormatCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUTextureFormat const * colorFormats; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat depthStencilFormat; + /** + * The `INIT` macro sets this to `1`. + */ + uint32_t sampleCount; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool depthReadOnly; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool stencilReadOnly; +} WGPURenderBundleEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderBundleEncoderDescriptor. + */ +#define WGPU_RENDER_BUNDLE_ENCODER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderBundleEncoderDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.colorFormatCount=*/0 _wgpu_COMMA \ + /*.colorFormats=*/NULL _wgpu_COMMA \ + /*.depthStencilFormat=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.sampleCount=*/1 _wgpu_COMMA \ + /*.depthReadOnly=*/WGPU_FALSE _wgpu_COMMA \ + /*.stencilReadOnly=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_DEPTH_STENCIL_ATTACHMENT_INIT as initializer. + */ +typedef struct WGPURenderPassDepthStencilAttachment { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUTextureView view; + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ + WGPULoadOp depthLoadOp; + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ + WGPUStoreOp depthStoreOp; + /** + * This is a @ref NullableFloatingPointType. + * + * If `NaN`, indicates an `undefined` value (as defined by the JS spec). + * Use @ref WGPU_DEPTH_CLEAR_VALUE_UNDEFINED to indicate this semantically. + * + * If infinite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to @ref WGPU_DEPTH_CLEAR_VALUE_UNDEFINED. + */ + float depthClearValue; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool depthReadOnly; + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ + WGPULoadOp stencilLoadOp; + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ + WGPUStoreOp stencilStoreOp; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t stencilClearValue; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool stencilReadOnly; +} WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderPassDepthStencilAttachment. + */ +#define WGPU_RENDER_PASS_DEPTH_STENCIL_ATTACHMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassDepthStencilAttachment, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.view=*/NULL _wgpu_COMMA \ + /*.depthLoadOp=*/WGPULoadOp_Undefined _wgpu_COMMA \ + /*.depthStoreOp=*/WGPUStoreOp_Undefined _wgpu_COMMA \ + /*.depthClearValue=*/WGPU_DEPTH_CLEAR_VALUE_UNDEFINED _wgpu_COMMA \ + /*.depthReadOnly=*/WGPU_FALSE _wgpu_COMMA \ + /*.stencilLoadOp=*/WGPULoadOp_Undefined _wgpu_COMMA \ + /*.stencilStoreOp=*/WGPUStoreOp_Undefined _wgpu_COMMA \ + /*.stencilClearValue=*/0 _wgpu_COMMA \ + /*.stencilReadOnly=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_MAX_DRAW_COUNT_INIT as initializer. + */ +typedef struct WGPURenderPassMaxDrawCount { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to `50000000`. + */ + uint64_t maxDrawCount; +} WGPURenderPassMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderPassMaxDrawCount. + */ +#define WGPU_RENDER_PASS_MAX_DRAW_COUNT_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassMaxDrawCount, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_RenderPassMaxDrawCount _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.maxDrawCount=*/50000000 _wgpu_COMMA \ +}) + +/** + * Extension providing requestAdapter options for implementations with WebXR interop (i.e. Wasm). + * + * Default values can be set using @ref WGPU_REQUEST_ADAPTER_WEBXR_OPTIONS_INIT as initializer. + */ +typedef struct WGPURequestAdapterWebXROptions { + WGPUChainedStruct chain; + /** + * Sets the `xrCompatible` option in the JS API. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool xrCompatible; +} WGPURequestAdapterWebXROptions WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURequestAdapterWebXROptions. + */ +#define WGPU_REQUEST_ADAPTER_WEBXR_OPTIONS_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestAdapterWebXROptions, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_RequestAdapterWebXROptions _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.xrCompatible=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SAMPLER_BINDING_LAYOUT_INIT as initializer. + */ +typedef struct WGPUSamplerBindingLayout { + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUSamplerBindingType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUSamplerBindingType_Filtering. + * + * The `INIT` macro sets this to @ref WGPUSamplerBindingType_Undefined. + */ + WGPUSamplerBindingType type; +} WGPUSamplerBindingLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSamplerBindingLayout. + */ +#define WGPU_SAMPLER_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSamplerBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.type=*/WGPUSamplerBindingType_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SAMPLER_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUSamplerDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ + WGPUAddressMode addressModeU; + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ + WGPUAddressMode addressModeV; + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ + WGPUAddressMode addressModeW; + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUFilterMode_Undefined. + */ + WGPUFilterMode magFilter; + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUFilterMode_Undefined. + */ + WGPUFilterMode minFilter; + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUMipmapFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUMipmapFilterMode_Undefined. + */ + WGPUMipmapFilterMode mipmapFilter; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ + float lodMinClamp; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `32.f`. + */ + float lodMaxClamp; + /** + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ + WGPUCompareFunction compare; + /** + * The `INIT` macro sets this to `1`. + */ + uint16_t maxAnisotropy; +} WGPUSamplerDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSamplerDescriptor. + */ +#define WGPU_SAMPLER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSamplerDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.addressModeU=*/WGPUAddressMode_Undefined _wgpu_COMMA \ + /*.addressModeV=*/WGPUAddressMode_Undefined _wgpu_COMMA \ + /*.addressModeW=*/WGPUAddressMode_Undefined _wgpu_COMMA \ + /*.magFilter=*/WGPUFilterMode_Undefined _wgpu_COMMA \ + /*.minFilter=*/WGPUFilterMode_Undefined _wgpu_COMMA \ + /*.mipmapFilter=*/WGPUMipmapFilterMode_Undefined _wgpu_COMMA \ + /*.lodMinClamp=*/0.f _wgpu_COMMA \ + /*.lodMaxClamp=*/32.f _wgpu_COMMA \ + /*.compare=*/WGPUCompareFunction_Undefined _wgpu_COMMA \ + /*.maxAnisotropy=*/1 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SHADER_SOURCE_SPIRV_INIT as initializer. + */ +typedef struct WGPUShaderSourceSPIRV { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t codeSize; + /** + * The `INIT` macro sets this to `NULL`. + */ + uint32_t const * code; +} WGPUShaderSourceSPIRV WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUShaderSourceSPIRV. + */ +#define WGPU_SHADER_SOURCE_SPIRV_INIT _wgpu_MAKE_INIT_STRUCT(WGPUShaderSourceSPIRV, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ShaderSourceSPIRV _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.codeSize=*/0 _wgpu_COMMA \ + /*.code=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SHADER_SOURCE_WGSL_INIT as initializer. + */ +typedef struct WGPUShaderSourceWGSL { + WGPUChainedStruct chain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView code; +} WGPUShaderSourceWGSL WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUShaderSourceWGSL. + */ +#define WGPU_SHADER_SOURCE_WGSL_INIT _wgpu_MAKE_INIT_STRUCT(WGPUShaderSourceWGSL, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ShaderSourceWGSL _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.code=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_STENCIL_FACE_STATE_INIT as initializer. + */ +typedef struct WGPUStencilFaceState { + /** + * If set to @ref WGPUCompareFunction_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUCompareFunction_Always. + * + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ + WGPUCompareFunction compare; + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ + WGPUStencilOperation failOp; + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ + WGPUStencilOperation depthFailOp; + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ + WGPUStencilOperation passOp; +} WGPUStencilFaceState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUStencilFaceState. + */ +#define WGPU_STENCIL_FACE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStencilFaceState, { \ + /*.compare=*/WGPUCompareFunction_Undefined _wgpu_COMMA \ + /*.failOp=*/WGPUStencilOperation_Undefined _wgpu_COMMA \ + /*.depthFailOp=*/WGPUStencilOperation_Undefined _wgpu_COMMA \ + /*.passOp=*/WGPUStencilOperation_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ +typedef struct WGPUStorageTextureBindingLayout { + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUStorageTextureAccess_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStorageTextureAccess_WriteOnly. + * + * The `INIT` macro sets this to @ref WGPUStorageTextureAccess_Undefined. + */ + WGPUStorageTextureAccess access; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * If set to @ref WGPUTextureViewDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + WGPUTextureViewDimension viewDimension; +} WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUStorageTextureBindingLayout. + */ +#define WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStorageTextureBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.access=*/WGPUStorageTextureAccess_Undefined _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.viewDimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SUPPORTED_FEATURES_INIT as initializer. + */ +typedef struct WGPUSupportedFeatures { + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + size_t featureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUFeatureName const * features; +} WGPUSupportedFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSupportedFeatures. + */ +#define WGPU_SUPPORTED_FEATURES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSupportedFeatures, { \ + /*.featureCount=*/0 _wgpu_COMMA \ + /*.features=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SUPPORTED_INSTANCE_FEATURES_INIT as initializer. + */ +typedef struct WGPUSupportedInstanceFeatures { + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + size_t featureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUInstanceFeatureName const * features; +} WGPUSupportedInstanceFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSupportedInstanceFeatures. + */ +#define WGPU_SUPPORTED_INSTANCE_FEATURES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSupportedInstanceFeatures, { \ + /*.featureCount=*/0 _wgpu_COMMA \ + /*.features=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SUPPORTED_WGSL_LANGUAGE_FEATURES_INIT as initializer. + */ +typedef struct WGPUSupportedWGSLLanguageFeatures { + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + size_t featureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUWGSLLanguageFeatureName const * features; +} WGPUSupportedWGSLLanguageFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSupportedWGSLLanguageFeatures. + */ +#define WGPU_SUPPORTED_WGSL_LANGUAGE_FEATURES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSupportedWGSLLanguageFeatures, { \ + /*.featureCount=*/0 _wgpu_COMMA \ + /*.features=*/NULL _wgpu_COMMA \ +}) + +/** + * Filled by @ref wgpuSurfaceGetCapabilities with what's supported for @ref wgpuSurfaceConfigure for a pair of @ref WGPUSurface and @ref WGPUAdapter. + * + * Default values can be set using @ref WGPU_SURFACE_CAPABILITIES_INIT as initializer. + */ +typedef struct WGPUSurfaceCapabilities { + WGPUChainedStruct * nextInChain; + /** + * The bit set of supported @ref WGPUTextureUsage bits. + * Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + * + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + WGPUTextureUsage usages; + /** + * Array count for `formats`. The `INIT` macro sets this to 0. + */ + size_t formatCount; + /** + * A list of supported @ref WGPUTextureFormat values, in order of preference. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUTextureFormat const * formats; + /** + * Array count for `presentModes`. The `INIT` macro sets this to 0. + */ + size_t presentModeCount; + /** + * A list of supported @ref WGPUPresentMode values. + * Guaranteed to contain @ref WGPUPresentMode_Fifo. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUPresentMode const * presentModes; + /** + * Array count for `alphaModes`. The `INIT` macro sets this to 0. + */ + size_t alphaModeCount; + /** + * 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. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUCompositeAlphaMode const * alphaModes; +} WGPUSurfaceCapabilities WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceCapabilities. + */ +#define WGPU_SURFACE_CAPABILITIES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceCapabilities, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.usages=*/WGPUTextureUsage_None _wgpu_COMMA \ + /*.formatCount=*/0 _wgpu_COMMA \ + /*.formats=*/NULL _wgpu_COMMA \ + /*.presentModeCount=*/0 _wgpu_COMMA \ + /*.presentModes=*/NULL _wgpu_COMMA \ + /*.alphaModeCount=*/0 _wgpu_COMMA \ + /*.alphaModes=*/NULL _wgpu_COMMA \ +}) + +/** + * Extension of @ref WGPUSurfaceConfiguration for color spaces and HDR. + * + * Default values can be set using @ref WGPU_SURFACE_COLOR_MANAGEMENT_INIT as initializer. + */ +typedef struct WGPUSurfaceColorManagement { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to (@ref WGPUPredefinedColorSpace)0. + */ + WGPUPredefinedColorSpace colorSpace; + /** + * The `INIT` macro sets this to (@ref WGPUToneMappingMode)0. + */ + WGPUToneMappingMode toneMappingMode; +} WGPUSurfaceColorManagement WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceColorManagement. + */ +#define WGPU_SURFACE_COLOR_MANAGEMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceColorManagement, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceColorManagement _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.colorSpace=*/_wgpu_ENUM_ZERO_INIT(WGPUPredefinedColorSpace) _wgpu_COMMA \ + /*.toneMappingMode=*/_wgpu_ENUM_ZERO_INIT(WGPUToneMappingMode) _wgpu_COMMA \ +}) + +/** + * Options to @ref wgpuSurfaceConfigure for defining how a @ref WGPUSurface will be rendered to and presented to the user. + * See @ref Surface-Configuration for more details. + * + * Default values can be set using @ref WGPU_SURFACE_CONFIGURATION_INIT as initializer. + */ +typedef struct WGPUSurfaceConfiguration { + WGPUChainedStruct * nextInChain; + /** + * The @ref WGPUDevice to use to render to surface's textures. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUDevice device; + /** + * The @ref WGPUTextureFormat of the surface's textures. + * + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * The @ref WGPUTextureUsage of the surface's textures. + * + * The `INIT` macro sets this to @ref WGPUTextureUsage_RenderAttachment. + */ + WGPUTextureUsage usage; + /** + * The width of the surface's textures. + * + * The `INIT` macro sets this to `0`. + */ + uint32_t width; + /** + * The height of the surface's textures. + * + * The `INIT` macro sets this to `0`. + */ + uint32_t height; + /** + * Array count for `viewFormats`. The `INIT` macro sets this to 0. + */ + size_t viewFormatCount; + /** + * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUTextureFormat const * viewFormats; + /** + * How the surface's frames will be composited on the screen. + * + * If set to @ref WGPUCompositeAlphaMode_Auto, + * [defaults] to @ref WGPUCompositeAlphaMode_Inherit in native (allowing the mode + * to be configured externally), and to @ref WGPUCompositeAlphaMode_Opaque in Wasm. + * + * The `INIT` macro sets this to @ref WGPUCompositeAlphaMode_Auto. + */ + WGPUCompositeAlphaMode alphaMode; + /** + * When and in which order the surface's frames will be shown on the screen. + * + * If set to @ref WGPUPresentMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUPresentMode_Fifo. + * + * The `INIT` macro sets this to @ref WGPUPresentMode_Undefined. + */ + WGPUPresentMode presentMode; +} WGPUSurfaceConfiguration WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceConfiguration. + */ +#define WGPU_SURFACE_CONFIGURATION_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceConfiguration, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.device=*/NULL _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.usage=*/WGPUTextureUsage_RenderAttachment _wgpu_COMMA \ + /*.width=*/0 _wgpu_COMMA \ + /*.height=*/0 _wgpu_COMMA \ + /*.viewFormatCount=*/0 _wgpu_COMMA \ + /*.viewFormats=*/NULL _wgpu_COMMA \ + /*.alphaMode=*/WGPUCompositeAlphaMode_Auto _wgpu_COMMA \ + /*.presentMode=*/WGPUPresentMode_Undefined _wgpu_COMMA \ +}) + +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_ANDROID_NATIVE_WINDOW_INIT as initializer. + */ +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. + * + * The `INIT` macro sets this to `NULL`. + */ + void * window; +} WGPUSurfaceSourceAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceSourceAndroidNativeWindow. + */ +#define WGPU_SURFACE_SOURCE_ANDROID_NATIVE_WINDOW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceAndroidNativeWindow, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceAndroidNativeWindow _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.window=*/NULL _wgpu_COMMA \ +}) + +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_METAL_LAYER_INIT as initializer. + */ +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. + * + * The `INIT` macro sets this to `NULL`. + */ + void * layer; +} WGPUSurfaceSourceMetalLayer WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceSourceMetalLayer. + */ +#define WGPU_SURFACE_SOURCE_METAL_LAYER_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceMetalLayer, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceMetalLayer _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.layer=*/NULL _wgpu_COMMA \ +}) + +/** + * 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). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_WAYLAND_SURFACE_INIT as initializer. + */ +typedef struct WGPUSurfaceSourceWaylandSurface { + WGPUChainedStruct chain; + /** + * A [`wl_display`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_display) for this Wayland instance. + * + * The `INIT` macro sets this to `NULL`. + */ + 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 + * + * The `INIT` macro sets this to `NULL`. + */ + void * surface; +} WGPUSurfaceSourceWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceSourceWaylandSurface. + */ +#define WGPU_SURFACE_SOURCE_WAYLAND_SURFACE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceWaylandSurface, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceWaylandSurface _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.display=*/NULL _wgpu_COMMA \ + /*.surface=*/NULL _wgpu_COMMA \ +}) + +/** + * 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). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_WINDOWS_HWND_INIT as initializer. + */ +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)`. + * + * The `INIT` macro sets this to `NULL`. + */ + 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. + * + * The `INIT` macro sets this to `NULL`. + */ + void * hwnd; +} WGPUSurfaceSourceWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceSourceWindowsHWND. + */ +#define WGPU_SURFACE_SOURCE_WINDOWS_HWND_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceWindowsHWND, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceWindowsHWND _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.hinstance=*/NULL _wgpu_COMMA \ + /*.hwnd=*/NULL _wgpu_COMMA \ +}) + +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_XCB_WINDOW_INIT as initializer. + */ +typedef struct WGPUSurfaceSourceXCBWindow { + WGPUChainedStruct chain; + /** + * The `xcb_connection_t` for the connection to the X server. + * + * The `INIT` macro sets this to `NULL`. + */ + void * connection; + /** + * The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `0`. + */ + uint32_t window; +} WGPUSurfaceSourceXCBWindow WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceSourceXCBWindow. + */ +#define WGPU_SURFACE_SOURCE_XCB_WINDOW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceXCBWindow, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceXCBWindow _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.connection=*/NULL _wgpu_COMMA \ + /*.window=*/0 _wgpu_COMMA \ +}) + +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_XLIB_WINDOW_INIT as initializer. + */ +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. + * + * The `INIT` macro sets this to `NULL`. + */ + 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. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t window; +} WGPUSurfaceSourceXlibWindow WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceSourceXlibWindow. + */ +#define WGPU_SURFACE_SOURCE_XLIB_WINDOW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceXlibWindow, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceXlibWindow _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.display=*/NULL _wgpu_COMMA \ + /*.window=*/0 _wgpu_COMMA \ +}) + +/** + * 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. + * + * Default values can be set using @ref WGPU_SURFACE_TEXTURE_INIT as initializer. + */ +typedef struct WGPUSurfaceTexture { + WGPUChainedStruct * nextInChain; + /** + * The @ref WGPUTexture representing the frame that will be shown on the surface. + * It is @ref ReturnedWithOwnership from @ref wgpuSurfaceGetCurrentTexture. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUTexture texture; + /** + * Whether the call to @ref wgpuSurfaceGetCurrentTexture succeeded and a hint as to why it might not have. + * + * The `INIT` macro sets this to (@ref WGPUSurfaceGetCurrentTextureStatus)0. + */ + WGPUSurfaceGetCurrentTextureStatus status; +} WGPUSurfaceTexture WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceTexture. + */ +#define WGPU_SURFACE_TEXTURE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceTexture, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.texture=*/NULL _wgpu_COMMA \ + /*.status=*/_wgpu_ENUM_ZERO_INIT(WGPUSurfaceGetCurrentTextureStatus) _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT as initializer. + */ +typedef struct WGPUTexelCopyBufferLayout { + /** + * The `INIT` macro sets this to `0`. + */ + uint64_t offset; + /** + * The `INIT` macro sets this to @ref WGPU_COPY_STRIDE_UNDEFINED. + */ + uint32_t bytesPerRow; + /** + * The `INIT` macro sets this to @ref WGPU_COPY_STRIDE_UNDEFINED. + */ + uint32_t rowsPerImage; +} WGPUTexelCopyBufferLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTexelCopyBufferLayout. + */ +#define WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTexelCopyBufferLayout, { \ + /*.offset=*/0 _wgpu_COMMA \ + /*.bytesPerRow=*/WGPU_COPY_STRIDE_UNDEFINED _wgpu_COMMA \ + /*.rowsPerImage=*/WGPU_COPY_STRIDE_UNDEFINED _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ +typedef struct WGPUTextureBindingLayout { + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUTextureSampleType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureSampleType_Float. + * + * The `INIT` macro sets this to @ref WGPUTextureSampleType_Undefined. + */ + WGPUTextureSampleType sampleType; + /** + * If set to @ref WGPUTextureViewDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + WGPUTextureViewDimension viewDimension; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool multisampled; +} WGPUTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureBindingLayout. + */ +#define WGPU_TEXTURE_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.sampleType=*/WGPUTextureSampleType_Undefined _wgpu_COMMA \ + /*.viewDimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ + /*.multisampled=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Note: While Compatibility Mode is optional to implement, this extension struct + * is required to be accepted (but per the WebGPU spec, its contents are ignored + * on devices that have the @ref WGPUFeatureName_CoreFeaturesAndLimits feature). + * + * Default values can be set using @ref WGPU_TEXTURE_BINDING_VIEW_DIMENSION_INIT as initializer. + */ +typedef struct WGPUTextureBindingViewDimension { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + WGPUTextureViewDimension textureBindingViewDimension; +} WGPUTextureBindingViewDimension WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureBindingViewDimension. + */ +#define WGPU_TEXTURE_BINDING_VIEW_DIMENSION_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureBindingViewDimension, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_TextureBindingViewDimension _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.textureBindingViewDimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ +}) + +/** + * When accessed by a shader, the red/green/blue/alpha channels are replaced + * by the value corresponding to the component specified in r, g, b, and a, + * respectively unlike the JS API which uses a string of length four, with + * each character mapping to the texture view's red/green/blue/alpha channels. + * + * Default values can be set using @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT as initializer. + */ +typedef struct WGPUTextureComponentSwizzle { + /** + * The value that replaces the red channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_R. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle r; + /** + * The value that replaces the green channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_G. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle g; + /** + * The value that replaces the blue channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_B. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle b; + /** + * The value that replaces the alpha channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_A. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle a; +} WGPUTextureComponentSwizzle WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureComponentSwizzle. + */ +#define WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureComponentSwizzle, { \ + /*.r=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ + /*.g=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ + /*.b=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ + /*.a=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_VERTEX_ATTRIBUTE_INIT as initializer. + */ +typedef struct WGPUVertexAttribute { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to (@ref WGPUVertexFormat)0. + */ + WGPUVertexFormat format; + /** + * The `INIT` macro sets this to `0`. + */ + uint64_t offset; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t shaderLocation; +} WGPUVertexAttribute WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUVertexAttribute. + */ +#define WGPU_VERTEX_ATTRIBUTE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUVertexAttribute, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.format=*/_wgpu_ENUM_ZERO_INIT(WGPUVertexFormat) _wgpu_COMMA \ + /*.offset=*/0 _wgpu_COMMA \ + /*.shaderLocation=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_ENTRY_INIT as initializer. + */ +typedef struct WGPUBindGroupEntry { + WGPUChainedStruct * nextInChain; + /** + * Binding index in the bind group. + * + * The `INIT` macro sets this to `0`. + */ + uint32_t binding; + /** + * Set this if the binding is a buffer object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUBuffer buffer; + /** + * If the binding is a buffer, this is the byte offset of the binding range. + * Otherwise ignored. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t offset; + /** + * If the binding is a buffer, this is the byte size of the binding range + * (@ref WGPU_WHOLE_SIZE means the binding ends at the end of the buffer). + * Otherwise ignored. + * + * The `INIT` macro sets this to @ref WGPU_WHOLE_SIZE. + */ + uint64_t size; + /** + * Set this if the binding is a sampler object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUSampler sampler; + /** + * Set this if the binding is a texture view object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUTextureView textureView; +} WGPUBindGroupEntry WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBindGroupEntry. + */ +#define WGPU_BIND_GROUP_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupEntry, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.binding=*/0 _wgpu_COMMA \ + /*.buffer=*/NULL _wgpu_COMMA \ + /*.offset=*/0 _wgpu_COMMA \ + /*.size=*/WGPU_WHOLE_SIZE _wgpu_COMMA \ + /*.sampler=*/NULL _wgpu_COMMA \ + /*.textureView=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_LAYOUT_ENTRY_INIT as initializer. + */ +typedef struct WGPUBindGroupLayoutEntry { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t binding; + /** + * The `INIT` macro sets this to @ref WGPUShaderStage_None. + */ + WGPUShaderStage visibility; + /** + * If non-zero, this entry defines a binding array with this size. + * + * The `INIT` macro sets this to `0`. + */ + uint32_t bindingArraySize; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + WGPUBufferBindingLayout buffer; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + WGPUSamplerBindingLayout sampler; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + WGPUTextureBindingLayout texture; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + WGPUStorageTextureBindingLayout storageTexture; +} WGPUBindGroupLayoutEntry WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBindGroupLayoutEntry. + */ +#define WGPU_BIND_GROUP_LAYOUT_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupLayoutEntry, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.binding=*/0 _wgpu_COMMA \ + /*.visibility=*/WGPUShaderStage_None _wgpu_COMMA \ + /*.bindingArraySize=*/0 _wgpu_COMMA \ + /*.buffer=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ + /*.sampler=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ + /*.texture=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ + /*.storageTexture=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BLEND_STATE_INIT as initializer. + */ +typedef struct WGPUBlendState { + /** + * The `INIT` macro sets this to @ref WGPU_BLEND_COMPONENT_INIT. + */ + WGPUBlendComponent color; + /** + * The `INIT` macro sets this to @ref WGPU_BLEND_COMPONENT_INIT. + */ + WGPUBlendComponent alpha; +} WGPUBlendState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBlendState. + */ +#define WGPU_BLEND_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBlendState, { \ + /*.color=*/WGPU_BLEND_COMPONENT_INIT _wgpu_COMMA \ + /*.alpha=*/WGPU_BLEND_COMPONENT_INIT _wgpu_COMMA \ +}) + +/** + * This is an @ref ImplementationAllocatedStructChain root. + * Arbitrary chains must be handled gracefully by the application! + * + * Default values can be set using @ref WGPU_COMPILATION_INFO_INIT as initializer. + */ +typedef struct WGPUCompilationInfo { + WGPUChainedStruct * nextInChain; + /** + * Array count for `messages`. The `INIT` macro sets this to 0. + */ + size_t messageCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUCompilationMessage const * messages; +} WGPUCompilationInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCompilationInfo. + */ +#define WGPU_COMPILATION_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompilationInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.messageCount=*/0 _wgpu_COMMA \ + /*.messages=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMPUTE_PASS_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUComputePassDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUPassTimestampWrites const * timestampWrites; +} WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUComputePassDescriptor. + */ +#define WGPU_COMPUTE_PASS_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUComputePassDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.timestampWrites=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMPUTE_STATE_INIT as initializer. + */ +typedef struct WGPUComputeState { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUShaderModule module; + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView entryPoint; + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + size_t constantCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUConstantEntry const * constants; +} WGPUComputeState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUComputeState. + */ +#define WGPU_COMPUTE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUComputeState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.module=*/NULL _wgpu_COMMA \ + /*.entryPoint=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.constantCount=*/0 _wgpu_COMMA \ + /*.constants=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_DEPTH_STENCIL_STATE_INIT as initializer. + */ +typedef struct WGPUDepthStencilState { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * The `INIT` macro sets this to @ref WGPUOptionalBool_Undefined. + */ + WGPUOptionalBool depthWriteEnabled; + /** + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ + WGPUCompareFunction depthCompare; + /** + * The `INIT` macro sets this to @ref WGPU_STENCIL_FACE_STATE_INIT. + */ + WGPUStencilFaceState stencilFront; + /** + * The `INIT` macro sets this to @ref WGPU_STENCIL_FACE_STATE_INIT. + */ + WGPUStencilFaceState stencilBack; + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ + uint32_t stencilReadMask; + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ + uint32_t stencilWriteMask; + /** + * The `INIT` macro sets this to `0`. + */ + int32_t depthBias; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ + float depthBiasSlopeScale; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ + float depthBiasClamp; +} WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUDepthStencilState. + */ +#define WGPU_DEPTH_STENCIL_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUDepthStencilState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.depthWriteEnabled=*/WGPUOptionalBool_Undefined _wgpu_COMMA \ + /*.depthCompare=*/WGPUCompareFunction_Undefined _wgpu_COMMA \ + /*.stencilFront=*/WGPU_STENCIL_FACE_STATE_INIT _wgpu_COMMA \ + /*.stencilBack=*/WGPU_STENCIL_FACE_STATE_INIT _wgpu_COMMA \ + /*.stencilReadMask=*/0xFFFFFFFF _wgpu_COMMA \ + /*.stencilWriteMask=*/0xFFFFFFFF _wgpu_COMMA \ + /*.depthBias=*/0 _wgpu_COMMA \ + /*.depthBiasSlopeScale=*/0.f _wgpu_COMMA \ + /*.depthBiasClamp=*/0.f _wgpu_COMMA \ +}) + +/** + * Struct holding a future to wait on, and a `completed` boolean flag. + * + * Default values can be set using @ref WGPU_FUTURE_WAIT_INFO_INIT as initializer. + */ +typedef struct WGPUFutureWaitInfo { + /** + * The future to wait on. + * + * The `INIT` macro sets this to @ref WGPU_FUTURE_INIT. + */ + WGPUFuture future; + /** + * Whether or not the future completed. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool completed; +} WGPUFutureWaitInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUFutureWaitInfo. + */ +#define WGPU_FUTURE_WAIT_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUFutureWaitInfo, { \ + /*.future=*/WGPU_FUTURE_INIT _wgpu_COMMA \ + /*.completed=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_INSTANCE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUInstanceDescriptor { + WGPUChainedStruct * nextInChain; + /** + * Array count for `requiredFeatures`. The `INIT` macro sets this to 0. + */ + size_t requiredFeatureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUInstanceFeatureName const * requiredFeatures; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUInstanceLimits const * requiredLimits; +} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUInstanceDescriptor. + */ +#define WGPU_INSTANCE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUInstanceDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.requiredFeatureCount=*/0 _wgpu_COMMA \ + /*.requiredFeatures=*/NULL _wgpu_COMMA \ + /*.requiredLimits=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_LIMITS_INIT as initializer. + */ +typedef struct WGPULimits { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureDimension1D; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureDimension2D; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureDimension3D; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureArrayLayers; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxBindGroups; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxBindGroupsPlusVertexBuffers; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxBindingsPerBindGroup; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxDynamicUniformBuffersPerPipelineLayout; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxDynamicStorageBuffersPerPipelineLayout; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxSampledTexturesPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxSamplersPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageBuffersPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageTexturesPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxUniformBuffersPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + uint64_t maxUniformBufferBindingSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + uint64_t maxStorageBufferBindingSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t minUniformBufferOffsetAlignment; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t minStorageBufferOffsetAlignment; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxVertexBuffers; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + uint64_t maxBufferSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxVertexAttributes; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxVertexBufferArrayStride; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxInterStageShaderVariables; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxColorAttachments; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxColorAttachmentBytesPerSample; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupStorageSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeInvocationsPerWorkgroup; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupSizeX; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupSizeY; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupSizeZ; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupsPerDimension; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxImmediateSize; +} WGPULimits WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPULimits. + */ +#define WGPU_LIMITS_INIT _wgpu_MAKE_INIT_STRUCT(WGPULimits, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.maxTextureDimension1D=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxTextureDimension2D=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxTextureDimension3D=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxTextureArrayLayers=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBindGroups=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBindGroupsPlusVertexBuffers=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBindingsPerBindGroup=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxDynamicUniformBuffersPerPipelineLayout=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxDynamicStorageBuffersPerPipelineLayout=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxSampledTexturesPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxSamplersPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageBuffersPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageTexturesPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxUniformBuffersPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxUniformBufferBindingSize=*/WGPU_LIMIT_U64_UNDEFINED _wgpu_COMMA \ + /*.maxStorageBufferBindingSize=*/WGPU_LIMIT_U64_UNDEFINED _wgpu_COMMA \ + /*.minUniformBufferOffsetAlignment=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.minStorageBufferOffsetAlignment=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxVertexBuffers=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBufferSize=*/WGPU_LIMIT_U64_UNDEFINED _wgpu_COMMA \ + /*.maxVertexAttributes=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxVertexBufferArrayStride=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxInterStageShaderVariables=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxColorAttachments=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxColorAttachmentBytesPerSample=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupStorageSize=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeInvocationsPerWorkgroup=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupSizeX=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupSizeY=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupSizeZ=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupsPerDimension=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxImmediateSize=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT as initializer. + */ +typedef struct WGPURenderPassColorAttachment { + WGPUChainedStruct * nextInChain; + /** + * If `NULL`, indicates a hole in the parent + * @ref WGPURenderPassDescriptor::colorAttachments array. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUTextureView view; + /** + * The `INIT` macro sets this to @ref WGPU_DEPTH_SLICE_UNDEFINED. + */ + uint32_t depthSlice; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUTextureView resolveTarget; + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ + WGPULoadOp loadOp; + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ + WGPUStoreOp storeOp; + /** + * The `INIT` macro sets this to @ref WGPU_COLOR_INIT. + */ + WGPUColor clearValue; +} WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderPassColorAttachment. + */ +#define WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassColorAttachment, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.view=*/NULL _wgpu_COMMA \ + /*.depthSlice=*/WGPU_DEPTH_SLICE_UNDEFINED _wgpu_COMMA \ + /*.resolveTarget=*/NULL _wgpu_COMMA \ + /*.loadOp=*/WGPULoadOp_Undefined _wgpu_COMMA \ + /*.storeOp=*/WGPUStoreOp_Undefined _wgpu_COMMA \ + /*.clearValue=*/WGPU_COLOR_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_REQUEST_ADAPTER_OPTIONS_INIT as initializer. + */ +typedef struct WGPURequestAdapterOptions { + WGPUChainedStruct * nextInChain; + /** + * "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + * + * If set to @ref WGPUFeatureLevel_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFeatureLevel_Core. + * Additionally, implementations may ignore @ref WGPUFeatureLevel_Compatibility + * and provide @ref WGPUFeatureLevel_Core instead. + * + * The `INIT` macro sets this to @ref WGPUFeatureLevel_Undefined. + */ + WGPUFeatureLevel featureLevel; + /** + * The `INIT` macro sets this to @ref WGPUPowerPreference_Undefined. + */ + WGPUPowerPreference powerPreference; + /** + * 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. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool forceFallbackAdapter; + /** + * If set, requires the adapter to have a particular backend type. + * If this is not possible, the request returns null. + * + * The `INIT` macro sets this to @ref WGPUBackendType_Undefined. + */ + 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. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUSurface compatibleSurface; +} WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURequestAdapterOptions. + */ +#define WGPU_REQUEST_ADAPTER_OPTIONS_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestAdapterOptions, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.featureLevel=*/WGPUFeatureLevel_Undefined _wgpu_COMMA \ + /*.powerPreference=*/WGPUPowerPreference_Undefined _wgpu_COMMA \ + /*.forceFallbackAdapter=*/WGPU_FALSE _wgpu_COMMA \ + /*.backendType=*/WGPUBackendType_Undefined _wgpu_COMMA \ + /*.compatibleSurface=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SHADER_MODULE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUShaderModuleDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUShaderModuleDescriptor. + */ +#define WGPU_SHADER_MODULE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUShaderModuleDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * The root descriptor for the creation of an @ref WGPUSurface with @ref wgpuInstanceCreateSurface. + * It isn't sufficient by itself and must have one of the `WGPUSurfaceSource*` in its chain. + * See @ref Surface-Creation for more details. + * + * Default values can be set using @ref WGPU_SURFACE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUSurfaceDescriptor { + WGPUChainedStruct * nextInChain; + /** + * Label used to refer to the object. + * + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceDescriptor. + */ +#define WGPU_SURFACE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_BUFFER_INFO_INIT as initializer. + */ +typedef struct WGPUTexelCopyBufferInfo { + /** + * The `INIT` macro sets this to @ref WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT. + */ + WGPUTexelCopyBufferLayout layout; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBuffer buffer; +} WGPUTexelCopyBufferInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTexelCopyBufferInfo. + */ +#define WGPU_TEXEL_COPY_BUFFER_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTexelCopyBufferInfo, { \ + /*.layout=*/WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT _wgpu_COMMA \ + /*.buffer=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_TEXTURE_INFO_INIT as initializer. + */ +typedef struct WGPUTexelCopyTextureInfo { + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUTexture texture; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t mipLevel; + /** + * The `INIT` macro sets this to @ref WGPU_ORIGIN_3D_INIT. + */ + WGPUOrigin3D origin; + /** + * If set to @ref WGPUTextureAspect_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + * + * The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined. + */ + WGPUTextureAspect aspect; +} WGPUTexelCopyTextureInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTexelCopyTextureInfo. + */ +#define WGPU_TEXEL_COPY_TEXTURE_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTexelCopyTextureInfo, { \ + /*.texture=*/NULL _wgpu_COMMA \ + /*.mipLevel=*/0 _wgpu_COMMA \ + /*.origin=*/WGPU_ORIGIN_3D_INIT _wgpu_COMMA \ + /*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUTextureComponentSwizzleDescriptor { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT. + */ + WGPUTextureComponentSwizzle swizzle; +} WGPUTextureComponentSwizzleDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureComponentSwizzleDescriptor. + */ +#define WGPU_TEXTURE_COMPONENT_SWIZZLE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureComponentSwizzleDescriptor, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_TextureComponentSwizzleDescriptor _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.swizzle=*/WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUTextureDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + WGPUTextureUsage usage; + /** + * If set to @ref WGPUTextureDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureDimension_Undefined. + */ + WGPUTextureDimension dimension; + /** + * The `INIT` macro sets this to @ref WGPU_EXTENT_3D_INIT. + */ + WGPUExtent3D size; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * The `INIT` macro sets this to `1`. + */ + uint32_t mipLevelCount; + /** + * The `INIT` macro sets this to `1`. + */ + uint32_t sampleCount; + /** + * Array count for `viewFormats`. The `INIT` macro sets this to 0. + */ + size_t viewFormatCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUTextureFormat const * viewFormats; +} WGPUTextureDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureDescriptor. + */ +#define WGPU_TEXTURE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.usage=*/WGPUTextureUsage_None _wgpu_COMMA \ + /*.dimension=*/WGPUTextureDimension_Undefined _wgpu_COMMA \ + /*.size=*/WGPU_EXTENT_3D_INIT _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.mipLevelCount=*/1 _wgpu_COMMA \ + /*.sampleCount=*/1 _wgpu_COMMA \ + /*.viewFormatCount=*/0 _wgpu_COMMA \ + /*.viewFormats=*/NULL _wgpu_COMMA \ +}) + +/** + * If `attributes` is empty *and* `stepMode` is @ref WGPUVertexStepMode_Undefined, + * indicates a "hole" in the parent @ref WGPUVertexState `buffers` array, + * with behavior equivalent to `null` in the JS API. + * + * If `attributes` is empty but `stepMode` is *not* @ref WGPUVertexStepMode_Undefined, + * indicates a vertex buffer with no attributes, with behavior equivalent to + * `{ attributes: [] }` in the JS API. (TODO: If the JS API changes not to + * distinguish these cases, then this distinction doesn't matter and we can + * remove this documentation.) + * + * If `stepMode` is @ref WGPUVertexStepMode_Undefined but `attributes` is *not* empty, + * `stepMode` [defaults](@ref SentinelValues) to @ref WGPUVertexStepMode_Vertex. + * + * Default values can be set using @ref WGPU_VERTEX_BUFFER_LAYOUT_INIT as initializer. + */ +typedef struct WGPUVertexBufferLayout { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to @ref WGPUVertexStepMode_Undefined. + */ + WGPUVertexStepMode stepMode; + /** + * The `INIT` macro sets this to `0`. + */ + uint64_t arrayStride; + /** + * Array count for `attributes`. The `INIT` macro sets this to 0. + */ + size_t attributeCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUVertexAttribute const * attributes; +} WGPUVertexBufferLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUVertexBufferLayout. + */ +#define WGPU_VERTEX_BUFFER_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUVertexBufferLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.stepMode=*/WGPUVertexStepMode_Undefined _wgpu_COMMA \ + /*.arrayStride=*/0 _wgpu_COMMA \ + /*.attributeCount=*/0 _wgpu_COMMA \ + /*.attributes=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUBindGroupDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBindGroupLayout layout; + /** + * Array count for `entries`. The `INIT` macro sets this to 0. + */ + size_t entryCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBindGroupEntry const * entries; +} WGPUBindGroupDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBindGroupDescriptor. + */ +#define WGPU_BIND_GROUP_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.layout=*/NULL _wgpu_COMMA \ + /*.entryCount=*/0 _wgpu_COMMA \ + /*.entries=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUBindGroupLayoutDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `entries`. The `INIT` macro sets this to 0. + */ + size_t entryCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBindGroupLayoutEntry const * entries; +} WGPUBindGroupLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBindGroupLayoutDescriptor. + */ +#define WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupLayoutDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.entryCount=*/0 _wgpu_COMMA \ + /*.entries=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COLOR_TARGET_STATE_INIT as initializer. + */ +typedef struct WGPUColorTargetState { + WGPUChainedStruct * 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`. + * + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUBlendState const * blend; + /** + * The `INIT` macro sets this to @ref WGPUColorWriteMask_All. + */ + WGPUColorWriteMask writeMask; +} WGPUColorTargetState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUColorTargetState. + */ +#define WGPU_COLOR_TARGET_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUColorTargetState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.blend=*/NULL _wgpu_COMMA \ + /*.writeMask=*/WGPUColorWriteMask_All _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUComputePipelineDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUPipelineLayout layout; + /** + * The `INIT` macro sets this to @ref WGPU_COMPUTE_STATE_INIT. + */ + WGPUComputeState compute; +} WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUComputePipelineDescriptor. + */ +#define WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUComputePipelineDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.layout=*/NULL _wgpu_COMMA \ + /*.compute=*/WGPU_COMPUTE_STATE_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_DEVICE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUDeviceDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `requiredFeatures`. The `INIT` macro sets this to 0. + */ + size_t requiredFeatureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUFeatureName const * requiredFeatures; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPULimits const * requiredLimits; + /** + * The `INIT` macro sets this to @ref WGPU_QUEUE_DESCRIPTOR_INIT. + */ + WGPUQueueDescriptor defaultQueue; + /** + * The `INIT` macro sets this to @ref WGPU_DEVICE_LOST_CALLBACK_INFO_INIT. + */ + WGPUDeviceLostCallbackInfo deviceLostCallbackInfo; + /** + * Called when there is an uncaptured error on this device, from any thread. + * See @ref ErrorScopes. + * + * **Important:** This callback does not have a configurable @ref WGPUCallbackMode; it may be called at any time (like @ref WGPUCallbackMode_AllowSpontaneous). As such, calls into the `webgpu.h` API from this callback are unsafe. See @ref CallbackReentrancy. + * + * The `INIT` macro sets this to @ref WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT. + */ + WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; +} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUDeviceDescriptor. + */ +#define WGPU_DEVICE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUDeviceDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.requiredFeatureCount=*/0 _wgpu_COMMA \ + /*.requiredFeatures=*/NULL _wgpu_COMMA \ + /*.requiredLimits=*/NULL _wgpu_COMMA \ + /*.defaultQueue=*/WGPU_QUEUE_DESCRIPTOR_INIT _wgpu_COMMA \ + /*.deviceLostCallbackInfo=*/WGPU_DEVICE_LOST_CALLBACK_INFO_INIT _wgpu_COMMA \ + /*.uncapturedErrorCallbackInfo=*/WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPURenderPassDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `colorAttachments`. The `INIT` macro sets this to 0. + */ + size_t colorAttachmentCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPURenderPassColorAttachment const * colorAttachments; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUQuerySet occlusionQuerySet; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUPassTimestampWrites const * timestampWrites; +} WGPURenderPassDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderPassDescriptor. + */ +#define WGPU_RENDER_PASS_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.colorAttachmentCount=*/0 _wgpu_COMMA \ + /*.colorAttachments=*/NULL _wgpu_COMMA \ + /*.depthStencilAttachment=*/NULL _wgpu_COMMA \ + /*.occlusionQuerySet=*/NULL _wgpu_COMMA \ + /*.timestampWrites=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUTextureViewDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + WGPUTextureViewDimension dimension; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t baseMipLevel; + /** + * The `INIT` macro sets this to @ref WGPU_MIP_LEVEL_COUNT_UNDEFINED. + */ + uint32_t mipLevelCount; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t baseArrayLayer; + /** + * The `INIT` macro sets this to @ref WGPU_ARRAY_LAYER_COUNT_UNDEFINED. + */ + uint32_t arrayLayerCount; + /** + * If set to @ref WGPUTextureAspect_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + * + * The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined. + */ + WGPUTextureAspect aspect; + /** + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + WGPUTextureUsage usage; +} WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureViewDescriptor. + */ +#define WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureViewDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.dimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ + /*.baseMipLevel=*/0 _wgpu_COMMA \ + /*.mipLevelCount=*/WGPU_MIP_LEVEL_COUNT_UNDEFINED _wgpu_COMMA \ + /*.baseArrayLayer=*/0 _wgpu_COMMA \ + /*.arrayLayerCount=*/WGPU_ARRAY_LAYER_COUNT_UNDEFINED _wgpu_COMMA \ + /*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \ + /*.usage=*/WGPUTextureUsage_None _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_VERTEX_STATE_INIT as initializer. + */ +typedef struct WGPUVertexState { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUShaderModule module; + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView entryPoint; + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + size_t constantCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUConstantEntry const * constants; + /** + * Array count for `buffers`. The `INIT` macro sets this to 0. + */ + size_t bufferCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUVertexBufferLayout const * buffers; +} WGPUVertexState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUVertexState. + */ +#define WGPU_VERTEX_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUVertexState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.module=*/NULL _wgpu_COMMA \ + /*.entryPoint=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.constantCount=*/0 _wgpu_COMMA \ + /*.constants=*/NULL _wgpu_COMMA \ + /*.bufferCount=*/0 _wgpu_COMMA \ + /*.buffers=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_FRAGMENT_STATE_INIT as initializer. + */ +typedef struct WGPUFragmentState { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUShaderModule module; + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView entryPoint; + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + size_t constantCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUConstantEntry const * constants; + /** + * Array count for `targets`. The `INIT` macro sets this to 0. + */ + size_t targetCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUColorTargetState const * targets; +} WGPUFragmentState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUFragmentState. + */ +#define WGPU_FRAGMENT_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUFragmentState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.module=*/NULL _wgpu_COMMA \ + /*.entryPoint=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.constantCount=*/0 _wgpu_COMMA \ + /*.constants=*/NULL _wgpu_COMMA \ + /*.targetCount=*/0 _wgpu_COMMA \ + /*.targets=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPURenderPipelineDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUPipelineLayout layout; + /** + * The `INIT` macro sets this to @ref WGPU_VERTEX_STATE_INIT. + */ + WGPUVertexState vertex; + /** + * The `INIT` macro sets this to @ref WGPU_PRIMITIVE_STATE_INIT. + */ + WGPUPrimitiveState primitive; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUDepthStencilState const * depthStencil; + /** + * The `INIT` macro sets this to @ref WGPU_MULTISAMPLE_STATE_INIT. + */ + WGPUMultisampleState multisample; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUFragmentState const * fragment; +} WGPURenderPipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURenderPipelineDescriptor. + */ +#define WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPipelineDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.layout=*/NULL _wgpu_COMMA \ + /*.vertex=*/WGPU_VERTEX_STATE_INIT _wgpu_COMMA \ + /*.primitive=*/WGPU_PRIMITIVE_STATE_INIT _wgpu_COMMA \ + /*.depthStencil=*/NULL _wgpu_COMMA \ + /*.multisample=*/WGPU_MULTISAMPLE_STATE_INIT _wgpu_COMMA \ + /*.fragment=*/NULL _wgpu_COMMA \ +}) + +/** @} */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(WGPU_SKIP_PROCS) +// Global procs +/** + * Proc pointer type for @ref wgpuCreateInstance: + * > @copydoc wgpuCreateInstance + */ +typedef WGPUInstance (*WGPUProcCreateInstance)(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetInstanceFeatures: + * > @copydoc wgpuGetInstanceFeatures + */ +typedef void (*WGPUProcGetInstanceFeatures)(WGPUSupportedInstanceFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetInstanceLimits: + * > @copydoc wgpuGetInstanceLimits + */ +typedef WGPUStatus (*WGPUProcGetInstanceLimits)(WGPUInstanceLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuHasInstanceFeature: + * > @copydoc wgpuHasInstanceFeature + */ +typedef WGPUBool (*WGPUProcHasInstanceFeature)(WGPUInstanceFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetProcAddress: + * > @copydoc wgpuGetProcAddress + */ +typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; + + +// Procs of Adapter +/** + * 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; +/** + * 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 +/** + * 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 +/** + * 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 wgpuBufferGetMappedRange: + * > @copydoc wgpuBufferGetMappedRange + */ +typedef void * (*WGPUProcBufferGetMappedRange)(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 wgpuBufferGetSize: + * > @copydoc wgpuBufferGetSize + */ +typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) 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 wgpuBufferReadMappedRange: + * > @copydoc wgpuBufferReadMappedRange + */ +typedef WGPUStatus (*WGPUProcBufferReadMappedRange)(WGPUBuffer buffer, size_t offset, void * data, size_t size) 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; +/** + * Proc pointer type for @ref wgpuBufferWriteMappedRange: + * > @copydoc wgpuBufferWriteMappedRange + */ +typedef WGPUStatus (*WGPUProcBufferWriteMappedRange)(WGPUBuffer buffer, size_t offset, void const * data, size_t size) 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 +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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 WGPU_NULLABLE 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; +/** + * 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; +/** + * 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; +/** + * Proc pointer type for @ref wgpuDeviceGetAdapterInfo: + * > @copydoc wgpuDeviceGetAdapterInfo + */ +typedef WGPUStatus (*WGPUProcDeviceGetAdapterInfo)(WGPUDevice device, WGPUAdapterInfo * adapterInfo) 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; +/** + * 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; +/** + * 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 ExternalTexture +/** + * Proc pointer type for @ref wgpuExternalTextureSetLabel: + * > @copydoc wgpuExternalTextureSetLabel + */ +typedef void (*WGPUProcExternalTextureSetLabel)(WGPUExternalTexture externalTexture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuExternalTextureAddRef: + * > @copydoc wgpuExternalTextureAddRef + */ +typedef void (*WGPUProcExternalTextureAddRef)(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuExternalTextureRelease: + * > @copydoc wgpuExternalTextureRelease + */ +typedef void (*WGPUProcExternalTextureRelease)(WGPUExternalTexture externalTexture) 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 void (*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; +/** + * 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 +/** + * 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; +/** + * 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 +/** + * 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; +/** + * 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 +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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; +/** + * 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 +/** + * 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 +/** + * 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 SupportedInstanceFeatures +/** + * Proc pointer type for @ref wgpuSupportedInstanceFeaturesFreeMembers: + * > @copydoc wgpuSupportedInstanceFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedInstanceFeaturesFreeMembers)(WGPUSupportedInstanceFeatures supportedInstanceFeatures) 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; +/** + * 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; +/** + * 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; +/** + * 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 +/** + * 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; +/** + * Proc pointer type for @ref wgpuTextureGetTextureBindingViewDimension: + * > @copydoc wgpuTextureGetTextureBindingViewDimension + */ +typedef WGPUTextureViewDimension (*WGPUProcTextureGetTextureBindingViewDimension)(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; +/** + * 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 +/** + * 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 + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUInstanceFeatureName values supported by the instance. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuGetInstanceFeatures(WGPUSupportedInstanceFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the limits supported by the instance. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuGetInstanceLimits(WGPUInstanceLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Check whether a particular @ref WGPUInstanceFeatureName is supported by the instance. + */ +WGPU_EXPORT WGPUBool wgpuHasInstanceFeature(WGPUInstanceFeatureName feature) 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; + +/** @} */ + +/** + * \defgroup Methods 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 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; + +/** @} */ + +/** + * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods + * \brief Functions whose first argument has type WGPUAdapterInfo. + * + * @{ + */ +/** + * Frees members 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; + +/** @} */ + +/** + * \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; + +/** @} */ + +/** + * \defgroup WGPUBufferMethods WGPUBuffer methods + * \brief Functions whose first argument has type WGPUBuffer. + * + * @{ + */ +WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns a const pointer to beginning of the mapped range. + * It must not be written; writing to this range causes undefined behavior. + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, if `memcpy`ing from this range, prefer using @ref wgpuBufferReadMappedRange + * instead for better performance. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. + * If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + * The returned pointer is valid for exactly this many bytes. + */ +WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns a mutable pointer to beginning of the mapped range. + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, if `memcpy`ing into this range, prefer using @ref wgpuBufferWriteMappedRange + * instead for better performance. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. + * If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + * The returned pointer is valid for exactly this many bytes. + */ +WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param mode + * The mapping mode (read or write). + * + * @param offset + * Byte offset relative to beginning of the buffer. + * + * @param size + * Byte size of the region to map. + * If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + */ +WGPU_EXPORT WGPUFuture wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Copies a range of data from the buffer mapping into the provided destination pointer. + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, this is more efficient than copying from a mapped range into a `malloc`'d range. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param data + * Destination, to read buffer data into. + * + * @param size + * Number of bytes of data to read from the buffer. + * (Note @ref WGPU_WHOLE_MAP_SIZE is *not* accepted here.) + * + * @returns + * @ref WGPUStatus_Error if the copy did not occur. + */ +WGPU_EXPORT WGPUStatus wgpuBufferReadMappedRange(WGPUBuffer buffer, size_t offset, void * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Copies a range of data from the provided source pointer into the buffer mapping. + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, this is more efficient than copying from a `malloc`'d range into a mapped range. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param data + * Source, to write buffer data from. + * + * @param size + * Number of bytes of data to write to the buffer. + * (Note @ref WGPU_WHOLE_MAP_SIZE is *not* accepted here.) + * + * @returns + * @ref WGPUStatus_Error if the copy did not occur. + */ +WGPU_EXPORT WGPUStatus wgpuBufferWriteMappedRange(WGPUBuffer buffer, size_t offset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferAddRef(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) 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; + +/** @} */ + +/** + * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods + * \brief Functions whose first argument has type WGPUCommandEncoder. + * + * @{ + */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +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, 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; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) 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, 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, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderAddRef(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \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, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) 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, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderAddRef(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods + * \brief Functions whose first argument has type WGPUComputePipeline. + * + * @{ + */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) 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; + +/** @} */ + +/** + * \defgroup WGPUDeviceMethods WGPUDevice methods + * \brief Functions whose first argument has type WGPUDevice. + * + * @{ + */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * TODO + * + * If @ref WGPUBufferDescriptor::mappedAtCreation is `true` and the mapping allocation fails, + * returns `NULL`. + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPU_NULLABLE WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param adapterInfo + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuDeviceGetAdapterInfo(WGPUDevice device, WGPUAdapterInfo * adapterInfo) 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; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Pops an error scope to the current thread's error scope stack, + * asynchronously returning the result. See @ref ErrorScopes. + */ +WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Pushes an error scope to the current thread's error scope stack. + * See @ref ErrorScopes. + */ +WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) 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; + +/** @} */ + +/** + * \defgroup WGPUExternalTextureMethods WGPUExternalTexture methods + * \brief Functions whose first argument has type WGPUExternalTexture. + * + * @{ + */ +WGPU_EXPORT void wgpuExternalTextureSetLabel(WGPUExternalTexture externalTexture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuExternalTextureAddRef(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuExternalTextureRelease(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \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). + * This value is @ref ReturnedWithOwnership. + */ +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 void 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 @ref WGPUCallbackMode_AllowProcessEvents. + * + * See @ref Process-Events for more information. + */ +WGPU_EXPORT void wgpuInstanceProcessEvents(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; + +/** @} */ + +/** + * \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; + +/** @} */ + +/** + * \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, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetAddRef(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) 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, 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; + +/** @} */ + +/** + * \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; + +/** @} */ + +/** + * \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; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) 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, 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, 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 wgpuRenderBundleEncoderAddRef(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \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; +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +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, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) 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; +/** + * @param color + * The RGBA blend constant. Represents an `f32` color using @ref DoubleAsSupertype. + */ +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, 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; +/** + * TODO + * + * If any argument is non-finite, produces a @ref NonFiniteFloatValueError. + */ +WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderAddRef(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods + * \brief Functions whose first argument has type WGPURenderPipeline. + * + * @{ + */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) 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; + +/** @} */ + +/** + * \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; + +/** @} */ + +/** + * \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; + +/** @} */ + +/** + * \defgroup WGPUSupportedFeaturesMethods WGPUSupportedFeatures methods + * \brief Functions whose first argument has type WGPUSupportedFeatures. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup WGPUSupportedInstanceFeaturesMethods WGPUSupportedInstanceFeatures methods + * \brief Functions whose first argument has type WGPUSupportedInstanceFeatures. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedInstanceFeaturesFreeMembers(WGPUSupportedInstanceFeatures supportedInstanceFeatures) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup WGPUSupportedWGSLLanguageFeaturesMethods WGPUSupportedWGSLLanguageFeatures methods + * \brief Functions whose first argument has type WGPUSupportedWGSLLanguageFeatures. + * + * @{ + */ +/** + * Frees members 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; +/** + * 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 @ref 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; +/** + * 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 wgpuSurfaceAddRef(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ + +/** + * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods + * \brief Functions whose first argument has type WGPUSurfaceCapabilities. + * + * @{ + */ +/** + * Frees members 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. + * + * @{ + */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +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; +WGPU_EXPORT WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +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 WGPUTextureViewDimension wgpuTextureGetTextureBindingViewDimension(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, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureAddRef(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) 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) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBGPU_H_ diff --git a/libs/wgpu-native/include/wgpu.h b/libs/wgpu-native/include/wgpu.h new file mode 100644 index 0000000..4bf1979 --- /dev/null +++ b/libs/wgpu-native/include/wgpu.h @@ -0,0 +1,1332 @@ +/** + * @file wgpu.h + * @brief wgpu-native specific extensions to the standard WebGPU C API. + * + * This header defines native-only types, enumerations, structures, and functions + * that extend the WebGPU specification defined in @c webgpu.h. All extension + * enum values and struct type identifiers (@ref WGPUNativeSType) are allocated + * within the @c 0x0003XXXX range reserved for wgpu-native. + * + * Include this header after @c webgpu.h (it is included automatically). + */ +#ifndef WGPU_H_ +#define WGPU_H_ + +#include "webgpu.h" + +typedef enum WGPUNativeSType +{ + // Start at 0003 since that's allocated range for wgpu-native + /** Identifies @ref WGPUDeviceExtras. */ + WGPUSType_DeviceExtras = 0x00030001, + /** Identifies @ref WGPUNativeLimits. */ + WGPUSType_NativeLimits = 0x00030002, + /** Identifies @ref WGPUPipelineLayoutExtras. */ + WGPUSType_PipelineLayoutExtras = 0x00030003, + /** Identifies @ref WGPUShaderSourceGLSL. */ + WGPUSType_ShaderSourceGLSL = 0x00030004, + /** Identifies @ref WGPUInstanceExtras. */ + WGPUSType_InstanceExtras = 0x00030006, + /** Identifies @ref WGPUBindGroupEntryExtras. */ + WGPUSType_BindGroupEntryExtras = 0x00030007, + /** Identifies @ref WGPUBindGroupLayoutEntryExtras. */ + WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, + /** Identifies @ref WGPUQuerySetDescriptorExtras. */ + WGPUSType_QuerySetDescriptorExtras = 0x00030009, + /** Identifies @ref WGPUSurfaceConfigurationExtras. */ + WGPUSType_SurfaceConfigurationExtras = 0x0003000A, + /** Identifies @ref WGPUSurfaceSourceSwapChainPanel. */ + WGPUSType_SurfaceSourceSwapChainPanel = 0x0003000B, + /** Identifies @ref WGPUPrimitiveStateExtras. */ + WGPUSType_PrimitiveStateExtras = 0x0003000C, + WGPUNativeSType_Force32 = 0x7FFFFFFF +} WGPUNativeSType; + +/** + * Additional surface-get-current-texture status codes defined by wgpu-native. + * + * These extend the standard @c WGPUSurfaceGetCurrentTextureStatus values. + */ +typedef enum WGPUNativeSurfaceGetCurrentTextureStatus +{ + /** + * The surface texture was not acquired because the window is occluded + * (e.g. minimized or fully covered by another window). + * + * No texture is returned and the @c texture field of + * @c WGPUSurfaceTexture will be NULL. The surface and swapchain remain + * valid -- there is no need to reconfigure or recreate the surface. + * + * Applications should skip rendering for the current frame and try + * again once the window is no longer occluded. If you are using a + * windowing library such as winit, listen for the window's "occluded" + * event and request a new redraw when the window becomes visible again. + * + * When does this occur? + * + * Currently this status is only produced by the Metal backend on macOS. + * When a window is not visible (checked via the @c NSWindow + * @c occlusionState property), acquiring the next drawable would block + * for up to one second waiting for vsync. wgpu-native returns + * @c Occluded instead to avoid that hang. + * + * Other backends (Vulkan, DX12, GL) do not currently report this + * status; an occluded window on those backends may produce + * @c WGPUSurfaceGetCurrentTextureStatus_Timeout or simply succeed + * normally. + */ + WGPUSurfaceGetCurrentTextureStatus_Occluded = 0x00030001, + WGPUNativeSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF +} WGPUNativeSurfaceGetCurrentTextureStatus; + +/** + * Native-only device features. + * + * These extend the standard @c WGPUFeatureName values and can be passed to + * @c WGPUDeviceDescriptor::requiredFeatures to request additional + * capabilities when creating a device. + */ +typedef enum WGPUNativeFeature +{ + /** + * Allows the use of immediate data: small, fast blocks of memory + * that can be updated inside a render pass, compute pass, or render + * bundle encoder. + * + * Enables @ref wgpuRenderPassEncoderSetImmediates, + * @ref wgpuComputePassEncoderSetImmediates, + * @ref wgpuRenderBundleEncoderSetImmediates, + * non-zero @c immediateDataSize in @ref WGPUPipelineLayoutExtras, + * and non-zero @c maxImmediateSize in @ref WGPUNativeLimits. + * + * A block of immediate data can be declared in WGSL with + * @c var: + * @code + * struct Immediates { example: f32, } + * var c: Immediates; + * @endcode + * + * In GLSL, this corresponds to @c layout(immediates) @c uniform @c Name @c {..}. + * + * Supported platforms: + * - DX12 + * - Vulkan + * - Metal + * - OpenGL (emulated with uniforms) + * - WebGPU + * + * This is a web and native feature. + */ + WGPUNativeFeature_Immediates = 0x00030001, + /** + * Enables device-specific texture format features. + * + * By default only texture format properties as defined by the WebGPU + * specification are allowed. Enabling this feature flag extends the + * features of each format to the ones supported by the current device. + * Note that without this flag, read/write storage access is not allowed + * at all. + * + * This extension does not enable additional formats. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_TextureAdapterSpecificFormatFeatures = 0x00030002, + /** + * Allows the use of a buffer containing the actual number of draw calls. + * + * Enables @ref wgpuRenderPassEncoderMultiDrawIndirectCount and + * @ref wgpuRenderPassEncoderMultiDrawIndexedIndirectCount. + * + * This feature being present also implies that all calls to + * @ref wgpuRenderPassEncoderMultiDrawIndirect and + * @ref wgpuRenderPassEncoderMultiDrawIndexedIndirect are not being + * emulated with a series of @c draw_indirect calls. + * + * Supported platforms: + * - DX12 + * - Vulkan 1.2+ (or VK_KHR_draw_indirect_count) + * + * This is a native only feature. + */ + WGPUNativeFeature_MultiDrawIndirectCount = 0x00030004, + /** + * Enables bindings of writable storage buffers and textures visible + * to vertex shaders. + * + * Note: some (tiled-based) platforms do not support vertex shaders + * with any side-effects. + * + * Supported platforms: + * - All + * + * This is a native only feature. + */ + WGPUNativeFeature_VertexWritableStorage = 0x00030005, + /** + * Allows the user to create uniform arrays of textures in shaders: + * + * - WGSL: @c var @c textures: @c binding_array, @c 10> + * - GLSL: @c uniform @c texture2D @c textures[10] + * + * If @ref WGPUNativeFeature_StorageResourceBindingArray is supported + * as well as this, the user may also create uniform arrays of storage + * textures. + * + * This capability allows them to exist and to be indexed by dynamically + * uniform values. + * + * Supported platforms: + * - DX12 + * - Metal (with MSL 2.0+ on macOS 10.13+) + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_TextureBindingArray = 0x00030006, + /** + * Allows shaders to index sampled texture and storage buffer resource + * arrays with dynamically non-uniform values: + * + * e.g. @c texture_array[vertex_data] + * + * In order to use this capability, the corresponding GLSL extension must + * be enabled: + * + * @c \#extension @c GL_EXT_nonuniform_qualifier @c : @c require + * + * and then used either as @c nonuniformEXT qualifier in variable + * declaration or as @c nonuniformEXT constructor. + * + * WGSL and HLSL do not need any extension. + * + * Supported platforms: + * - DX12 + * - Metal (with MSL 2.0+ on macOS 10.13+) + * - Vulkan 1.2+ (or VK_EXT_descriptor_indexing) + * + * This is a native only feature. + */ + WGPUNativeFeature_SampledTextureAndStorageBufferArrayNonUniformIndexing = 0x00030007, + /** + * Enables use of Pipeline Statistics Queries. These queries report the + * count of various operations performed between the start and stop call. + * + * Use @ref wgpuRenderPassEncoderBeginPipelineStatisticsQuery / + * @ref wgpuRenderPassEncoderEndPipelineStatisticsQuery (or the compute + * pass equivalents) to start and stop a query. + * + * They must be resolved using @c wgpuCommandEncoderResolveQuerySet into + * a buffer. See @ref WGPUPipelineStatisticName for the list of available + * statistics. + * + * Supported platforms: + * - Vulkan + * - DX12 + * + * This is a native only feature. + */ + WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008, + /** + * Allows the user to create uniform arrays of storage buffers or + * textures in shaders, if @ref WGPUNativeFeature_BufferBindingArray + * or @ref WGPUNativeFeature_TextureBindingArray (respectively) + * is also supported. + * + * This capability allows them to exist and to be indexed by dynamically + * uniform values. + * + * Supported platforms: + * - Metal (with MSL 2.2+ on macOS 10.13+) + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_StorageResourceBindingArray = 0x00030009, + /** + * Allows the user to create bind groups containing arrays with fewer + * bindings than the @c WGPUBindGroupLayout requires. + * + * Supported platforms: + * - Vulkan + * - DX12 + * + * This is a native only feature. + */ + WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, + /** + * Enables normalized 16-bit texture formats: + * @ref WGPUNativeTextureFormat_R16Unorm, @ref WGPUNativeTextureFormat_R16Snorm, + * @ref WGPUNativeTextureFormat_Rg16Unorm, @ref WGPUNativeTextureFormat_Rg16Snorm, + * @ref WGPUNativeTextureFormat_Rgba16Unorm, @ref WGPUNativeTextureFormat_Rgba16Snorm. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B, + /** + * Enables ASTC HDR family of compressed textures. + * + * Compressed textures sacrifice some quality in exchange for + * significantly reduced bandwidth usage. + * + * Support for this feature guarantees availability of + * @c COPY_SRC | @c COPY_DST | @c TEXTURE_BINDING for ASTC formats + * with the HDR channel type. + * @ref WGPUNativeFeature_TextureAdapterSpecificFormatFeatures may + * enable additional usages. + * + * Supported platforms: + * - Metal + * - Vulkan + * - OpenGL + * + * This is a native only feature. + */ + WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C, + /** + * Removes the WebGPU restriction that @c MAP_READ and @c MAP_WRITE + * buffer usages must be paired exclusively with @c COPY_DST and + * @c COPY_SRC respectively. + * + * This is only beneficial on systems that share memory between CPU and + * GPU. If enabled on a system that doesn't, this can severely hinder + * performance. Only use if you understand the consequences. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E, + /** + * Allows the user to create arrays of buffers in shaders: + * + * - WGSL: @c var @c buffer_array: @c array + * - GLSL: @c uniform @c myBuffer @c { @c ... @c } @c buffer_array[10] + * + * This capability allows them to exist and to be indexed by dynamically + * uniform values. + * + * If @ref WGPUNativeFeature_StorageResourceBindingArray is supported as + * well as this, the user may also create arrays of storage buffers. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_BufferBindingArray = 0x0003000F, + /** + * Allows shaders to index uniform buffer and storage texture resource + * arrays with dynamically non-uniform values. + * + * This is a native only feature. + */ + WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010, + // TODO: requires wgpu.h api change + // WGPUNativeFeature_AddressModeClampToZero = 0x00030011, + // WGPUNativeFeature_AddressModeClampToBorder = 0x00030012, + /** + * Allows the user to set @ref WGPUPolygonMode_Line in + * @ref WGPUPrimitiveStateExtras::polygonMode. + * + * This allows drawing polygons/triangles as lines (wireframe) instead + * of filled. + * + * Supported platforms: + * - DX12 + * - Vulkan + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_PolygonModeLine = 0x00030013, + /** + * Allows the user to set @ref WGPUPolygonMode_Point in + * @ref WGPUPrimitiveStateExtras::polygonMode. + * + * This allows only drawing the vertices of polygons/triangles instead + * of filled. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_PolygonModePoint = 0x00030014, + /** + * Allows the user to enable overestimation conservative rasterization + * via @ref WGPUPrimitiveStateExtras::conservative. + * + * Processing of degenerate triangles/lines is hardware specific. + * Only triangles are supported. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_ConservativeRasterization = 0x00030015, + // WGPUNativeFeature_ClearTexture = 0x00030016, + /** + * Enables creating shader modules from pre-compiled SPIR-V binary via + * @ref wgpuDeviceCreateShaderModuleSpirV. + * + * Shader code isn't parsed or interpreted in any way. It is the caller's + * responsibility to ensure the code is correct. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * - WebGPU + * + * This is a native only feature. + */ + WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, + // WGPUNativeFeature_Multiview = 0x00030018, + /** + * Enables using 64-bit types for vertex attributes. + * + * Requires @ref WGPUNativeFeature_ShaderF64. + * + * This is a native only feature. + */ + WGPUNativeFeature_VertexAttribute64bit = 0x00030019, + /** + * Allows for creation of textures of format + * @ref WGPUNativeTextureFormat_NV12. + * + * Supported platforms: + * - DX12 + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, + /** + * Allows for the creation of ray-tracing queries within shaders. + * + * @b EXPERIMENTAL: Features enabled by this may have major bugs and are + * expected to be subject to breaking changes. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_RayQuery = 0x0003001C, + /** + * Enables 64-bit floating point types in SPIR-V shaders. + * + * Note: even when supported by GPU hardware, 64-bit floating point + * operations are frequently between 16 and 64 @e times slower than + * equivalent operations on 32-bit floats. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_ShaderF64 = 0x0003001D, + /** + * Allows shaders to use i16. Not currently supported in naga, only + * available through SPIR-V passthrough. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_ShaderI16 = 0x0003001E, + /** + * Allows shaders to use the @c early_depth_test attribute. + * + * The attribute is applied to the fragment shader entry point and can be + * used in two ways: + * + * 1. Force early depth/stencil tests: + * - WGSL: @c \@early_depth_test(force) + * - GLSL: @c layout(early_fragment_tests) @c in; + * + * 2. Provide a conservative depth specifier that allows an additional + * early depth test under certain conditions: + * - WGSL: @c \@early_depth_test(greater_equal/less_equal/unchanged) + * - GLSL: @c layout(depth_) @c out @c float @c gl_FragDepth; + * + * Supported platforms: + * - Vulkan + * - GLES 3.1+ + * + * This is a native only feature. + */ + WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, + /** + * Allows compute and fragment shaders to use the subgroup operation + * built-ins and perform subgroup operations (except barriers). + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_Subgroup = 0x00030021, + /** + * Allows vertex shaders to use the subgroup operation built-ins and + * perform subgroup operations (except barriers). + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_SubgroupVertex = 0x00030022, + /** + * Allows compute shaders to use the subgroup barrier. + * + * Requires @ref WGPUNativeFeature_Subgroup. Without it, enables nothing. + * + * Supported platforms: + * - Vulkan + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_SubgroupBarrier = 0x00030023, + /** + * Allows for timestamp queries directly on command encoders. + * + * Implies @c WGPUFeatureName_TimestampQuery is supported. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * - OpenGL (with GL_ARB_timer_query) + * + * This is a native only feature. + */ + WGPUNativeFeature_TimestampQueryInsideEncoders = 0x00030024, + /** + * Allows for timestamp queries inside render and compute passes. + * + * Implies @c WGPUFeatureName_TimestampQuery and + * @ref WGPUNativeFeature_TimestampQueryInsideEncoders are supported. + * + * Enables @ref wgpuRenderPassEncoderWriteTimestamp and + * @ref wgpuComputePassEncoderWriteTimestamp. + * + * This is generally not available on tile-based rasterization GPUs. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal (AMD & Intel, not Apple GPUs) + * - OpenGL (with GL_ARB_timer_query) + * + * This is a native only feature. + */ + WGPUNativeFeature_TimestampQueryInsidePasses = 0x00030025, + /** + * Allows shaders to use i64 and u64. + * + * Supported platforms: + * - Vulkan + * - DX12 (DXC only) + * - Metal (with MSL 2.3+) + * + * This is a native only feature. + */ + WGPUNativeFeature_ShaderInt64 = 0x00030026, + WGPUNativeFeature_Force32 = 0x7FFFFFFF +} WGPUNativeFeature; + +typedef enum WGPULogLevel +{ + WGPULogLevel_Off = 0x00000000, + /** Only error messages. */ + WGPULogLevel_Error = 0x00000001, + /** Errors and warnings. */ + WGPULogLevel_Warn = 0x00000002, + /** Errors, warnings, and informational messages. */ + WGPULogLevel_Info = 0x00000003, + /** Errors, warnings, informational, and debug messages. */ + WGPULogLevel_Debug = 0x00000004, + /** All messages, including very verbose trace-level output. */ + WGPULogLevel_Trace = 0x00000005, + WGPULogLevel_Force32 = 0x7FFFFFFF +} WGPULogLevel; + +/** + * Bitflags selecting which graphics backends the @ref WGPUInstance should + * enable. + * + * Pass in the @c backends field of @ref WGPUInstanceExtras. + */ +typedef WGPUFlags WGPUInstanceBackend; +/** All backends (the default when zero-initialized). */ +static const WGPUInstanceBackend WGPUInstanceBackend_All = 0x00000000; +/** + * Vulkan backend. + * Supported on Windows, Linux/Android, and macOS/iOS via Vulkan Portability. + */ +static const WGPUInstanceBackend WGPUInstanceBackend_Vulkan = 1 << 0; +/** + * OpenGL / OpenGL ES backend. + * Supported on Linux/Android, the web via WebGL, and Windows/macOS via ANGLE. + */ +static const WGPUInstanceBackend WGPUInstanceBackend_GL = 1 << 1; +/** + * Metal backend. + * Supported on macOS and iOS. + */ +static const WGPUInstanceBackend WGPUInstanceBackend_Metal = 1 << 2; +/** + * Direct3D 12 backend. + * Supported on Windows 10 and later. + */ +static const WGPUInstanceBackend WGPUInstanceBackend_DX12 = 1 << 3; +/** + * Browser WebGPU backend. + * Supported when targeting the web through WebAssembly. + */ +static const WGPUInstanceBackend WGPUInstanceBackend_BrowserWebGPU = 1 << 5; +/** Primary (first-tier) backends: Vulkan, Metal, DX12, and BrowserWebGPU. */ +static const WGPUInstanceBackend WGPUInstanceBackend_Primary = (1 << 0) | (1 << 2) | (1 << 3) | (1 << 5); +/** Secondary (second-tier) backends: GL. */ +static const WGPUInstanceBackend WGPUInstanceBackend_Secondary = (1 << 1); +static const WGPUInstanceBackend WGPUInstanceBackend_Force32 = 0x7FFFFFFF; + +/** + * Bitflags controlling instance debugging and validation behavior. + * + * These are not part of the WebGPU standard. + * + * Pass in the @c flags field of @ref WGPUInstanceExtras. + */ +typedef WGPUFlags WGPUInstanceFlag; +/** No flags set. */ +static const WGPUInstanceFlag WGPUInstanceFlag_Empty = 0x00000000; +/** + * Generate debug information in shaders and objects. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_DEBUG environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_Debug = 1 << 0; +/** + * Enable validation in the backend API, if possible: + * + * - On the DX12 backend, this calls @c ID3D12Debug::EnableDebugLayer. + * - On the Vulkan backend, this enables the Vulkan Validation Layers. + * - On the GLES backend (Windows), this enables debug output. + * - On the GLES backend (non-Windows), this calls @c eglDebugMessageControlKHR. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_VALIDATION environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_Validation = 1 << 1; +/** + * Don't pass labels to the backend API (wgpu-hal). + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_DISCARD_HAL_LABELS environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_DiscardHalLabels = 1 << 2; +/** + * Whether wgpu should expose adapters that run on top of non-compliant + * adapters. + * + * Turning this on might mean that some of the functionality provided by the + * wgpu adapter/device is not working or broken. This mainly applies to a + * Vulkan driver's compliance version. If the major compliance version is 0, + * then the driver is ignored unless this flag is set. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_AllowUnderlyingNoncompliantAdapter = 1 << 3; +/** + * Enable GPU-based validation. Implies @ref WGPUInstanceFlag_Validation. + * Currently only changes behavior on the DX12 and Vulkan backends. + * + * - D3D12: Called "GPU-based validation" (GBV). + * - Vulkan: Called "GPU-Assisted Validation" via VK_LAYER_KHRONOS_validation. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_GPU_BASED_VALIDATION environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_GPUBasedValidation = 1 << 4; +/** + * Validate indirect buffer content prior to issuing indirect draws/dispatches. + * + * This validation will transform indirect calls into no-ops if they are not + * valid. For example, @c dispatch_workgroups_indirect arguments must be less + * than the @c max_compute_workgroups_per_dimension device limit. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_VALIDATION_INDIRECT_CALL environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_ValidationIndirectCall = 1 << 5; +/** + * Enable automatic timestamp normalization. When enabled, + * @c wgpuCommandEncoderResolveQuerySet will automatically normalize timestamps + * to nanoseconds instead of returning raw timestamp values. + * + * This introduces a compute shader into the resolution of query sets. When + * enabled, the timestamp period returned by @ref wgpuQueueGetTimestampPeriod + * will always be @c 1.0. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_AutomaticTimestampNormalization = 1 << 6; +/** + * Use the default flags for the current build configuration. + * In debug builds, this typically enables @ref WGPUInstanceFlag_Debug and + * @ref WGPUInstanceFlag_Validation. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_Default = 1 << 24; +/** + * Convenience alias that enables @ref WGPUInstanceFlag_Debug and + * @ref WGPUInstanceFlag_Validation. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_Debugging = 1 << 25; +/** + * Convenience alias that enables @ref WGPUInstanceFlag_Debug, + * @ref WGPUInstanceFlag_Validation, and + * @ref WGPUInstanceFlag_GPUBasedValidation. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_AdvancedDebugging = 1 << 26; +/** + * Modify the flags based on environment variables. Flags with environment + * variable support (e.g. @c WGPU_DEBUG, @c WGPU_VALIDATION) will be read + * from the process environment and applied on top of the explicitly set flags. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_WithEnv = 1 << 27; +static const WGPUInstanceFlag WGPUInstanceFlag_Force32 = 0x7FFFFFFF; + +typedef enum WGPUDx12Compiler +{ + WGPUDx12Compiler_Undefined = 0x00000000, + /** + * Use the FXC (D3DCompile) shader compiler. + * + * The FXC compiler is old, slow, and unmaintained. However, it doesn't + * require any additional DLLs to be shipped with the application. + */ + WGPUDx12Compiler_Fxc = 0x00000001, + /** + * Use the DXC (DirectX Shader Compiler). + * + * The DXC compiler is new, fast, and maintained. However, it requires + * @c dxcompiler.dll to be available. The path to this DLL can be + * specified via @ref WGPUInstanceExtras::dxcPath. + * + * Minimum supported version: v1.8.2502. + * Requires WDDM 2.1 (Windows 10 version 1607). + */ + WGPUDx12Compiler_Dxc = 0x00000002, + WGPUDx12Compiler_Force32 = 0x7FFFFFFF +} WGPUDx12Compiler; + +typedef enum WGPUGles3MinorVersion +{ + WGPUGles3MinorVersion_Automatic = 0x00000000, + /** Request an ES 3.0 context. */ + WGPUGles3MinorVersion_Version0 = 0x00000001, + /** Request an ES 3.1 context. */ + WGPUGles3MinorVersion_Version1 = 0x00000002, + /** Request an ES 3.2 context. */ + WGPUGles3MinorVersion_Version2 = 0x00000003, + WGPUGles3MinorVersion_Force32 = 0x7FFFFFFF +} WGPUGles3MinorVersion; + +typedef enum WGPUPipelineStatisticName +{ + WGPUPipelineStatisticName_VertexShaderInvocations = 0x00000000, + /** + * Number of times the clipper is invoked. This is also the number of + * triangles output by the vertex shader. + */ + WGPUPipelineStatisticName_ClipperInvocations = 0x00000001, + /** + * Number of primitives that are not culled by the clipper. This is the + * number of triangles that are actually on screen and will be rasterized + * and rendered. + */ + WGPUPipelineStatisticName_ClipperPrimitivesOut = 0x00000002, + /** + * Number of times the fragment shader is invoked. Accounts for fragment + * shaders running in 2x2 blocks in order to get derivatives. + */ + WGPUPipelineStatisticName_FragmentShaderInvocations = 0x00000003, + /** + * Number of times a compute shader is invoked. This will be equivalent + * to the dispatch count times the workgroup size. + */ + WGPUPipelineStatisticName_ComputeShaderInvocations = 0x00000004, + WGPUPipelineStatisticName_Force32 = 0x7FFFFFFF +} WGPUPipelineStatisticName WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUNativeQueryType +{ + WGPUNativeQueryType_PipelineStatistics = 0x00030000, + WGPUNativeQueryType_Force32 = 0x7FFFFFFF +} WGPUNativeQueryType WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUDxcMaxShaderModel +{ + WGPUDxcMaxShaderModel_V6_0 = 0x00000000, + /** Shader Model 6.1 */ + WGPUDxcMaxShaderModel_V6_1 = 0x00000001, + /** Shader Model 6.2 */ + WGPUDxcMaxShaderModel_V6_2 = 0x00000002, + /** Shader Model 6.3 */ + WGPUDxcMaxShaderModel_V6_3 = 0x00000003, + /** Shader Model 6.4 */ + WGPUDxcMaxShaderModel_V6_4 = 0x00000004, + /** Shader Model 6.5 */ + WGPUDxcMaxShaderModel_V6_5 = 0x00000005, + /** Shader Model 6.6 */ + WGPUDxcMaxShaderModel_V6_6 = 0x00000006, + /** Shader Model 6.7 */ + WGPUDxcMaxShaderModel_V6_7 = 0x00000007, + WGPUDxcMaxShaderModel_Force32 = 0x7FFFFFFF +} WGPUDxcMaxShaderModel; + +typedef enum WGPUGLFenceBehaviour +{ + WGPUGLFenceBehaviour_Normal = 0x00000000, + /** + * Fences are short-circuited to always report completion immediately. + * + * This solves a specific issue that arose due to a bug in wgpu-core that + * made many WebGL programs work when they shouldn't have. If you have + * code that calls @ref wgpuDevicePoll with @c wait=true on WebGL, you + * may need to enable this option for "wait" to behave how you expect. + * + * When this is set, @c wgpuQueueOnCompletedWorkDone callbacks will fire + * the next time the device is polled, not when work is actually done on + * the GPU. + */ + WGPUGLFenceBehaviour_AutoFinish = 0x00000001, + WGPUGLFenceBehaviour_Force32 = 0x7FFFFFFF +} WGPUGLFenceBehaviour; + +typedef enum WGPUDx12SwapchainKind +{ + WGPUDx12SwapchainKind_Undefined = 0x00000000, + /** + * Use a DXGI swapchain created directly from the window's HWND. + * + * This does not support transparency but has better support from + * developer tooling such as RenderDoc. + */ + WGPUDx12SwapchainKind_DxgiFromHwnd = 0x00000001, + /** + * Use a DXGI swapchain created from a DirectComposition visual made + * automatically from the window's HWND. + * + * This creates a single @c IDCompositionVisual over the entire window. + * Supports transparency. If you want to manage the composition tree + * yourself, create your own device and composition and pass the relevant + * visual via the surface target. + */ + WGPUDx12SwapchainKind_DxgiFromVisual = 0x00000002, + WGPUDx12SwapchainKind_Force32 = 0x7FFFFFFF +} WGPUDx12SwapchainKind; + +/** + * Discriminant for @ref WGPUNativeDisplayHandle. + * + * Identifies which platform's display connection is stored in the tagged union. + * Use @ref WGPUNativeDisplayHandleType_None (the default when zero-initialized) when + * no display handle is needed. Platforms with no display connection data (Windows, + * macOS, iOS, Android) should use @ref WGPUNativeDisplayHandleType_None. + */ +typedef enum WGPUNativeDisplayHandleType +{ + /** No display handle provided. */ + WGPUNativeDisplayHandleType_None = 0x00000000, + /** X11 display connection via Xlib. See @ref WGPUXlibDisplayHandle. */ + WGPUNativeDisplayHandleType_Xlib = 0x00000001, + /** X11 display connection via XCB. See @ref WGPUXcbDisplayHandle. */ + WGPUNativeDisplayHandleType_Xcb = 0x00000002, + /** Wayland display connection. See @ref WGPUWaylandDisplayHandle. */ + WGPUNativeDisplayHandleType_Wayland = 0x00000003, + WGPUNativeDisplayHandleType_Force32 = 0x7FFFFFFF +} WGPUNativeDisplayHandleType; + +/** + * Xlib display connection data for @ref WGPUNativeDisplayHandle. + */ +typedef struct WGPUXlibDisplayHandle +{ + /** Pointer to the X11 @c Display (i.e. @c Display*). Must not be NULL. */ + void *display; + /** X11 screen number. */ + int screen; +} WGPUXlibDisplayHandle; + +/** + * XCB display connection data for @ref WGPUNativeDisplayHandle. + */ +typedef struct WGPUXcbDisplayHandle +{ + /** Pointer to the XCB connection (i.e. @c xcb_connection_t*). Must not be NULL. */ + void *connection; + /** X11 screen number. */ + int screen; +} WGPUXcbDisplayHandle; + +/** + * Wayland display connection data for @ref WGPUNativeDisplayHandle. + */ +typedef struct WGPUWaylandDisplayHandle +{ + /** Pointer to the Wayland display (i.e. @c wl_display*). Must not be NULL. */ + void *display; +} WGPUWaylandDisplayHandle; + +/** + * Platform display connection, passed as a field of @ref WGPUInstanceExtras. + * + * This is a tagged union. Set @c type to indicate which variant is active, then + * populate the corresponding field in @c data. Zero-initialization yields + * @ref WGPUNativeDisplayHandleType_None, meaning no display handle is provided. + * + * Currently required by the GLES backend when presenting on Wayland. Other + * backends ignore this field. If the instance is created with a display handle, + * all surfaces created from it must use the same display connection. + */ +typedef struct WGPUNativeDisplayHandle +{ + WGPUNativeDisplayHandleType type; + union + { + WGPUXlibDisplayHandle xlib; + WGPUXcbDisplayHandle xcb; + WGPUWaylandDisplayHandle wayland; + } data; +} WGPUNativeDisplayHandle; + +typedef struct WGPUInstanceExtras +{ + WGPUChainedStruct chain; + /** + * Which backends to enable. + * Zero (@ref WGPUInstanceBackend_All) enables all backends. + */ + WGPUInstanceBackend backends; + /** + * Flags controlling debug/validation behavior. + * See @ref WGPUInstanceFlag for available flags. + */ + WGPUInstanceFlag flags; + /** + * Which DX12 shader compiler to use. + * See @ref WGPUDx12Compiler. Ignored on non-DX12 backends. + */ + WGPUDx12Compiler dx12ShaderCompiler; + /** + * Which OpenGL ES 3 minor version to request. + * See @ref WGPUGles3MinorVersion. Ignored on non-GL backends. + */ + WGPUGles3MinorVersion gles3MinorVersion; + /** + * Controls OpenGL fence synchronization behavior. + * See @ref WGPUGLFenceBehaviour. Ignored on non-GL backends. + */ + WGPUGLFenceBehaviour glFenceBehaviour; + /** + * File system path to @c dxcompiler.dll for dynamic DXC loading. + * Only used when @c dx12ShaderCompiler is @ref WGPUDx12Compiler_Dxc. + * An empty/undefined string view means the DLL will be searched for + * on the system PATH. + */ + WGPUStringView dxcPath; + /** + * Maximum HLSL shader model version that DXC should target. + * See @ref WGPUDxcMaxShaderModel. Only used with the DXC compiler. + */ + WGPUDxcMaxShaderModel dxcMaxShaderModel; + /** + * Which DX12 presentation system (swapchain kind) to use. + * See @ref WGPUDx12SwapchainKind. Ignored on non-DX12 backends. + */ + WGPUDx12SwapchainKind dx12PresentationSystem; + + WGPU_NULLABLE const uint8_t *budgetForDeviceCreation; + WGPU_NULLABLE const uint8_t *budgetForDeviceLoss; + + /** + * Platform display connection to associate with this instance. + * Zero-initialized yields @ref WGPUNativeDisplayHandleType_None (no handle). + */ + WGPUNativeDisplayHandle displayHandle; +} WGPUInstanceExtras; + +typedef struct WGPUDeviceExtras +{ + WGPUChainedStruct chain; + /** + * File system path for API trace output. + * + * When set to a non-empty path, wgpu will record all API calls to + * the given directory, which can later be replayed for debugging. + * An empty/undefined string view disables tracing. + */ + WGPUStringView tracePath; +} WGPUDeviceExtras; + +typedef struct WGPUNativeLimits +{ + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStruct chain; + /** + * Amount of storage available for immediate data, in bytes. + * + * Defaults to 0. A non-zero value requires + * @ref WGPUNativeFeature_Immediates. Expected maximum sizes vary by + * backend: + * - Vulkan: 128-256 bytes + * - DX12: 128 bytes + * - Metal: 4096 bytes + * - OpenGL: ~256 bytes (emulated with uniforms) + */ + uint32_t maxImmediateSize; + /** + * Maximum number of live non-sampler bindings. + * + * Default is 1,000,000. Only meaningful on D3D12. + * + * @b Warning: On integrated GPUs, large values can cause significant + * system RAM consumption. + */ + uint32_t maxNonSamplerBindings; + /** + * Maximum number of individual resources within binding arrays per + * shader stage. + */ + uint32_t maxBindingArrayElementsPerShaderStage; +} WGPUNativeLimits; + +typedef struct WGPUPipelineLayoutExtras +{ + WGPUChainedStruct chain; + /** + * The number of bytes of immediate data allocated for use in shaders + * attached to this pipeline. + * + * The @c var declarations in the shader must be equal or + * smaller than this size. If this value is non-zero, + * @ref WGPUNativeFeature_Immediates must be enabled. + */ + uint32_t immediateDataSize; +} WGPUPipelineLayoutExtras; + +/** + * Identifier for a particular call to @ref wgpuQueueSubmitForIndex. + * + * Can be passed to @ref wgpuDevicePoll to block until a particular + * submission has finished execution. + * + * This type is unique to wgpu-native; there is no analogue in the + * WebGPU specification. + */ +typedef uint64_t WGPUSubmissionIndex; + +typedef struct WGPUShaderDefine +{ + WGPUStringView name; + /** The value of the preprocessor macro (e.g. @c "1"). */ + WGPUStringView value; +} WGPUShaderDefine; + +typedef struct WGPUShaderSourceGLSL +{ + WGPUChainedStruct chain; + /** The shader stage this GLSL source targets. */ + WGPUShaderStage stage; + /** GLSL source code. */ + WGPUStringView code; + /** Number of entries in @c defines. */ + uint32_t defineCount; + WGPUShaderDefine const *defines; +} WGPUShaderSourceGLSL; + +typedef struct WGPUShaderModuleDescriptorSpirV +{ + WGPUStringView label; + /** Number of 32-bit words in @c source. */ + uint32_t sourceSize; + uint32_t const *source; +} WGPUShaderModuleDescriptorSpirV; + +typedef struct WGPURegistryReport +{ + size_t numAllocated; + size_t numKeptFromUser; + size_t numReleasedFromUser; + size_t elementSize; +} WGPURegistryReport; + +typedef struct WGPUHubReport +{ + WGPURegistryReport adapters; + WGPURegistryReport devices; + WGPURegistryReport queues; + WGPURegistryReport pipelineLayouts; + WGPURegistryReport shaderModules; + WGPURegistryReport bindGroupLayouts; + WGPURegistryReport bindGroups; + WGPURegistryReport commandBuffers; + WGPURegistryReport renderBundles; + WGPURegistryReport renderPipelines; + WGPURegistryReport computePipelines; + WGPURegistryReport pipelineCaches; + WGPURegistryReport querySets; + WGPURegistryReport buffers; + WGPURegistryReport textures; + WGPURegistryReport textureViews; + WGPURegistryReport samplers; +} WGPUHubReport; + +typedef struct WGPUGlobalReport +{ + WGPURegistryReport surfaces; + /** Statistics for all other resource types, grouped by backend hub. */ + WGPUHubReport hub; +} WGPUGlobalReport; + +typedef struct WGPUInstanceEnumerateAdapterOptions +{ + WGPUChainedStruct const *nextInChain; + WGPUInstanceBackend backends; +} WGPUInstanceEnumerateAdapterOptions; + +typedef struct WGPUBindGroupEntryExtras +{ + WGPUChainedStruct chain; + WGPUBuffer const *buffers; + size_t bufferCount; + WGPUSampler const *samplers; + size_t samplerCount; + WGPUTextureView const *textureViews; + size_t textureViewCount; +} WGPUBindGroupEntryExtras; + +typedef struct WGPUBindGroupLayoutEntryExtras +{ + WGPUChainedStruct chain; + /** + * Number of resources in this binding array slot. Corresponds to the + * array size in the shader (e.g. @c binding_array). + */ + uint32_t count; +} WGPUBindGroupLayoutEntryExtras; + +typedef struct WGPUQuerySetDescriptorExtras +{ + WGPUChainedStruct chain; + WGPUPipelineStatisticName const *pipelineStatistics; + size_t pipelineStatisticCount; +} WGPUQuerySetDescriptorExtras WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUSurfaceConfigurationExtras +{ + WGPUChainedStruct chain; + /** + * Desired maximum number of frames in flight (i.e. the number of monitor + * refreshes between @c wgpuSurfaceGetCurrentTexture and presentation). + * + * - 1: Minimize latency (CPU and GPU cannot run in parallel). + * - 2: Balance between latency and throughput (the default). + * - 3+: Maximize throughput. + */ + uint32_t desiredMaximumFrameLatency; +} WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Chained in @ref WGPUSurfaceDescriptor to make a @ref WGPUSurface wrapping a WinUI [`SwapChainPanel`](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.swapchainpanel). + */ +typedef struct WGPUSurfaceSourceSwapChainPanel +{ + WGPUChainedStruct chain; + /** + * A pointer to the [`ISwapChainPanelNative`](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/win32/microsoft.ui.xaml.media.dxinterop/nn-microsoft-ui-xaml-media-dxinterop-iswapchainpanelnative) + * interface of the SwapChainPanel that will be wrapped by the @ref WGPUSurface. + */ + void *panelNative; +} WGPUSurfaceSourceSwapChainPanel WGPU_STRUCTURE_ATTRIBUTE; + +typedef enum WGPUPolygonMode +{ + WGPUPolygonMode_Fill = 0, + /** + * Polygons are drawn as line segments (wireframe). + * Requires @ref WGPUNativeFeature_PolygonModeLine. + */ + WGPUPolygonMode_Line = 1, + /** + * Polygons are drawn as points (vertices only). + * Requires @ref WGPUNativeFeature_PolygonModePoint. + */ + WGPUPolygonMode_Point = 2, +} WGPUPolygonMode; + +typedef struct WGPUPrimitiveStateExtras +{ + WGPUChainedStruct chain; + /** + * Controls the way each polygon is rasterized. + * See @ref WGPUPolygonMode. Defaults to @ref WGPUPolygonMode_Fill. + */ + WGPUPolygonMode polygonMode; + /** + * If set to true, the primitives are rendered with conservative + * overestimation. Only valid when @c polygonMode is + * @ref WGPUPolygonMode_Fill. + * Requires @ref WGPUNativeFeature_ConservativeRasterization. + */ + WGPUBool conservative; +} WGPUPrimitiveStateExtras WGPU_STRUCTURE_ATTRIBUTE; + +typedef void (*WGPULogCallback)(WGPULogLevel level, WGPUStringView message, void *userdata); + +typedef enum WGPUNativeTextureFormat +{ + // From Features::TEXTURE_FORMAT_16BIT_NORM + WGPUNativeTextureFormat_R16Unorm = 0x00030001, + /** + * Red channel only. 16-bit signed integer per channel. + * [-32767, 32767] converted to/from float [-1, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ + WGPUNativeTextureFormat_R16Snorm = 0x00030002, + /** + * Red and green channels. 16-bit unsigned integer per channel. + * [0, 65535] converted to/from float [0, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ + WGPUNativeTextureFormat_Rg16Unorm = 0x00030003, + /** + * Red and green channels. 16-bit signed integer per channel. + * [-32767, 32767] converted to/from float [-1, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ + WGPUNativeTextureFormat_Rg16Snorm = 0x00030004, + /** + * Red, green, blue, and alpha channels. 16-bit unsigned integer per channel. + * [0, 65535] converted to/from float [0, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ + WGPUNativeTextureFormat_Rgba16Unorm = 0x00030005, + /** + * Red, green, blue, and alpha channels. 16-bit signed integer per channel. + * [-32767, 32767] converted to/from float [-1, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ + WGPUNativeTextureFormat_Rgba16Snorm = 0x00030006, + /** + * YUV 4:2:0 chroma subsampled format (NV12). + * Plane 0 contains R8Unorm luminance (Y), Plane 1 contains Rg8Unorm + * chrominance (UV) at half width and half height. + * Requires @ref WGPUNativeFeature_TextureFormatNv12. + */ + WGPUNativeTextureFormat_NV12 = 0x00030007, + /** + * YUV 4:2:0 with 10 bits used from 16-bit channels (P010). + * Plane 0 contains R16Unorm luminance (Y), Plane 1 contains Rg16Unorm + * chrominance (UV) at half width and half height. + */ + WGPUNativeTextureFormat_P010 = 0x00030008, +} WGPUNativeTextureFormat; + +#ifdef __cplusplus +extern "C" +{ +#endif + + void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport *report); + size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const *options, WGPUAdapter *adapters); + + WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const *commands); + float wgpuQueueGetTimestampPeriod(WGPUQueue queue); + + // 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 WGPUSubmissionIndex const *submissionIndex); + WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const *descriptor); + + void wgpuSetLogCallback(WGPULogCallback callback, void *userdata); + + void wgpuSetLogLevel(WGPULogLevel level); + + uint32_t wgpuGetVersion(void); + + /** + * Returns the backend-native `id` as an opaque pointer. + * + * The returned pointer is borrowed and remains valid only while `device` is alive. + * Ownership is retained by wgpu-native; callers must not release or destroy it. + * Returns NULL when the active backend is not Metal or when the handle is unavailable. + */ + void *wgpuDeviceGetNativeMetalDevice(WGPUDevice device); + + /** + * Returns the backend-native `id` as an opaque pointer. + * + * The returned pointer is borrowed and remains valid only while `queue` is alive. + * Ownership is retained by wgpu-native; callers must not release or destroy it. + * Returns NULL when the active backend is not Metal or when the handle is unavailable. + */ + void *wgpuQueueGetNativeMetalCommandQueue(WGPUQueue queue); + + /** + * Returns the backend-native `id` as an opaque pointer. + * + * The returned pointer is borrowed and remains valid only while `texture` is alive. + * Ownership is retained by wgpu-native; callers must not release or destroy it. + * Returns NULL when the active backend is not Metal or when the handle is unavailable. + */ + void *wgpuTextureGetNativeMetalTexture(WGPUTexture texture); + + void wgpuRenderPassEncoderSetImmediates(WGPURenderPassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); + void wgpuComputePassEncoderSetImmediates(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); + void wgpuRenderBundleEncoderSetImmediates(WGPURenderBundleEncoder encoder, 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); + + void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); + void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); + + void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder); + 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); + + // Returns true if the capture was successfully started, or false if it failed to start or is not supported on the current platform. + WGPUBool wgpuDeviceStartGraphicsDebuggerCapture(WGPUDevice device); + void wgpuDeviceStopGraphicsDebuggerCapture(WGPUDevice device); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif diff --git a/libs/wgpu-native/lib/libwgpu_native.a b/libs/wgpu-native/lib/libwgpu_native.a new file mode 100644 index 0000000..b10ccf3 Binary files /dev/null and b/libs/wgpu-native/lib/libwgpu_native.a differ diff --git a/libs/wgpu-native/lib/libwgpu_native.so b/libs/wgpu-native/lib/libwgpu_native.so new file mode 100755 index 0000000..e478796 Binary files /dev/null and b/libs/wgpu-native/lib/libwgpu_native.so differ diff --git a/libs/wgpu-native/wgpu-native-meta/webgpu.yml b/libs/wgpu-native/wgpu-native-meta/webgpu.yml new file mode 100644 index 0000000..8177c16 --- /dev/null +++ b/libs/wgpu-native/wgpu-native-meta/webgpu.yml @@ -0,0 +1,5454 @@ +copyright: | + Copyright 2019-2023 WebGPU-Native developers + + SPDX-License-Identifier: BSD-3-Clause +name: webgpu +enum_prefix: 0x0000 +doc: | + **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. + + For all details where behavior is not otherwise specified, `webgpu.h` has + the same behavior as the WebGPU specification for JavaScript on the Web. + The WebIDL-based Web specification is mapped into C as faithfully (and + bidirectionally) as practical/possible. + The working draft of WebGPU can be found at . + + The standard include directive for this header is `#include ` + (if it is provided in a system-wide or toolchain-wide include directory). +constants: + - name: array_layer_count_undefined + value: uint32_max + doc: | + Indicates no array layer count is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: copy_stride_undefined + value: uint32_max + doc: | + Indicates no copy stride is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: depth_clear_value_undefined + value: nan + doc: | + Indicates no depth clear value is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: depth_slice_undefined + value: uint32_max + doc: | + Indicates no depth slice is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: limit_u32_undefined + value: uint32_max + doc: | + For `uint32_t` limits, indicates no limit value is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: limit_u64_undefined + value: uint64_max + doc: | + For `uint64_t` limits, indicates no limit value is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: mip_level_count_undefined + value: uint32_max + doc: | + Indicates no mip level count is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: query_set_index_undefined + value: uint32_max + doc: | + Indicates no query set index is specified. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: strlen + value: usize_max + doc: | + Sentinel value used in @ref WGPUStringView to indicate that the pointer + is to a null-terminated string, rather than an explicitly-sized string. + - name: whole_map_size + value: usize_max + doc: | + Indicates a size extending to the end of the buffer. For more info, + see @ref SentinelValues and the places that use this sentinel value. + - name: whole_size + value: uint64_max + doc: | + Indicates a size extending to the end of the buffer. For more info, + see @ref SentinelValues and the places that use this sentinel value. +typedefs: [] +enums: + - name: adapter_type + doc: | + TODO + entries: + - null + - name: discrete_GPU + doc: | + TODO + - name: integrated_GPU + doc: | + TODO + - name: CPU + doc: | + TODO + - name: unknown + doc: | + TODO + - name: address_mode + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: clamp_to_edge + doc: | + TODO + - name: repeat + doc: | + TODO + - name: mirror_repeat + doc: | + TODO + - name: backend_type + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: "null" + doc: | + TODO + - name: WebGPU + doc: | + TODO + - name: D3D11 + doc: | + TODO + - name: D3D12 + doc: | + TODO + - name: metal + doc: | + TODO + - name: vulkan + doc: | + TODO + - name: openGL + doc: | + TODO + - name: openGLES + doc: | + TODO + - name: blend_factor + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: zero + doc: | + TODO + - name: one + doc: | + TODO + - name: src + doc: | + TODO + - name: one_minus_src + doc: | + TODO + - name: src_alpha + doc: | + TODO + - name: one_minus_src_alpha + doc: | + TODO + - name: dst + doc: | + TODO + - name: one_minus_dst + doc: | + TODO + - name: dst_alpha + doc: | + TODO + - name: one_minus_dst_alpha + doc: | + TODO + - name: src_alpha_saturated + doc: | + TODO + - name: constant + doc: | + TODO + - name: one_minus_constant + doc: | + TODO + - name: src1 + doc: | + TODO + - name: one_minus_src1 + doc: | + TODO + - name: src1_alpha + doc: | + TODO + - name: one_minus_src1_alpha + doc: | + TODO + - name: blend_operation + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: add + doc: | + TODO + - name: subtract + doc: | + TODO + - name: reverse_subtract + doc: | + TODO + - name: min + doc: | + TODO + - name: max + doc: | + TODO + - name: buffer_binding_type + doc: | + TODO + entries: + - name: binding_not_used + doc: | + Indicates that this @ref WGPUBufferBindingLayout member of + its parent @ref WGPUBindGroupLayoutEntry is not used. + (See also @ref SentinelValues.) + - name: undefined + doc: | + `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + - name: uniform + doc: | + TODO + - name: storage + doc: | + TODO + - name: read_only_storage + doc: | + TODO + - name: buffer_map_state + doc: | + TODO + entries: + - null + - name: unmapped + doc: | + TODO + - name: pending + doc: | + TODO + - name: mapped + doc: | + TODO + - name: callback_mode + doc: The callback mode controls how a callback for an asynchronous operation may be fired. See @ref Asynchronous-Operations for how these are used. + entries: + - null + - name: wait_any_only + doc: | + Callbacks created with `WGPUCallbackMode_WaitAnyOnly`: + - fire when the asynchronous operation's future is passed to a call to @ref wgpuInstanceWaitAny + AND the operation has already completed or it completes inside the call to @ref wgpuInstanceWaitAny. + - name: allow_process_events + doc: | + Callbacks created with `WGPUCallbackMode_AllowProcessEvents`: + - fire for the same reasons as callbacks created with `WGPUCallbackMode_WaitAnyOnly` + - fire inside a call to @ref wgpuInstanceProcessEvents if the asynchronous operation is complete. + - name: allow_spontaneous + doc: | + 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`. + - name: compare_function + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: never + doc: | + TODO + - name: less + doc: | + TODO + - name: equal + doc: | + TODO + - name: less_equal + doc: | + TODO + - name: greater + doc: | + TODO + - name: not_equal + doc: | + TODO + - name: greater_equal + doc: | + TODO + - name: always + doc: | + TODO + - name: compilation_info_request_status + doc: | + TODO + entries: + - null + - name: success + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: compilation_message_type + doc: | + TODO + entries: + - null + - name: error + doc: | + TODO + - name: warning + doc: | + TODO + - name: info + doc: | + TODO + - name: component_swizzle + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: zero + doc: | + Force its value to 0. + - name: one + doc: | + Force its value to 1. + - name: r + doc: | + Take its value from the red channel of the texture. + - name: g + doc: | + Take its value from the green channel of the texture. + - name: b + doc: | + Take its value from the blue channel of the texture. + - name: a + doc: | + Take its value from the alpha channel of the texture. + - name: composite_alpha_mode + doc: Describes how frames are composited with other contents on the screen when @ref wgpuSurfacePresent is called. + entries: + - name: auto + doc: Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between @ref WGPUCompositeAlphaMode_Opaque or @ref WGPUCompositeAlphaMode_Inherit. + - name: opaque + doc: The alpha component of the image is ignored and teated as if it is always 1.0. + - name: premultiplied + doc: 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. + - name: unpremultiplied + doc: 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. + - name: inherit + doc: 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). + - name: create_pipeline_async_status + doc: | + TODO + entries: + - null + - name: success + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: validation_error + doc: | + TODO + - name: internal_error + doc: | + TODO + - name: cull_mode + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: none + doc: | + TODO + - name: front + doc: | + TODO + - name: back + doc: | + TODO + - name: device_lost_reason + doc: | + TODO + entries: + - null + - name: unknown + doc: | + TODO + - name: destroyed + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: failed_creation + doc: | + TODO + - name: error_filter + doc: | + TODO + entries: + - null + - name: validation + doc: | + TODO + - name: out_of_memory + doc: | + TODO + - name: internal + doc: | + TODO + - name: error_type + doc: | + TODO + entries: + - null + - name: no_error + doc: | + TODO + - name: validation + doc: | + TODO + - name: out_of_memory + doc: | + TODO + - name: internal + doc: | + TODO + - name: unknown + doc: | + TODO + - name: feature_level + doc: | + See @ref WGPURequestAdapterOptions::featureLevel. + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: compatibility + doc: | + "Compatibility" profile which can be supported on OpenGL ES 3.1 and D3D11. + - name: core + doc: | + "Core" profile which can be supported on Vulkan/Metal/D3D12 (at least). + - name: feature_name + doc: | + TODO + entries: + - null + - name: core_features_and_limits + doc: | + TODO + - name: depth_clip_control + doc: | + TODO + - name: depth32_float_stencil8 + doc: | + TODO + - name: texture_compression_BC + doc: | + TODO + - name: texture_compression_BC_sliced_3D + doc: | + TODO + - name: texture_compression_ETC2 + doc: | + TODO + - name: texture_compression_ASTC + doc: | + TODO + - name: texture_compression_ASTC_sliced_3D + doc: | + TODO + - name: timestamp_query + doc: | + TODO + - name: indirect_first_instance + doc: | + TODO + - name: shader_f16 + doc: | + TODO + - name: RG11B10_ufloat_renderable + doc: | + TODO + - name: BGRA8_unorm_storage + doc: | + TODO + - name: float32_filterable + doc: | + TODO + - name: float32_blendable + doc: | + TODO + - name: clip_distances + doc: | + TODO + - name: dual_source_blending + doc: | + TODO + - name: subgroups + doc: | + TODO + - name: texture_formats_tier_1 + doc: | + TODO + - name: texture_formats_tier_2 + doc: | + TODO + - name: primitive_index + doc: | + TODO + - name: texture_component_swizzle + doc: | + TODO + - name: filter_mode + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: nearest + doc: | + TODO + - name: linear + doc: | + TODO + - name: front_face + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: CCW + doc: | + TODO + - name: CW + doc: | + TODO + - name: index_format + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: uint16 + doc: | + TODO + - name: uint32 + doc: | + TODO + - name: instance_feature_name + doc: | + TODO + entries: + - null + - name: timed_wait_any + doc: | + Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + - name: shader_source_SPIRV + doc: | + Enable passing SPIR-V shaders to @ref wgpuDeviceCreateShaderModule, + via @ref WGPUShaderSourceSPIRV. + - name: multiple_devices_per_adapter + doc: | + Normally, a @ref WGPUAdapter can only create a single device. If this is + available and enabled, then adapters won't immediately expire when they + create a device, so can be reused to make multiple devices. They may + still expire for other reasons. + - name: load_op + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: load + doc: | + TODO + - name: clear + doc: | + TODO + - name: map_async_status + doc: | + TODO + entries: + - null + - name: success + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: error + doc: | + TODO + - name: aborted + doc: | + TODO + - name: mipmap_filter_mode + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: nearest + doc: | + TODO + - name: linear + doc: | + TODO + - name: optional_bool + doc: | + TODO + entries: + - name: "false" + doc: | + TODO + - name: "true" + doc: | + TODO + - name: undefined + doc: | + TODO + - name: pop_error_scope_status + doc: | + TODO + entries: + - null + - name: success + doc: | + The error scope stack was successfully popped and a result was reported. + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: error + doc: | + The error scope stack could not be popped, because it was empty. + - name: power_preference + doc: | + TODO + entries: + - name: undefined + doc: No preference. (See also @ref SentinelValues.) + - name: low_power + doc: | + TODO + - name: high_performance + doc: | + TODO + - name: predefined_color_space + doc: | + TODO + entries: + - null + - name: SRGB + doc: | + TODO + - name: display_p3 + doc: | + TODO + - name: present_mode + doc: Describes when and in which order frames are presented on the screen when @ref wgpuSurfacePresent is called. + entries: + - name: undefined + doc: | + Present mode is not specified. Use the default. + - name: fifo + doc: | + 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. + - name: fifo_relaxed + doc: | + 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. + - name: immediate + doc: | + 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. + - name: mailbox + doc: | + 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. + - name: primitive_topology + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: point_list + doc: | + TODO + - name: line_list + doc: | + TODO + - name: line_strip + doc: | + TODO + - name: triangle_list + doc: | + TODO + - name: triangle_strip + doc: | + TODO + - name: query_type + doc: | + TODO + entries: + - null + - name: occlusion + doc: | + TODO + - name: timestamp + doc: | + TODO + - name: queue_work_done_status + doc: | + TODO + entries: + - null + - name: success + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: error + doc: | + There was some deterministic error. (Note this is currently never used, + but it will be relevant when it's possible to create a queue object.) + - name: request_adapter_status + doc: | + TODO + entries: + - null + - name: success + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: unavailable + doc: | + TODO + - name: error + doc: | + TODO + - name: request_device_status + doc: | + TODO + entries: + - null + - name: success + doc: | + TODO + - name: callback_cancelled + doc: | + See @ref CallbackStatuses. + - name: error + doc: | + TODO + - name: s_type + doc: | + TODO + entries: + - null + - name: shader_source_SPIRV + doc: | + TODO + - name: shader_source_WGSL + doc: | + TODO + - name: render_pass_max_draw_count + doc: | + TODO + - name: surface_source_metal_layer + doc: | + TODO + - name: surface_source_windows_HWND + doc: | + TODO + - name: surface_source_xlib_window + doc: | + TODO + - name: surface_source_wayland_surface + doc: | + TODO + - name: surface_source_android_native_window + doc: | + TODO + - name: surface_source_XCB_window + doc: | + TODO + - name: surface_color_management + doc: | + TODO + - name: request_adapter_WebXR_options + doc: | + TODO + - name: texture_component_swizzle_descriptor + doc: | + TODO + - name: external_texture_binding_layout + doc: | + TODO + - name: external_texture_binding_entry + doc: | + TODO + - name: compatibility_mode_limits + doc: | + TODO + - name: texture_binding_view_dimension + doc: | + TODO + - name: sampler_binding_type + doc: | + TODO + entries: + - name: binding_not_used + doc: | + Indicates that this @ref WGPUSamplerBindingLayout member of + its parent @ref WGPUBindGroupLayoutEntry is not used. + (See also @ref SentinelValues.) + - name: undefined + doc: | + `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + - name: filtering + doc: | + TODO + - name: non_filtering + doc: | + TODO + - name: comparison + doc: | + TODO + - name: status + doc: | + 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. + entries: + - null + - name: success + doc: "" + - name: error + doc: "" + - name: stencil_operation + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: keep + doc: | + TODO + - name: zero + doc: | + TODO + - name: replace + doc: | + TODO + - name: invert + doc: | + TODO + - name: increment_clamp + doc: | + TODO + - name: decrement_clamp + doc: | + TODO + - name: increment_wrap + doc: | + TODO + - name: decrement_wrap + doc: | + TODO + - name: storage_texture_access + doc: | + TODO + entries: + - name: binding_not_used + doc: | + Indicates that this @ref WGPUStorageTextureBindingLayout member of + its parent @ref WGPUBindGroupLayoutEntry is not used. + (See also @ref SentinelValues.) + - name: undefined + doc: | + `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + - name: write_only + doc: | + TODO + - name: read_only + doc: | + TODO + - name: read_write + doc: | + TODO + - name: store_op + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: store + doc: | + TODO + - name: discard + doc: | + TODO + - name: surface_get_current_texture_status + doc: The status enum for @ref wgpuSurfaceGetCurrentTexture. + entries: + - null + - name: success_optimal + doc: Yay! Everything is good and we can render this frame. + - name: success_suboptimal + doc: Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + - name: timeout + doc: Some operation timed out while trying to acquire the frame. + - name: outdated + doc: The surface is too different to be used, compared to when it was originally created. + - name: lost + doc: The connection to whatever owns the surface was lost, or generally needs to be fully reinitialized. + - name: error + doc: There was some deterministic error (for example, the surface is not configured, or there was an @ref OutStructChainError). Should produce @ref ImplementationDefinedLogging containing details. + - name: texture_aspect + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: all + doc: | + TODO + - name: stencil_only + doc: | + TODO + - name: depth_only + doc: | + TODO + - name: texture_dimension + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: 1D + doc: | + TODO + - name: 2D + doc: | + TODO + - name: 3D + doc: | + TODO + - name: texture_format + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: R8_unorm + doc: | + TODO + - name: R8_snorm + doc: | + TODO + - name: R8_uint + doc: | + TODO + - name: R8_sint + doc: | + TODO + - name: R16_unorm + doc: | + TODO + - name: R16_snorm + doc: | + TODO + - name: R16_uint + doc: | + TODO + - name: R16_sint + doc: | + TODO + - name: R16_float + doc: | + TODO + - name: RG8_unorm + doc: | + TODO + - name: RG8_snorm + doc: | + TODO + - name: RG8_uint + doc: | + TODO + - name: RG8_sint + doc: | + TODO + - name: R32_float + doc: | + TODO + - name: R32_uint + doc: | + TODO + - name: R32_sint + doc: | + TODO + - name: RG16_unorm + doc: | + TODO + - name: RG16_snorm + doc: | + TODO + - name: RG16_uint + doc: | + TODO + - name: RG16_sint + doc: | + TODO + - name: RG16_float + doc: | + TODO + - name: RGBA8_unorm + doc: | + TODO + - name: RGBA8_unorm_srgb + doc: | + TODO + - name: RGBA8_snorm + doc: | + TODO + - name: RGBA8_uint + doc: | + TODO + - name: RGBA8_sint + doc: | + TODO + - name: BGRA8_unorm + doc: | + TODO + - name: BGRA8_unorm_srgb + doc: | + TODO + - name: RGB10_A2_uint + doc: | + TODO + - name: RGB10_A2_unorm + doc: | + TODO + - name: RG11_B10_ufloat + doc: | + TODO + - name: RGB9_E5_ufloat + doc: | + TODO + - name: RG32_float + doc: | + TODO + - name: RG32_uint + doc: | + TODO + - name: RG32_sint + doc: | + TODO + - name: RGBA16_unorm + doc: | + TODO + - name: RGBA16_snorm + doc: | + TODO + - name: RGBA16_uint + doc: | + TODO + - name: RGBA16_sint + doc: | + TODO + - name: RGBA16_float + doc: | + TODO + - name: RGBA32_float + doc: | + TODO + - name: RGBA32_uint + doc: | + TODO + - name: RGBA32_sint + doc: | + TODO + - name: stencil8 + doc: | + TODO + - name: depth16_unorm + doc: | + TODO + - name: depth24_plus + doc: | + TODO + - name: depth24_plus_stencil8 + doc: | + TODO + - name: depth32_float + doc: | + TODO + - name: depth32_float_stencil8 + doc: | + TODO + - name: BC1_RGBA_unorm + doc: | + TODO + - name: BC1_RGBA_unorm_srgb + doc: | + TODO + - name: BC2_RGBA_unorm + doc: | + TODO + - name: BC2_RGBA_unorm_srgb + doc: | + TODO + - name: BC3_RGBA_unorm + doc: | + TODO + - name: BC3_RGBA_unorm_srgb + doc: | + TODO + - name: BC4_R_unorm + doc: | + TODO + - name: BC4_R_snorm + doc: | + TODO + - name: BC5_RG_unorm + doc: | + TODO + - name: BC5_RG_snorm + doc: | + TODO + - name: BC6H_RGB_ufloat + doc: | + TODO + - name: BC6H_RGB_float + doc: | + TODO + - name: BC7_RGBA_unorm + doc: | + TODO + - name: BC7_RGBA_unorm_srgb + doc: | + TODO + - name: ETC2_RGB8_unorm + doc: | + TODO + - name: ETC2_RGB8_unorm_srgb + doc: | + TODO + - name: ETC2_RGB8A1_unorm + doc: | + TODO + - name: ETC2_RGB8A1_unorm_srgb + doc: | + TODO + - name: ETC2_RGBA8_unorm + doc: | + TODO + - name: ETC2_RGBA8_unorm_srgb + doc: | + TODO + - name: EAC_R11_unorm + doc: | + TODO + - name: EAC_R11_snorm + doc: | + TODO + - name: EAC_RG11_unorm + doc: | + TODO + - name: EAC_RG11_snorm + doc: | + TODO + - name: ASTC_4x4_unorm + doc: | + TODO + - name: ASTC_4x4_unorm_srgb + doc: | + TODO + - name: ASTC_5x4_unorm + doc: | + TODO + - name: ASTC_5x4_unorm_srgb + doc: | + TODO + - name: ASTC_5x5_unorm + doc: | + TODO + - name: ASTC_5x5_unorm_srgb + doc: | + TODO + - name: ASTC_6x5_unorm + doc: | + TODO + - name: ASTC_6x5_unorm_srgb + doc: | + TODO + - name: ASTC_6x6_unorm + doc: | + TODO + - name: ASTC_6x6_unorm_srgb + doc: | + TODO + - name: ASTC_8x5_unorm + doc: | + TODO + - name: ASTC_8x5_unorm_srgb + doc: | + TODO + - name: ASTC_8x6_unorm + doc: | + TODO + - name: ASTC_8x6_unorm_srgb + doc: | + TODO + - name: ASTC_8x8_unorm + doc: | + TODO + - name: ASTC_8x8_unorm_srgb + doc: | + TODO + - name: ASTC_10x5_unorm + doc: | + TODO + - name: ASTC_10x5_unorm_srgb + doc: | + TODO + - name: ASTC_10x6_unorm + doc: | + TODO + - name: ASTC_10x6_unorm_srgb + doc: | + TODO + - name: ASTC_10x8_unorm + doc: | + TODO + - name: ASTC_10x8_unorm_srgb + doc: | + TODO + - name: ASTC_10x10_unorm + doc: | + TODO + - name: ASTC_10x10_unorm_srgb + doc: | + TODO + - name: ASTC_12x10_unorm + doc: | + TODO + - name: ASTC_12x10_unorm_srgb + doc: | + TODO + - name: ASTC_12x12_unorm + doc: | + TODO + - name: ASTC_12x12_unorm_srgb + doc: | + TODO + - name: texture_sample_type + doc: | + TODO + entries: + - name: binding_not_used + doc: | + Indicates that this @ref WGPUTextureBindingLayout member of + its parent @ref WGPUBindGroupLayoutEntry is not used. + (See also @ref SentinelValues.) + - name: undefined + doc: | + `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + - name: float + doc: | + TODO + - name: unfilterable_float + doc: | + TODO + - name: depth + doc: | + TODO + - name: sint + doc: | + TODO + - name: uint + doc: | + TODO + - name: texture_view_dimension + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: 1D + doc: | + TODO + - name: 2D + doc: | + TODO + - name: 2D_array + doc: | + TODO + - name: cube + doc: | + TODO + - name: cube_array + doc: | + TODO + - name: 3D + doc: | + TODO + - name: tone_mapping_mode + doc: | + TODO + entries: + - null + - name: standard + doc: | + TODO + - name: extended + doc: | + TODO + - name: vertex_format + doc: | + TODO + entries: + - null + - name: uint8 + doc: | + TODO + - name: uint8x2 + doc: | + TODO + - name: uint8x4 + doc: | + TODO + - name: sint8 + doc: | + TODO + - name: sint8x2 + doc: | + TODO + - name: sint8x4 + doc: | + TODO + - name: unorm8 + doc: | + TODO + - name: unorm8x2 + doc: | + TODO + - name: unorm8x4 + doc: | + TODO + - name: snorm8 + doc: | + TODO + - name: snorm8x2 + doc: | + TODO + - name: snorm8x4 + doc: | + TODO + - name: uint16 + doc: | + TODO + - name: uint16x2 + doc: | + TODO + - name: uint16x4 + doc: | + TODO + - name: sint16 + doc: | + TODO + - name: sint16x2 + doc: | + TODO + - name: sint16x4 + doc: | + TODO + - name: unorm16 + doc: | + TODO + - name: unorm16x2 + doc: | + TODO + - name: unorm16x4 + doc: | + TODO + - name: snorm16 + doc: | + TODO + - name: snorm16x2 + doc: | + TODO + - name: snorm16x4 + doc: | + TODO + - name: float16 + doc: | + TODO + - name: float16x2 + doc: | + TODO + - name: float16x4 + doc: | + TODO + - name: float32 + doc: | + TODO + - name: float32x2 + doc: | + TODO + - name: float32x3 + doc: | + TODO + - name: float32x4 + doc: | + TODO + - name: uint32 + doc: | + TODO + - name: uint32x2 + doc: | + TODO + - name: uint32x3 + doc: | + TODO + - name: uint32x4 + doc: | + TODO + - name: sint32 + doc: | + TODO + - name: sint32x2 + doc: | + TODO + - name: sint32x3 + doc: | + TODO + - name: sint32x4 + doc: | + TODO + - name: unorm10__10__10__2 + doc: | + TODO + - name: unorm8x4_B_G_R_A + doc: | + TODO + - name: vertex_step_mode + doc: | + TODO + entries: + - name: undefined + doc: Indicates no value is passed for this argument. See @ref SentinelValues. + - name: vertex + doc: | + TODO + - name: instance + doc: | + TODO + - name: wait_status + doc: Status returned from a call to ::wgpuInstanceWaitAny. + entries: + - null + - name: success + doc: At least one WGPUFuture completed successfully. + - name: timed_out + doc: The wait operation succeeded, but no WGPUFutures completed within the timeout. + - name: error + doc: | + The call was invalid for some reason (see @ref Wait-Any). + Should produce @ref ImplementationDefinedLogging containing details. + - name: WGSL_language_feature_name + doc: | + TODO + entries: + - null + - name: readonly_and_readwrite_storage_textures + doc: | + TODO + - name: packed4x8_integer_dot_product + doc: | + TODO + - name: unrestricted_pointer_parameters + doc: | + TODO + - name: pointer_composite_access + doc: | + TODO + - name: uniform_buffer_standard_layout + doc: | + TODO + - name: subgroup_id + doc: | + TODO + - name: texture_and_sampler_let + doc: | + TODO + - name: subgroup_uniformity + doc: | + TODO + - name: texture_formats_tier1 + doc: | + TODO +bitflags: + - name: buffer_usage + doc: | + TODO + entries: + - name: none + doc: | + TODO + - name: map_read + doc: | + The buffer can be *mapped* on the CPU side in *read* mode (using @ref WGPUMapMode_Read). + - name: map_write + doc: | + The buffer can be *mapped* on the CPU side in *write* mode (using @ref WGPUMapMode_Write). + + @note This usage is **not** required to set `mappedAtCreation` to `true` in @ref WGPUBufferDescriptor. + - name: copy_src + doc: | + The buffer can be used as the *source* of a GPU-side copy operation. + - name: copy_dst + doc: | + The buffer can be used as the *destination* of a GPU-side copy operation. + - name: index + doc: | + The buffer can be used as an Index buffer when doing indexed drawing in a render pipeline. + - name: vertex + doc: | + The buffer can be used as a Vertex buffer when using a render pipeline. + - name: uniform + doc: | + The buffer can be bound to a shader as a uniform buffer. + - name: storage + doc: | + The buffer can be bound to a shader as a storage buffer. + - name: indirect + doc: | + The buffer can store arguments for an indirect draw call. + - name: query_resolve + doc: | + The buffer can store the result of a timestamp or occlusion query. + - name: color_write_mask + doc: | + TODO + entries: + - name: none + doc: | + TODO + - name: red + doc: | + TODO + - name: green + doc: | + TODO + - name: blue + doc: | + TODO + - name: alpha + doc: | + TODO + - name: all + value_combination: + - red + - green + - blue + - alpha + doc: | + TODO + - name: map_mode + doc: | + TODO + entries: + - name: none + doc: | + TODO + - name: read + doc: | + TODO + - name: write + doc: | + TODO + - name: shader_stage + doc: | + TODO + entries: + - name: none + doc: | + TODO + - name: vertex + doc: | + TODO + - name: fragment + doc: | + TODO + - name: compute + doc: | + TODO + - name: texture_usage + doc: | + TODO + entries: + - name: none + doc: | + TODO + - name: copy_src + doc: | + TODO + - name: copy_dst + doc: | + TODO + - name: texture_binding + doc: | + TODO + - name: storage_binding + doc: | + TODO + - name: render_attachment + doc: | + TODO + - name: transient_attachment + doc: | + TODO +structs: + - name: adapter_info + doc: | + TODO + type: extensible + free_members: true + members: + - name: vendor + doc: | + TODO + type: out_string + - name: architecture + doc: | + TODO + type: out_string + - name: device + doc: | + TODO + type: out_string + - name: description + doc: | + TODO + type: out_string + - name: backend_type + doc: | + TODO + type: enum.backend_type + - name: adapter_type + doc: | + TODO + type: enum.adapter_type + - name: vendor_ID + doc: | + TODO + type: uint32 + - name: device_ID + doc: | + TODO + type: uint32 + - name: subgroup_min_size + doc: | + TODO + type: uint32 + - name: subgroup_max_size + doc: | + TODO + type: uint32 + - name: bind_group_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: layout + doc: | + TODO + type: object.bind_group_layout + - name: entries + doc: | + TODO + type: array + pointer: immutable + - name: bind_group_entry + doc: | + TODO + type: extensible + members: + - name: binding + doc: | + Binding index in the bind group. + type: uint32 + - name: buffer + doc: | + Set this if the binding is a buffer object. + Otherwise must be null. + type: object.buffer + optional: true + - name: offset + doc: | + If the binding is a buffer, this is the byte offset of the binding range. + Otherwise ignored. + type: uint64 + - name: size + doc: | + If the binding is a buffer, this is the byte size of the binding range + (@ref WGPU_WHOLE_SIZE means the binding ends at the end of the buffer). + Otherwise ignored. + type: uint64 + default: constant.whole_size + - name: sampler + doc: | + Set this if the binding is a sampler object. + Otherwise must be null. + type: object.sampler + optional: true + - name: texture_view + doc: | + Set this if the binding is a texture view object. + Otherwise must be null. + type: object.texture_view + optional: true + - name: bind_group_layout_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: entries + doc: | + TODO + type: array + pointer: immutable + - name: bind_group_layout_entry + doc: | + TODO + type: extensible + members: + - name: binding + doc: | + TODO + type: uint32 + - name: visibility + doc: | + TODO + type: bitflag.shader_stage + default: none + - name: binding_array_size + doc: | + If non-zero, this entry defines a binding array with this size. + type: uint32 + - name: buffer + doc: | + TODO + type: struct.buffer_binding_layout + # Use struct-zero-init here to get .type=BindingNotUsed (0), instead of + # Undefined which is the default in WGPU_BUFFER_BINDING_LAYOUT_INIT. + # Zero-init is conveniently correct for the rest of the fields, too. + default: zero + - name: sampler + doc: | + TODO + type: struct.sampler_binding_layout + # Use struct-zero-init here to get .type=BindingNotUsed (0), instead of + # Undefined which is the default in WGPU_SAMPLER_BINDING_LAYOUT_INIT. + # Zero-init is conveniently correct for the rest of the fields, too. + default: zero + - name: texture + doc: | + TODO + type: struct.texture_binding_layout + # Use struct-zero-init here to get .sampleType=BindingNotUsed (0), instead of + # Undefined which is the default in WGPU_TEXTURE_BINDING_LAYOUT_INIT. + # Zero-init is conveniently correct for the rest of the fields, too. + default: zero + - name: storage_texture + doc: | + TODO + type: struct.storage_texture_binding_layout + # Use struct-zero-init here to get .access=BindingNotUsed (0), instead of + # Undefined which is the default in WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT. + # Zero-init is conveniently correct for the rest of the fields, too. + default: zero + - name: blend_component + doc: | + TODO + type: standalone + members: + - name: operation + doc: | + If set to @ref WGPUBlendOperation_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUBlendOperation_Add. + type: enum.blend_operation + - name: src_factor + doc: | + If set to @ref WGPUBlendFactor_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_One. + type: enum.blend_factor + - name: dst_factor + doc: | + If set to @ref WGPUBlendFactor_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_Zero. + type: enum.blend_factor + - name: blend_state + doc: | + TODO + type: standalone + members: + - name: color + doc: | + TODO + type: struct.blend_component + - name: alpha + doc: | + TODO + type: struct.blend_component + - name: buffer_binding_layout + doc: | + TODO + type: extensible + members: + - name: type + doc: | + If set to @ref WGPUBufferBindingType_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUBufferBindingType_Uniform. + type: enum.buffer_binding_type + - name: has_dynamic_offset + doc: | + TODO + type: bool + default: false + - name: min_binding_size + doc: | + TODO + type: uint64 + default: 0 + - name: buffer_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: usage + doc: | + TODO + type: bitflag.buffer_usage + default: none + - name: size + doc: | + TODO + type: uint64 + - name: mapped_at_creation + doc: | + When true, the buffer is mapped in write mode at creation. It should thus be unmapped once its initial data has been written. + + @note Mapping at creation does **not** require the usage @ref WGPUBufferUsage_MapWrite. + type: bool + default: false + - name: color + doc: | + An RGBA color. Represents a `f32`, `i32`, or `u32` color using @ref DoubleAsSupertype. + + If any channel is non-finite, produces a @ref NonFiniteFloatValueError. + type: standalone + members: + - name: r + doc: "" + type: float64_supertype + - name: g + doc: "" + type: float64_supertype + - name: b + doc: "" + type: float64_supertype + - name: a + doc: "" + type: float64_supertype + - name: color_target_state + doc: | + TODO + type: extensible + members: + - name: format + doc: | + 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`. + type: enum.texture_format + - name: blend + doc: | + TODO + type: struct.blend_state + pointer: immutable + optional: true + - name: write_mask + doc: | + TODO + type: bitflag.color_write_mask + default: all + - name: command_buffer_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: command_encoder_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: compatibility_mode_limits + doc: | + Note: While Compatibility Mode is optional to implement, this extension struct + is required to be supported (for both queries and requests) and behave as + defined in the WebGPU spec. + type: extension + extends: + - limits + members: + - name: max_storage_buffers_in_vertex_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_storage_textures_in_vertex_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_storage_buffers_in_fragment_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_storage_textures_in_fragment_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: compilation_info + doc: | + TODO + type: extensible_callback_arg + members: + - name: messages + doc: | + TODO + type: array + pointer: immutable + - name: compilation_message + doc: | + TODO + type: extensible_callback_arg + members: + - name: message + doc: | + A @ref LocalizableHumanReadableMessageString. + type: out_string + - name: type + doc: | + Severity level of the message. + type: enum.compilation_message_type + - name: line_num + doc: | + Line number where the message is attached, starting at 1. + type: uint64 + - name: line_pos + doc: | + Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + type: uint64 + - name: offset + doc: | + Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + type: uint64 + - name: length + doc: | + Length in UTF-8 code units (bytes) of the span the message corresponds to. + type: uint64 + - name: compute_pass_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: timestamp_writes + doc: | + TODO + type: struct.pass_timestamp_writes + pointer: immutable + optional: true + - name: compute_pipeline_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: layout + doc: | + TODO + type: object.pipeline_layout + optional: true + - name: compute + doc: | + TODO + type: struct.compute_state + - name: compute_state + doc: | + TODO + type: extensible + members: + - name: module + doc: | + TODO + type: object.shader_module + - name: entry_point + doc: | + TODO + type: nullable_string + - name: constants + doc: | + TODO + type: array + pointer: immutable + - name: constant_entry + doc: | + TODO + type: extensible + members: + - name: key + doc: | + TODO + type: string_with_default_empty + - name: value + doc: | + Represents a WGSL numeric or boolean value using @ref DoubleAsSupertype. + + If non-finite, produces a @ref NonFiniteFloatValueError. + type: float64_supertype + - name: depth_stencil_state + doc: | + TODO + type: extensible + members: + - name: format + doc: | + TODO + type: enum.texture_format + - name: depth_write_enabled + doc: | + TODO + type: enum.optional_bool + - name: depth_compare + doc: | + TODO + type: enum.compare_function + - name: stencil_front + doc: | + TODO + type: struct.stencil_face_state + - name: stencil_back + doc: | + TODO + type: struct.stencil_face_state + - name: stencil_read_mask + doc: | + TODO + type: uint32 + default: "0xFFFFFFFF" + - name: stencil_write_mask + doc: | + TODO + type: uint32 + default: "0xFFFFFFFF" + - name: depth_bias + doc: | + TODO + type: int32 + default: 0 + - name: depth_bias_slope_scale + doc: | + TODO + + If non-finite, produces a @ref NonFiniteFloatValueError. + type: float32 + default: 0.0 + - name: depth_bias_clamp + doc: | + TODO + + If non-finite, produces a @ref NonFiniteFloatValueError. + type: float32 + default: 0.0 + - name: device_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: required_features + doc: | + TODO + type: array + pointer: immutable + - name: required_limits + doc: | + TODO + type: struct.limits + pointer: immutable + optional: true + - name: default_queue + doc: | + TODO + type: struct.queue_descriptor + - name: device_lost_callback_info + doc: | + TODO + type: callback.device_lost + - name: uncaptured_error_callback_info + doc: | + Called when there is an uncaptured error on this device, from any thread. + See @ref ErrorScopes. + + **Important:** This callback does not have a configurable @ref WGPUCallbackMode; it may be called at any time (like @ref WGPUCallbackMode_AllowSpontaneous). As such, calls into the `webgpu.h` API from this callback are unsafe. See @ref CallbackReentrancy. + type: callback.uncaptured_error + - name: extent_3D + doc: | + TODO + type: standalone + members: + - name: width + doc: | + TODO + type: uint32 + - name: height + doc: | + TODO + type: uint32 + default: 1 + - name: depth_or_array_layers + doc: | + TODO + type: uint32 + default: 1 + - name: external_texture_binding_entry + doc: Chained in an @ref WGPUBindGroupEntry to set it to an @ref WGPUExternalTexture. This must have a corresponding @ref WGPUExternalTextureBindingLayout in the @ref WGPUBindGroupLayout. + type: extension + extends: + - bind_group_entry + members: + - name: external_texture + type: object.external_texture + doc: | + TODO + - name: external_texture_binding_layout + doc: Chained in @ref WGPUBindGroupLayoutEntry to specify that the corresponding entries in an @ref WGPUBindGroup will contain an @ref WGPUExternalTexture. + type: extension + extends: + - bind_group_layout_entry + - name: fragment_state + doc: | + TODO + type: extensible + members: + - name: module + doc: | + TODO + type: object.shader_module + - name: entry_point + doc: | + TODO + type: nullable_string + - name: constants + doc: | + TODO + type: array + pointer: immutable + - name: targets + doc: | + TODO + type: array + pointer: immutable + - name: future + doc: Opaque handle to an asynchronous operation. See @ref Asynchronous-Operations for more information. + type: standalone + members: + - name: id + doc: Opaque id of the @ref WGPUFuture + type: uint64 + - name: future_wait_info + doc: Struct holding a future to wait on, and a `completed` boolean flag. + type: standalone + members: + - name: future + doc: The future to wait on. + type: struct.future + - name: completed + doc: Whether or not the future completed. + type: bool + - name: instance_descriptor + doc: | + TODO + type: extensible + members: + - name: required_features + doc: | + TODO + type: array + pointer: immutable + - name: required_limits + doc: | + TODO + type: struct.instance_limits + pointer: immutable + optional: true + - name: instance_limits + doc: | + TODO + type: extensible + members: + - name: timed_wait_any_max_count + doc: The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + type: usize + - name: limits + doc: | + TODO + type: extensible + members: + - name: max_texture_dimension_1D + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_texture_dimension_2D + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_texture_dimension_3D + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_texture_array_layers + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_bind_groups + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_bind_groups_plus_vertex_buffers + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_bindings_per_bind_group + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_dynamic_uniform_buffers_per_pipeline_layout + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_dynamic_storage_buffers_per_pipeline_layout + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_sampled_textures_per_shader_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_samplers_per_shader_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_storage_buffers_per_shader_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_storage_textures_per_shader_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_uniform_buffers_per_shader_stage + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_uniform_buffer_binding_size + doc: | + TODO + type: uint64 + default: constant.limit_u64_undefined + - name: max_storage_buffer_binding_size + doc: | + TODO + type: uint64 + default: constant.limit_u64_undefined + - name: min_uniform_buffer_offset_alignment + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: min_storage_buffer_offset_alignment + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_vertex_buffers + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_buffer_size + doc: | + TODO + type: uint64 + default: constant.limit_u64_undefined + - name: max_vertex_attributes + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_vertex_buffer_array_stride + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_inter_stage_shader_variables + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_color_attachments + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_color_attachment_bytes_per_sample + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_compute_workgroup_storage_size + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_compute_invocations_per_workgroup + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_compute_workgroup_size_x + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_compute_workgroup_size_y + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_compute_workgroup_size_z + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_compute_workgroups_per_dimension + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: max_immediate_size + doc: | + TODO + type: uint32 + default: constant.limit_u32_undefined + - name: multisample_state + doc: | + TODO + type: extensible + members: + - name: count + doc: | + TODO + type: uint32 + default: 1 + - name: mask + doc: | + TODO + type: uint32 + default: "0xFFFFFFFF" + - name: alpha_to_coverage_enabled + doc: | + TODO + type: bool + default: false + - name: origin_3D + doc: | + TODO + type: standalone + members: + - name: x + doc: | + TODO + type: uint32 + default: 0 + - name: y + doc: | + TODO + type: uint32 + default: 0 + - name: z + doc: | + TODO + type: uint32 + default: 0 + - name: pass_timestamp_writes + doc: | + TODO + type: extensible + members: + - name: query_set + doc: | + Query set to write timestamps to. + type: object.query_set + - name: beginning_of_pass_write_index + doc: | + TODO + type: uint32 + default: constant.query_set_index_undefined + - name: end_of_pass_write_index + doc: | + TODO + type: uint32 + default: constant.query_set_index_undefined + - name: pipeline_layout_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: bind_group_layouts + doc: | + TODO + type: array + pointer: immutable + - name: immediate_size + doc: | + TODO + type: uint32 + default: 0 + - name: primitive_state + doc: | + TODO + type: extensible + members: + - name: topology + doc: | + If set to @ref WGPUPrimitiveTopology_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUPrimitiveTopology_TriangleList. + type: enum.primitive_topology + - name: strip_index_format + doc: | + TODO + type: enum.index_format + - name: front_face + doc: | + If set to @ref WGPUFrontFace_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUFrontFace_CCW. + type: enum.front_face + - name: cull_mode + doc: | + If set to @ref WGPUCullMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUCullMode_None. + type: enum.cull_mode + - name: unclipped_depth + doc: | + TODO + type: bool + default: false + - name: query_set_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: type + doc: | + TODO + type: enum.query_type + - name: count + doc: | + TODO + type: uint32 + - name: queue_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: render_bundle_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: render_bundle_encoder_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: color_formats + doc: | + TODO + type: array + pointer: immutable + - name: depth_stencil_format + doc: | + TODO + type: enum.texture_format + - name: sample_count + doc: | + TODO + type: uint32 + default: 1 + - name: depth_read_only + doc: | + TODO + type: bool + default: false + - name: stencil_read_only + doc: | + TODO + type: bool + default: false + - name: render_pass_color_attachment + doc: | + TODO + type: extensible + members: + - name: view + doc: | + If `NULL`, indicates a hole in the parent + @ref WGPURenderPassDescriptor::colorAttachments array. + type: object.texture_view + optional: true + - name: depth_slice + doc: | + TODO + type: uint32 + default: constant.depth_slice_undefined + - name: resolve_target + doc: | + TODO + type: object.texture_view + optional: true + - name: load_op + doc: | + TODO + type: enum.load_op + - name: store_op + doc: | + TODO + type: enum.store_op + - name: clear_value + doc: | + TODO + type: struct.color + - name: render_pass_depth_stencil_attachment + doc: | + TODO + type: extensible + members: + - name: view + doc: | + TODO + type: object.texture_view + - name: depth_load_op + doc: | + TODO + type: enum.load_op + - name: depth_store_op + doc: | + TODO + type: enum.store_op + - name: depth_clear_value + doc: | + This is a @ref NullableFloatingPointType. + + If `NaN`, indicates an `undefined` value (as defined by the JS spec). + Use @ref WGPU_DEPTH_CLEAR_VALUE_UNDEFINED to indicate this semantically. + + If infinite, produces a @ref NonFiniteFloatValueError. + type: nullable_float32 + default: constant.depth_clear_value_undefined + - name: depth_read_only + doc: | + TODO + type: bool + default: false + - name: stencil_load_op + doc: | + TODO + type: enum.load_op + - name: stencil_store_op + doc: | + TODO + type: enum.store_op + - name: stencil_clear_value + doc: | + TODO + type: uint32 + - name: stencil_read_only + doc: | + TODO + type: bool + default: false + - name: render_pass_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: color_attachments + doc: | + TODO + type: array + pointer: immutable + - name: depth_stencil_attachment + doc: | + TODO + type: struct.render_pass_depth_stencil_attachment + pointer: immutable + optional: true + - name: occlusion_query_set + doc: | + TODO + type: object.query_set + optional: true + - name: timestamp_writes + doc: | + TODO + type: struct.pass_timestamp_writes + pointer: immutable + optional: true + - name: render_pass_max_draw_count + doc: | + TODO + type: extension + extends: + - render_pass_descriptor + members: + - name: max_draw_count + doc: | + TODO + type: uint64 + default: 50000000 + - name: render_pipeline_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: layout + doc: | + TODO + type: object.pipeline_layout + optional: true + - name: vertex + doc: | + TODO + type: struct.vertex_state + - name: primitive + doc: | + TODO + type: struct.primitive_state + - name: depth_stencil + doc: | + TODO + type: struct.depth_stencil_state + pointer: immutable + optional: true + - name: multisample + doc: | + TODO + type: struct.multisample_state + - name: fragment + doc: | + TODO + type: struct.fragment_state + pointer: immutable + optional: true + - name: request_adapter_options + doc: | + TODO + type: extensible + members: + - name: feature_level + doc: | + "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + + If set to @ref WGPUFeatureLevel_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUFeatureLevel_Core. + Additionally, implementations may ignore @ref WGPUFeatureLevel_Compatibility + and provide @ref WGPUFeatureLevel_Core instead. + type: enum.feature_level + - name: power_preference + doc: | + TODO + type: enum.power_preference + - name: force_fallback_adapter + doc: | + 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. + type: bool + default: false + - name: backend_type + doc: | + If set, requires the adapter to have a particular backend type. + If this is not possible, the request returns null. + type: enum.backend_type + - name: compatible_surface + doc: | + If set, requires the adapter to be able to output to a particular surface. + If this is not possible, the request returns null. + type: object.surface + optional: true + - name: request_adapter_WebXR_options + doc: | + Extension providing requestAdapter options for implementations with WebXR interop (i.e. Wasm). + type: extension + extends: + - request_adapter_options + members: + - name: xr_compatible + doc: | + Sets the `xrCompatible` option in the JS API. + type: bool + default: false + - name: sampler_binding_layout + doc: | + TODO + type: extensible + members: + - name: type + doc: | + If set to @ref WGPUSamplerBindingType_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUSamplerBindingType_Filtering. + type: enum.sampler_binding_type + - name: sampler_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: address_mode_u + doc: | + If set to @ref WGPUAddressMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + type: enum.address_mode + - name: address_mode_v + doc: | + If set to @ref WGPUAddressMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + type: enum.address_mode + - name: address_mode_w + doc: | + If set to @ref WGPUAddressMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + type: enum.address_mode + - name: mag_filter + doc: | + If set to @ref WGPUFilterMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + type: enum.filter_mode + - name: min_filter + doc: | + If set to @ref WGPUFilterMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + type: enum.filter_mode + - name: mipmap_filter + doc: | + If set to @ref WGPUFilterMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUMipmapFilterMode_Nearest. + type: enum.mipmap_filter_mode + - name: lod_min_clamp + doc: | + TODO + + If non-finite, produces a @ref NonFiniteFloatValueError. + type: float32 + default: 0.0 + - name: lod_max_clamp + doc: | + TODO + + If non-finite, produces a @ref NonFiniteFloatValueError. + type: float32 + default: 32.0 + - name: compare + doc: | + TODO + type: enum.compare_function + - name: max_anisotropy + doc: | + TODO + type: uint16 + default: 1 + - name: shader_module_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: shader_source_SPIRV + doc: | + TODO + type: extension + extends: + - shader_module_descriptor + members: + - name: code_size + doc: | + TODO + type: uint32 + default: 0 + - name: code + doc: | + TODO + type: uint32 + pointer: immutable + - name: shader_source_WGSL + doc: | + TODO + type: extension + extends: + - shader_module_descriptor + members: + - name: code + doc: | + TODO + type: string_with_default_empty + - name: stencil_face_state + doc: | + TODO + type: standalone + members: + - name: compare + doc: | + If set to @ref WGPUCompareFunction_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUCompareFunction_Always. + type: enum.compare_function + - name: fail_op + doc: | + If set to @ref WGPUStencilOperation_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + type: enum.stencil_operation + - name: depth_fail_op + doc: | + If set to @ref WGPUStencilOperation_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + type: enum.stencil_operation + - name: pass_op + doc: | + If set to @ref WGPUStencilOperation_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + type: enum.stencil_operation + - name: storage_texture_binding_layout + doc: | + TODO + type: extensible + members: + - name: access + doc: | + If set to @ref WGPUStorageTextureAccess_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUStorageTextureAccess_WriteOnly. + type: enum.storage_texture_access + - name: format + doc: | + TODO + type: enum.texture_format + - name: view_dimension + doc: | + If set to @ref WGPUTextureViewDimension_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + type: enum.texture_view_dimension + - name: supported_features + doc: | + TODO + type: standalone + free_members: true + members: + - name: features + doc: | + TODO + type: array + pointer: immutable + - name: supported_instance_features + doc: | + TODO + type: standalone + free_members: true + members: + - name: features + doc: | + TODO + type: array + pointer: immutable + - name: supported_WGSL_language_features + doc: | + TODO + type: standalone + free_members: true + members: + - name: features + doc: | + TODO + type: array + pointer: immutable + - name: surface_capabilities + doc: Filled by @ref wgpuSurfaceGetCapabilities with what's supported for @ref wgpuSurfaceConfigure for a pair of @ref WGPUSurface and @ref WGPUAdapter. + type: extensible + free_members: true + members: + - name: usages + doc: | + The bit set of supported @ref WGPUTextureUsage bits. + Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + type: bitflag.texture_usage + - name: formats + doc: A list of supported @ref WGPUTextureFormat values, in order of preference. + type: array + pointer: immutable + - name: present_modes + doc: | + A list of supported @ref WGPUPresentMode values. + Guaranteed to contain @ref WGPUPresentMode_Fifo. + type: array + pointer: immutable + - name: alpha_modes + doc: | + 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. + type: array + pointer: immutable + - name: surface_color_management + doc: | + Extension of @ref WGPUSurfaceConfiguration for color spaces and HDR. + type: extension + members: + - name: color_space + doc: TODO + type: enum.predefined_color_space + - name: tone_mapping_mode + doc: TODO + type: enum.tone_mapping_mode + - name: surface_configuration + doc: | + Options to @ref wgpuSurfaceConfigure for defining how a @ref WGPUSurface will be rendered to and presented to the user. + See @ref Surface-Configuration for more details. + type: extensible + members: + - name: device + doc: The @ref WGPUDevice to use to render to surface's textures. + type: object.device + - name: format + doc: The @ref WGPUTextureFormat of the surface's textures. + type: enum.texture_format + - name: usage + doc: The @ref WGPUTextureUsage of the surface's textures. + type: bitflag.texture_usage + default: render_attachment + - name: width + doc: The width of the surface's textures. + type: uint32 + - name: height + doc: The height of the surface's textures. + type: uint32 + - name: view_formats + doc: The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + type: array + pointer: immutable + - name: alpha_mode + doc: | + How the surface's frames will be composited on the screen. + + If set to @ref WGPUCompositeAlphaMode_Auto, + [defaults] to @ref WGPUCompositeAlphaMode_Inherit in native (allowing the mode + to be configured externally), and to @ref WGPUCompositeAlphaMode_Opaque in Wasm. + type: enum.composite_alpha_mode + default: auto + - name: present_mode + doc: | + When and in which order the surface's frames will be shown on the screen. + + If set to @ref WGPUPresentMode_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUPresentMode_Fifo. + type: enum.present_mode + - name: surface_descriptor + doc: | + The root descriptor for the creation of an @ref WGPUSurface with @ref wgpuInstanceCreateSurface. + It isn't sufficient by itself and must have one of the `WGPUSurfaceSource*` in its chain. + See @ref Surface-Creation for more details. + type: extensible + members: + - name: label + doc: Label used to refer to the object. + type: string_with_default_empty + - name: surface_source_android_native_window + doc: Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). + type: extension + extends: + - surface_descriptor + members: + - name: window + doc: The pointer to the [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window) that will be wrapped by the @ref WGPUSurface. + type: c_void + pointer: mutable + - name: surface_source_metal_layer + doc: Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). + type: extension + extends: + - surface_descriptor + members: + - name: layer + doc: The pointer to the [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc) that will be wrapped by the @ref WGPUSurface. + type: c_void + pointer: mutable + - name: surface_source_wayland_surface + doc: 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). + type: extension + extends: + - surface_descriptor + members: + - name: display + doc: A [`wl_display`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_display) for this Wayland instance. + type: c_void + pointer: mutable + - name: surface + doc: A [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface) that will be wrapped by the @ref WGPUSurface + type: c_void + pointer: mutable + - name: surface_source_windows_HWND + doc: 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). + type: extension + extends: + - surface_descriptor + members: + - name: hinstance + doc: | + The [`HINSTANCE`](https://learn.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point) for this application. + Most commonly `GetModuleHandle(nullptr)`. + type: c_void + pointer: mutable + - name: hwnd + doc: The [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd) that will be wrapped by the @ref WGPUSurface. + type: c_void + pointer: mutable + - name: surface_source_XCB_window + doc: Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. + type: extension + extends: + - surface_descriptor + members: + - name: connection + doc: The `xcb_connection_t` for the connection to the X server. + type: c_void + pointer: mutable + - name: window + doc: The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + type: uint32 + - name: surface_source_xlib_window + doc: Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. + type: extension + extends: + - surface_descriptor + members: + - name: display + doc: A pointer to the [`Display`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Opening_the_Display) connected to the X server. + type: c_void + pointer: mutable + - name: window + doc: The [`Window`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Creating_Windows) that will be wrapped by the @ref WGPUSurface. + type: uint64 + - name: surface_texture + doc: | + 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. + type: extensible + members: + - name: texture + doc: | + The @ref WGPUTexture representing the frame that will be shown on the surface. + It is @ref ReturnedWithOwnership from @ref wgpuSurfaceGetCurrentTexture. + type: object.texture + - name: status + doc: Whether the call to @ref wgpuSurfaceGetCurrentTexture succeeded and a hint as to why it might not have. + type: enum.surface_get_current_texture_status + - name: texel_copy_buffer_info + doc: | + TODO + type: standalone + members: + - name: layout + doc: | + TODO + type: struct.texel_copy_buffer_layout + - name: buffer + doc: | + TODO + type: object.buffer + - name: texel_copy_buffer_layout + doc: | + TODO + type: standalone + members: + - name: offset + doc: | + TODO + type: uint64 + default: 0 + - name: bytes_per_row + doc: | + TODO + type: uint32 + default: constant.copy_stride_undefined + - name: rows_per_image + doc: | + TODO + type: uint32 + default: constant.copy_stride_undefined + - name: texel_copy_texture_info + doc: | + TODO + type: standalone + members: + - name: texture + doc: | + TODO + type: object.texture + - name: mip_level + doc: | + TODO + type: uint32 + default: 0 + - name: origin + doc: | + TODO + type: struct.origin_3D + - name: aspect + doc: | + If set to @ref WGPUTextureAspect_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + type: enum.texture_aspect + - name: texture_binding_layout + doc: | + TODO + type: extensible + members: + - name: sample_type + doc: | + If set to @ref WGPUTextureSampleType_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUTextureSampleType_Float. + type: enum.texture_sample_type + - name: view_dimension + doc: | + If set to @ref WGPUTextureViewDimension_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + type: enum.texture_view_dimension + - name: multisampled + doc: | + TODO + type: bool + default: false + - name: texture_binding_view_dimension + doc: | + Note: While Compatibility Mode is optional to implement, this extension struct + is required to be accepted (but per the WebGPU spec, its contents are ignored + on devices that have the @ref WGPUFeatureName_CoreFeaturesAndLimits feature). + type: extension + extends: + - texture_descriptor + members: + - name: texture_binding_view_dimension + doc: | + TODO + type: enum.texture_view_dimension + - name: texture_component_swizzle + doc: | + When accessed by a shader, the red/green/blue/alpha channels are replaced + by the value corresponding to the component specified in r, g, b, and a, + respectively unlike the JS API which uses a string of length four, with + each character mapping to the texture view's red/green/blue/alpha channels. + type: standalone + members: + - name: r + doc: | + The value that replaces the red channel in the shader. + + If set to @ref WGPUComponentSwizzle_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_R. + type: enum.component_swizzle + - name: g + doc: | + The value that replaces the green channel in the shader. + + If set to @ref WGPUComponentSwizzle_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_G. + type: enum.component_swizzle + - name: b + doc: | + The value that replaces the blue channel in the shader. + + If set to @ref WGPUComponentSwizzle_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_B. + type: enum.component_swizzle + - name: a + doc: | + The value that replaces the alpha channel in the shader. + + If set to @ref WGPUComponentSwizzle_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_A. + type: enum.component_swizzle + - name: texture_component_swizzle_descriptor + doc: | + TODO + type: extension + extends: + - texture_view_descriptor + members: + - name: swizzle + doc: | + TODO + type: struct.texture_component_swizzle + - name: texture_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: usage + doc: | + TODO + type: bitflag.texture_usage + default: none + - name: dimension + doc: | + If set to @ref WGPUTextureDimension_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUTextureDimension_2D. + type: enum.texture_dimension + - name: size + doc: | + TODO + type: struct.extent_3D + - name: format + doc: | + TODO + type: enum.texture_format + - name: mip_level_count + doc: | + TODO + type: uint32 + default: 1 + - name: sample_count + doc: | + TODO + type: uint32 + default: 1 + - name: view_formats + doc: | + TODO + type: array + pointer: immutable + - name: texture_view_descriptor + doc: | + TODO + type: extensible + members: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: format + doc: | + TODO + type: enum.texture_format + - name: dimension + doc: | + TODO + type: enum.texture_view_dimension + - name: base_mip_level + doc: | + TODO + type: uint32 + default: 0 + - name: mip_level_count + doc: | + TODO + type: uint32 + default: constant.mip_level_count_undefined + - name: base_array_layer + doc: | + TODO + type: uint32 + default: 0 + - name: array_layer_count + doc: | + TODO + type: uint32 + default: constant.array_layer_count_undefined + - name: aspect + doc: | + If set to @ref WGPUTextureAspect_Undefined, + [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + type: enum.texture_aspect + - name: usage + doc: | + TODO + type: bitflag.texture_usage + default: none + - name: vertex_attribute + doc: | + TODO + type: extensible + members: + - name: format + doc: | + TODO + type: enum.vertex_format + - name: offset + doc: | + TODO + type: uint64 + - name: shader_location + doc: | + TODO + type: uint32 + - name: vertex_buffer_layout + doc: | + If `attributes` is empty *and* `stepMode` is @ref WGPUVertexStepMode_Undefined, + indicates a "hole" in the parent @ref WGPUVertexState `buffers` array, + with behavior equivalent to `null` in the JS API. + + If `attributes` is empty but `stepMode` is *not* @ref WGPUVertexStepMode_Undefined, + indicates a vertex buffer with no attributes, with behavior equivalent to + `{ attributes: [] }` in the JS API. (TODO: If the JS API changes not to + distinguish these cases, then this distinction doesn't matter and we can + remove this documentation.) + + If `stepMode` is @ref WGPUVertexStepMode_Undefined but `attributes` is *not* empty, + `stepMode` [defaults](@ref SentinelValues) to @ref WGPUVertexStepMode_Vertex. + type: extensible + members: + - name: step_mode + doc: | + TODO + type: enum.vertex_step_mode + - name: array_stride + doc: | + TODO + type: uint64 + - name: attributes + doc: | + TODO + type: array + pointer: immutable + - name: vertex_state + doc: | + TODO + type: extensible + members: + - name: module + doc: | + TODO + type: object.shader_module + - name: entry_point + doc: | + TODO + type: nullable_string + - name: constants + doc: | + TODO + type: array + pointer: immutable + - name: buffers + doc: | + TODO + type: array + pointer: immutable +callbacks: + - name: buffer_map + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.map_async_status + - name: message + doc: | + TODO + type: out_string + passed_with_ownership: false + - name: compilation_info + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.compilation_info_request_status + - name: compilation_info + doc: | + This argument contains multiple @ref ImplementationAllocatedStructChain roots. + Arbitrary chains must be handled gracefully by the application! + type: struct.compilation_info + pointer: immutable + passed_with_ownership: false + - name: create_compute_pipeline_async + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.create_pipeline_async_status + - name: pipeline + doc: | + TODO + type: object.compute_pipeline + passed_with_ownership: true + - name: message + doc: | + TODO + type: out_string + - name: create_render_pipeline_async + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.create_pipeline_async_status + - name: pipeline + doc: | + TODO + type: object.render_pipeline + passed_with_ownership: true + - name: message + doc: | + TODO + type: out_string + - name: device_lost + doc: TODO + style: callback_mode + args: + - name: device + doc: | + Pointer to the device which was lost. This is always a non-null pointer. + The pointed-to @ref WGPUDevice will be null if, and only if, either: + (1) The `reason` is @ref WGPUDeviceLostReason_FailedCreation. + (2) The last ref of the device has been (or is being) released: see @ref DeviceRelease. + type: object.device + pointer: immutable + passed_with_ownership: false + - name: reason + doc: | + An error code explaining why the device was lost. + type: enum.device_lost_reason + - name: message + doc: | + A @ref LocalizableHumanReadableMessageString describing why the device was lost. + type: out_string + passed_with_ownership: false + - name: pop_error_scope + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + See @ref WGPUPopErrorScopeStatus. + type: enum.pop_error_scope_status + - name: type + doc: | + 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. + type: enum.error_type + - name: message + doc: | + If the `status` is not @ref WGPUPopErrorScopeStatus_Success **or** + the `type` is not @ref WGPUErrorType_NoError, this is a non-empty + @ref LocalizableHumanReadableMessageString; + otherwise, this is an empty string. + type: out_string + passed_with_ownership: false + - name: queue_work_done + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + See @ref WGPUQueueWorkDoneStatus. + type: enum.queue_work_done_status + - name: message + doc: | + If the `status` is not @ref WGPUQueueWorkDoneStatus_Success, + this is a non-empty @ref LocalizableHumanReadableMessageString; + otherwise, this is an empty string. + type: out_string + passed_with_ownership: false + - name: request_adapter + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.request_adapter_status + - name: adapter + doc: | + TODO + type: object.adapter + passed_with_ownership: true + - name: message + doc: | + TODO + type: out_string + passed_with_ownership: false + - name: request_device + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.request_device_status + - name: device + doc: | + TODO + type: object.device + passed_with_ownership: true + - name: message + doc: | + TODO + type: out_string + passed_with_ownership: false + - name: uncaptured_error + doc: | + TODO + style: immediate + args: + - name: device + doc: | + TODO + type: object.device + pointer: immutable + passed_with_ownership: false + - name: type + doc: | + TODO + type: enum.error_type + - name: message + doc: | + TODO + type: out_string + passed_with_ownership: false +functions: + - name: create_instance + doc: Create a WGPUInstance + returns: + doc: | + TODO + type: object.instance + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.instance_descriptor + pointer: immutable + optional: true + - name: get_instance_features + doc: | + Get the list of @ref WGPUInstanceFeatureName values supported by the instance. + args: + - name: features + doc: | + TODO + type: struct.supported_instance_features + pointer: mutable + passed_with_ownership: true + - name: get_instance_limits + doc: | + Get the limits supported by the instance. + returns: + doc: Indicates if there was an @ref OutStructChainError. + type: enum.status + args: + - name: limits + doc: | + TODO + type: struct.instance_limits + pointer: mutable + - name: has_instance_feature + doc: | + Check whether a particular @ref WGPUInstanceFeatureName is supported by the instance. + returns: + doc: | + TODO + type: bool + args: + - name: feature + doc: | + TODO + type: enum.instance_feature_name +objects: + - name: adapter + doc: | + TODO + methods: + - name: get_limits + doc: | + TODO + returns: + doc: Indicates if there was an @ref OutStructChainError. + type: enum.status + args: + - name: limits + doc: | + TODO + type: struct.limits + pointer: mutable + - name: has_feature + doc: | + TODO + returns: + doc: | + TODO + type: bool + args: + - name: feature + doc: | + TODO + type: enum.feature_name + - name: get_features + doc: | + Get the list of @ref WGPUFeatureName values supported by the adapter. + args: + - name: features + doc: | + TODO + type: struct.supported_features + pointer: mutable + passed_with_ownership: true + - name: get_info + doc: | + TODO + returns: + doc: Indicates if there was an @ref OutStructChainError. + type: enum.status + args: + - name: info + doc: | + TODO + type: struct.adapter_info + pointer: mutable + passed_with_ownership: true + - name: request_device + doc: | + TODO + callback: callback.request_device + args: + - name: descriptor + doc: | + TODO + type: struct.device_descriptor + pointer: immutable + optional: true + - name: bind_group + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: bind_group_layout + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: buffer + doc: | + TODO + methods: + - name: map_async + doc: | + TODO + callback: callback.buffer_map + args: + - name: mode + doc: | + The mapping mode (read or write). + type: bitflag.map_mode + - name: offset + doc: | + Byte offset relative to beginning of the buffer. + type: usize + - name: size + doc: | + Byte size of the region to map. + If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + type: usize + - name: get_mapped_range + doc: | + Returns a mutable pointer to beginning of the mapped range. + See @ref MappedRangeBehavior for error conditions and guarantees. + This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + + In Wasm, if `memcpy`ing into this range, prefer using @ref wgpuBufferWriteMappedRange + instead for better performance. + returns: + doc: "" + type: c_void + pointer: mutable + args: + - name: offset + doc: | + Byte offset relative to the beginning of the buffer. + type: usize + - name: size + doc: | + Byte size of the range to get. + If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + The returned pointer is valid for exactly this many bytes. + type: usize + - name: get_const_mapped_range + doc: | + Returns a const pointer to beginning of the mapped range. + It must not be written; writing to this range causes undefined behavior. + See @ref MappedRangeBehavior for error conditions and guarantees. + This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + + In Wasm, if `memcpy`ing from this range, prefer using @ref wgpuBufferReadMappedRange + instead for better performance. + returns: + doc: "" + type: c_void + pointer: immutable + args: + - name: offset + doc: | + Byte offset relative to the beginning of the buffer. + type: usize + - name: size + doc: | + Byte size of the range to get. + If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + The returned pointer is valid for exactly this many bytes. + type: usize + - name: read_mapped_range + doc: | + Copies a range of data from the buffer mapping into the provided destination pointer. + See @ref MappedRangeBehavior for error conditions and guarantees. + This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + + In Wasm, this is more efficient than copying from a mapped range into a `malloc`'d range. + returns: + doc: | + @ref WGPUStatus_Error if the copy did not occur. + type: enum.status + args: + - name: offset + doc: | + Byte offset relative to the beginning of the buffer. + type: usize + - name: data + doc: | + Destination, to read buffer data into. + type: c_void + pointer: mutable + - name: size + doc: | + Number of bytes of data to read from the buffer. + (Note @ref WGPU_WHOLE_MAP_SIZE is *not* accepted here.) + type: usize + - name: write_mapped_range + doc: | + Copies a range of data from the provided source pointer into the buffer mapping. + See @ref MappedRangeBehavior for error conditions and guarantees. + This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + + In Wasm, this is more efficient than copying from a `malloc`'d range into a mapped range. + returns: + doc: | + @ref WGPUStatus_Error if the copy did not occur. + type: enum.status + args: + - name: offset + doc: | + Byte offset relative to the beginning of the buffer. + type: usize + - name: data + doc: | + Source, to write buffer data from. + type: c_void + pointer: immutable + - name: size + doc: | + Number of bytes of data to write to the buffer. + (Note @ref WGPU_WHOLE_MAP_SIZE is *not* accepted here.) + type: usize + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: get_usage + doc: | + TODO + returns: + doc: | + TODO + type: bitflag.buffer_usage + - name: get_size + doc: | + TODO + returns: + doc: | + TODO + type: uint64 + - name: get_map_state + doc: | + TODO + returns: + doc: | + TODO + type: enum.buffer_map_state + - name: unmap + doc: | + TODO + - name: destroy + doc: | + TODO + - name: command_buffer + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: command_encoder + doc: | + TODO + methods: + - name: finish + doc: | + TODO + returns: + doc: | + TODO + type: object.command_buffer + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.command_buffer_descriptor + pointer: immutable + optional: true + - name: begin_compute_pass + doc: | + TODO + returns: + doc: | + TODO + type: object.compute_pass_encoder + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.compute_pass_descriptor + pointer: immutable + optional: true + - name: begin_render_pass + doc: | + TODO + returns: + doc: | + TODO + type: object.render_pass_encoder + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.render_pass_descriptor + pointer: immutable + - name: copy_buffer_to_buffer + doc: | + TODO + args: + - name: source + doc: | + TODO + type: object.buffer + - name: source_offset + doc: | + TODO + type: uint64 + - name: destination + doc: | + TODO + type: object.buffer + - name: destination_offset + doc: | + TODO + type: uint64 + - name: size + doc: | + TODO + type: uint64 + - name: copy_buffer_to_texture + doc: | + TODO + args: + - name: source + doc: | + TODO + type: struct.texel_copy_buffer_info + pointer: immutable + - name: destination + doc: | + TODO + type: struct.texel_copy_texture_info + pointer: immutable + - name: copy_size + doc: | + TODO + type: struct.extent_3D + pointer: immutable + - name: copy_texture_to_buffer + doc: | + TODO + args: + - name: source + doc: | + TODO + type: struct.texel_copy_texture_info + pointer: immutable + - name: destination + doc: | + TODO + type: struct.texel_copy_buffer_info + pointer: immutable + - name: copy_size + doc: | + TODO + type: struct.extent_3D + pointer: immutable + - name: copy_texture_to_texture + doc: | + TODO + args: + - name: source + doc: | + TODO + type: struct.texel_copy_texture_info + pointer: immutable + - name: destination + doc: | + TODO + type: struct.texel_copy_texture_info + pointer: immutable + - name: copy_size + doc: | + TODO + type: struct.extent_3D + pointer: immutable + - name: clear_buffer + doc: | + TODO + args: + - name: buffer + doc: | + TODO + type: object.buffer + - name: offset + doc: | + TODO + type: uint64 + - name: size + doc: | + TODO + type: uint64 + - name: insert_debug_marker + doc: | + TODO + args: + - name: marker_label + doc: | + TODO + type: string_with_default_empty + - name: pop_debug_group + doc: | + TODO + - name: push_debug_group + doc: | + TODO + args: + - name: group_label + doc: | + TODO + type: string_with_default_empty + - name: resolve_query_set + doc: | + TODO + args: + - name: query_set + doc: | + TODO + type: object.query_set + - name: first_query + doc: | + TODO + type: uint32 + - name: query_count + doc: | + TODO + type: uint32 + - name: destination + doc: | + TODO + type: object.buffer + - name: destination_offset + doc: | + TODO + type: uint64 + - name: write_timestamp + doc: | + TODO + args: + - name: query_set + doc: | + TODO + type: object.query_set + - name: query_index + doc: | + TODO + type: uint32 + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: compute_pass_encoder + doc: | + TODO + methods: + - name: insert_debug_marker + doc: | + TODO + args: + - name: marker_label + doc: | + TODO + type: string_with_default_empty + - name: pop_debug_group + doc: | + TODO + - name: push_debug_group + doc: | + TODO + args: + - name: group_label + doc: | + TODO + type: string_with_default_empty + - name: set_pipeline + doc: | + TODO + args: + - name: pipeline + doc: | + TODO + type: object.compute_pipeline + - name: set_bind_group + doc: | + TODO + args: + - name: group_index + doc: | + TODO + type: uint32 + - name: group + doc: | + TODO + type: object.bind_group + optional: true + - name: dynamic_offsets + doc: | + TODO + type: array + pointer: immutable + - name: dispatch_workgroups + doc: | + TODO + args: + - name: workgroupCountX + doc: | + TODO + type: uint32 + - name: workgroupCountY + doc: | + TODO + type: uint32 + - name: workgroupCountZ + doc: | + TODO + type: uint32 + - name: dispatch_workgroups_indirect + doc: | + TODO + args: + - name: indirect_buffer + doc: | + TODO + type: object.buffer + - name: indirect_offset + doc: | + TODO + type: uint64 + - name: end + doc: | + TODO + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: compute_pipeline + doc: | + TODO + methods: + - name: get_bind_group_layout + doc: | + TODO + returns: + doc: | + TODO + type: object.bind_group_layout + passed_with_ownership: true + args: + - name: group_index + doc: | + TODO + type: uint32 + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: device + doc: | + TODO + + Releasing the last ref to a `WGPUDevice` also calls @ref wgpuDeviceDestroy. + For more info, see @ref DeviceRelease. + methods: + - name: create_bind_group + doc: | + TODO + returns: + doc: | + TODO + type: object.bind_group + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.bind_group_descriptor + pointer: immutable + - name: create_bind_group_layout + doc: | + TODO + returns: + doc: | + TODO + type: object.bind_group_layout + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.bind_group_layout_descriptor + pointer: immutable + - name: create_buffer + doc: | + TODO + + If @ref WGPUBufferDescriptor::mappedAtCreation is `true` and the mapping allocation fails, + returns `NULL`. + returns: + doc: | + TODO + type: object.buffer + optional: true + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.buffer_descriptor + pointer: immutable + - name: create_command_encoder + doc: | + TODO + returns: + doc: | + TODO + type: object.command_encoder + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.command_encoder_descriptor + pointer: immutable + optional: true + - name: create_compute_pipeline + doc: | + TODO + returns: + doc: | + TODO + type: object.compute_pipeline + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.compute_pipeline_descriptor + pointer: immutable + - name: create_compute_pipeline_async + doc: | + TODO + callback: callback.create_compute_pipeline_async + args: + - name: descriptor + doc: | + TODO + type: struct.compute_pipeline_descriptor + pointer: immutable + - name: create_pipeline_layout + doc: | + TODO + returns: + doc: | + TODO + type: object.pipeline_layout + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.pipeline_layout_descriptor + pointer: immutable + - name: create_query_set + doc: | + TODO + returns: + doc: | + TODO + type: object.query_set + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.query_set_descriptor + pointer: immutable + - name: create_render_pipeline_async + doc: | + TODO + callback: callback.create_render_pipeline_async + args: + - name: descriptor + doc: | + TODO + type: struct.render_pipeline_descriptor + pointer: immutable + - name: create_render_bundle_encoder + doc: | + TODO + returns: + doc: | + TODO + type: object.render_bundle_encoder + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.render_bundle_encoder_descriptor + pointer: immutable + - name: create_render_pipeline + doc: | + TODO + returns: + doc: | + TODO + type: object.render_pipeline + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.render_pipeline_descriptor + pointer: immutable + - name: create_sampler + doc: | + TODO + returns: + doc: | + TODO + type: object.sampler + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.sampler_descriptor + pointer: immutable + optional: true + - name: create_shader_module + doc: | + TODO + returns: + doc: | + TODO + type: object.shader_module + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.shader_module_descriptor + pointer: immutable + - name: create_texture + doc: | + TODO + returns: + doc: | + TODO + type: object.texture + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.texture_descriptor + pointer: immutable + - name: destroy + doc: | + TODO + - name: get_lost_future + doc: "" + returns: + doc: | + The @ref WGPUFuture for the device-lost event of the device. + type: struct.future + - name: get_limits + doc: | + TODO + returns: + doc: Indicates if there was an @ref OutStructChainError. + type: enum.status + args: + - name: limits + doc: | + TODO + type: struct.limits + pointer: mutable + - name: has_feature + doc: | + TODO + returns: + doc: | + TODO + type: bool + args: + - name: feature + doc: | + TODO + type: enum.feature_name + - name: get_features + doc: | + Get the list of @ref WGPUFeatureName values supported by the device. + args: + - name: features + doc: | + TODO + type: struct.supported_features + pointer: mutable + passed_with_ownership: true + - name: get_adapter_info + doc: | + TODO + returns: + doc: Indicates if there was an @ref OutStructChainError. + type: enum.status + args: + - name: adapter_info + doc: | + TODO + type: struct.adapter_info + pointer: mutable + passed_with_ownership: true + - name: get_queue + doc: | + TODO + returns: + doc: | + TODO + type: object.queue + passed_with_ownership: true + - name: push_error_scope + doc: | + Pushes an error scope to the current thread's error scope stack. + See @ref ErrorScopes. + args: + - name: filter + doc: | + TODO + type: enum.error_filter + - name: pop_error_scope + doc: | + Pops an error scope to the current thread's error scope stack, + asynchronously returning the result. See @ref ErrorScopes. + callback: callback.pop_error_scope + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: external_texture + doc: A sampleable 2D texture that may perform 0-copy YUV sampling internally. Creation of @ref WGPUExternalTexture is extremely implementation-dependent and not defined in this header. + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: instance + doc: | + TODO + methods: + - name: create_surface + doc: Creates a @ref WGPUSurface, see @ref Surface-Creation for more details. + returns: + doc: A new @ref WGPUSurface for this descriptor (or an error @ref WGPUSurface). + type: object.surface + passed_with_ownership: true + args: + - name: descriptor + doc: The description of the @ref WGPUSurface to create. + type: struct.surface_descriptor + pointer: immutable + - name: get_WGSL_language_features + doc: | + Get the list of @ref WGPUWGSLLanguageFeatureName values supported by the instance. + args: + - name: features + doc: | + TODO + type: struct.supported_WGSL_language_features + pointer: mutable + - name: has_WGSL_language_feature + doc: | + TODO + returns: + doc: | + TODO + type: bool + args: + - name: feature + doc: | + TODO + type: enum.WGSL_language_feature_name + - name: process_events + doc: | + Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with @ref WGPUCallbackMode_AllowProcessEvents. + + See @ref Process-Events for more information. + - name: request_adapter + doc: | + TODO + callback: callback.request_adapter + args: + - name: options + doc: | + TODO + type: struct.request_adapter_options + pointer: immutable + optional: true + - name: wait_any + doc: | + 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. + returns: + doc: | + TODO + type: enum.wait_status + args: + - name: future_count + doc: | + TODO + type: usize + - name: futures + doc: | + TODO + type: struct.future_wait_info + pointer: mutable + optional: true + - name: timeout_NS + doc: | + TODO + type: uint64 + - name: pipeline_layout + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: query_set + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: get_type + doc: | + TODO + returns: + doc: | + TODO + type: enum.query_type + - name: get_count + doc: | + TODO + returns: + doc: | + TODO + type: uint32 + - name: destroy + doc: | + TODO + - name: queue + doc: | + TODO + methods: + - name: submit + doc: | + TODO + args: + - name: commands + doc: | + TODO + type: array + pointer: immutable + - name: on_submitted_work_done + doc: | + TODO + callback: callback.queue_work_done + - name: write_buffer + doc: | + Produces a @ref DeviceError both content-timeline (`size` alignment) and device-timeline + errors defined by the WebGPU specification. + args: + - name: buffer + doc: | + TODO + type: object.buffer + - name: buffer_offset + doc: | + TODO + type: uint64 + - name: data + doc: | + TODO + type: c_void + pointer: immutable + - name: size + doc: | + TODO + type: usize + - name: write_texture + doc: | + TODO + args: + - name: destination + doc: | + TODO + type: struct.texel_copy_texture_info + pointer: immutable + - name: data + doc: | + TODO + type: c_void + pointer: immutable + - name: data_size + doc: | + TODO + type: usize + - name: data_layout + doc: | + TODO + type: struct.texel_copy_buffer_layout + pointer: immutable + - name: write_size + doc: | + TODO + type: struct.extent_3D + pointer: immutable + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: render_bundle + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: render_bundle_encoder + doc: | + TODO + methods: + - name: set_pipeline + doc: | + TODO + args: + - name: pipeline + doc: | + TODO + type: object.render_pipeline + - name: set_bind_group + doc: | + TODO + args: + - name: group_index + doc: | + TODO + type: uint32 + - name: group + doc: | + TODO + type: object.bind_group + optional: true + - name: dynamic_offsets + doc: | + TODO + type: array + pointer: immutable + - name: draw + doc: | + TODO + args: + - name: vertex_count + doc: | + TODO + type: uint32 + - name: instance_count + doc: | + TODO + type: uint32 + - name: first_vertex + doc: | + TODO + type: uint32 + - name: first_instance + doc: | + TODO + type: uint32 + - name: draw_indexed + doc: | + TODO + args: + - name: index_count + doc: | + TODO + type: uint32 + - name: instance_count + doc: | + TODO + type: uint32 + - name: first_index + doc: | + TODO + type: uint32 + - name: base_vertex + doc: | + TODO + type: int32 + - name: first_instance + doc: | + TODO + type: uint32 + - name: draw_indirect + doc: | + TODO + args: + - name: indirect_buffer + doc: | + TODO + type: object.buffer + - name: indirect_offset + doc: | + TODO + type: uint64 + - name: draw_indexed_indirect + doc: | + TODO + args: + - name: indirect_buffer + doc: | + TODO + type: object.buffer + - name: indirect_offset + doc: | + TODO + type: uint64 + - name: insert_debug_marker + doc: | + TODO + args: + - name: marker_label + doc: | + TODO + type: string_with_default_empty + - name: pop_debug_group + doc: | + TODO + - name: push_debug_group + doc: | + TODO + args: + - name: group_label + doc: | + TODO + type: string_with_default_empty + - name: set_vertex_buffer + doc: | + TODO + args: + - name: slot + doc: | + TODO + type: uint32 + - name: buffer + doc: | + TODO + type: object.buffer + optional: true + - name: offset + doc: | + TODO + type: uint64 + - name: size + doc: | + TODO + type: uint64 + - name: set_index_buffer + doc: | + TODO + args: + - name: buffer + doc: | + TODO + type: object.buffer + - name: format + doc: | + TODO + type: enum.index_format + - name: offset + doc: | + TODO + type: uint64 + - name: size + doc: | + TODO + type: uint64 + - name: finish + doc: | + TODO + returns: + doc: | + TODO + type: object.render_bundle + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.render_bundle_descriptor + pointer: immutable + optional: true + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: render_pass_encoder + doc: | + TODO + methods: + - name: set_pipeline + doc: | + TODO + args: + - name: pipeline + doc: | + TODO + type: object.render_pipeline + - name: set_bind_group + doc: | + TODO + args: + - name: group_index + doc: | + TODO + type: uint32 + - name: group + doc: | + TODO + type: object.bind_group + optional: true + - name: dynamic_offsets + doc: | + TODO + type: array + pointer: immutable + - name: draw + doc: | + TODO + args: + - name: vertex_count + doc: | + TODO + type: uint32 + - name: instance_count + doc: | + TODO + type: uint32 + - name: first_vertex + doc: | + TODO + type: uint32 + - name: first_instance + doc: | + TODO + type: uint32 + - name: draw_indexed + doc: | + TODO + args: + - name: index_count + doc: | + TODO + type: uint32 + - name: instance_count + doc: | + TODO + type: uint32 + - name: first_index + doc: | + TODO + type: uint32 + - name: base_vertex + doc: | + TODO + type: int32 + - name: first_instance + doc: | + TODO + type: uint32 + - name: draw_indirect + doc: | + TODO + args: + - name: indirect_buffer + doc: | + TODO + type: object.buffer + - name: indirect_offset + doc: | + TODO + type: uint64 + - name: draw_indexed_indirect + doc: | + TODO + args: + - name: indirect_buffer + doc: | + TODO + type: object.buffer + - name: indirect_offset + doc: | + TODO + type: uint64 + - name: execute_bundles + doc: | + TODO + args: + - name: bundles + doc: | + TODO + type: array + pointer: immutable + - name: insert_debug_marker + doc: | + TODO + args: + - name: marker_label + doc: | + TODO + type: string_with_default_empty + - name: pop_debug_group + doc: | + TODO + - name: push_debug_group + doc: | + TODO + args: + - name: group_label + doc: | + TODO + type: string_with_default_empty + - name: set_stencil_reference + doc: | + TODO + args: + - name: reference + doc: | + TODO + type: uint32 + - name: set_blend_constant + doc: | + TODO + args: + - name: color + doc: | + The RGBA blend constant. Represents an `f32` color using @ref DoubleAsSupertype. + type: struct.color + pointer: immutable + - name: set_viewport + doc: | + TODO + + If any argument is non-finite, produces a @ref NonFiniteFloatValueError. + args: + - name: x + doc: | + TODO + type: float32 + - name: y + doc: | + TODO + type: float32 + - name: width + doc: | + TODO + type: float32 + - name: height + doc: | + TODO + type: float32 + - name: min_depth + doc: | + TODO + type: float32 + - name: max_depth + doc: | + TODO + type: float32 + - name: set_scissor_rect + doc: | + TODO + args: + - name: x + doc: | + TODO + type: uint32 + - name: y + doc: | + TODO + type: uint32 + - name: width + doc: | + TODO + type: uint32 + - name: height + doc: | + TODO + type: uint32 + - name: set_vertex_buffer + doc: | + TODO + args: + - name: slot + doc: | + TODO + type: uint32 + - name: buffer + doc: | + TODO + type: object.buffer + optional: true + - name: offset + doc: | + TODO + type: uint64 + - name: size + doc: | + TODO + type: uint64 + - name: set_index_buffer + doc: | + TODO + args: + - name: buffer + doc: | + TODO + type: object.buffer + - name: format + doc: | + TODO + type: enum.index_format + - name: offset + doc: | + TODO + type: uint64 + - name: size + doc: | + TODO + type: uint64 + - name: begin_occlusion_query + doc: | + TODO + args: + - name: query_index + doc: | + TODO + type: uint32 + - name: end_occlusion_query + doc: | + TODO + - name: end + doc: | + TODO + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: render_pipeline + doc: | + TODO + methods: + - name: get_bind_group_layout + doc: | + TODO + returns: + doc: | + TODO + type: object.bind_group_layout + passed_with_ownership: true + args: + - name: group_index + doc: | + TODO + type: uint32 + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: sampler + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: shader_module + doc: | + TODO + methods: + - name: get_compilation_info + doc: | + TODO + callback: callback.compilation_info + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: surface + doc: An object used to continuously present image data to the user, see @ref Surfaces for more details. + methods: + - name: configure + doc: | + 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. + args: + - name: config + doc: The new configuration to use. + type: struct.surface_configuration + pointer: immutable + - name: get_capabilities + doc: | + Provides information on how `adapter` is able to use `surface`. + See @ref Surface-Capabilities for more details. + returns: + doc: Indicates if there was an @ref OutStructChainError. + type: enum.status + args: + - name: adapter + doc: The @ref WGPUAdapter to get capabilities for presenting to this @ref WGPUSurface. + type: object.adapter + - name: capabilities + doc: | + The structure to fill capabilities in. + It may contain memory allocations so @ref wgpuSurfaceCapabilitiesFreeMembers must be called to avoid memory leaks. + type: struct.surface_capabilities + pointer: mutable + passed_with_ownership: true + - name: get_current_texture + doc: | + 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. + args: + - name: surface_texture + doc: The structure to fill the @ref WGPUTexture and metadata in. + type: struct.surface_texture + pointer: mutable + - name: present + doc: | + Shows `surface`'s current texture to the user. + See @ref Surface-Presenting for more details. + returns: + doc: | + Returns @ref WGPUStatus_Error if the surface doesn't have a current texture. + type: enum.status + - name: unconfigure + doc: | + Removes the configuration for `surface`. + See @ref Surface-Configuration for more details. + - name: set_label + doc: Modifies the label used to refer to `surface`. + args: + - name: label + doc: The new label. + type: string_with_default_empty + - name: texture + doc: | + TODO + methods: + - name: create_view + doc: | + TODO + returns: + doc: | + TODO + type: object.texture_view + passed_with_ownership: true + args: + - name: descriptor + doc: | + TODO + type: struct.texture_view_descriptor + pointer: immutable + optional: true + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty + - name: get_width + doc: | + TODO + returns: + doc: | + TODO + type: uint32 + - name: get_height + doc: | + TODO + returns: + doc: | + TODO + type: uint32 + - name: get_depth_or_array_layers + doc: | + TODO + returns: + doc: | + TODO + type: uint32 + - name: get_mip_level_count + doc: | + TODO + returns: + doc: | + TODO + type: uint32 + - name: get_sample_count + doc: | + TODO + returns: + doc: | + TODO + type: uint32 + - name: get_dimension + doc: | + TODO + returns: + doc: | + TODO + type: enum.texture_dimension + - name: get_texture_binding_view_dimension + doc: | + TODO + returns: + doc: | + TODO + type: enum.texture_view_dimension + - name: get_format + doc: | + TODO + returns: + doc: | + TODO + type: enum.texture_format + - name: get_usage + doc: | + TODO + returns: + doc: | + TODO + type: bitflag.texture_usage + - name: destroy + doc: | + TODO + - name: texture_view + doc: | + TODO + methods: + - name: set_label + doc: | + TODO + args: + - name: label + doc: | + TODO + type: string_with_default_empty diff --git a/libs/wgpu-native/wgpu-native-meta/wgpu-native-git-tag b/libs/wgpu-native/wgpu-native-meta/wgpu-native-git-tag new file mode 100644 index 0000000..988b210 --- /dev/null +++ b/libs/wgpu-native/wgpu-native-meta/wgpu-native-git-tag @@ -0,0 +1 @@ +v29.0.0.0 diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..4392f24 --- /dev/null +++ b/src/main.zig @@ -0,0 +1,238 @@ +// Minimal WebGPU compute in Zig: element-wise matrix addition +// Uses wgpu-native C bindings. +// Build: see ../build.zig +// +// Data flow: +// CPU (mat_a, mat_b) → GPU storage buffers → compute shader → GPU buf_c +// → staging buffer (mapped) → CPU read → print + +const std = @import("std"); +const c = @cImport(@cInclude("wgpu.h")); + +// ── Config ──────────────────────────────────────────────────────────────────── +const ROWS: u32 = 4; +const COLS: u32 = 4; +const N = ROWS * COLS; // 16 elements +const BUF_BYTES = N * @sizeOf(f32); + +// ── WGSL Compute Shader ─────────────────────────────────────────────────────── +// workgroup_size(4,4) matches one full 4×4 matrix → dispatch(1,1,1) +const SHADER = + \\@group(0) @binding(0) var mat_a : array; + \\@group(0) @binding(1) var mat_b : array; + \\@group(0) @binding(2) var mat_c : array; + \\ + \\@compute @workgroup_size(4, 4) + \\fn main(@builtin(global_invocation_id) gid : vec3) { + \\ let idx = gid.y * 4u + gid.x; + \\ if (idx < arrayLength(&mat_c)) { + \\ mat_c[idx] = mat_a[idx] + mat_b[idx]; + \\ } + \\} +; + +// ── Callback state ──────────────────────────────────────────────────────────── +const Ctx = struct { + adapter: c.WGPUAdapter = null, + device: c.WGPUDevice = null, +}; + +fn onAdapter( + status: c.WGPURequestAdapterStatus, + adapter: c.WGPUAdapter, + _: c.WGPUStringView, + userdata1: ?*anyopaque, + _: ?*anyopaque, +) callconv(.c) void { + if (status != c.WGPURequestAdapterStatus_Success) { + std.log.err("Adapter request failed (status={d})", .{status}); + return; + } + const ctx: *Ctx = @ptrCast(@alignCast(userdata1.?)); + ctx.adapter = adapter; +} + +fn onDevice( + status: c.WGPURequestDeviceStatus, + device: c.WGPUDevice, + _: c.WGPUStringView, + userdata1: ?*anyopaque, + _: ?*anyopaque, +) callconv(.c) void { + if (status != c.WGPURequestDeviceStatus_Success) { + std.log.err("Device request failed (status={d})", .{status}); + return; + } + const ctx: *Ctx = @ptrCast(@alignCast(userdata1.?)); + ctx.device = device; +} + +fn onMapped( + status: c.WGPUMapAsyncStatus, + _: c.WGPUStringView, + userdata1: ?*anyopaque, + _: ?*anyopaque, +) callconv(.c) void { + const flag: *bool = @ptrCast(@alignCast(userdata1.?)); + flag.* = (status == c.WGPUMapAsyncStatus_Success); +} + +fn sv(s: []const u8) c.WGPUStringView { + return .{ .data = s.ptr, .length = s.len }; +} + +// ── Main ────────────────────────────────────────────────────────────────────── +pub fn main() !void { + + // 1. Instance ────────────────────────────────────────────────────────────── + const instance = c.wgpuCreateInstance(&std.mem.zeroes(c.WGPUInstanceDescriptor)) orelse + return error.NoInstance; + defer c.wgpuInstanceRelease(instance); + + // 2. Adapter (async → poll) ──────────────────────────────────────────────── + var ctx = Ctx{}; + _ = c.wgpuInstanceRequestAdapter( + instance, + &.{ .powerPreference = c.WGPUPowerPreference_HighPerformance }, + .{ .callback = onAdapter, .userdata1 = &ctx }, + ); + c.wgpuInstanceProcessEvents(instance); // drive callbacks + const adapter = ctx.adapter orelse return error.NoAdapter; + defer c.wgpuAdapterRelease(adapter); + + // 3. Device ──────────────────────────────────────────────────────────────── + _ = c.wgpuAdapterRequestDevice(adapter, null, .{ .callback = onDevice, .userdata1 = &ctx }); + c.wgpuInstanceProcessEvents(instance); + const device = ctx.device orelse return error.NoDevice; + defer c.wgpuDeviceRelease(device); + + const queue = c.wgpuDeviceGetQueue(device); + defer c.wgpuQueueRelease(queue); + + // 4. Input data ──────────────────────────────────────────────────────────── + // mat_a[i] = i (0 … 15) + // mat_b[i] = 15 − i → every element of mat_c should equal 15 + var mat_a: [N]f32 = undefined; + var mat_b: [N]f32 = undefined; + for (0..N) |i| { + mat_a[i] = @floatFromInt(i); + mat_b[i] = @floatFromInt(N - 1 - i); + } + + // 5. GPU Buffers ─────────────────────────────────────────────────────────── + const buf_a = c.wgpuDeviceCreateBuffer(device, &.{ + .usage = c.WGPUBufferUsage_Storage | c.WGPUBufferUsage_CopyDst, + .size = BUF_BYTES, + }) orelse return error.BufferA; + + const buf_b = c.wgpuDeviceCreateBuffer(device, &.{ + .usage = c.WGPUBufferUsage_Storage | c.WGPUBufferUsage_CopyDst, + .size = BUF_BYTES, + }) orelse return error.BufferB; + + // buf_c: GPU-only result; staging: CPU-readable copy + const buf_c = c.wgpuDeviceCreateBuffer(device, &.{ + .usage = c.WGPUBufferUsage_Storage | c.WGPUBufferUsage_CopySrc, + .size = BUF_BYTES, + }) orelse return error.BufferC; + + const buf_staging = c.wgpuDeviceCreateBuffer(device, &.{ + .usage = c.WGPUBufferUsage_MapRead | c.WGPUBufferUsage_CopyDst, + .size = BUF_BYTES, + }) orelse return error.BufferStaging; + + defer c.wgpuBufferRelease(buf_a); + defer c.wgpuBufferRelease(buf_b); + defer c.wgpuBufferRelease(buf_c); + defer c.wgpuBufferRelease(buf_staging); + + // Upload inputs + c.wgpuQueueWriteBuffer(queue, buf_a, 0, &mat_a, BUF_BYTES); + c.wgpuQueueWriteBuffer(queue, buf_b, 0, &mat_b, BUF_BYTES); + + // 6. Shader module ───────────────────────────────────────────────────────── + // ✅ New API (0.20+) + var wgsl_src = c.WGPUShaderSourceWGSL{ + .chain = .{ .sType = c.WGPUSType_ShaderSourceWGSL }, + .code = sv(SHADER), + }; + const shader = c.wgpuDeviceCreateShaderModule(device, &.{ + .nextInChain = @ptrCast(&wgsl_src), + }) orelse return error.Shader; + + // 7. Compute pipeline (layout auto-inferred from shader) ─────────────────── + // ✅ + const pipeline = c.wgpuDeviceCreateComputePipeline(device, &.{ + .compute = .{ + .module = shader, + .entryPoint = sv("main"), + }, + }) orelse return error.Pipeline; + defer c.wgpuComputePipelineRelease(pipeline); + + // 8. Bind group ──────────────────────────────────────────────────────────── + const bgl = c.wgpuComputePipelineGetBindGroupLayout(pipeline, 0); + defer c.wgpuBindGroupLayoutRelease(bgl); + + const entries = [_]c.WGPUBindGroupEntry{ + .{ .binding = 0, .buffer = buf_a, .offset = 0, .size = BUF_BYTES }, + .{ .binding = 1, .buffer = buf_b, .offset = 0, .size = BUF_BYTES }, + .{ .binding = 2, .buffer = buf_c, .offset = 0, .size = BUF_BYTES }, + }; + const bind_group = c.wgpuDeviceCreateBindGroup(device, &.{ + .layout = bgl, + .entries = &entries, + .entryCount = entries.len, + }) orelse return error.BindGroup; + defer c.wgpuBindGroupRelease(bind_group); + + // 9. Encode compute pass + buffer copy ──────────────────────────────────── + const encoder = c.wgpuDeviceCreateCommandEncoder(device, null) orelse + return error.Encoder; + + const pass = c.wgpuCommandEncoderBeginComputePass(encoder, null); + c.wgpuComputePassEncoderSetPipeline(pass, pipeline); + c.wgpuComputePassEncoderSetBindGroup(pass, 0, bind_group, 0, null); + // dispatch(1,1,1): one workgroup of size (4,4) covers the whole 4×4 matrix + c.wgpuComputePassEncoderDispatchWorkgroups(pass, 1, 1, 1); + c.wgpuComputePassEncoderEnd(pass); + c.wgpuComputePassEncoderRelease(pass); + + // Copy result buffer → CPU-readable staging buffer + c.wgpuCommandEncoderCopyBufferToBuffer(encoder, buf_c, 0, buf_staging, 0, BUF_BYTES); + + const cmdbuf = c.wgpuCommandEncoderFinish(encoder, null); + defer c.wgpuCommandEncoderRelease(encoder); + defer c.wgpuCommandBufferRelease(cmdbuf); + + // 10. Submit ─────────────────────────────────────────────────────────────── + c.wgpuQueueSubmit(queue, 1, &cmdbuf); + + // 11. Map staging buffer back to CPU ────────────────────────────────────── + var mapped = false; + _ = c.wgpuBufferMapAsync( + buf_staging, + c.WGPUMapMode_Read, + 0, + BUF_BYTES, + .{ .callback = onMapped, .userdata1 = &mapped }, + ); + // Poll the device until the async map completes + while (!mapped) _ = c.wgpuDevicePoll(device, 1, null); + + const ptr: [*]const f32 = @ptrCast(@alignCast( + c.wgpuBufferGetConstMappedRange(buf_staging, 0, BUF_BYTES), + )); + const result = ptr[0..N]; + + // 12. Print ──────────────────────────────────────────────────────────────── + std.debug.print("\nmat_a + mat_b ({d}×{d}):\n", .{ ROWS, COLS }); + for (0..ROWS) |r| { + for (0..COLS) |col| + std.debug.print("{d:6.0}", .{result[r * COLS + col]}); + std.debug.print("\n", .{}); + } + // Expected output: every cell = 15.0 + + c.wgpuBufferUnmap(buf_staging); +}