diff --git a/_posts/2025-12-15-improving-usability-of-c-libraries-in-swift.md b/_posts/2025-12-15-improving-usability-of-c-libraries-in-swift.md new file mode 100644 index 000000000..35252bf4c --- /dev/null +++ b/_posts/2025-12-15-improving-usability-of-c-libraries-in-swift.md @@ -0,0 +1,694 @@ +--- +layout: new-layouts/post +published: true +date: 2025-12-15 12:00:00 +title: "Improving the usability of C libraries in Swift" +author: [doug_gregor] +category: "Language" +--- + +There are many interesting, useful, and fun C libraries in the software ecosystem. While one could go and rewrite these libraries in Swift, usually there is no need, because Swift provides direct interoperability with C. With a little setup, you can directly use existing C libraries from your Swift code. + +When you use a C library directly from Swift, it will look and feel similar to using it from C. That can be useful if you're following sample code or a tutorial written in C, but it can also feel out-of-place. For example, here's a small amount of code using a C API: + +```swift + var instanceDescriptor = WGPUInstanceDescriptor() + let instance = wgpuCreateInstance(&instanceDescriptor) + var surfaceDescriptor = WGPUSurfaceDescriptor() + let surface = wgpuInstanceCreateSurface(instance, &surfaceDescriptor) + if wgpuSurfacePresent(&surface) == WGPUStatus_Error { + // report error + } + wgpuSurfaceRelease(surface) + wgpuInstanceRelease(instance) +``` + +The C library here that Swift is using comes from the [webgpu-headers project](https://github.com/webgpu-native/webgpu-headers), which vends a C header (`webgpu.h`) that is used by several implementations of [WebGPU](https://www.w3.org/TR/webgpu/). WebGPU is a technology that enables web developers to use the system's GPU (Graphics Processing Unit) from the browser. For the purposes of this post, you don't really need to know anything about WebGPU: I'm using it as an example of a typical C library, and the techniques described in this blog post apply to lots of other well-designed C libraries. + +The Swift code above has a very "C" feel to it. It has global function calls with prefixed names like `wgpuInstanceCreateSurface` and global integer constants like `WGPUStatus_Error`. It pervasively uses unsafe pointers, some of which are managed with explicit reference counting, where the user provides calls to `wpuXYZAddRef` and `wgpuXYZRelease` functions. It works, but it doesn't feel like Swift, and inherits various safety problems of C. + +Fortunately, we can improve this situtation, providing a safer and more ergonomic interface to WebGPU from Swift that feels like it belongs in Swift. More importantly, we can do so without changing the WebGPU implementation: Swift provides a suite of annotations that you can apply to C headers to improve the way in which the C APIs are expressed in Swift. These annotations describe common conventions in C that match up with Swift constructs, projecting a more Swift-friendly interface on top of the C code. + +In this post, I'm going to leverage these annotations to improve how Swift interacts with WebGPU. By the end, we'll be able to take advantage of Swift features like argument labels, methods, enums, and automatic reference counting, like this: + +```swift + var instanceDescriptor = WGPUInstanceDescriptor() + let instance = WGPUInstance(descriptor: &instanceDescriptor) + var surfaceDescriptor = WGPUSurfaceDescriptor() + let surface = instance.createSurface(descriptor: &surfaceDescriptor) + if surface.present() == .error { + // report error + } + // Swift automatically deallocates the instance and surface when we're done +``` + +These same annotations can be used for any C library to provide a safer, more ergonomic development experience in Swift without changing the C library at all. + +> **Note**: Some of what is covered in this post requires bug fixes that first became available in Swift 6.2.3. + +## Setup: Writing a module map + +A [module map](https://clang.llvm.org/docs/Modules.html) is a way of layering a Swift-friendly modular structure on top of C headers. You can create a module map for the WebGPU header by writing the following to a file `module.modulemap`: + +```swift +module WebGPU { + header "webgpu.h" +} +``` + +The easiest thing to do is to put `module.modulemap` alongside the header itself. For my experiment here, I put it in the root direction of my `webgpu-headers` checkout. If you're in a Swift package, put it into its own target with this layout: + +```swift +├── Package.swift +└── Sources + └── WebGPU + ├── include + │ ├── webgpu.h + │ └── module.modulemap + └── WebGPU.c (empty file) +``` + +If you reference this `WebGPU` target from elsewhere in the package, you can `import WebGPU` to get access to the C APIs. + +## Seeing the results + +There are a few ways to see what the Swift interface for a C library looks like. + +* Xcode's "Swift 5 interface" counterpart to the `webgpu.h` header will show how the header has been mapped into Swift. +* The `swift-synthesize-interface` tool in Swift 6.2+ prints the Swift interface to the terminal. + +I'm going to do it from the command line, using `swift-synthesize-interface`. From the directory containing `webgpu.h` and `module.modulemap`, run: + +```swift +swift-synthesize-interface -I . -module-name WebGPU -target arm64-apple-macos14 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk +``` + +The `-sdk` argument with the path is only needed because I'm on a Mac. The `-target` operation is the triple provided if you run `swiftc -print-target-info`. For me, it looks like this: + +```json +{ + "compilerVersion": "Apple Swift version 6.2 (swiftlang-6.2.2.15.4 clang-1700.3.15.2)", + "target": { + "triple": "arm64-apple-macosx15.0", + "unversionedTriple": "arm64-apple-macosx", + "moduleTriple": "arm64-apple-macos", + "compatibilityLibraries": [ ], + "librariesRequireRPath": false + }, + "paths": { + "runtimeLibraryPaths": [ + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx", + "/usr/lib/swift" + ], + "runtimeLibraryImportPaths": [ + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx" + ], + "runtimeResourcePath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift" + } +} +``` + +The output of this is the Swift API for the WebGPU module, directly translated from C. For example, this code from the WebGPU header: + +```c +typedef enum WGPUAdapterType { + WGPUAdapterType_DiscreteGPU = 0x00000001, + WGPUAdapterType_IntegratedGPU = 0x00000002, + WGPUAdapterType_CPU = 0x00000003, + WGPUAdapterType_Unknown = 0x00000004, + WGPUAdapterType_Force32 = 0x7FFFFFFF +} WGPUAdapterType WGPU_ENUM_ATTRIBUTE; +``` + +will be translated into: + +```swift +public struct WGPUAdapterType : Hashable, Equatable, RawRepresentable { + public init(_ rawValue: UInt32) + public init(rawValue: UInt32) + public var rawValue: UInt32 +} + +public var WGPUAdapterType_DiscreteGPU: WGPUAdapterType { get } +public var WGPUAdapterType_IntegratedGPU: WGPUAdapterType { get } +public var WGPUAdapterType_CPU: WGPUAdapterType { get } +public var WGPUAdapterType_Unknown: WGPUAdapterType { get } +public var WGPUAdapterType_Force32: WGPUAdapterType { get } +``` + +and there will be lots of global functions like this: + +```swift +public func wgpuComputePipelineGetBindGroupLayout(_ computePipeline: WGPUComputePipeline!, _ groupIndex: UInt32) -> WGPUBindGroupLayout! +public func wgpuComputePipelineSetLabel(_ computePipeline: WGPUComputePipeline!, _ label: WGPUStringView) +public func wgpuComputePipelineAddRef(_ computePipeline: WGPUComputePipeline!) +public func wgpuComputePipelineRelease(_ computePipeline: WGPUComputePipeline!) +``` + +It's a starting point! You can absolutely write Swift programs using these WebGPU APIs, and they'll feel a lot like writing them in C. Let's see what we can do to make it better. + +## Cleaning up enumeration types + +C enums can be used for several things. Sometimes they really represent a choice among several alternatives. Sometimes they represent flags in a set of options, from which you can choose several. Sometimes they're just a convenient way to create a bunch of named constants. Swift conservatively imports enum types as wrappers over the underlying C type used to store values of the enum (e.g., `WGPUAdapterType` wraps a `UInt32`) and makes the enumerators into global constants. It covers all of the possible use cases, but it isn't *nice*. + +The `WGPUAdapterType` enum really is a choice among one of several options, which would be best represented as an `enum` in Swift. If we were willing to modify the header, we could apply the [`enum_extensibility` attribute](https://clang.llvm.org/docs/AttributeReference.html#enum-extensibility) to the enum, like this: + +```c +typedef enum __attribute__((enum_extensibility(closed))) WGPUAdapterType { + WGPUAdapterType_DiscreteGPU = 0x00000001, + WGPUAdapterType_IntegratedGPU = 0x00000002, + WGPUAdapterType_CPU = 0x00000003, + WGPUAdapterType_Unknown = 0x00000004, + WGPUAdapterType_Force32 = 0x7FFFFFFF +} WGPUAdapterType WGPU_ENUM_ATTRIBUTE; +``` + +This works, and results in a much nicer Swift API: + +```swift +@frozen public enum WGPUAdapterType : UInt32, @unchecked Sendable { + case discreteGPU = 1 + case integratedGPU = 2 + case CPU = 3 + case unknown = 4 + case force32 = 2147483647 +} +``` + +Now, we get an `enum` that we can switch over, and nice short case names, e.g., + +```swift +switch adapterType { + case .discreteGPU, .integratedGPU: + print("definitely a GPU") + default: + print("not so sure") +} +``` + +That's great, but I already broke my rule: no header modifications unless I have to! + +## API notes + +The problem of needing to layer information on top of existing C headers is not a new one. As noted earlier, Swift relies on a Clang feature called [API notes](https://clang.llvm.org/docs/APINotes.html) to let us express this same information in a separate file, so we don't have to edit the header. In this case, we create a file called `WebGPU.apinotes` (the name `WebGPU` matches the module name from `module.map`), which is a YAML file describing the extra information. We'll start with one that turns `WGPUAdapterType` into an `enum`: + +```yaml +--- +Name: WebGPU +Tags: +- Name: WGPUAdapterType + EnumExtensibility: closed +``` + +`Tags` here is a term used in the C and C++ standard to refer to enum, struct, union, or class types. Any information about those types in the API notes file will go into that section. + +Put `WebGPU.apinotes` alongside the `module.map`, and now `WGPUAdapterType` gets mapped into a `Swift` enum. For a package, the structure will look like this: + +```swift +├── Package.swift +└── Sources + └── WebGPU + ├── include + │ ├── webgpu.h + │ ├── WebGPU.apinotes + │ └── module.modulemap + └── WebGPU.c (empty file) +``` + +We'll be adding more to this API notes file as we keep digging through the interface. + +## Reference-counted object types + +The WebGPU header has a number of "object" types that are defined like this: + +```c +typedef struct WGPUBindGroupImpl* WGPUBindGroup WGPU_OBJECT_ATTRIBUTE; +``` + +This gets imported into Swift as an alias for an opaque pointer type, which is... not great: + +```swift +public typealias WGPUBindGroup = OpaquePointer +``` + +WebGPU object types are reference counted, and each object type has corresponding `AddRef` and `Release` functions to increment and decrement the reference count, like this: + +```c +WGPU_EXPORT void wgpuBindGroupAddRef(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +``` + +Of course, you can use these functions in Swift exactly how you do in C, making sure to balance out calls to `AddRef` and `Release`, but then it would be every bit as unsafe as C. + +We can do better with [`SWIFT_SHARED_REFERENCE`](https://www.swift.org/documentation/cxx-interop/#shared-reference-types). It's a macro (defined in the `` header) that can turn a reference-counted C type like the above into an automatically reference-counted `class` in Swift. Here's how we would use it in the header: + +```swift +typedef struct SWIFT_SHARED_REFERENCE(wgpuBindGroupAddRef, wgpuBindGroupRelease) WGPUBindGroupImpl* WGPUBindGroup WGPU_OBJECT_ATTRIBUTE; +``` + +Now, `WGPUBindGroup` gets imported like this: + +```swift +public class WGPUBindGroupImpl { } +public typealias WGPUBindGroup = WGPUBindGroupImpl +``` + +The extra typealias is a little weird, but overall this is a huge improvement: Swift is treating `WGPUBindGroup` as a class, meaning that it automatically manages retains and releases for you! This is both an ergonomic win (less code to write) and a safety win, because it's eliminated the possibility of mismanaging these instances. + +There's one more thing: when dealing with reference-counting APIs, you need to know whether a particular function that returns an object is expecting you to call "release" when you're done. In the WebGPU header, this information is embedded in a comment: + +```c +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +``` + +"ReturnedWithOwnership" here means that the result of the call has already been retained one extra time, and the caller is responsible for calling "release" when they are done with it. The `` header has a `SWIFT_RETURNS_RETAINED` macro that expresses this notion. One can use it like this: + +```swift +WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE SWIFT_RETURNS_RETAINED; +``` + +Now, Swift will balance out the retain that `wgpuDeviceCreateBindGroup` has promised to do by performing the extra release once you're done using the object. Once these annotations are done, we're all set with a more ergonomic and memory-safe API for this C library. There's no need to ever call `wgpuBindGroupRelease` or `wgpuBindGroupAddRef` yourself. + +We've hacked up our header again, so let's undo that and move all of this out to API notes. To turn a type into a foreign reference type, we augment the `Tags` section of our API notes with the same information, but in YAML form: + +```yaml +- Name: WGPUBindGroupImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuBindGroupRelease + SwiftRetainOp: wgpuBindGroupAddRef +``` + +That makes `WGPUBindGroupImpl` import as a class type, with the given retain and release functions. We can express the "returns retained" behavior of the `wgpuDeviceCreateBindGroup` function like this: + +```yaml +Functions: +- Name: wgpuDeviceCreateBindGroup + SwiftReturnOwnership: retained +``` + +That's enums and classes, so now let's tackle... functions. + +## Importing functions + +A typical function from `webgpu.h`, like this: + +```c +WGPU_EXPORT void wgpuQueueWriteBuffer( + WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, + void const * data, size_t size +) WGPU_FUNCTION_ATTRIBUTE; +``` + +will come into Swift like this: + +```swift +public func wgpuQueueWriteBuffer(_ queue: WGPUQueue!, _ buffer: WGPUBuffer!, _ bufferOffset: UInt64, _ data: UnsafeRawPointer!, _ size: Int) +``` + +Note that `_` on each parameter, which means that we won't use argument labels for anything when we call it: + +```swift +wgpuQueueWriteBuffer(myQueue, buffer, position, dataToWrite, bytesToWrite) +``` + +That matches C, but it isn't as clear as it could be in Swift. Let's clean this up by providing a better name in Swift that includes argument labels. We can do so using `SWIFT_NAME` (also in ``), like this: + +```c +WGPU_EXPORT void wgpuQueueWriteBuffer( + WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, + void const * data, size_t size + ) WGPU_FUNCTION_ATTRIBUTE + SWIFT_NAME("wgpuQueueWriteBuffer(_:buffer:bufferOffset:data:size:)"); +``` + +Within the parentheses, we have each of the argument labels that we want (or `_` meaning "no label"), each followed by a `:`. This is how one describes a full function name in Swift. Once we've made this change to the Swift name, the C function comes into Swift with argument labels, like this: + +```swift +public func wgpuQueueWriteBuffer(_ queue: WGPUQueue!, buffer: WGPUBuffer!, bufferOffset: UInt64, data: UnsafeRawPointer!, size: Int) +``` + +That makes the call site more clear and self-documenting: + +```swift +wgpuQueueWriteBuffer(myQueue, buffer: buffer, offset: position, data: dataToWrite, size: bytesToWrite) +``` + +### Importing functions as methods + +There is more usable structure in this API. Note that the `wgpuQueueWriteBuffer` function takes, as its first argument, an instance of `WGPUQueue`. Most of the C functions in `WebGPU.h` are like this, because these are effectively functions that operate on their first argument. In a language that has methods, they would be methods. Swift has methods, so let's make them methods! + +```c +WGPU_EXPORT void wgpuQueueWriteBuffer( + WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) + WGPU_FUNCTION_ATTRIBUTE SWIFT_NAME("WGPUBufferImpl.writeBuffer(self:buffer:bufferOffset:data:size:)"); +``` + +There are three things to notice about this `SWIFT_NAME` string: + +* It starts with `WGPUBufferImpl.`, which tells Swift to make this function a member inside `WGPUBufferImpl`. +* I've changed the function name to `writeBuffer`, because we no longer need the `wgpuQueue` prefix to distinguish it from other "write buffer" operations on other types. +* The name of the first argument in parentheses is `self`, which indicates that the `self` argument (in Swift) should be passed as that positional argument to the C function. The other arguments are passed in-order. + +Note that this also requires `WGPUBuffer(Impl)` to be imported as a `class`, as we did earlier for `WGPUBindGroupImpl`. Once we've done so, we get a much-nicer Swift API: + +```swift +extension WGPUQueueImpl { + /** + * Produces a @ref DeviceError both content-timeline (`size` alignment) and d +evice-timeline + * errors defined by the WebGPU specification. + */ + public func writeBuffer(buffer: WGPUBuffer!, bufferOffset: UInt64, data: UnsafeRawPointer!, size: Int) +} +``` + +I've gone and hacked up the header again, but I didn't have to. In `WebGPU.apinotes`, you can put a `SwiftName` attribute on any entity. For `wgpuQueueWriteBuffer`, it would look like this (in the `Functions` section): + +```yaml +- Name: wgpuQueueWriteBuffer + SwiftName: WGPUQueueImpl.writeBuffer(self:buffer:bufferOffset:data:size:) +``` + +### Importing functions as properties + +`WebGPU.h` has a number of `Get` functions that produce information about some aspect of a type. Here are two for the `WGPUQuerySet` type: + +```c +WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +``` + +With the `SWIFT_NAME` tricks above, we can turn these into "get" methods on `WGPUQuerySet`, like this: + +```swift +extension WGPUQuerySetImpl { + public func getCount() -> UInt32 + public func getType() -> WGPUQueryType +} +``` + +That's okay, but it's not what you'd do in Swift. Let's go one step further and turn them into read-only computed properties. To do so, we use the `getter:` prefix on the Swift name we define. I'll skip ahead to the YAML form that goes into API notes: + +```yaml +- Name: wgpuQuerySetGetCount + SwiftName: getter:WGPUQuerySetImpl.count(self:) +- Name: wgpuQuerySetGetType + SwiftName: getter:WGPUQuerySetImpl.type(self:) +``` + +And now, we arrive at a nice Swift API: + +```swift +extension WGPUQuerySetImpl { + public var count: UInt32 { get } + public var type: WGPUQueryType { get } +} +``` + +### Importing functions as initializers + +`SWIFT_NAME` can also be used to import a function that returns a new instance as a Swift initializer. For example, this function creates a new `WGPUInstance` (which I'm assuming is getting imported as a `class` like I've been doing above): + +```c +/** + * Create a WGPUInstance + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +``` + +We can turn this into a Swift initializer, which is used to create a new object, using the same `SWIFT_NAME` syntax but where the method name is `init`. Here is the YAML form that goes into API notes: + +```yaml +- Name: wgpuCreateInstance + SwiftReturnOwnership: retained + SwiftName: WGPUInstanceImpl.init(descriptor:) +``` + +and here is the resulting Swift initializer: + +```swift +extension WGPUInstanceImpl { + /** + * Create a WGPUInstance + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public /*not inherited*/ init!(descriptor: UnsafePointer!) +} +``` + +Now, one can create a new `WGPUInstance` with the normal object-creation syntax, e.g., + +```swift +let instance = WGPUInstance(descriptor: myDescriptor) +``` + +## Another Boolean type? + +The WebGPU header defines its own Boolean type. I wish everyone would use C99's `_Bool` and be done with it, but alas, here are the definitions for WebGPUs Boolean types: + +```c +#define WGPU_TRUE (UINT32_C(1)) +#define WGPU_FALSE (UINT32_C(0)) +typedef uint32_t WGPUBool; +``` + +This means that `WGPUBool` will come in to Swift as a `UInt32`. The two macros aren't available in Swift at all: they're "too complicated" to be recognized as integral constants. Even if they were available in Swift, it still wouldn't be great because we want to use `true` and `false` for Boolean values in Swift, not `WGPU_TRUE` and `WGPU_FALSE`. + +To make `WGPUBool` easier to use from Swift, we're first going to map that typedef to its own `struct` that stores the underlying `UInt32`, giving it an identity separate from `UInt32`. We can do this using a `SwiftWrapper` API note within the `Typedefs` section of the file, like this: + +```yaml +- Name: WGPUBool + SwiftWrapper: struct +``` + +Now, we get `WGPUBool` imported like this: + +```swift +public struct WGPUBool : Hashable, Equatable, RawRepresentable { + public init(_ rawValue: UInt32) + public init(rawValue: UInt32) +} +``` + +To be able to use `true` and `false` literals with this new `WGPUBool`, we can write a little bit of Swift code that makes this type conform to the [`ExpressibleByBooleanLiteral`](https://developer.apple.com/documentation/swift/expressiblebybooleanliteral) protocol, like this: + +```swift +extension WGPUBool: ExpressibleByBooleanLiteral { + init(booleanLiteral value: Bool) { + self.init(rawValue: value ? 1 : 0) + } +} +``` + +That's it! Better type safety (you cannot confuse a `WGPUBool` with any other integer value) and the convenience of Boolean literals in Swift. + +## Option sets + +`webgpu.h` describes a set of flags using a `typedef` of the `WGPUFlags` type (a 64-bit unsigned integer) along with a set of global constants for the different flag values. For example, here is the `WGPUBufferUsage` flag type and some of its constants: + +```c +typedef WGPUFlags WGPUBufferUsage; +static const WGPUBufferUsage WGPUBufferUsage_MapRead = 0x0000000000000001; +static const WGPUBufferUsage WGPUBufferUsage_MapWrite = 0x0000000000000002; +static const WGPUBufferUsage WGPUBufferUsage_CopySrc = 0x0000000000000004; +static const WGPUBufferUsage WGPUBufferUsage_Index = 0x0000000000000010; +``` + +Similar to what we saw with `WGPUBool`, `WGPUBufferUsage` is a `typedef` of a `typedef` of a `uint64_t`. There's no type safety in this C API, and one could easily mix up these flags with, say, those of `WGPUMapMode`: + +```c +typedef WGPUFlags WGPUMapMode; +static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001; +static const WGPUMapMode WGPUMapMode_Write = 0x0000000000000002; +``` + +We can do better, by layering more structure for the Swift version of this API using the same `SwiftWrapper` approach from `WGPUBool`. This goes into the `Typedefs` section of API notes: + +```yaml +Typedefs: +- Name: WGPUBufferUsage + SwiftWrapper: struct +``` + +Now, `WGPUBufferUsage` comes in as its own `struct`: + +```swift +public struct WGPUBufferUsage : Hashable, Equatable, RawRepresentable { + public init(_ rawValue: WGPUFlags) + public init(rawValue: WGPUFlags) +} +``` + +The initializers let you create a `WGPUBufferUsage` from a `WGPUFlags` value, and there is also a `rawValue` property to get a `WGPUFlags` value out of a `WGPUBufferInstance`, so the raw value is always there... but the default is to be type safe. Additionally, those global constants will come in as members of `WGPUBufferUsage`, like this: + +```swift +extension WGPUBufferUsage { + /** + * The buffer can be *mapped* on the CPU side in *read* mode (using @ref WGPUMapMode_Read). + */ + public static var _MapRead: WGPUBufferUsage { get } + + /** + * 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. + */ + public static var _MapWrite: WGPUBufferUsage { get } + + /** + * The buffer can be used as the *source* of a GPU-side copy operation. + */ + public static var _CopySrc: WGPUBufferUsage { get } + + /** + * The buffer can be used as the *destination* of a GPU-side copy operation. + */ + public static var _CopyDst: WGPUBufferUsage { get } +} +``` + +This means that, if you're passing a value of type `WPUBufferUsage`, you can use the shorthand "leading dot" syntax. For example: + +```swift +func setBufferUsage(_ usage: WGPUBufferUsage) { ... } + +setBufferUsage(._MapRead) +``` + +Swift has dropped the common `WPUBufferUsage` prefix from the constants when it made them into members. However, the resulting names aren't great. We can rename them by providing a `SwiftName` in the API notes file within the `Globals` section: + +```yaml +Globals: +- Name: WGPUBufferUsage_MapRead + SwiftName: WGPUBufferUsage.mapRead +- Name: WGPUBufferUsage_MapWrite + SwiftName: WGPUBufferUsage.mapWrite +``` + +We can go one step further by making the `WGPUBufferUsage` type conform to Swift's [`OptionSet`](https://developer.apple.com/documentation/swift/optionset) protocol. If we revise the API notes like this: + +```yaml +Typedefs: +- Name: WGPUBufferUsage + SwiftWrapper: struct + SwiftConformsTo: Swift.OptionSet +``` + +Now, we get the nice option-set syntax we expect in Swift: + +```swift +let usageFlags: WGPUBufferUsage = [.mapRead, .mapWrite] +``` + +## Nullability + +Throughout `webgpu.h`, the `WGPU_NULLABLE` macro is used to indicate pointers that can be NULL. The implication is that any pointer that is not marked with `WGPU_NULLABLE` cannot be NULL. For example, here is the definition of `wgpuCreateInstance` we used above: + +```c +WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +``` + +The `WGPU_NULLABLE` indicates that it's acceptable to pass a NULL pointer in as the `descriptor` parameter. Clang already has [nullability specifiers](https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes) to express this information. We could alter the declaration in the header to express that this parameter is nullable but the result type is never NULL, like this: + +```swift +WGPU_EXPORT WGPUInstance _Nonnull wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * _Nullable descriptor) WGPU_FUNCTION_ATTRIBUTE; +``` + +This eliminates the implicitly-unwrapped optionals (`!`) from the signature of the initializer, so we end up with one that explicitly accepts a `nil` descriptor argument and always returns a new instance (never `nil`): + +```swift +extension WGPUInstanceImpl { + /** + * Create a WGPUInstance + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public /*not inherited*/ init(descriptor: UnsafePointer?) +} +``` + +Now, I did cheat by hacking the header. Instead, we can express this with API notes on the parameters and result type by extending the entry we already have for `wgpuCreateInstance` like this: + +```yaml +- Name: wgpuCreateInstance + SwiftReturnOwnership: retained + SwiftName: WGPUInstanceImpl.init(descriptor:) + Parameters: + - Position: 0 + Nullability: O + ResultType: "WGPUInstance _Nonnull" +``` + +To specific nullability of pointer parameters, one can identify them by position (where 0 is the first parameter to the function) and then specify whether the parameter should come into Swift as optional (`O`, corresponds to `_Nullable`), non-optional (`N`, corresponds to `_Nonnull`) or by left unspecified as an implicitly-unwrapped optional (`U`, corresponds to `_Null_unspecified`). For the result type, it's a little different: we specified the result type along with the nullability specifier, i.e., `WGPUInstance _Nonnull`. The end result of these annotations is the same as the modified header, so we can layer nullability information on top of the header. + +## Scripting the creation of `WebGPU.apinotes` + +`webgpu.h` is about 6,400 lines long, and is regenerated from a database of the API as needed. Each of the WebGPU implementations seems to augment or tweak the header a bit. So, rather than grind through and manually do annotations, I wrote a little Swift script to "parse" `webgpu.h`, identify its patterns, and generate `WebGPU.apinotes` for most of what is discussed in this post. The entirety of the script is [here](webgpu_apinotes.swift). It reads `webgpu.h` from standard input and prints `WebGPU.apinotes` to standard output. + +Because `webgpu.h` is generated, it has a very regular structure that we can pick up on via regular expressions. For example: + +```swift +// Enum definitions, marked by WGPU_ENUM_ATTRIBUTE. +let enumMatcher = /} (?\w+?) WGPU_ENUM_ATTRIBUTE/ + +// Object definitions, marked by WGPU_OBJECT_ATTRIBUTE. +let objectMatcher = /typedef struct (?\w+?)\* (?\w+?) WGPU_OBJECT_ATTRIBUTE;/ + +// Function declarations, marked by WGPU_FUNCTION_ATTRIBUTE +let functionMatcher = /WGPU_EXPORT (?WGPU_NULLABLE ?)?(?\w+?) (?\w+?)\((?.*\)?) WGPU_FUNCTION_ATTRIBUTE;/ +let parameterMatcher = /(?[^),]+?) (?\w+?)[),]/ +``` + +That's enough to identify all of the enum types (so we can emit the `EnumExtensibility: closed` API notes), object types (to turn them into shared references), and functions (which get nicer names and such). The script is just a big `readLine` loop that applies the regexes to capture all of the various types and functions, then does some quick classification before printing out the API notes. The resulting API notes are [in WebGPU.apinotes](WebGPU.apinotes), and the generated Swift interface after these API notes are applied is [here](WebGPU.swiftinterface). + +This script full of regular expressions is, admittedly, a bit of a hack. A better approach for an arbitrary C header would be to use [`libclang`](https://clang.llvm.org/docs/LibClang.html) to properly parse the headers. For WebGPU specifically, the webgpu-headers project contains a database from which the header is generated, and one could also generate API notes directly from that header. Regardless of how you get there, many C libraries have well-structured headers with conventions that can be leveraged to create safer, more ergonomic projections in Swift. + +## Swiftifying your favorite C library + +The techniques described in this post can be applied to just about any C library. To do so, I recommend setting up a small package like the one described here for WebGPU, so you can iterate quickly on example code to get a feel for how the Swift projection of the C API will work. The annotations might not get you all the way to the best Swift API, but they are a lightweight way to get most of the way there. Feel free to also extend the C types to convenience APIs that make sense in Swift, like I did above to make `WGPUBool` conform to `ExpressibleByBooleanLiteral`. + +A little bit of annotation work on your favorite C library can make for a safer, more ergonomic, more Swifty experience of working with that library. + +## Postscript: Thoughts for improving the generated `webgpu.h` + +The regular structure of `webgpu.h` helped considerably when trying to expose the API nicely in Swift. That said, there are a few ways in which `webgpu.h` could be improved to require less annotation for this purpose: + +* `WGPU_ENUM_ATTRIBUTE` would be slightly nicer if placed on the `enum` itself, rather than on the `typedef`. If it were there, we could use + + ```c + #define WGPU_ENUM_ATTRIBUTE __attribute__((enum_extensibility(closed))) + ``` + + and not have to generate any API notes to bring these types in as proper enums in Swift. + +* `WGPU_OBJECT_ATTRIBUTE` could provide the names of the retain and release operations and be placed on the `struct` itself. If it were there, we could use + + ```c + #define WGPU_OBJECT_ATTRIBUTE(RetainFn,ReleaseFn) SWIFT_SHARED_REFERENCE(RetainFn,ReleaseFn) + ``` + + and not have to generate any API notes to bring these types in as classes in Swift. + +* `WGPU_NULLABLE` could be placed on the pointer itself (i.e., after the `*`) rather than at the beginning of the type, to match the position of [Clang's nullability attributes](https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes). If it were placed there, then + + ```c + #define WGPU_NULLABLE _Nullable + ``` + + would work with Clangs' longstanding nullable-types support. Swift would then import such pointers as optional types (with `?`). Moreover, if some macros `WGPU_ASSUME_NONNULL_BEGIN` and `WGPU_ASSUME_NONNULL_END` were placed at the beginning and end of the header, they could be mapped to Clang's pragmas to assume that any pointer not marked "nullable" is always non-null: + ```c + #define WGPU_ASSUME_NONNULL_BEGIN #pragma clang assume_nonnull begin + #define WGPU_ASSUME_NONNULL_END #pragma clang assume_nonnull end + ``` + + This would eliminate all of the implicitly unwrapped optionals (marked `!` in the Swift interface), making it easier to use safely. diff --git a/blog/improving-usability-of-c-libraries-in-swift/WebGPU.apinotes b/blog/improving-usability-of-c-libraries-in-swift/WebGPU.apinotes new file mode 100644 index 000000000..19da80c4c --- /dev/null +++ b/blog/improving-usability-of-c-libraries-in-swift/WebGPU.apinotes @@ -0,0 +1,1331 @@ +--- +Name: WebGPU +Tags: +- Name: WGPUAdapterType + EnumExtensibility: closed +- Name: WGPUAddressMode + EnumExtensibility: closed +- Name: WGPUBackendType + EnumExtensibility: closed +- Name: WGPUBlendFactor + EnumExtensibility: closed +- Name: WGPUBlendOperation + EnumExtensibility: closed +- Name: WGPUBufferBindingType + EnumExtensibility: closed +- Name: WGPUBufferMapState + EnumExtensibility: closed +- Name: WGPUCallbackMode + EnumExtensibility: closed +- Name: WGPUCompareFunction + EnumExtensibility: closed +- Name: WGPUCompilationInfoRequestStatus + EnumExtensibility: closed +- Name: WGPUCompilationMessageType + EnumExtensibility: closed +- Name: WGPUCompositeAlphaMode + EnumExtensibility: closed +- Name: WGPUCreatePipelineAsyncStatus + EnumExtensibility: closed +- Name: WGPUCullMode + EnumExtensibility: closed +- Name: WGPUDeviceLostReason + EnumExtensibility: closed +- Name: WGPUErrorFilter + EnumExtensibility: closed +- Name: WGPUErrorType + EnumExtensibility: closed +- Name: WGPUFeatureLevel + EnumExtensibility: closed +- Name: WGPUFeatureName + EnumExtensibility: closed +- Name: WGPUFilterMode + EnumExtensibility: closed +- Name: WGPUFrontFace + EnumExtensibility: closed +- Name: WGPUIndexFormat + EnumExtensibility: closed +- Name: WGPUInstanceFeatureName + EnumExtensibility: closed +- Name: WGPULoadOp + EnumExtensibility: closed +- Name: WGPUMapAsyncStatus + EnumExtensibility: closed +- Name: WGPUMipmapFilterMode + EnumExtensibility: closed +- Name: WGPUOptionalBool + EnumExtensibility: closed +- Name: WGPUPopErrorScopeStatus + EnumExtensibility: closed +- Name: WGPUPowerPreference + EnumExtensibility: closed +- Name: WGPUPredefinedColorSpace + EnumExtensibility: closed +- Name: WGPUPresentMode + EnumExtensibility: closed +- Name: WGPUPrimitiveTopology + EnumExtensibility: closed +- Name: WGPUQueryType + EnumExtensibility: closed +- Name: WGPUQueueWorkDoneStatus + EnumExtensibility: closed +- Name: WGPURequestAdapterStatus + EnumExtensibility: closed +- Name: WGPURequestDeviceStatus + EnumExtensibility: closed +- Name: WGPUSType + EnumExtensibility: closed +- Name: WGPUSamplerBindingType + EnumExtensibility: closed +- Name: WGPUStatus + EnumExtensibility: closed +- Name: WGPUStencilOperation + EnumExtensibility: closed +- Name: WGPUStorageTextureAccess + EnumExtensibility: closed +- Name: WGPUStoreOp + EnumExtensibility: closed +- Name: WGPUSurfaceGetCurrentTextureStatus + EnumExtensibility: closed +- Name: WGPUTextureAspect + EnumExtensibility: closed +- Name: WGPUTextureDimension + EnumExtensibility: closed +- Name: WGPUTextureFormat + EnumExtensibility: closed +- Name: WGPUTextureSampleType + EnumExtensibility: closed +- Name: WGPUTextureViewDimension + EnumExtensibility: closed +- Name: WGPUToneMappingMode + EnumExtensibility: closed +- Name: WGPUVertexFormat + EnumExtensibility: closed +- Name: WGPUVertexStepMode + EnumExtensibility: closed +- Name: WGPUWGSLLanguageFeatureName + EnumExtensibility: closed +- Name: WGPUWaitStatus + EnumExtensibility: closed +- Name: WGPUAdapterImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuAdapterRelease + SwiftRetainOp: wgpuAdapterAddRef +- Name: WGPUBindGroupImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuBindGroupRelease + SwiftRetainOp: wgpuBindGroupAddRef +- Name: WGPUBindGroupLayoutImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuBindGroupLayoutRelease + SwiftRetainOp: wgpuBindGroupLayoutAddRef +- Name: WGPUBufferImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuBufferRelease + SwiftRetainOp: wgpuBufferAddRef +- Name: WGPUCommandBufferImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuCommandBufferRelease + SwiftRetainOp: wgpuCommandBufferAddRef +- Name: WGPUCommandEncoderImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuCommandEncoderRelease + SwiftRetainOp: wgpuCommandEncoderAddRef +- Name: WGPUComputePassEncoderImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuComputePassEncoderRelease + SwiftRetainOp: wgpuComputePassEncoderAddRef +- Name: WGPUComputePipelineImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuComputePipelineRelease + SwiftRetainOp: wgpuComputePipelineAddRef +- Name: WGPUDeviceImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuDeviceRelease + SwiftRetainOp: wgpuDeviceAddRef +- Name: WGPUInstanceImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuInstanceRelease + SwiftRetainOp: wgpuInstanceAddRef +- Name: WGPUPipelineLayoutImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuPipelineLayoutRelease + SwiftRetainOp: wgpuPipelineLayoutAddRef +- Name: WGPUQuerySetImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuQuerySetRelease + SwiftRetainOp: wgpuQuerySetAddRef +- Name: WGPUQueueImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuQueueRelease + SwiftRetainOp: wgpuQueueAddRef +- Name: WGPURenderBundleImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuRenderBundleRelease + SwiftRetainOp: wgpuRenderBundleAddRef +- Name: WGPURenderBundleEncoderImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuRenderBundleEncoderRelease + SwiftRetainOp: wgpuRenderBundleEncoderAddRef +- Name: WGPURenderPassEncoderImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuRenderPassEncoderRelease + SwiftRetainOp: wgpuRenderPassEncoderAddRef +- Name: WGPURenderPipelineImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuRenderPipelineRelease + SwiftRetainOp: wgpuRenderPipelineAddRef +- Name: WGPUSamplerImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuSamplerRelease + SwiftRetainOp: wgpuSamplerAddRef +- Name: WGPUShaderModuleImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuShaderModuleRelease + SwiftRetainOp: wgpuShaderModuleAddRef +- Name: WGPUSurfaceImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuSurfaceRelease + SwiftRetainOp: wgpuSurfaceAddRef +- Name: WGPUTextureImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuTextureRelease + SwiftRetainOp: wgpuTextureAddRef +- Name: WGPUTextureViewImpl + SwiftImportAs: reference + SwiftReleaseOp: wgpuTextureViewRelease + SwiftRetainOp: wgpuTextureViewAddRef +Typedefs: +- Name: WGPUBufferUsage + SwiftWrapper: struct +- Name: WGPUColorWriteMask + SwiftWrapper: struct +- Name: WGPUMapMode + SwiftWrapper: struct +- Name: WGPUShaderStage + SwiftWrapper: struct +- Name: WGPUTextureUsage + SwiftWrapper: struct +Functions: +- Name: wgpuAdapterAddRef + SwiftName: WGPUAdapterImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" +- Name: wgpuAdapterGetFeatures + SwiftName: WGPUAdapterImpl.getFeatures(self:features:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" + - Position: 1 + Type: " WGPUSupportedFeatures * _Nonnull" +- Name: wgpuAdapterGetInfo + SwiftName: WGPUAdapterImpl.getInfo(self:info:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" + - Position: 1 + Type: " WGPUAdapterInfo * _Nonnull" +- Name: wgpuAdapterGetLimits + SwiftName: WGPUAdapterImpl.getLimits(self:limits:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" + - Position: 1 + Type: " WGPULimits * _Nonnull" +- Name: wgpuAdapterHasFeature + SwiftName: WGPUAdapterImpl.hasFeature(self:feature:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" +- Name: wgpuAdapterRelease + SwiftName: WGPUAdapterImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" +- Name: wgpuAdapterRequestDevice + SwiftName: WGPUAdapterImpl.requestDevice(self:descriptor:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUAdapter _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPUDeviceDescriptor const * _Nonnull" +- Name: wgpuBindGroupAddRef + SwiftName: WGPUBindGroupImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUBindGroup _Nonnull" +- Name: wgpuBindGroupLayoutAddRef + SwiftName: WGPUBindGroupLayoutImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUBindGroupLayout _Nonnull" +- Name: wgpuBindGroupLayoutRelease + SwiftName: WGPUBindGroupLayoutImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUBindGroupLayout _Nonnull" +- Name: wgpuBindGroupLayoutSetLabel + SwiftName: WGPUBindGroupLayoutImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUBindGroupLayout _Nonnull" +- Name: wgpuBindGroupRelease + SwiftName: WGPUBindGroupImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUBindGroup _Nonnull" +- Name: wgpuBindGroupSetLabel + SwiftName: WGPUBindGroupImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUBindGroup _Nonnull" +- Name: wgpuBufferAddRef + SwiftName: WGPUBufferImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferDestroy + SwiftName: WGPUBufferImpl.destroy(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferGetMapState + SwiftName: getter:WGPUBufferImpl.mapState(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferGetSize + SwiftName: getter:WGPUBufferImpl.size(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferGetUsage + SwiftName: getter:WGPUBufferImpl.usage(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferMapAsync + SwiftName: WGPUBufferImpl.mapAsync(self:mode:offset:size:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferReadMappedRange + SwiftName: WGPUBufferImpl.readMappedRange(self:offset:data:size:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" + - Position: 2 + Type: " void * _Nonnull" +- Name: wgpuBufferRelease + SwiftName: WGPUBufferImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferSetLabel + SwiftName: WGPUBufferImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferUnmap + SwiftName: WGPUBufferImpl.unmap(self:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" +- Name: wgpuBufferWriteMappedRange + SwiftName: WGPUBufferImpl.writeMappedRange(self:offset:data:size:) + Parameters: + - Position: 0 + Type: "WGPUBuffer _Nonnull" + - Position: 2 + Type: " void const * _Nonnull" +- Name: wgpuCommandBufferAddRef + SwiftName: WGPUCommandBufferImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUCommandBuffer _Nonnull" +- Name: wgpuCommandBufferRelease + SwiftName: WGPUCommandBufferImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUCommandBuffer _Nonnull" +- Name: wgpuCommandBufferSetLabel + SwiftName: WGPUCommandBufferImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUCommandBuffer _Nonnull" +- Name: wgpuCommandEncoderAddRef + SwiftName: WGPUCommandEncoderImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderBeginComputePass + SwiftName: WGPUCommandEncoderImpl.beginComputePass(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPUComputePassDescriptor const * _Nonnull" +- Name: wgpuCommandEncoderBeginRenderPass + SwiftName: WGPUCommandEncoderImpl.beginRenderPass(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" + - Position: 1 + Type: " WGPURenderPassDescriptor const * _Nonnull" +- Name: wgpuCommandEncoderClearBuffer + SwiftName: WGPUCommandEncoderImpl.clearBuffer(self:buffer:offset:size:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderCopyBufferToBuffer + SwiftName: WGPUCommandEncoderImpl.copyBufferToBuffer(self:source:sourceOffset:destination:destinationOffset:size:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderCopyBufferToTexture + SwiftName: WGPUCommandEncoderImpl.copyBufferToTexture(self:source:destination:copySize:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" + - Position: 1 + Type: " WGPUTexelCopyBufferInfo const * _Nonnull" + - Position: 2 + Type: " WGPUTexelCopyTextureInfo const * _Nonnull" + - Position: 3 + Type: " WGPUExtent3D const * _Nonnull" +- Name: wgpuCommandEncoderCopyTextureToBuffer + SwiftName: WGPUCommandEncoderImpl.copyTextureToBuffer(self:source:destination:copySize:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" + - Position: 1 + Type: " WGPUTexelCopyTextureInfo const * _Nonnull" + - Position: 2 + Type: " WGPUTexelCopyBufferInfo const * _Nonnull" + - Position: 3 + Type: " WGPUExtent3D const * _Nonnull" +- Name: wgpuCommandEncoderCopyTextureToTexture + SwiftName: WGPUCommandEncoderImpl.copyTextureToTexture(self:source:destination:copySize:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" + - Position: 1 + Type: " WGPUTexelCopyTextureInfo const * _Nonnull" + - Position: 2 + Type: " WGPUTexelCopyTextureInfo const * _Nonnull" + - Position: 3 + Type: " WGPUExtent3D const * _Nonnull" +- Name: wgpuCommandEncoderFinish + SwiftName: WGPUCommandEncoderImpl.finish(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPUCommandBufferDescriptor const * _Nonnull" +- Name: wgpuCommandEncoderInsertDebugMarker + SwiftName: WGPUCommandEncoderImpl.insertDebugMarker(self:markerLabel:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderPopDebugGroup + SwiftName: WGPUCommandEncoderImpl.popDebugGroup(self:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderPushDebugGroup + SwiftName: WGPUCommandEncoderImpl.pushDebugGroup(self:groupLabel:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderRelease + SwiftName: WGPUCommandEncoderImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderResolveQuerySet + SwiftName: WGPUCommandEncoderImpl.resolveQuerySet(self:querySet:firstQuery:queryCount:destination:destinationOffset:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderSetLabel + SwiftName: WGPUCommandEncoderImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuCommandEncoderWriteTimestamp + SwiftName: WGPUCommandEncoderImpl.writeTimestamp(self:querySet:queryIndex:) + Parameters: + - Position: 0 + Type: "WGPUCommandEncoder _Nonnull" +- Name: wgpuComputePassEncoderAddRef + SwiftName: WGPUComputePassEncoderImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderDispatchWorkgroups + SwiftName: WGPUComputePassEncoderImpl.dispatchWorkgroups(self:workgroupCountX:workgroupCountY:workgroupCountZ:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderDispatchWorkgroupsIndirect + SwiftName: WGPUComputePassEncoderImpl.dispatchWorkgroupsIndirect(self:indirectBuffer:indirectOffset:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderEnd + SwiftName: WGPUComputePassEncoderImpl.end(self:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderInsertDebugMarker + SwiftName: WGPUComputePassEncoderImpl.insertDebugMarker(self:markerLabel:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderPopDebugGroup + SwiftName: WGPUComputePassEncoderImpl.popDebugGroup(self:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderPushDebugGroup + SwiftName: WGPUComputePassEncoderImpl.pushDebugGroup(self:groupLabel:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderRelease + SwiftName: WGPUComputePassEncoderImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderSetBindGroup + SwiftName: WGPUComputePassEncoderImpl.setBindGroup(self:groupIndex:group:dynamicOffsetCount:dynamicOffsets:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" + - Position: 4 + Type: " uint32_t const * _Nonnull" +- Name: wgpuComputePassEncoderSetLabel + SwiftName: WGPUComputePassEncoderImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePassEncoderSetPipeline + SwiftName: WGPUComputePassEncoderImpl.setPipeline(self:pipeline:) + Parameters: + - Position: 0 + Type: "WGPUComputePassEncoder _Nonnull" +- Name: wgpuComputePipelineAddRef + SwiftName: WGPUComputePipelineImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUComputePipeline _Nonnull" +- Name: wgpuComputePipelineGetBindGroupLayout + SwiftName: WGPUComputePipelineImpl.getbindGroupLayout(self:groupIndex:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUComputePipeline _Nonnull" +- Name: wgpuComputePipelineRelease + SwiftName: WGPUComputePipelineImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUComputePipeline _Nonnull" +- Name: wgpuComputePipelineSetLabel + SwiftName: WGPUComputePipelineImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUComputePipeline _Nonnull" +- Name: wgpuCreateInstance + SwiftName: WGPUInstanceImpl.init(descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUInstanceDescriptor const * _Nullable" +- Name: wgpuDeviceAddRef + SwiftName: WGPUDeviceImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDeviceCreateBindGroup + SwiftName: WGPUDeviceImpl.createBindGroup(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUBindGroupDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateBindGroupLayout + SwiftName: WGPUDeviceImpl.createBindGroupLayout(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUBindGroupLayoutDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateBuffer + SwiftName: WGPUDeviceImpl.createBuffer(self:descriptor:) + SwiftReturnOwnership: retained + ResultType: "WGPUBuffer _Nullable" + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUBufferDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateCommandEncoder + SwiftName: WGPUDeviceImpl.createCommandEncoder(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPUCommandEncoderDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateComputePipeline + SwiftName: WGPUDeviceImpl.createComputePipeline(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUComputePipelineDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateComputePipelineAsync + SwiftName: WGPUDeviceImpl.createComputePipelineAsync(self:descriptor:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUComputePipelineDescriptor const * _Nonnull" +- Name: wgpuDeviceCreatePipelineLayout + SwiftName: WGPUDeviceImpl.createPipelineLayout(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUPipelineLayoutDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateQuerySet + SwiftName: WGPUDeviceImpl.createQuerySet(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUQuerySetDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateRenderBundleEncoder + SwiftName: WGPUDeviceImpl.createRenderBundleEncoder(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPURenderBundleEncoderDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateRenderPipeline + SwiftName: WGPUDeviceImpl.createRenderPipeline(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPURenderPipelineDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateRenderPipelineAsync + SwiftName: WGPUDeviceImpl.createRenderPipelineAsync(self:descriptor:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPURenderPipelineDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateSampler + SwiftName: WGPUDeviceImpl.createSampler(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPUSamplerDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateShaderModule + SwiftName: WGPUDeviceImpl.createShaderModule(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUShaderModuleDescriptor const * _Nonnull" +- Name: wgpuDeviceCreateTexture + SwiftName: WGPUDeviceImpl.createTexture(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUTextureDescriptor const * _Nonnull" +- Name: wgpuDeviceDestroy + SwiftName: WGPUDeviceImpl.destroy(self:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDeviceGetAdapterInfo + SwiftName: WGPUDeviceImpl.getAdapterInfo(self:adapterInfo:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUAdapterInfo * _Nonnull" +- Name: wgpuDeviceGetFeatures + SwiftName: WGPUDeviceImpl.getFeatures(self:features:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPUSupportedFeatures * _Nonnull" +- Name: wgpuDeviceGetLimits + SwiftName: WGPUDeviceImpl.getLimits(self:limits:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" + - Position: 1 + Type: " WGPULimits * _Nonnull" +- Name: wgpuDeviceGetLostFuture + SwiftName: getter:WGPUDeviceImpl.lostFuture(self:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDeviceGetQueue + SwiftName: getter:WGPUDeviceImpl.queue(self:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDeviceHasFeature + SwiftName: WGPUDeviceImpl.hasFeature(self:feature:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDevicePopErrorScope + SwiftName: WGPUDeviceImpl.popErrorScope(self:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDevicePushErrorScope + SwiftName: WGPUDeviceImpl.pushErrorScope(self:filter:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDeviceRelease + SwiftName: WGPUDeviceImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuDeviceSetLabel + SwiftName: WGPUDeviceImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUDevice _Nonnull" +- Name: wgpuGetInstanceFeatures + Parameters: + - Position: 0 + Type: "WGPUSupportedInstanceFeatures * _Nonnull" +- Name: wgpuGetInstanceLimits + Parameters: + - Position: 0 + Type: "WGPUInstanceLimits * _Nonnull" +- Name: wgpuInstanceAddRef + SwiftName: WGPUInstanceImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" +- Name: wgpuInstanceCreateSurface + SwiftName: WGPUInstanceImpl.createSurface(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" + - Position: 1 + Type: " WGPUSurfaceDescriptor const * _Nonnull" +- Name: wgpuInstanceGetWGSLLanguageFeatures + SwiftName: WGPUInstanceImpl.getwgslLanguageFeatures(self:features:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" + - Position: 1 + Type: " WGPUSupportedWGSLLanguageFeatures * _Nonnull" +- Name: wgpuInstanceHasWGSLLanguageFeature + SwiftName: WGPUInstanceImpl.haswgslLanguageFeature(self:feature:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" +- Name: wgpuInstanceProcessEvents + SwiftName: WGPUInstanceImpl.processEvents(self:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" +- Name: wgpuInstanceRelease + SwiftName: WGPUInstanceImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" +- Name: wgpuInstanceRequestAdapter + SwiftName: WGPUInstanceImpl.requestAdapter(self:options:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPURequestAdapterOptions const * _Nonnull" +- Name: wgpuInstanceWaitAny + SwiftName: WGPUInstanceImpl.waitAny(self:futureCount:futures:timeoutNS:) + Parameters: + - Position: 0 + Type: "WGPUInstance _Nonnull" + - Position: 2 + Type: " WGPU_NULLABLE WGPUFutureWaitInfo * _Nonnull" +- Name: wgpuPipelineLayoutAddRef + SwiftName: WGPUPipelineLayoutImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUPipelineLayout _Nonnull" +- Name: wgpuPipelineLayoutRelease + SwiftName: WGPUPipelineLayoutImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUPipelineLayout _Nonnull" +- Name: wgpuPipelineLayoutSetLabel + SwiftName: WGPUPipelineLayoutImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUPipelineLayout _Nonnull" +- Name: wgpuQuerySetAddRef + SwiftName: WGPUQuerySetImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUQuerySet _Nonnull" +- Name: wgpuQuerySetDestroy + SwiftName: WGPUQuerySetImpl.destroy(self:) + Parameters: + - Position: 0 + Type: "WGPUQuerySet _Nonnull" +- Name: wgpuQuerySetGetCount + SwiftName: getter:WGPUQuerySetImpl.count(self:) + Parameters: + - Position: 0 + Type: "WGPUQuerySet _Nonnull" +- Name: wgpuQuerySetGetType + SwiftName: getter:WGPUQuerySetImpl.type(self:) + Parameters: + - Position: 0 + Type: "WGPUQuerySet _Nonnull" +- Name: wgpuQuerySetRelease + SwiftName: WGPUQuerySetImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUQuerySet _Nonnull" +- Name: wgpuQuerySetSetLabel + SwiftName: WGPUQuerySetImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUQuerySet _Nonnull" +- Name: wgpuQueueAddRef + SwiftName: WGPUQueueImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" +- Name: wgpuQueueOnSubmittedWorkDone + SwiftName: WGPUQueueImpl.onsubmittedWorkDone(self:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" +- Name: wgpuQueueRelease + SwiftName: WGPUQueueImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" +- Name: wgpuQueueSetLabel + SwiftName: WGPUQueueImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" +- Name: wgpuQueueSubmit + SwiftName: WGPUQueueImpl.submit(self:commandCount:commands:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" + - Position: 2 + Type: " WGPUCommandBuffer const * _Nonnull" +- Name: wgpuQueueWriteBuffer + SwiftName: WGPUQueueImpl.writeBuffer(self:buffer:bufferOffset:data:size:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" + - Position: 3 + Type: " void const * _Nonnull" +- Name: wgpuQueueWriteTexture + SwiftName: WGPUQueueImpl.writeTexture(self:destination:data:dataSize:dataLayout:writeSize:) + Parameters: + - Position: 0 + Type: "WGPUQueue _Nonnull" + - Position: 1 + Type: " WGPUTexelCopyTextureInfo const * _Nonnull" + - Position: 2 + Type: " void const * _Nonnull" + - Position: 4 + Type: " WGPUTexelCopyBufferLayout const * _Nonnull" + - Position: 5 + Type: " WGPUExtent3D const * _Nonnull" +- Name: wgpuRenderBundleAddRef + SwiftName: WGPURenderBundleImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPURenderBundle _Nonnull" +- Name: wgpuRenderBundleEncoderAddRef + SwiftName: WGPURenderBundleEncoderImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderDraw + SwiftName: WGPURenderBundleEncoderImpl.draw(self:vertexCount:instanceCount:firstVertex:firstInstance:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderDrawIndexed + SwiftName: WGPURenderBundleEncoderImpl.drawIndexed(self:indexCount:instanceCount:firstIndex:baseVertex:firstInstance:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderDrawIndexedIndirect + SwiftName: WGPURenderBundleEncoderImpl.drawIndexedIndirect(self:indirectBuffer:indirectOffset:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderDrawIndirect + SwiftName: WGPURenderBundleEncoderImpl.drawIndirect(self:indirectBuffer:indirectOffset:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderFinish + SwiftName: WGPURenderBundleEncoderImpl.finish(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPURenderBundleDescriptor const * _Nonnull" +- Name: wgpuRenderBundleEncoderInsertDebugMarker + SwiftName: WGPURenderBundleEncoderImpl.insertDebugMarker(self:markerLabel:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderPopDebugGroup + SwiftName: WGPURenderBundleEncoderImpl.popDebugGroup(self:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderPushDebugGroup + SwiftName: WGPURenderBundleEncoderImpl.pushDebugGroup(self:groupLabel:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderRelease + SwiftName: WGPURenderBundleEncoderImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderSetBindGroup + SwiftName: WGPURenderBundleEncoderImpl.setBindGroup(self:groupIndex:group:dynamicOffsetCount:dynamicOffsets:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" + - Position: 4 + Type: " uint32_t const * _Nonnull" +- Name: wgpuRenderBundleEncoderSetIndexBuffer + SwiftName: WGPURenderBundleEncoderImpl.setIndexBuffer(self:buffer:format:offset:size:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderSetLabel + SwiftName: WGPURenderBundleEncoderImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderSetPipeline + SwiftName: WGPURenderBundleEncoderImpl.setPipeline(self:pipeline:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleEncoderSetVertexBuffer + SwiftName: WGPURenderBundleEncoderImpl.setVertexBuffer(self:slot:buffer:offset:size:) + Parameters: + - Position: 0 + Type: "WGPURenderBundleEncoder _Nonnull" +- Name: wgpuRenderBundleRelease + SwiftName: WGPURenderBundleImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPURenderBundle _Nonnull" +- Name: wgpuRenderBundleSetLabel + SwiftName: WGPURenderBundleImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPURenderBundle _Nonnull" +- Name: wgpuRenderPassEncoderAddRef + SwiftName: WGPURenderPassEncoderImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderBeginOcclusionQuery + SwiftName: WGPURenderPassEncoderImpl.beginOcclusionQuery(self:queryIndex:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderDraw + SwiftName: WGPURenderPassEncoderImpl.draw(self:vertexCount:instanceCount:firstVertex:firstInstance:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderDrawIndexed + SwiftName: WGPURenderPassEncoderImpl.drawIndexed(self:indexCount:instanceCount:firstIndex:baseVertex:firstInstance:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderDrawIndexedIndirect + SwiftName: WGPURenderPassEncoderImpl.drawIndexedIndirect(self:indirectBuffer:indirectOffset:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderDrawIndirect + SwiftName: WGPURenderPassEncoderImpl.drawIndirect(self:indirectBuffer:indirectOffset:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderEnd + SwiftName: WGPURenderPassEncoderImpl.end(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderEndOcclusionQuery + SwiftName: WGPURenderPassEncoderImpl.endOcclusionQuery(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderExecuteBundles + SwiftName: WGPURenderPassEncoderImpl.executeBundles(self:bundleCount:bundles:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" + - Position: 2 + Type: " WGPURenderBundle const * _Nonnull" +- Name: wgpuRenderPassEncoderInsertDebugMarker + SwiftName: WGPURenderPassEncoderImpl.insertDebugMarker(self:markerLabel:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderPopDebugGroup + SwiftName: WGPURenderPassEncoderImpl.popDebugGroup(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderPushDebugGroup + SwiftName: WGPURenderPassEncoderImpl.pushDebugGroup(self:groupLabel:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderRelease + SwiftName: WGPURenderPassEncoderImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetBindGroup + SwiftName: WGPURenderPassEncoderImpl.setBindGroup(self:groupIndex:group:dynamicOffsetCount:dynamicOffsets:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" + - Position: 4 + Type: " uint32_t const * _Nonnull" +- Name: wgpuRenderPassEncoderSetBlendConstant + SwiftName: WGPURenderPassEncoderImpl.setBlendConstant(self:color:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" + - Position: 1 + Type: " WGPUColor const * _Nonnull" +- Name: wgpuRenderPassEncoderSetIndexBuffer + SwiftName: WGPURenderPassEncoderImpl.setIndexBuffer(self:buffer:format:offset:size:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetLabel + SwiftName: WGPURenderPassEncoderImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetPipeline + SwiftName: WGPURenderPassEncoderImpl.setPipeline(self:pipeline:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetScissorRect + SwiftName: WGPURenderPassEncoderImpl.setScissorRect(self:_:_:width:height:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetStencilReference + SwiftName: WGPURenderPassEncoderImpl.setStencilReference(self:reference:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetVertexBuffer + SwiftName: WGPURenderPassEncoderImpl.setVertexBuffer(self:slot:buffer:offset:size:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPassEncoderSetViewport + SwiftName: WGPURenderPassEncoderImpl.setViewport(self:_:_:width:height:minDepth:maxDepth:) + Parameters: + - Position: 0 + Type: "WGPURenderPassEncoder _Nonnull" +- Name: wgpuRenderPipelineAddRef + SwiftName: WGPURenderPipelineImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPipeline _Nonnull" +- Name: wgpuRenderPipelineGetBindGroupLayout + SwiftName: WGPURenderPipelineImpl.getbindGroupLayout(self:groupIndex:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPURenderPipeline _Nonnull" +- Name: wgpuRenderPipelineRelease + SwiftName: WGPURenderPipelineImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPURenderPipeline _Nonnull" +- Name: wgpuRenderPipelineSetLabel + SwiftName: WGPURenderPipelineImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPURenderPipeline _Nonnull" +- Name: wgpuSamplerAddRef + SwiftName: WGPUSamplerImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUSampler _Nonnull" +- Name: wgpuSamplerRelease + SwiftName: WGPUSamplerImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUSampler _Nonnull" +- Name: wgpuSamplerSetLabel + SwiftName: WGPUSamplerImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUSampler _Nonnull" +- Name: wgpuShaderModuleAddRef + SwiftName: WGPUShaderModuleImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUShaderModule _Nonnull" +- Name: wgpuShaderModuleGetCompilationInfo + SwiftName: WGPUShaderModuleImpl.getCompilationInfo(self:callbackInfo:) + Parameters: + - Position: 0 + Type: "WGPUShaderModule _Nonnull" +- Name: wgpuShaderModuleRelease + SwiftName: WGPUShaderModuleImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUShaderModule _Nonnull" +- Name: wgpuShaderModuleSetLabel + SwiftName: WGPUShaderModuleImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUShaderModule _Nonnull" +- Name: wgpuSurfaceAddRef + SwiftName: WGPUSurfaceImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" +- Name: wgpuSurfaceConfigure + SwiftName: WGPUSurfaceImpl.configure(self:config:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" + - Position: 1 + Type: " WGPUSurfaceConfiguration const * _Nonnull" +- Name: wgpuSurfaceGetCapabilities + SwiftName: WGPUSurfaceImpl.getCapabilities(self:adapter:capabilities:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" + - Position: 2 + Type: " WGPUSurfaceCapabilities * _Nonnull" +- Name: wgpuSurfaceGetCurrentTexture + SwiftName: WGPUSurfaceImpl.getCurrentTexture(self:surfaceTexture:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" + - Position: 1 + Type: " WGPUSurfaceTexture * _Nonnull" +- Name: wgpuSurfacePresent + SwiftName: WGPUSurfaceImpl.present(self:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" +- Name: wgpuSurfaceRelease + SwiftName: WGPUSurfaceImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" +- Name: wgpuSurfaceSetLabel + SwiftName: WGPUSurfaceImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" +- Name: wgpuSurfaceUnconfigure + SwiftName: WGPUSurfaceImpl.unconfigure(self:) + Parameters: + - Position: 0 + Type: "WGPUSurface _Nonnull" +- Name: wgpuTextureAddRef + SwiftName: WGPUTextureImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureCreateView + SwiftName: WGPUTextureImpl.createView(self:descriptor:) + SwiftReturnOwnership: retained + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" + - Position: 1 + Type: " WGPU_NULLABLE WGPUTextureViewDescriptor const * _Nonnull" +- Name: wgpuTextureDestroy + SwiftName: WGPUTextureImpl.destroy(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetDepthOrArrayLayers + SwiftName: getter:WGPUTextureImpl.depthOrArrayLayers(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetDimension + SwiftName: getter:WGPUTextureImpl.dimension(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetFormat + SwiftName: getter:WGPUTextureImpl.format(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetHeight + SwiftName: getter:WGPUTextureImpl.height(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetMipLevelCount + SwiftName: getter:WGPUTextureImpl.mipLevelCount(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetSampleCount + SwiftName: getter:WGPUTextureImpl.sampleCount(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetUsage + SwiftName: getter:WGPUTextureImpl.usage(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureGetWidth + SwiftName: getter:WGPUTextureImpl.width(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureRelease + SwiftName: WGPUTextureImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureSetLabel + SwiftName: WGPUTextureImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUTexture _Nonnull" +- Name: wgpuTextureViewAddRef + SwiftName: WGPUTextureViewImpl.addRef(self:) + Parameters: + - Position: 0 + Type: "WGPUTextureView _Nonnull" +- Name: wgpuTextureViewRelease + SwiftName: WGPUTextureViewImpl.release(self:) + Parameters: + - Position: 0 + Type: "WGPUTextureView _Nonnull" +- Name: wgpuTextureViewSetLabel + SwiftName: WGPUTextureViewImpl.setLabel(self:label:) + Parameters: + - Position: 0 + Type: "WGPUTextureView _Nonnull" +Globals: +- Name: WGPUBufferUsage_None + SwiftName: WGPUBufferUsage.none +- Name: WGPUBufferUsage_MapRead + SwiftName: WGPUBufferUsage.mapRead +- Name: WGPUBufferUsage_MapWrite + SwiftName: WGPUBufferUsage.mapWrite +- Name: WGPUBufferUsage_CopySrc + SwiftName: WGPUBufferUsage.copySrc +- Name: WGPUBufferUsage_CopyDst + SwiftName: WGPUBufferUsage.copyDst +- Name: WGPUBufferUsage_Index + SwiftName: WGPUBufferUsage.index +- Name: WGPUBufferUsage_Vertex + SwiftName: WGPUBufferUsage.vertex +- Name: WGPUBufferUsage_Uniform + SwiftName: WGPUBufferUsage.uniform +- Name: WGPUBufferUsage_Storage + SwiftName: WGPUBufferUsage.storage +- Name: WGPUBufferUsage_Indirect + SwiftName: WGPUBufferUsage.indirect +- Name: WGPUBufferUsage_QueryResolve + SwiftName: WGPUBufferUsage.queryResolve +- Name: WGPUColorWriteMask_None + SwiftName: WGPUColorWriteMask.none +- Name: WGPUColorWriteMask_Red + SwiftName: WGPUColorWriteMask.red +- Name: WGPUColorWriteMask_Green + SwiftName: WGPUColorWriteMask.green +- Name: WGPUColorWriteMask_Blue + SwiftName: WGPUColorWriteMask.blue +- Name: WGPUColorWriteMask_Alpha + SwiftName: WGPUColorWriteMask.alpha +- Name: WGPUColorWriteMask_All + SwiftName: WGPUColorWriteMask.all +- Name: WGPUMapMode_None + SwiftName: WGPUMapMode.none +- Name: WGPUMapMode_Read + SwiftName: WGPUMapMode.read +- Name: WGPUMapMode_Write + SwiftName: WGPUMapMode.write +- Name: WGPUShaderStage_None + SwiftName: WGPUShaderStage.none +- Name: WGPUShaderStage_Vertex + SwiftName: WGPUShaderStage.vertex +- Name: WGPUShaderStage_Fragment + SwiftName: WGPUShaderStage.fragment +- Name: WGPUShaderStage_Compute + SwiftName: WGPUShaderStage.compute +- Name: WGPUTextureUsage_None + SwiftName: WGPUTextureUsage.none +- Name: WGPUTextureUsage_CopySrc + SwiftName: WGPUTextureUsage.copySrc +- Name: WGPUTextureUsage_CopyDst + SwiftName: WGPUTextureUsage.copyDst +- Name: WGPUTextureUsage_TextureBinding + SwiftName: WGPUTextureUsage.textureBinding +- Name: WGPUTextureUsage_StorageBinding + SwiftName: WGPUTextureUsage.storageBinding +- Name: WGPUTextureUsage_RenderAttachment + SwiftName: WGPUTextureUsage.renderAttachment diff --git a/blog/improving-usability-of-c-libraries-in-swift/WebGPU.swiftinterface b/blog/improving-usability-of-c-libraries-in-swift/WebGPU.swiftinterface new file mode 100644 index 000000000..7efdec9fb --- /dev/null +++ b/blog/improving-usability-of-c-libraries-in-swift/WebGPU.swiftinterface @@ -0,0 +1,7621 @@ +import _Builtin_stdint +import _math + +/** + * 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. + */ +public struct WGPUStringView { + + public init() + + public init(data: UnsafePointer!, length: Int) + + public var data: UnsafePointer! + + public var length: Int +} + +public typealias WGPUFlags = UInt64 + +public typealias WGPUBool = UInt32 + +public class WGPUAdapterImpl { +} + +/** + * \defgroup Objects Objects + * \brief Opaque, non-dispatchable handles to WebGPU objects. + * + * @{ + */ +public typealias WGPUAdapter = WGPUAdapterImpl + +public class WGPUBindGroupImpl { +} + +public typealias WGPUBindGroup = WGPUBindGroupImpl + +public class WGPUBindGroupLayoutImpl { +} + +public typealias WGPUBindGroupLayout = WGPUBindGroupLayoutImpl + +public class WGPUBufferImpl { +} + +public typealias WGPUBuffer = WGPUBufferImpl + +public class WGPUCommandBufferImpl { +} + +public typealias WGPUCommandBuffer = WGPUCommandBufferImpl + +public class WGPUCommandEncoderImpl { +} + +public typealias WGPUCommandEncoder = WGPUCommandEncoderImpl + +public class WGPUComputePassEncoderImpl { +} + +public typealias WGPUComputePassEncoder = WGPUComputePassEncoderImpl + +public class WGPUComputePipelineImpl { +} + +public typealias WGPUComputePipeline = WGPUComputePipelineImpl + +public class WGPUDeviceImpl { +} + +/** + * TODO + * + * Releasing the last ref to a `WGPUDevice` also calls @ref wgpuDeviceDestroy. + * For more info, see @ref DeviceRelease. + */ +public typealias WGPUDevice = WGPUDeviceImpl + +public class WGPUInstanceImpl { +} + +public typealias WGPUInstance = WGPUInstanceImpl + +public class WGPUPipelineLayoutImpl { +} + +public typealias WGPUPipelineLayout = WGPUPipelineLayoutImpl + +public class WGPUQuerySetImpl { +} + +public typealias WGPUQuerySet = WGPUQuerySetImpl + +public class WGPUQueueImpl { +} + +public typealias WGPUQueue = WGPUQueueImpl + +public class WGPURenderBundleImpl { +} + +public typealias WGPURenderBundle = WGPURenderBundleImpl + +public class WGPURenderBundleEncoderImpl { +} + +public typealias WGPURenderBundleEncoder = WGPURenderBundleEncoderImpl + +public class WGPURenderPassEncoderImpl { +} + +public typealias WGPURenderPassEncoder = WGPURenderPassEncoderImpl + +public class WGPURenderPipelineImpl { +} + +public typealias WGPURenderPipeline = WGPURenderPipelineImpl + +public class WGPUSamplerImpl { +} + +public typealias WGPUSampler = WGPUSamplerImpl + +public class WGPUShaderModuleImpl { +} + +public typealias WGPUShaderModule = WGPUShaderModuleImpl + +public class WGPUSurfaceImpl { +} + +/** + * An object used to continuously present image data to the user, see @ref Surfaces for more details. + */ +public typealias WGPUSurface = WGPUSurfaceImpl + +public class WGPUTextureImpl { +} + +public typealias WGPUTexture = WGPUTextureImpl + +public class WGPUTextureViewImpl { +} + +public typealias WGPUTextureView = WGPUTextureViewImpl + +/** + * \defgroup Enumerations Enumerations + * \brief Enums. + * + * @{ + */ +@frozen public enum WGPUAdapterType : UInt32, @unchecked Sendable { + + case discreteGPU = 1 + + case integratedGPU = 2 + + case CPU = 3 + + case unknown = 4 + + case force32 = 2147483647 +} + +@frozen public enum WGPUAddressMode : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case clampToEdge = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case `repeat` = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case mirrorRepeat = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUBackendType : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case null = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case webGPU = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case D3D11 = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case D3D12 = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case metal = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case vulkan = 6 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case openGL = 7 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case openGLES = 8 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUBlendFactor : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case zero = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case one = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case src = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusSrc = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case srcAlpha = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusSrcAlpha = 6 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case dst = 7 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusDst = 8 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case dstAlpha = 9 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusDstAlpha = 10 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case srcAlphaSaturated = 11 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case constant = 12 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusConstant = 13 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case src1 = 14 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusSrc1 = 15 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case src1Alpha = 16 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case oneMinusSrc1Alpha = 17 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUBlendOperation : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case add = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case subtract = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case reverseSubtract = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case min = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case max = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUBufferBindingType : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates that this @ref WGPUBufferBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + case bindingNotUsed = 0 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 1 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case uniform = 2 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case storage = 3 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case readOnlyStorage = 4 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUBufferMapState : UInt32, @unchecked Sendable { + + case unmapped = 1 + + case pending = 2 + + case mapped = 3 + + case force32 = 2147483647 +} + +/** + * The callback mode controls how a callback for an asynchronous operation may be fired. See @ref Asynchronous-Operations for how these are used. + */ +@frozen public enum WGPUCallbackMode : UInt32, @unchecked Sendable { + + /** + * 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. + */ + case waitAnyOnly = 1 + + /** + * 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. + */ + case allowProcessEvents = 2 + + /** + * 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`. + */ + case allowSpontaneous = 3 + + /** + * 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`. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUCompareFunction : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case never = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case less = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case equal = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case lessEqual = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case greater = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case notEqual = 6 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case greaterEqual = 7 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case always = 8 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUCompilationInfoRequestStatus : UInt32, @unchecked Sendable { + + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * See @ref CallbackStatuses. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUCompilationMessageType : UInt32, @unchecked Sendable { + + case error = 1 + + case warning = 2 + + case info = 3 + + case force32 = 2147483647 +} + +/** + * Describes how frames are composited with other contents on the screen when @ref wgpuSurfacePresent is called. + */ +@frozen public enum WGPUCompositeAlphaMode : UInt32, @unchecked Sendable { + + /** + * `0`. Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between @ref WGPUCompositeAlphaMode_Opaque or @ref WGPUCompositeAlphaMode_Inherit. + */ + case auto = 0 + + /** + * The alpha component of the image is ignored and teated as if it is always 1.0. + */ + case opaque = 1 + + /** + * 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. + */ + case premultiplied = 2 + + /** + * 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. + */ + case unpremultiplied = 3 + + /** + * 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). + */ + case inherit = 4 + + /** + * 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). + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUCreatePipelineAsyncStatus : UInt32, @unchecked Sendable { + + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * See @ref CallbackStatuses. + */ + case validationError = 3 + + /** + * See @ref CallbackStatuses. + */ + case internalError = 4 + + /** + * See @ref CallbackStatuses. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUCullMode : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case none = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case front = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case back = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUDeviceLostReason : UInt32, @unchecked Sendable { + + case unknown = 1 + + case destroyed = 2 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 3 + + /** + * See @ref CallbackStatuses. + */ + case failedCreation = 4 + + /** + * See @ref CallbackStatuses. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUErrorFilter : UInt32, @unchecked Sendable { + + case validation = 1 + + case outOfMemory = 2 + + case `internal` = 3 + + case force32 = 2147483647 +} + +@frozen public enum WGPUErrorType : UInt32, @unchecked Sendable { + + case noError = 1 + + case validation = 2 + + case outOfMemory = 3 + + case `internal` = 4 + + case unknown = 5 + + case force32 = 2147483647 +} + +/** + * See @ref WGPURequestAdapterOptions::featureLevel. + */ +@frozen public enum WGPUFeatureLevel : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * "Compatibility" profile which can be supported on OpenGL ES 3.1 and D3D11. + */ + case compatibility = 1 + + /** + * "Core" profile which can be supported on Vulkan/Metal/D3D12 (at least). + */ + case core = 2 + + /** + * "Core" profile which can be supported on Vulkan/Metal/D3D12 (at least). + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUFeatureName : UInt32, @unchecked Sendable { + + case coreFeaturesAndLimits = 1 + + case depthClipControl = 2 + + case depth32FloatStencil8 = 3 + + case textureCompressionBC = 4 + + case textureCompressionBCSliced3D = 5 + + case textureCompressionETC2 = 6 + + case textureCompressionASTC = 7 + + case textureCompressionASTCSliced3D = 8 + + case timestampQuery = 9 + + case indirectFirstInstance = 10 + + case shaderF16 = 11 + + case rg11B10UfloatRenderable = 12 + + case bgra8UnormStorage = 13 + + case float32Filterable = 14 + + case float32Blendable = 15 + + case clipDistances = 16 + + case dualSourceBlending = 17 + + case subgroups = 18 + + case textureFormatsTier1 = 19 + + case textureFormatsTier2 = 20 + + case force32 = 2147483647 +} + +@frozen public enum WGPUFilterMode : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case nearest = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case linear = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUFrontFace : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case CCW = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case CW = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUIndexFormat : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case uint16 = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case uint32 = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUInstanceFeatureName : UInt32, @unchecked Sendable { + + /** + * Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + case timedWaitAny = 1 + + /** + * Enable passing SPIR-V shaders to @ref wgpuDeviceCreateShaderModule, + * via @ref WGPUShaderSourceSPIRV. + */ + case shaderSourceSPIRV = 2 + + /** + * 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. + */ + case multipleDevicesPerAdapter = 3 + + /** + * 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. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPULoadOp : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case load = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case clear = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUMapAsyncStatus : UInt32, @unchecked Sendable { + + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * See @ref CallbackStatuses. + */ + case error = 3 + + /** + * See @ref CallbackStatuses. + */ + case aborted = 4 + + /** + * See @ref CallbackStatuses. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUMipmapFilterMode : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case nearest = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case linear = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUOptionalBool : UInt32, @unchecked Sendable { + + /** + * `0`. + */ + case `false` = 0 + + /** + * `0`. + */ + case `true` = 1 + + /** + * `0`. + */ + case undefined = 2 + + /** + * `0`. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUPopErrorScopeStatus : UInt32, @unchecked Sendable { + + /** + * The error scope stack was successfully popped and a result was reported. + */ + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * The error scope stack could not be popped, because it was empty. + */ + case error = 3 + + /** + * The error scope stack could not be popped, because it was empty. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUPowerPreference : UInt32, @unchecked Sendable { + + /** + * `0`. No preference. (See also @ref SentinelValues.) + */ + case undefined = 0 + + /** + * `0`. No preference. (See also @ref SentinelValues.) + */ + case lowPower = 1 + + /** + * `0`. No preference. (See also @ref SentinelValues.) + */ + case highPerformance = 2 + + /** + * `0`. No preference. (See also @ref SentinelValues.) + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUPredefinedColorSpace : UInt32, @unchecked Sendable { + + case SRGB = 1 + + case displayP3 = 2 + + case force32 = 2147483647 +} + +/** + * Describes when and in which order frames are presented on the screen when @ref wgpuSurfacePresent is called. + */ +@frozen public enum WGPUPresentMode : UInt32, @unchecked Sendable { + + /** + * `0`. Present mode is not specified. Use the default. + */ + case undefined = 0 + + /** + * 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. + */ + case fifo = 1 + + /** + * 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. + */ + case fifoRelaxed = 2 + + /** + * 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. + */ + case immediate = 3 + + /** + * 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. + */ + case mailbox = 4 + + /** + * 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. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUPrimitiveTopology : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case pointList = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case lineList = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case lineStrip = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case triangleList = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case triangleStrip = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUQueryType : UInt32, @unchecked Sendable { + + case occlusion = 1 + + case timestamp = 2 + + case force32 = 2147483647 +} + +@frozen public enum WGPUQueueWorkDoneStatus : UInt32, @unchecked Sendable { + + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * 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.) + */ + case error = 3 + + /** + * 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.) + */ + case force32 = 2147483647 +} + +@frozen public enum WGPURequestAdapterStatus : UInt32, @unchecked Sendable { + + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * See @ref CallbackStatuses. + */ + case unavailable = 3 + + /** + * See @ref CallbackStatuses. + */ + case error = 4 + + /** + * See @ref CallbackStatuses. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPURequestDeviceStatus : UInt32, @unchecked Sendable { + + case success = 1 + + /** + * See @ref CallbackStatuses. + */ + case callbackCancelled = 2 + + /** + * See @ref CallbackStatuses. + */ + case error = 3 + + /** + * See @ref CallbackStatuses. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUSamplerBindingType : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates that this @ref WGPUSamplerBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + case bindingNotUsed = 0 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 1 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case filtering = 2 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case nonFiltering = 3 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case comparison = 4 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +/** + * 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. + */ +@frozen public enum WGPUStatus : UInt32, @unchecked Sendable { + + case success = 1 + + case error = 2 + + case force32 = 2147483647 +} + +@frozen public enum WGPUStencilOperation : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case keep = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case zero = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case replace = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case invert = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case incrementClamp = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case decrementClamp = 6 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case incrementWrap = 7 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case decrementWrap = 8 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUStorageTextureAccess : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates that this @ref WGPUStorageTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + case bindingNotUsed = 0 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 1 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case writeOnly = 2 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case readOnly = 3 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case readWrite = 4 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUStoreOp : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case store = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case discard = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUSType : UInt32, @unchecked Sendable { + + case shaderSourceSPIRV = 1 + + case shaderSourceWGSL = 2 + + case renderPassMaxDrawCount = 3 + + case surfaceSourceMetalLayer = 4 + + case surfaceSourceWindowsHWND = 5 + + case surfaceSourceXlibWindow = 6 + + case surfaceSourceWaylandSurface = 7 + + case surfaceSourceAndroidNativeWindow = 8 + + case surfaceSourceXCBWindow = 9 + + case surfaceColorManagement = 10 + + case requestAdapterWebXROptions = 11 + + case force32 = 2147483647 +} + +/** + * The status enum for @ref wgpuSurfaceGetCurrentTexture. + */ +@frozen public enum WGPUSurfaceGetCurrentTextureStatus : UInt32, @unchecked Sendable { + + /** + * Yay! Everything is good and we can render this frame. + */ + case successOptimal = 1 + + /** + * Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + */ + case successSuboptimal = 2 + + /** + * Some operation timed out while trying to acquire the frame. + */ + case timeout = 3 + + /** + * The surface is too different to be used, compared to when it was originally created. + */ + case outdated = 4 + + /** + * The connection to whatever owns the surface was lost, or generally needs to be fully reinitialized. + */ + case lost = 5 + + /** + * There was some deterministic error (for example, the surface is not configured, or there was an @ref OutStructChainError). Should produce @ref ImplementationDefinedLogging containing details. + */ + case error = 6 + + /** + * There was some deterministic error (for example, the surface is not configured, or there was an @ref OutStructChainError). Should produce @ref ImplementationDefinedLogging containing details. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUTextureAspect : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case all = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case stencilOnly = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depthOnly = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUTextureDimension : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _Undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _1D = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _2D = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _3D = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _Force32 = 2147483647 +} + +@frozen public enum WGPUTextureFormat : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r8Unorm = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r8Snorm = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r8Uint = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r8Sint = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r16Unorm = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r16Snorm = 6 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r16Uint = 7 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r16Sint = 8 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r16Float = 9 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg8Unorm = 10 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg8Snorm = 11 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg8Uint = 12 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg8Sint = 13 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r32Float = 14 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r32Uint = 15 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case r32Sint = 16 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg16Unorm = 17 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg16Snorm = 18 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg16Uint = 19 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg16Sint = 20 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg16Float = 21 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba8Unorm = 22 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba8UnormSrgb = 23 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba8Snorm = 24 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba8Uint = 25 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba8Sint = 26 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bgra8Unorm = 27 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bgra8UnormSrgb = 28 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgb10A2Uint = 29 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgb10A2Unorm = 30 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg11B10Ufloat = 31 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgb9E5Ufloat = 32 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg32Float = 33 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg32Uint = 34 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rg32Sint = 35 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba16Unorm = 36 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba16Snorm = 37 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba16Uint = 38 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba16Sint = 39 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba16Float = 40 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba32Float = 41 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba32Uint = 42 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case rgba32Sint = 43 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case stencil8 = 44 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depth16Unorm = 45 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depth24Plus = 46 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depth24PlusStencil8 = 47 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depth32Float = 48 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depth32FloatStencil8 = 49 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc1RGBAUnorm = 50 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc1RGBAUnormSrgb = 51 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc2RGBAUnorm = 52 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc2RGBAUnormSrgb = 53 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc3RGBAUnorm = 54 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc3RGBAUnormSrgb = 55 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc4RUnorm = 56 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc4RSnorm = 57 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc5RGUnorm = 58 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc5RGSnorm = 59 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc6HRGBUfloat = 60 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc6HRGBFloat = 61 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc7RGBAUnorm = 62 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case bc7RGBAUnormSrgb = 63 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case etc2RGB8Unorm = 64 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case etc2RGB8UnormSrgb = 65 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case etc2RGB8A1Unorm = 66 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case etc2RGB8A1UnormSrgb = 67 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case etc2RGBA8Unorm = 68 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case etc2RGBA8UnormSrgb = 69 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case eacr11Unorm = 70 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case eacr11Snorm = 71 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case eacrg11Unorm = 72 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case eacrg11Snorm = 73 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc4x4Unorm = 74 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc4x4UnormSrgb = 75 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc5x4Unorm = 76 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc5x4UnormSrgb = 77 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc5x5Unorm = 78 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc5x5UnormSrgb = 79 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc6x5Unorm = 80 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc6x5UnormSrgb = 81 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc6x6Unorm = 82 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc6x6UnormSrgb = 83 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc8x5Unorm = 84 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc8x5UnormSrgb = 85 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc8x6Unorm = 86 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc8x6UnormSrgb = 87 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc8x8Unorm = 88 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc8x8UnormSrgb = 89 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x5Unorm = 90 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x5UnormSrgb = 91 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x6Unorm = 92 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x6UnormSrgb = 93 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x8Unorm = 94 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x8UnormSrgb = 95 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x10Unorm = 96 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc10x10UnormSrgb = 97 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc12x10Unorm = 98 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc12x10UnormSrgb = 99 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc12x12Unorm = 100 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case astc12x12UnormSrgb = 101 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUTextureSampleType : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates that this @ref WGPUTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + case bindingNotUsed = 0 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 1 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case float = 2 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case unfilterableFloat = 3 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case depth = 4 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case sint = 5 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case uint = 6 + + /** + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUTextureViewDimension : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _Undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _1D = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _2D = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _2DArray = 3 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _Cube = 4 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _CubeArray = 5 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _3D = 6 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case _Force32 = 2147483647 +} + +@frozen public enum WGPUToneMappingMode : UInt32, @unchecked Sendable { + + case standard = 1 + + case extended = 2 + + case force32 = 2147483647 +} + +@frozen public enum WGPUVertexFormat : UInt32, @unchecked Sendable { + + case uint8 = 1 + + case uint8x2 = 2 + + case uint8x4 = 3 + + case sint8 = 4 + + case sint8x2 = 5 + + case sint8x4 = 6 + + case unorm8 = 7 + + case unorm8x2 = 8 + + case unorm8x4 = 9 + + case snorm8 = 10 + + case snorm8x2 = 11 + + case snorm8x4 = 12 + + case uint16 = 13 + + case uint16x2 = 14 + + case uint16x4 = 15 + + case sint16 = 16 + + case sint16x2 = 17 + + case sint16x4 = 18 + + case unorm16 = 19 + + case unorm16x2 = 20 + + case unorm16x4 = 21 + + case snorm16 = 22 + + case snorm16x2 = 23 + + case snorm16x4 = 24 + + case float16 = 25 + + case float16x2 = 26 + + case float16x4 = 27 + + case float32 = 28 + + case float32x2 = 29 + + case float32x3 = 30 + + case float32x4 = 31 + + case uint32 = 32 + + case uint32x2 = 33 + + case uint32x3 = 34 + + case uint32x4 = 35 + + case sint32 = 36 + + case sint32x2 = 37 + + case sint32x3 = 38 + + case sint32x4 = 39 + + case unorm10_10_10_2 = 40 + + case unorm8x4BGRA = 41 + + case force32 = 2147483647 +} + +@frozen public enum WGPUVertexStepMode : UInt32, @unchecked Sendable { + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case undefined = 0 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case vertex = 1 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case instance = 2 + + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + case force32 = 2147483647 +} + +/** + * Status returned from a call to ::wgpuInstanceWaitAny. + */ +@frozen public enum WGPUWaitStatus : UInt32, @unchecked Sendable { + + /** + * At least one WGPUFuture completed successfully. + */ + case success = 1 + + /** + * The wait operation succeeded, but no WGPUFutures completed within the timeout. + */ + case timedOut = 2 + + /** + * The call was invalid for some reason (see @ref Wait-Any). + * Should produce @ref ImplementationDefinedLogging containing details. + */ + case error = 3 + + /** + * The call was invalid for some reason (see @ref Wait-Any). + * Should produce @ref ImplementationDefinedLogging containing details. + */ + case force32 = 2147483647 +} + +@frozen public enum WGPUWGSLLanguageFeatureName : UInt32, @unchecked Sendable { + + case readonlyAndReadwriteStorageTextures = 1 + + case packed4x8IntegerDotProduct = 2 + + case unrestrictedPointerParameters = 3 + + case pointerCompositeAccess = 4 + + case force32 = 2147483647 +} + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +public struct WGPUBufferUsage : Hashable, Equatable, RawRepresentable, @unchecked Sendable { + + public init(_ rawValue: WGPUFlags) + + public init(rawValue: WGPUFlags) +} + +extension WGPUBufferUsage { + + /** + * `0`. + */ + public static var none: WGPUBufferUsage { get } + + /** + * The buffer can be *mapped* on the CPU side in *read* mode (using @ref WGPUMapMode_Read). + */ + public static var mapRead: WGPUBufferUsage { get } + + /** + * 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. + */ + public static var mapWrite: WGPUBufferUsage { get } + + /** + * The buffer can be used as the *source* of a GPU-side copy operation. + */ + public static var copySrc: WGPUBufferUsage { get } + + /** + * The buffer can be used as the *destination* of a GPU-side copy operation. + */ + public static var copyDst: WGPUBufferUsage { get } + + /** + * The buffer can be used as an Index buffer when doing indexed drawing in a render pipeline. + */ + public static var index: WGPUBufferUsage { get } + + /** + * The buffer can be used as an Vertex buffer when using a render pipeline. + */ + public static var vertex: WGPUBufferUsage { get } + + /** + * The buffer can be bound to a shader as a uniform buffer. + */ + public static var uniform: WGPUBufferUsage { get } + + /** + * The buffer can be bound to a shader as a storage buffer. + */ + public static var storage: WGPUBufferUsage { get } + + /** + * The buffer can store arguments for an indirect draw call. + */ + public static var indirect: WGPUBufferUsage { get } + + /** + * The buffer can store the result of a timestamp or occlusion query. + */ + public static var queryResolve: WGPUBufferUsage { get } +} + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +public struct WGPUColorWriteMask : Hashable, Equatable, RawRepresentable, @unchecked Sendable { + + public init(_ rawValue: WGPUFlags) + + public init(rawValue: WGPUFlags) +} + +extension WGPUColorWriteMask { + + /** + * `0`. + */ + public static var none: WGPUColorWriteMask { get } + + public static var red: WGPUColorWriteMask { get } + + public static var green: WGPUColorWriteMask { get } + + public static var blue: WGPUColorWriteMask { get } + + public static var alpha: WGPUColorWriteMask { get } + + /** + * `Red | Green | Blue | Alpha`. + */ + public static var all: WGPUColorWriteMask { get } +} + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +public struct WGPUMapMode : Hashable, Equatable, RawRepresentable, @unchecked Sendable { + + public init(_ rawValue: WGPUFlags) + + public init(rawValue: WGPUFlags) +} + +extension WGPUMapMode { + + /** + * `0`. + */ + public static var none: WGPUMapMode { get } + + public static var read: WGPUMapMode { get } + + public static var write: WGPUMapMode { get } +} + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +public struct WGPUShaderStage : Hashable, Equatable, RawRepresentable, @unchecked Sendable { + + public init(_ rawValue: WGPUFlags) + + public init(rawValue: WGPUFlags) +} + +extension WGPUShaderStage { + + /** + * `0`. + */ + public static var none: WGPUShaderStage { get } + + public static var vertex: WGPUShaderStage { get } + + public static var fragment: WGPUShaderStage { get } + + public static var compute: WGPUShaderStage { get } +} + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ +public struct WGPUTextureUsage : Hashable, Equatable, RawRepresentable, @unchecked Sendable { + + public init(_ rawValue: WGPUFlags) + + public init(rawValue: WGPUFlags) +} + +extension WGPUTextureUsage { + + /** + * `0`. + */ + public static var none: WGPUTextureUsage { get } + + public static var copySrc: WGPUTextureUsage { get } + + public static var copyDst: WGPUTextureUsage { get } + + public static var textureBinding: WGPUTextureUsage { get } + + public static var storageBinding: WGPUTextureUsage { get } + + public static var renderAttachment: WGPUTextureUsage { get } +} + +/** @} */ +public typealias WGPUProc = @convention(c) () -> Void + +/** + * See also @ref CallbackError. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +public typealias WGPUBufferMapCallback = @convention(c) (WGPUMapAsyncStatus, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * 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. + */ +public typealias WGPUCompilationInfoCallback = @convention(c) (WGPUCompilationInfoRequestStatus, UnsafePointer?, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * See also @ref CallbackError. + * + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +public typealias WGPUCreateComputePipelineAsyncCallback = @convention(c) (WGPUCreatePipelineAsyncStatus, WGPUComputePipeline?, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * See also @ref CallbackError. + * + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +public typealias WGPUCreateRenderPipelineAsyncCallback = @convention(c) (WGPUCreatePipelineAsyncStatus, WGPURenderPipeline?, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * 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 message + * This parameter is @ref PassedWithoutOwnership. + */ +public typealias WGPUDeviceLostCallback = @convention(c) (UnsafePointer?, WGPUDeviceLostReason, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * 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. + */ +public typealias WGPUPopErrorScopeCallback = @convention(c) (WGPUPopErrorScopeStatus, WGPUErrorType, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * 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. + */ +public typealias WGPUQueueWorkDoneCallback = @convention(c) (WGPUQueueWorkDoneStatus, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * See also @ref CallbackError. + * + * @param adapter + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +public typealias WGPURequestAdapterCallback = @convention(c) (WGPURequestAdapterStatus, WGPUAdapter?, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * See also @ref CallbackError. + * + * @param device + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +public typealias WGPURequestDeviceCallback = @convention(c) (WGPURequestDeviceStatus, WGPUDevice?, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** + * See also @ref CallbackError. + * + * @param device + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +public typealias WGPUUncapturedErrorCallback = @convention(c) (UnsafePointer?, WGPUErrorType, WGPUStringView, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Void + +/** @} */ +/** + * \defgroup ChainedStructures Chained Structures + * \brief Structures used to extend descriptors. + * + * @{ + */ +public struct WGPUChainedStruct { + + public init() + + public init(next: UnsafeMutablePointer!, sType: WGPUSType) + + public var next: UnsafeMutablePointer! + + public var sType: WGPUSType +} + +/** + * \defgroup CallbackInfoStructs Callback Info Structs + * \brief Callback info structures that are used in asynchronous functions. + * + * @{ + */ +public struct WGPUBufferMapCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUBufferMapCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUBufferMapCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUCompilationInfoCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUCompilationInfoCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUCompilationInfoCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUCreateComputePipelineAsyncCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUCreateComputePipelineAsyncCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUCreateComputePipelineAsyncCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUCreateRenderPipelineAsyncCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUCreateRenderPipelineAsyncCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUCreateRenderPipelineAsyncCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUDeviceLostCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUDeviceLostCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUDeviceLostCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUPopErrorScopeCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUPopErrorScopeCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUPopErrorScopeCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUQueueWorkDoneCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPUQueueWorkDoneCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPUQueueWorkDoneCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPURequestAdapterCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPURequestAdapterCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPURequestAdapterCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPURequestDeviceCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, mode: WGPUCallbackMode, callback: WGPURequestDeviceCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ + public var mode: WGPUCallbackMode + + public var callback: WGPURequestDeviceCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +public struct WGPUUncapturedErrorCallbackInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, callback: WGPUUncapturedErrorCallback!, userdata1: UnsafeMutableRawPointer!, userdata2: UnsafeMutableRawPointer!) + + public var nextInChain: UnsafeMutablePointer! + + public var callback: WGPUUncapturedErrorCallback! + + public var userdata1: UnsafeMutableRawPointer! + + public var userdata2: UnsafeMutableRawPointer! +} + +/** + * Default values can be set using @ref WGPU_ADAPTER_INFO_INIT as initializer. + */ +public struct WGPUAdapterInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, vendor: WGPUStringView, architecture: WGPUStringView, device: WGPUStringView, description: WGPUStringView, backendType: WGPUBackendType, adapterType: WGPUAdapterType, vendorID: UInt32, deviceID: UInt32, subgroupMinSize: UInt32, subgroupMaxSize: UInt32) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var vendor: WGPUStringView + + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var architecture: WGPUStringView + + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var device: WGPUStringView + + /** + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var description: WGPUStringView + + /** + * The `INIT` macro sets this to @ref WGPUBackendType_Undefined. + */ + public var backendType: WGPUBackendType + + /** + * The `INIT` macro sets this to (@ref WGPUAdapterType)0. + */ + public var adapterType: WGPUAdapterType + + /** + * The `INIT` macro sets this to `0`. + */ + public var vendorID: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var deviceID: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var subgroupMinSize: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var subgroupMaxSize: UInt32 +} + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_ENTRY_INIT as initializer. + */ +public struct WGPUBindGroupEntry { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, binding: UInt32, buffer: WGPUBuffer!, offset: UInt64, size: UInt64, sampler: WGPUSampler!, textureView: WGPUTextureView!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Binding index in the bind group. + * + * The `INIT` macro sets this to `0`. + */ + public var binding: UInt32 + + /** + * Set this if the binding is a buffer object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + public var buffer: WGPUBuffer! + + /** + * If the binding is a buffer, this is the byte offset of the binding range. + * Otherwise ignored. + * + * The `INIT` macro sets this to `0`. + */ + public var offset: UInt64 + + /** + * 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. + */ + public var size: UInt64 + + /** + * Set this if the binding is a sampler object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + public var sampler: WGPUSampler! + + /** + * Set this if the binding is a texture view object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + public var textureView: WGPUTextureView! +} + +/** + * Default values can be set using @ref WGPU_BLEND_COMPONENT_INIT as initializer. + */ +public struct WGPUBlendComponent { + + public init() + + public init(operation: WGPUBlendOperation, srcFactor: WGPUBlendFactor, dstFactor: WGPUBlendFactor) + + /** + * If set to @ref WGPUBlendOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendOperation_Add. + * + * The `INIT` macro sets this to @ref WGPUBlendOperation_Undefined. + */ + public var operation: WGPUBlendOperation + + /** + * If set to @ref WGPUBlendFactor_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_One. + * + * The `INIT` macro sets this to @ref WGPUBlendFactor_Undefined. + */ + public var srcFactor: WGPUBlendFactor + + /** + * If set to @ref WGPUBlendFactor_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_Zero. + * + * The `INIT` macro sets this to @ref WGPUBlendFactor_Undefined. + */ + public var dstFactor: WGPUBlendFactor +} + +/** + * Default values can be set using @ref WGPU_BUFFER_BINDING_LAYOUT_INIT as initializer. + */ +public struct WGPUBufferBindingLayout { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, type: WGPUBufferBindingType, hasDynamicOffset: WGPUBool, minBindingSize: UInt64) + + public var nextInChain: UnsafeMutablePointer! + + /** + * If set to @ref WGPUBufferBindingType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBufferBindingType_Uniform. + * + * The `INIT` macro sets this to @ref WGPUBufferBindingType_Undefined. + */ + public var type: WGPUBufferBindingType + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var hasDynamicOffset: WGPUBool + + /** + * The `INIT` macro sets this to `0`. + */ + public var minBindingSize: UInt64 +} + +/** + * Default values can be set using @ref WGPU_BUFFER_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUBufferDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, usage: WGPUBufferUsage, size: UInt64, mappedAtCreation: WGPUBool) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to @ref WGPUBufferUsage_None. + */ + public var usage: WGPUBufferUsage + + /** + * The `INIT` macro sets this to `0`. + */ + public var size: UInt64 + + /** + * 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`. + */ + public var mappedAtCreation: WGPUBool +} + +/** + * 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. + */ +public struct WGPUColor { + + public init() + + public init(r: Double, g: Double, b: Double, a: Double) + + /** + * The `INIT` macro sets this to `0.`. + */ + public var r: Double + + /** + * The `INIT` macro sets this to `0.`. + */ + public var g: Double + + /** + * The `INIT` macro sets this to `0.`. + */ + public var b: Double + + /** + * The `INIT` macro sets this to `0.`. + */ + public var a: Double +} + +/** + * Default values can be set using @ref WGPU_COMMAND_BUFFER_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUCommandBufferDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView +} + +/** + * Default values can be set using @ref WGPU_COMMAND_ENCODER_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUCommandEncoderDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView +} + +/** + * 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. + */ +public struct WGPUCompilationMessage { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, message: WGPUStringView, type: WGPUCompilationMessageType, lineNum: UInt64, linePos: UInt64, offset: UInt64, length: UInt64) + + public var nextInChain: UnsafeMutablePointer! + + /** + * A @ref LocalizableHumanReadableMessageString. + * + * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var message: WGPUStringView + + /** + * Severity level of the message. + * + * The `INIT` macro sets this to (@ref WGPUCompilationMessageType)0. + */ + public var type: WGPUCompilationMessageType + + /** + * Line number where the message is attached, starting at 1. + * + * The `INIT` macro sets this to `0`. + */ + public var lineNum: UInt64 + + /** + * Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + * + * The `INIT` macro sets this to `0`. + */ + public var linePos: UInt64 + + /** + * Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + * + * The `INIT` macro sets this to `0`. + */ + public var offset: UInt64 + + /** + * Length in UTF-8 code units (bytes) of the span the message corresponds to. + * + * The `INIT` macro sets this to `0`. + */ + public var length: UInt64 +} + +/** + * Default values can be set using @ref WGPU_CONSTANT_ENTRY_INIT as initializer. + */ +public struct WGPUConstantEntry { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, key: WGPUStringView, value: Double) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var key: WGPUStringView + + /** + * Represents a WGSL numeric or boolean value using @ref DoubleAsSupertype. + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.`. + */ + public var value: Double +} + +/** + * Default values can be set using @ref WGPU_EXTENT_3D_INIT as initializer. + */ +public struct WGPUExtent3D { + + public init() + + public init(width: UInt32, height: UInt32, depthOrArrayLayers: UInt32) + + /** + * The `INIT` macro sets this to `0`. + */ + public var width: UInt32 + + /** + * The `INIT` macro sets this to `1`. + */ + public var height: UInt32 + + /** + * The `INIT` macro sets this to `1`. + */ + public var depthOrArrayLayers: UInt32 +} + +/** + * 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. + */ +public struct WGPUFuture { + + public init() + + public init(id: UInt64) + + /** + * Opaque id of the @ref WGPUFuture + * + * The `INIT` macro sets this to `0`. + */ + public var id: UInt64 +} + +/** + * Default values can be set using @ref WGPU_INSTANCE_LIMITS_INIT as initializer. + */ +public struct WGPUInstanceLimits { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, timedWaitAnyMaxCount: Int) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + * + * The `INIT` macro sets this to `0`. + */ + public var timedWaitAnyMaxCount: Int +} + +/** + * Default values can be set using @ref WGPU_LIMITS_INIT as initializer. + */ +public struct WGPULimits { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, maxTextureDimension1D: UInt32, maxTextureDimension2D: UInt32, maxTextureDimension3D: UInt32, maxTextureArrayLayers: UInt32, maxBindGroups: UInt32, maxBindGroupsPlusVertexBuffers: UInt32, maxBindingsPerBindGroup: UInt32, maxDynamicUniformBuffersPerPipelineLayout: UInt32, maxDynamicStorageBuffersPerPipelineLayout: UInt32, maxSampledTexturesPerShaderStage: UInt32, maxSamplersPerShaderStage: UInt32, maxStorageBuffersPerShaderStage: UInt32, maxStorageTexturesPerShaderStage: UInt32, maxUniformBuffersPerShaderStage: UInt32, maxUniformBufferBindingSize: UInt64, maxStorageBufferBindingSize: UInt64, minUniformBufferOffsetAlignment: UInt32, minStorageBufferOffsetAlignment: UInt32, maxVertexBuffers: UInt32, maxBufferSize: UInt64, maxVertexAttributes: UInt32, maxVertexBufferArrayStride: UInt32, maxInterStageShaderVariables: UInt32, maxColorAttachments: UInt32, maxColorAttachmentBytesPerSample: UInt32, maxComputeWorkgroupStorageSize: UInt32, maxComputeInvocationsPerWorkgroup: UInt32, maxComputeWorkgroupSizeX: UInt32, maxComputeWorkgroupSizeY: UInt32, maxComputeWorkgroupSizeZ: UInt32, maxComputeWorkgroupsPerDimension: UInt32, maxImmediateSize: UInt32) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxTextureDimension1D: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxTextureDimension2D: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxTextureDimension3D: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxTextureArrayLayers: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxBindGroups: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxBindGroupsPlusVertexBuffers: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxBindingsPerBindGroup: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxDynamicUniformBuffersPerPipelineLayout: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxDynamicStorageBuffersPerPipelineLayout: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxSampledTexturesPerShaderStage: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxSamplersPerShaderStage: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxStorageBuffersPerShaderStage: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxStorageTexturesPerShaderStage: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxUniformBuffersPerShaderStage: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + public var maxUniformBufferBindingSize: UInt64 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + public var maxStorageBufferBindingSize: UInt64 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var minUniformBufferOffsetAlignment: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var minStorageBufferOffsetAlignment: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxVertexBuffers: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + public var maxBufferSize: UInt64 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxVertexAttributes: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxVertexBufferArrayStride: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxInterStageShaderVariables: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxColorAttachments: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxColorAttachmentBytesPerSample: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxComputeWorkgroupStorageSize: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxComputeInvocationsPerWorkgroup: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxComputeWorkgroupSizeX: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxComputeWorkgroupSizeY: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxComputeWorkgroupSizeZ: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxComputeWorkgroupsPerDimension: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + public var maxImmediateSize: UInt32 +} + +/** + * Default values can be set using @ref WGPU_MULTISAMPLE_STATE_INIT as initializer. + */ +public struct WGPUMultisampleState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, count: UInt32, mask: UInt32, alphaToCoverageEnabled: WGPUBool) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to `1`. + */ + public var count: UInt32 + + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ + public var mask: UInt32 + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var alphaToCoverageEnabled: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_ORIGIN_3D_INIT as initializer. + */ +public struct WGPUOrigin3D { + + public init() + + public init(x: UInt32, y: UInt32, z: UInt32) + + /** + * The `INIT` macro sets this to `0`. + */ + public var x: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var y: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var z: UInt32 +} + +/** + * Default values can be set using @ref WGPU_PASS_TIMESTAMP_WRITES_INIT as initializer. + */ +public struct WGPUPassTimestampWrites { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, querySet: WGPUQuerySet!, beginningOfPassWriteIndex: UInt32, endOfPassWriteIndex: UInt32) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Query set to write timestamps to. + * + * The `INIT` macro sets this to `NULL`. + */ + public var querySet: WGPUQuerySet! + + /** + * The `INIT` macro sets this to @ref WGPU_QUERY_SET_INDEX_UNDEFINED. + */ + public var beginningOfPassWriteIndex: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_QUERY_SET_INDEX_UNDEFINED. + */ + public var endOfPassWriteIndex: UInt32 +} + +/** + * Default values can be set using @ref WGPU_PIPELINE_LAYOUT_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUPipelineLayoutDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, bindGroupLayoutCount: Int, bindGroupLayouts: UnsafePointer!, immediateSize: UInt32) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * Array count for `bindGroupLayouts`. The `INIT` macro sets this to 0. + */ + public var bindGroupLayoutCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var bindGroupLayouts: UnsafePointer! + + /** + * The `INIT` macro sets this to `0`. + */ + public var immediateSize: UInt32 +} + +/** + * Default values can be set using @ref WGPU_PRIMITIVE_STATE_INIT as initializer. + */ +public struct WGPUPrimitiveState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, topology: WGPUPrimitiveTopology, stripIndexFormat: WGPUIndexFormat, frontFace: WGPUFrontFace, cullMode: WGPUCullMode, unclippedDepth: WGPUBool) + + public var nextInChain: UnsafeMutablePointer! + + /** + * If set to @ref WGPUPrimitiveTopology_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUPrimitiveTopology_TriangleList. + * + * The `INIT` macro sets this to @ref WGPUPrimitiveTopology_Undefined. + */ + public var topology: WGPUPrimitiveTopology + + /** + * The `INIT` macro sets this to @ref WGPUIndexFormat_Undefined. + */ + public var stripIndexFormat: WGPUIndexFormat + + /** + * If set to @ref WGPUFrontFace_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFrontFace_CCW. + * + * The `INIT` macro sets this to @ref WGPUFrontFace_Undefined. + */ + public var frontFace: WGPUFrontFace + + /** + * If set to @ref WGPUCullMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUCullMode_None. + * + * The `INIT` macro sets this to @ref WGPUCullMode_Undefined. + */ + public var cullMode: WGPUCullMode + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var unclippedDepth: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_QUERY_SET_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUQuerySetDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, type: WGPUQueryType, count: UInt32) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to (@ref WGPUQueryType)0. + */ + public var type: WGPUQueryType + + /** + * The `INIT` macro sets this to `0`. + */ + public var count: UInt32 +} + +/** + * Default values can be set using @ref WGPU_QUEUE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUQueueDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView +} + +/** + * Default values can be set using @ref WGPU_RENDER_BUNDLE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPURenderBundleDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView +} + +/** + * Default values can be set using @ref WGPU_RENDER_BUNDLE_ENCODER_DESCRIPTOR_INIT as initializer. + */ +public struct WGPURenderBundleEncoderDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, colorFormatCount: Int, colorFormats: UnsafePointer!, depthStencilFormat: WGPUTextureFormat, sampleCount: UInt32, depthReadOnly: WGPUBool, stencilReadOnly: WGPUBool) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * Array count for `colorFormats`. The `INIT` macro sets this to 0. + */ + public var colorFormatCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var colorFormats: UnsafePointer! + + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + public var depthStencilFormat: WGPUTextureFormat + + /** + * The `INIT` macro sets this to `1`. + */ + public var sampleCount: UInt32 + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var depthReadOnly: WGPUBool + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var stencilReadOnly: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_DEPTH_STENCIL_ATTACHMENT_INIT as initializer. + */ +public struct WGPURenderPassDepthStencilAttachment { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, view: WGPUTextureView!, depthLoadOp: WGPULoadOp, depthStoreOp: WGPUStoreOp, depthClearValue: Float, depthReadOnly: WGPUBool, stencilLoadOp: WGPULoadOp, stencilStoreOp: WGPUStoreOp, stencilClearValue: UInt32, stencilReadOnly: WGPUBool) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var view: WGPUTextureView! + + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ + public var depthLoadOp: WGPULoadOp + + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ + public var depthStoreOp: WGPUStoreOp + + /** + * 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. + */ + public var depthClearValue: Float + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var depthReadOnly: WGPUBool + + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ + public var stencilLoadOp: WGPULoadOp + + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ + public var stencilStoreOp: WGPUStoreOp + + /** + * The `INIT` macro sets this to `0`. + */ + public var stencilClearValue: UInt32 + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var stencilReadOnly: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_MAX_DRAW_COUNT_INIT as initializer. + */ +public struct WGPURenderPassMaxDrawCount { + + public init() + + public init(chain: WGPUChainedStruct, maxDrawCount: UInt64) + + public var chain: WGPUChainedStruct + + /** + * The `INIT` macro sets this to `50000000`. + */ + public var maxDrawCount: UInt64 +} + +/** + * 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. + */ +public struct WGPURequestAdapterWebXROptions { + + public init() + + public init(chain: WGPUChainedStruct, xrCompatible: WGPUBool) + + public var chain: WGPUChainedStruct + + /** + * Sets the `xrCompatible` option in the JS API. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var xrCompatible: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_SAMPLER_BINDING_LAYOUT_INIT as initializer. + */ +public struct WGPUSamplerBindingLayout { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, type: WGPUSamplerBindingType) + + public var nextInChain: UnsafeMutablePointer! + + /** + * If set to @ref WGPUSamplerBindingType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUSamplerBindingType_Filtering. + * + * The `INIT` macro sets this to @ref WGPUSamplerBindingType_Undefined. + */ + public var type: WGPUSamplerBindingType +} + +/** + * Default values can be set using @ref WGPU_SAMPLER_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUSamplerDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, addressModeU: WGPUAddressMode, addressModeV: WGPUAddressMode, addressModeW: WGPUAddressMode, magFilter: WGPUFilterMode, minFilter: WGPUFilterMode, mipmapFilter: WGPUMipmapFilterMode, lodMinClamp: Float, lodMaxClamp: Float, compare: WGPUCompareFunction, maxAnisotropy: UInt16) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ + public var addressModeU: WGPUAddressMode + + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ + public var addressModeV: WGPUAddressMode + + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ + public var addressModeW: WGPUAddressMode + + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUFilterMode_Undefined. + */ + public var magFilter: WGPUFilterMode + + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUFilterMode_Undefined. + */ + public var minFilter: WGPUFilterMode + + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUMipmapFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUMipmapFilterMode_Undefined. + */ + public var mipmapFilter: WGPUMipmapFilterMode + + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ + public var lodMinClamp: Float + + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `32.f`. + */ + public var lodMaxClamp: Float + + /** + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ + public var compare: WGPUCompareFunction + + /** + * The `INIT` macro sets this to `1`. + */ + public var maxAnisotropy: UInt16 +} + +/** + * Default values can be set using @ref WGPU_SHADER_SOURCE_SPIRV_INIT as initializer. + */ +public struct WGPUShaderSourceSPIRV { + + public init() + + public init(chain: WGPUChainedStruct, codeSize: UInt32, code: UnsafePointer!) + + public var chain: WGPUChainedStruct + + /** + * The `INIT` macro sets this to `0`. + */ + public var codeSize: UInt32 + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var code: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_SHADER_SOURCE_WGSL_INIT as initializer. + */ +public struct WGPUShaderSourceWGSL { + + public init() + + public init(chain: WGPUChainedStruct, code: WGPUStringView) + + public var chain: WGPUChainedStruct + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var code: WGPUStringView +} + +/** + * Default values can be set using @ref WGPU_STENCIL_FACE_STATE_INIT as initializer. + */ +public struct WGPUStencilFaceState { + + public init() + + public init(compare: WGPUCompareFunction, failOp: WGPUStencilOperation, depthFailOp: WGPUStencilOperation, passOp: WGPUStencilOperation) + + /** + * If set to @ref WGPUCompareFunction_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUCompareFunction_Always. + * + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ + public var compare: WGPUCompareFunction + + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ + public var failOp: WGPUStencilOperation + + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ + public var depthFailOp: WGPUStencilOperation + + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ + public var passOp: WGPUStencilOperation +} + +/** + * Default values can be set using @ref WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ +public struct WGPUStorageTextureBindingLayout { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, access: WGPUStorageTextureAccess, format: WGPUTextureFormat, viewDimension: WGPUTextureViewDimension) + + public var nextInChain: UnsafeMutablePointer! + + /** + * If set to @ref WGPUStorageTextureAccess_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStorageTextureAccess_WriteOnly. + * + * The `INIT` macro sets this to @ref WGPUStorageTextureAccess_Undefined. + */ + public var access: WGPUStorageTextureAccess + + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + public var format: WGPUTextureFormat + + /** + * If set to @ref WGPUTextureViewDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + public var viewDimension: WGPUTextureViewDimension +} + +/** + * Default values can be set using @ref WGPU_SUPPORTED_FEATURES_INIT as initializer. + */ +public struct WGPUSupportedFeatures { + + public init() + + public init(featureCount: Int, features: UnsafePointer!) + + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + public var featureCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var features: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_SUPPORTED_INSTANCE_FEATURES_INIT as initializer. + */ +public struct WGPUSupportedInstanceFeatures { + + public init() + + public init(featureCount: Int, features: UnsafePointer!) + + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + public var featureCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var features: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_SUPPORTED_WGSL_LANGUAGE_FEATURES_INIT as initializer. + */ +public struct WGPUSupportedWGSLLanguageFeatures { + + public init() + + public init(featureCount: Int, features: UnsafePointer!) + + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + public var featureCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var features: UnsafePointer! +} + +/** + * 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. + */ +public struct WGPUSurfaceCapabilities { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, usages: WGPUTextureUsage, formatCount: Int, formats: UnsafePointer!, presentModeCount: Int, presentModes: UnsafePointer!, alphaModeCount: Int, alphaModes: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The bit set of supported @ref WGPUTextureUsage bits. + * Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + * + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + public var usages: WGPUTextureUsage + + /** + * Array count for `formats`. The `INIT` macro sets this to 0. + */ + public var formatCount: Int + + /** + * A list of supported @ref WGPUTextureFormat values, in order of preference. + * + * The `INIT` macro sets this to `NULL`. + */ + public var formats: UnsafePointer! + + /** + * Array count for `presentModes`. The `INIT` macro sets this to 0. + */ + public var presentModeCount: Int + + /** + * A list of supported @ref WGPUPresentMode values. + * Guaranteed to contain @ref WGPUPresentMode_Fifo. + * + * The `INIT` macro sets this to `NULL`. + */ + public var presentModes: UnsafePointer! + + /** + * Array count for `alphaModes`. The `INIT` macro sets this to 0. + */ + public var alphaModeCount: Int + + /** + * 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`. + */ + public var alphaModes: UnsafePointer! +} + +/** + * Extension of @ref WGPUSurfaceConfiguration for color spaces and HDR. + * + * Default values can be set using @ref WGPU_SURFACE_COLOR_MANAGEMENT_INIT as initializer. + */ +public struct WGPUSurfaceColorManagement { + + public init() + + public init(chain: WGPUChainedStruct, colorSpace: WGPUPredefinedColorSpace, toneMappingMode: WGPUToneMappingMode) + + public var chain: WGPUChainedStruct + + /** + * The `INIT` macro sets this to (@ref WGPUPredefinedColorSpace)0. + */ + public var colorSpace: WGPUPredefinedColorSpace + + /** + * The `INIT` macro sets this to (@ref WGPUToneMappingMode)0. + */ + public var toneMappingMode: WGPUToneMappingMode +} + +/** + * 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. + */ +public struct WGPUSurfaceConfiguration { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, device: WGPUDevice!, format: WGPUTextureFormat, usage: WGPUTextureUsage, width: UInt32, height: UInt32, viewFormatCount: Int, viewFormats: UnsafePointer!, alphaMode: WGPUCompositeAlphaMode, presentMode: WGPUPresentMode) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The @ref WGPUDevice to use to render to surface's textures. + * + * The `INIT` macro sets this to `NULL`. + */ + public var device: WGPUDevice! + + /** + * The @ref WGPUTextureFormat of the surface's textures. + * + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + public var format: WGPUTextureFormat + + /** + * The @ref WGPUTextureUsage of the surface's textures. + * + * The `INIT` macro sets this to @ref WGPUTextureUsage_RenderAttachment. + */ + public var usage: WGPUTextureUsage + + /** + * The width of the surface's textures. + * + * The `INIT` macro sets this to `0`. + */ + public var width: UInt32 + + /** + * The height of the surface's textures. + * + * The `INIT` macro sets this to `0`. + */ + public var height: UInt32 + + /** + * Array count for `viewFormats`. The `INIT` macro sets this to 0. + */ + public var viewFormatCount: Int + + /** + * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + * + * The `INIT` macro sets this to `NULL`. + */ + public var viewFormats: UnsafePointer! + + /** + * 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. + */ + public var alphaMode: WGPUCompositeAlphaMode + + /** + * 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. + */ + public var presentMode: WGPUPresentMode +} + +/** + * 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. + */ +public struct WGPUSurfaceSourceAndroidNativeWindow { + + public init() + + public init(chain: WGPUChainedStruct, window: UnsafeMutableRawPointer!) + + public var chain: WGPUChainedStruct + + /** + * 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`. + */ + public var window: UnsafeMutableRawPointer! +} + +/** + * 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. + */ +public struct WGPUSurfaceSourceMetalLayer { + + public init() + + public init(chain: WGPUChainedStruct, layer: UnsafeMutableRawPointer!) + + public var chain: WGPUChainedStruct + + /** + * 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`. + */ + public var layer: UnsafeMutableRawPointer! +} + +/** + * 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. + */ +public struct WGPUSurfaceSourceWaylandSurface { + + public init() + + public init(chain: WGPUChainedStruct, display: UnsafeMutableRawPointer!, surface: UnsafeMutableRawPointer!) + + public var chain: WGPUChainedStruct + + /** + * 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`. + */ + public var display: UnsafeMutableRawPointer! + + /** + * 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`. + */ + public var surface: UnsafeMutableRawPointer! +} + +/** + * 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. + */ +public struct WGPUSurfaceSourceWindowsHWND { + + public init() + + public init(chain: WGPUChainedStruct, hinstance: UnsafeMutableRawPointer!, hwnd: UnsafeMutableRawPointer!) + + public var chain: WGPUChainedStruct + + /** + * 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`. + */ + public var hinstance: UnsafeMutableRawPointer! + + /** + * 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`. + */ + public var hwnd: UnsafeMutableRawPointer! +} + +/** + * 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. + */ +public struct WGPUSurfaceSourceXCBWindow { + + public init() + + public init(chain: WGPUChainedStruct, connection: UnsafeMutableRawPointer!, window: UInt32) + + public var chain: WGPUChainedStruct + + /** + * The `xcb_connection_t` for the connection to the X server. + * + * The `INIT` macro sets this to `NULL`. + */ + public var connection: UnsafeMutableRawPointer! + + /** + * The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `0`. + */ + public var window: UInt32 +} + +/** + * 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. + */ +public struct WGPUSurfaceSourceXlibWindow { + + public init() + + public init(chain: WGPUChainedStruct, display: UnsafeMutableRawPointer!, window: UInt64) + + public var chain: WGPUChainedStruct + + /** + * 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`. + */ + public var display: UnsafeMutableRawPointer! + + /** + * 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`. + */ + public var window: UInt64 +} + +/** + * 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. + */ +public struct WGPUSurfaceTexture { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, texture: WGPUTexture!, status: WGPUSurfaceGetCurrentTextureStatus) + + public var nextInChain: UnsafeMutablePointer! + + /** + * 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`. + */ + public var texture: WGPUTexture! + + /** + * 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. + */ + public var status: WGPUSurfaceGetCurrentTextureStatus +} + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT as initializer. + */ +public struct WGPUTexelCopyBufferLayout { + + public init() + + public init(offset: UInt64, bytesPerRow: UInt32, rowsPerImage: UInt32) + + /** + * The `INIT` macro sets this to `0`. + */ + public var offset: UInt64 + + /** + * The `INIT` macro sets this to @ref WGPU_COPY_STRIDE_UNDEFINED. + */ + public var bytesPerRow: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_COPY_STRIDE_UNDEFINED. + */ + public var rowsPerImage: UInt32 +} + +/** + * Default values can be set using @ref WGPU_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ +public struct WGPUTextureBindingLayout { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, sampleType: WGPUTextureSampleType, viewDimension: WGPUTextureViewDimension, multisampled: WGPUBool) + + public var nextInChain: UnsafeMutablePointer! + + /** + * If set to @ref WGPUTextureSampleType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureSampleType_Float. + * + * The `INIT` macro sets this to @ref WGPUTextureSampleType_Undefined. + */ + public var sampleType: WGPUTextureSampleType + + /** + * If set to @ref WGPUTextureViewDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + public var viewDimension: WGPUTextureViewDimension + + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var multisampled: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUTextureViewDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, format: WGPUTextureFormat, dimension: WGPUTextureViewDimension, baseMipLevel: UInt32, mipLevelCount: UInt32, baseArrayLayer: UInt32, arrayLayerCount: UInt32, aspect: WGPUTextureAspect, usage: WGPUTextureUsage) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + public var format: WGPUTextureFormat + + /** + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + public var dimension: WGPUTextureViewDimension + + /** + * The `INIT` macro sets this to `0`. + */ + public var baseMipLevel: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_MIP_LEVEL_COUNT_UNDEFINED. + */ + public var mipLevelCount: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var baseArrayLayer: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_ARRAY_LAYER_COUNT_UNDEFINED. + */ + public var arrayLayerCount: UInt32 + + /** + * If set to @ref WGPUTextureAspect_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + * + * The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined. + */ + public var aspect: WGPUTextureAspect + + /** + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + public var usage: WGPUTextureUsage +} + +/** + * Default values can be set using @ref WGPU_VERTEX_ATTRIBUTE_INIT as initializer. + */ +public struct WGPUVertexAttribute { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, format: WGPUVertexFormat, offset: UInt64, shaderLocation: UInt32) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to (@ref WGPUVertexFormat)0. + */ + public var format: WGPUVertexFormat + + /** + * The `INIT` macro sets this to `0`. + */ + public var offset: UInt64 + + /** + * The `INIT` macro sets this to `0`. + */ + public var shaderLocation: UInt32 +} + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUBindGroupDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, layout: WGPUBindGroupLayout!, entryCount: Int, entries: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var layout: WGPUBindGroupLayout! + + /** + * Array count for `entries`. The `INIT` macro sets this to 0. + */ + public var entryCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var entries: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_LAYOUT_ENTRY_INIT as initializer. + */ +public struct WGPUBindGroupLayoutEntry { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, binding: UInt32, visibility: WGPUShaderStage, bindingArraySize: UInt32, buffer: WGPUBufferBindingLayout, sampler: WGPUSamplerBindingLayout, texture: WGPUTextureBindingLayout, storageTexture: WGPUStorageTextureBindingLayout) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to `0`. + */ + public var binding: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPUShaderStage_None. + */ + public var visibility: WGPUShaderStage + + /** + * If non-zero, this entry defines a binding array with this size. + * + * The `INIT` macro sets this to `0`. + */ + public var bindingArraySize: UInt32 + + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + public var buffer: WGPUBufferBindingLayout + + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + public var sampler: WGPUSamplerBindingLayout + + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + public var texture: WGPUTextureBindingLayout + + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ + public var storageTexture: WGPUStorageTextureBindingLayout +} + +/** + * Default values can be set using @ref WGPU_BLEND_STATE_INIT as initializer. + */ +public struct WGPUBlendState { + + public init() + + public init(color: WGPUBlendComponent, alpha: WGPUBlendComponent) + + /** + * The `INIT` macro sets this to @ref WGPU_BLEND_COMPONENT_INIT. + */ + public var color: WGPUBlendComponent + + /** + * The `INIT` macro sets this to @ref WGPU_BLEND_COMPONENT_INIT. + */ + public var alpha: WGPUBlendComponent +} + +/** + * 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. + */ +public struct WGPUCompilationInfo { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, messageCount: Int, messages: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Array count for `messages`. The `INIT` macro sets this to 0. + */ + public var messageCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var messages: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_COMPUTE_PASS_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUComputePassDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, timestampWrites: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var timestampWrites: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_COMPUTE_STATE_INIT as initializer. + */ +public struct WGPUComputeState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, module: WGPUShaderModule!, entryPoint: WGPUStringView, constantCount: Int, constants: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var module: WGPUShaderModule! + + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var entryPoint: WGPUStringView + + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + public var constantCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var constants: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_DEPTH_STENCIL_STATE_INIT as initializer. + */ +public struct WGPUDepthStencilState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, format: WGPUTextureFormat, depthWriteEnabled: WGPUOptionalBool, depthCompare: WGPUCompareFunction, stencilFront: WGPUStencilFaceState, stencilBack: WGPUStencilFaceState, stencilReadMask: UInt32, stencilWriteMask: UInt32, depthBias: Int32, depthBiasSlopeScale: Float, depthBiasClamp: Float) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + public var format: WGPUTextureFormat + + /** + * The `INIT` macro sets this to @ref WGPUOptionalBool_Undefined. + */ + public var depthWriteEnabled: WGPUOptionalBool + + /** + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ + public var depthCompare: WGPUCompareFunction + + /** + * The `INIT` macro sets this to @ref WGPU_STENCIL_FACE_STATE_INIT. + */ + public var stencilFront: WGPUStencilFaceState + + /** + * The `INIT` macro sets this to @ref WGPU_STENCIL_FACE_STATE_INIT. + */ + public var stencilBack: WGPUStencilFaceState + + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ + public var stencilReadMask: UInt32 + + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ + public var stencilWriteMask: UInt32 + + /** + * The `INIT` macro sets this to `0`. + */ + public var depthBias: Int32 + + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ + public var depthBiasSlopeScale: Float + + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ + public var depthBiasClamp: Float +} + +/** + * Default values can be set using @ref WGPU_DEVICE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUDeviceDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, requiredFeatureCount: Int, requiredFeatures: UnsafePointer!, requiredLimits: UnsafePointer!, defaultQueue: WGPUQueueDescriptor, deviceLostCallbackInfo: WGPUDeviceLostCallbackInfo, uncapturedErrorCallbackInfo: WGPUUncapturedErrorCallbackInfo) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * Array count for `requiredFeatures`. The `INIT` macro sets this to 0. + */ + public var requiredFeatureCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var requiredFeatures: UnsafePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var requiredLimits: UnsafePointer! + + /** + * The `INIT` macro sets this to @ref WGPU_QUEUE_DESCRIPTOR_INIT. + */ + public var defaultQueue: WGPUQueueDescriptor + + /** + * The `INIT` macro sets this to @ref WGPU_DEVICE_LOST_CALLBACK_INFO_INIT. + */ + public var deviceLostCallbackInfo: WGPUDeviceLostCallbackInfo + + /** + * 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. + */ + public var uncapturedErrorCallbackInfo: WGPUUncapturedErrorCallbackInfo +} + +/** + * 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. + */ +public struct WGPUFutureWaitInfo { + + public init() + + public init(future: WGPUFuture, completed: WGPUBool) + + /** + * The future to wait on. + * + * The `INIT` macro sets this to @ref WGPU_FUTURE_INIT. + */ + public var future: WGPUFuture + + /** + * Whether or not the future completed. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + public var completed: WGPUBool +} + +/** + * Default values can be set using @ref WGPU_INSTANCE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUInstanceDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, requiredFeatureCount: Int, requiredFeatures: UnsafePointer!, requiredLimits: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Array count for `requiredFeatures`. The `INIT` macro sets this to 0. + */ + public var requiredFeatureCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var requiredFeatures: UnsafePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var requiredLimits: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT as initializer. + */ +public struct WGPURenderPassColorAttachment { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, view: WGPUTextureView!, depthSlice: UInt32, resolveTarget: WGPUTextureView!, loadOp: WGPULoadOp, storeOp: WGPUStoreOp, clearValue: WGPUColor) + + public var nextInChain: UnsafeMutablePointer! + + /** + * If `NULL`, indicates a hole in the parent + * @ref WGPURenderPassDescriptor::colorAttachments array. + * + * The `INIT` macro sets this to `NULL`. + */ + public var view: WGPUTextureView! + + /** + * The `INIT` macro sets this to @ref WGPU_DEPTH_SLICE_UNDEFINED. + */ + public var depthSlice: UInt32 + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var resolveTarget: WGPUTextureView! + + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ + public var loadOp: WGPULoadOp + + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ + public var storeOp: WGPUStoreOp + + /** + * The `INIT` macro sets this to @ref WGPU_COLOR_INIT. + */ + public var clearValue: WGPUColor +} + +/** + * Default values can be set using @ref WGPU_REQUEST_ADAPTER_OPTIONS_INIT as initializer. + */ +public struct WGPURequestAdapterOptions { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, featureLevel: WGPUFeatureLevel, powerPreference: WGPUPowerPreference, forceFallbackAdapter: WGPUBool, backendType: WGPUBackendType, compatibleSurface: WGPUSurface!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * "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. + */ + public var featureLevel: WGPUFeatureLevel + + /** + * The `INIT` macro sets this to @ref WGPUPowerPreference_Undefined. + */ + public var powerPreference: WGPUPowerPreference + + /** + * 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`. + */ + public var forceFallbackAdapter: WGPUBool + + /** + * 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. + */ + public var backendType: WGPUBackendType + + /** + * 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`. + */ + public var compatibleSurface: WGPUSurface! +} + +/** + * Default values can be set using @ref WGPU_SHADER_MODULE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUShaderModuleDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView +} + +/** + * 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. + */ +public struct WGPUSurfaceDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView) + + public var nextInChain: UnsafeMutablePointer! + + /** + * Label used to refer to the object. + * + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView +} + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_BUFFER_INFO_INIT as initializer. + */ +public struct WGPUTexelCopyBufferInfo { + + public init() + + public init(layout: WGPUTexelCopyBufferLayout, buffer: WGPUBuffer!) + + /** + * The `INIT` macro sets this to @ref WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT. + */ + public var layout: WGPUTexelCopyBufferLayout + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var buffer: WGPUBuffer! +} + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_TEXTURE_INFO_INIT as initializer. + */ +public struct WGPUTexelCopyTextureInfo { + + public init() + + public init(texture: WGPUTexture!, mipLevel: UInt32, origin: WGPUOrigin3D, aspect: WGPUTextureAspect) + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var texture: WGPUTexture! + + /** + * The `INIT` macro sets this to `0`. + */ + public var mipLevel: UInt32 + + /** + * The `INIT` macro sets this to @ref WGPU_ORIGIN_3D_INIT. + */ + public var origin: WGPUOrigin3D + + /** + * If set to @ref WGPUTextureAspect_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + * + * The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined. + */ + public var aspect: WGPUTextureAspect +} + +/** + * Default values can be set using @ref WGPU_TEXTURE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUTextureDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, usage: WGPUTextureUsage, dimension: WGPUTextureDimension, size: WGPUExtent3D, format: WGPUTextureFormat, mipLevelCount: UInt32, sampleCount: UInt32, viewFormatCount: Int, viewFormats: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + public var usage: WGPUTextureUsage + + /** + * If set to @ref WGPUTextureDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureDimension_Undefined. + */ + public var dimension: WGPUTextureDimension + + /** + * The `INIT` macro sets this to @ref WGPU_EXTENT_3D_INIT. + */ + public var size: WGPUExtent3D + + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + public var format: WGPUTextureFormat + + /** + * The `INIT` macro sets this to `1`. + */ + public var mipLevelCount: UInt32 + + /** + * The `INIT` macro sets this to `1`. + */ + public var sampleCount: UInt32 + + /** + * Array count for `viewFormats`. The `INIT` macro sets this to 0. + */ + public var viewFormatCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var viewFormats: UnsafePointer! +} + +/** + * 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. + */ +public struct WGPUVertexBufferLayout { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, stepMode: WGPUVertexStepMode, arrayStride: UInt64, attributeCount: Int, attributes: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to @ref WGPUVertexStepMode_Undefined. + */ + public var stepMode: WGPUVertexStepMode + + /** + * The `INIT` macro sets this to `0`. + */ + public var arrayStride: UInt64 + + /** + * Array count for `attributes`. The `INIT` macro sets this to 0. + */ + public var attributeCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var attributes: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUBindGroupLayoutDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, entryCount: Int, entries: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * Array count for `entries`. The `INIT` macro sets this to 0. + */ + public var entryCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var entries: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_COLOR_TARGET_STATE_INIT as initializer. + */ +public struct WGPUColorTargetState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, format: WGPUTextureFormat, blend: UnsafePointer!, writeMask: WGPUColorWriteMask) + + public var nextInChain: UnsafeMutablePointer! + + /** + * 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. + */ + public var format: WGPUTextureFormat + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var blend: UnsafePointer! + + /** + * The `INIT` macro sets this to @ref WGPUColorWriteMask_All. + */ + public var writeMask: WGPUColorWriteMask +} + +/** + * Default values can be set using @ref WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPUComputePipelineDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, layout: WGPUPipelineLayout!, compute: WGPUComputeState) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var layout: WGPUPipelineLayout! + + /** + * The `INIT` macro sets this to @ref WGPU_COMPUTE_STATE_INIT. + */ + public var compute: WGPUComputeState +} + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_DESCRIPTOR_INIT as initializer. + */ +public struct WGPURenderPassDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, colorAttachmentCount: Int, colorAttachments: UnsafePointer!, depthStencilAttachment: UnsafePointer!, occlusionQuerySet: WGPUQuerySet!, timestampWrites: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * Array count for `colorAttachments`. The `INIT` macro sets this to 0. + */ + public var colorAttachmentCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var colorAttachments: UnsafePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var depthStencilAttachment: UnsafePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var occlusionQuerySet: WGPUQuerySet! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var timestampWrites: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_VERTEX_STATE_INIT as initializer. + */ +public struct WGPUVertexState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, module: WGPUShaderModule!, entryPoint: WGPUStringView, constantCount: Int, constants: UnsafePointer!, bufferCount: Int, buffers: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var module: WGPUShaderModule! + + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var entryPoint: WGPUStringView + + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + public var constantCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var constants: UnsafePointer! + + /** + * Array count for `buffers`. The `INIT` macro sets this to 0. + */ + public var bufferCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var buffers: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_FRAGMENT_STATE_INIT as initializer. + */ +public struct WGPUFragmentState { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, module: WGPUShaderModule!, entryPoint: WGPUStringView, constantCount: Int, constants: UnsafePointer!, targetCount: Int, targets: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var module: WGPUShaderModule! + + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var entryPoint: WGPUStringView + + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + public var constantCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var constants: UnsafePointer! + + /** + * Array count for `targets`. The `INIT` macro sets this to 0. + */ + public var targetCount: Int + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var targets: UnsafePointer! +} + +/** + * Default values can be set using @ref WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT as initializer. + */ +public struct WGPURenderPipelineDescriptor { + + public init() + + public init(nextInChain: UnsafeMutablePointer!, label: WGPUStringView, layout: WGPUPipelineLayout!, vertex: WGPUVertexState, primitive: WGPUPrimitiveState, depthStencil: UnsafePointer!, multisample: WGPUMultisampleState, fragment: UnsafePointer!) + + public var nextInChain: UnsafeMutablePointer! + + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + public var label: WGPUStringView + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var layout: WGPUPipelineLayout! + + /** + * The `INIT` macro sets this to @ref WGPU_VERTEX_STATE_INIT. + */ + public var vertex: WGPUVertexState + + /** + * The `INIT` macro sets this to @ref WGPU_PRIMITIVE_STATE_INIT. + */ + public var primitive: WGPUPrimitiveState + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var depthStencil: UnsafePointer! + + /** + * The `INIT` macro sets this to @ref WGPU_MULTISAMPLE_STATE_INIT. + */ + public var multisample: WGPUMultisampleState + + /** + * The `INIT` macro sets this to `NULL`. + */ + public var fragment: UnsafePointer! +} + +/** + * Proc pointer type for @ref wgpuCreateInstance: + * > @copydoc wgpuCreateInstance + */ +public typealias WGPUProcCreateInstance = @convention(c) (UnsafePointer?) -> WGPUInstance? + +/** + * Proc pointer type for @ref wgpuGetInstanceFeatures: + * > @copydoc wgpuGetInstanceFeatures + */ +public typealias WGPUProcGetInstanceFeatures = @convention(c) (UnsafeMutablePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuGetInstanceLimits: + * > @copydoc wgpuGetInstanceLimits + */ +public typealias WGPUProcGetInstanceLimits = @convention(c) (UnsafeMutablePointer?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuHasInstanceFeature: + * > @copydoc wgpuHasInstanceFeature + */ +public typealias WGPUProcHasInstanceFeature = @convention(c) (WGPUInstanceFeatureName) -> WGPUBool + +/** + * Proc pointer type for @ref wgpuGetProcAddress: + * > @copydoc wgpuGetProcAddress + */ +public typealias WGPUProcGetProcAddress = @convention(c) (WGPUStringView) -> WGPUProc? + +/** + * Proc pointer type for @ref wgpuAdapterGetFeatures: + * > @copydoc wgpuAdapterGetFeatures + */ +public typealias WGPUProcAdapterGetFeatures = @convention(c) (WGPUAdapter?, UnsafeMutablePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuAdapterGetInfo: + * > @copydoc wgpuAdapterGetInfo + */ +public typealias WGPUProcAdapterGetInfo = @convention(c) (WGPUAdapter?, UnsafeMutablePointer?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuAdapterGetLimits: + * > @copydoc wgpuAdapterGetLimits + */ +public typealias WGPUProcAdapterGetLimits = @convention(c) (WGPUAdapter?, UnsafeMutablePointer?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuAdapterHasFeature: + * > @copydoc wgpuAdapterHasFeature + */ +public typealias WGPUProcAdapterHasFeature = @convention(c) (WGPUAdapter?, WGPUFeatureName) -> WGPUBool + +/** + * Proc pointer type for @ref wgpuAdapterRequestDevice: + * > @copydoc wgpuAdapterRequestDevice + */ +public typealias WGPUProcAdapterRequestDevice = @convention(c) (WGPUAdapter?, UnsafePointer?, WGPURequestDeviceCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuAdapterAddRef: + * > @copydoc wgpuAdapterAddRef + */ +public typealias WGPUProcAdapterAddRef = @convention(c) (WGPUAdapter?) -> Void + +/** + * Proc pointer type for @ref wgpuAdapterRelease: + * > @copydoc wgpuAdapterRelease + */ +public typealias WGPUProcAdapterRelease = @convention(c) (WGPUAdapter?) -> Void + +/** + * Proc pointer type for @ref wgpuAdapterInfoFreeMembers: + * > @copydoc wgpuAdapterInfoFreeMembers + */ +public typealias WGPUProcAdapterInfoFreeMembers = @convention(c) (WGPUAdapterInfo) -> Void + +/** + * Proc pointer type for @ref wgpuBindGroupSetLabel: + * > @copydoc wgpuBindGroupSetLabel + */ +public typealias WGPUProcBindGroupSetLabel = @convention(c) (WGPUBindGroup?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuBindGroupAddRef: + * > @copydoc wgpuBindGroupAddRef + */ +public typealias WGPUProcBindGroupAddRef = @convention(c) (WGPUBindGroup?) -> Void + +/** + * Proc pointer type for @ref wgpuBindGroupRelease: + * > @copydoc wgpuBindGroupRelease + */ +public typealias WGPUProcBindGroupRelease = @convention(c) (WGPUBindGroup?) -> Void + +/** + * Proc pointer type for @ref wgpuBindGroupLayoutSetLabel: + * > @copydoc wgpuBindGroupLayoutSetLabel + */ +public typealias WGPUProcBindGroupLayoutSetLabel = @convention(c) (WGPUBindGroupLayout?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuBindGroupLayoutAddRef: + * > @copydoc wgpuBindGroupLayoutAddRef + */ +public typealias WGPUProcBindGroupLayoutAddRef = @convention(c) (WGPUBindGroupLayout?) -> Void + +/** + * Proc pointer type for @ref wgpuBindGroupLayoutRelease: + * > @copydoc wgpuBindGroupLayoutRelease + */ +public typealias WGPUProcBindGroupLayoutRelease = @convention(c) (WGPUBindGroupLayout?) -> Void + +/** + * Proc pointer type for @ref wgpuBufferDestroy: + * > @copydoc wgpuBufferDestroy + */ +public typealias WGPUProcBufferDestroy = @convention(c) (WGPUBuffer?) -> Void + +/** + * Proc pointer type for @ref wgpuBufferGetConstMappedRange: + * > @copydoc wgpuBufferGetConstMappedRange + */ +public typealias WGPUProcBufferGetConstMappedRange = @convention(c, cType: "const void *(*)(WGPUBuffer, size_t, size_t)") (WGPUBuffer?, Int, Int) -> UnsafeRawPointer? + +/** + * Proc pointer type for @ref wgpuBufferGetMappedRange: + * > @copydoc wgpuBufferGetMappedRange + */ +public typealias WGPUProcBufferGetMappedRange = @convention(c, cType: "void *(*)(WGPUBuffer, size_t, size_t)") (WGPUBuffer?, Int, Int) -> UnsafeMutableRawPointer? + +/** + * Proc pointer type for @ref wgpuBufferGetMapState: + * > @copydoc wgpuBufferGetMapState + */ +public typealias WGPUProcBufferGetMapState = @convention(c) (WGPUBuffer?) -> WGPUBufferMapState + +/** + * Proc pointer type for @ref wgpuBufferGetSize: + * > @copydoc wgpuBufferGetSize + */ +public typealias WGPUProcBufferGetSize = @convention(c) (WGPUBuffer?) -> UInt64 + +/** + * Proc pointer type for @ref wgpuBufferGetUsage: + * > @copydoc wgpuBufferGetUsage + */ +public typealias WGPUProcBufferGetUsage = @convention(c) (WGPUBuffer?) -> WGPUBufferUsage + +/** + * Proc pointer type for @ref wgpuBufferMapAsync: + * > @copydoc wgpuBufferMapAsync + */ +public typealias WGPUProcBufferMapAsync = @convention(c, cType: "WGPUFuture (*)(WGPUBuffer, WGPUMapMode, size_t, size_t, WGPUBufferMapCallbackInfo)") (WGPUBuffer?, WGPUMapMode, Int, Int, WGPUBufferMapCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuBufferReadMappedRange: + * > @copydoc wgpuBufferReadMappedRange + */ +public typealias WGPUProcBufferReadMappedRange = @convention(c, cType: "WGPUStatus (*)(WGPUBuffer, size_t, void *, size_t)") (WGPUBuffer?, Int, UnsafeMutableRawPointer?, Int) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuBufferSetLabel: + * > @copydoc wgpuBufferSetLabel + */ +public typealias WGPUProcBufferSetLabel = @convention(c) (WGPUBuffer?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuBufferUnmap: + * > @copydoc wgpuBufferUnmap + */ +public typealias WGPUProcBufferUnmap = @convention(c) (WGPUBuffer?) -> Void + +/** + * Proc pointer type for @ref wgpuBufferWriteMappedRange: + * > @copydoc wgpuBufferWriteMappedRange + */ +public typealias WGPUProcBufferWriteMappedRange = @convention(c, cType: "WGPUStatus (*)(WGPUBuffer, size_t, const void *, size_t)") (WGPUBuffer?, Int, UnsafeRawPointer?, Int) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuBufferAddRef: + * > @copydoc wgpuBufferAddRef + */ +public typealias WGPUProcBufferAddRef = @convention(c) (WGPUBuffer?) -> Void + +/** + * Proc pointer type for @ref wgpuBufferRelease: + * > @copydoc wgpuBufferRelease + */ +public typealias WGPUProcBufferRelease = @convention(c) (WGPUBuffer?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandBufferSetLabel: + * > @copydoc wgpuCommandBufferSetLabel + */ +public typealias WGPUProcCommandBufferSetLabel = @convention(c) (WGPUCommandBuffer?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuCommandBufferAddRef: + * > @copydoc wgpuCommandBufferAddRef + */ +public typealias WGPUProcCommandBufferAddRef = @convention(c) (WGPUCommandBuffer?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandBufferRelease: + * > @copydoc wgpuCommandBufferRelease + */ +public typealias WGPUProcCommandBufferRelease = @convention(c) (WGPUCommandBuffer?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginComputePass: + * > @copydoc wgpuCommandEncoderBeginComputePass + */ +public typealias WGPUProcCommandEncoderBeginComputePass = @convention(c) (WGPUCommandEncoder?, UnsafePointer?) -> WGPUComputePassEncoder? + +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginRenderPass: + * > @copydoc wgpuCommandEncoderBeginRenderPass + */ +public typealias WGPUProcCommandEncoderBeginRenderPass = @convention(c) (WGPUCommandEncoder?, UnsafePointer?) -> WGPURenderPassEncoder? + +/** + * Proc pointer type for @ref wgpuCommandEncoderClearBuffer: + * > @copydoc wgpuCommandEncoderClearBuffer + */ +public typealias WGPUProcCommandEncoderClearBuffer = @convention(c) (WGPUCommandEncoder?, WGPUBuffer?, UInt64, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToBuffer: + * > @copydoc wgpuCommandEncoderCopyBufferToBuffer + */ +public typealias WGPUProcCommandEncoderCopyBufferToBuffer = @convention(c) (WGPUCommandEncoder?, WGPUBuffer?, UInt64, WGPUBuffer?, UInt64, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToTexture: + * > @copydoc wgpuCommandEncoderCopyBufferToTexture + */ +public typealias WGPUProcCommandEncoderCopyBufferToTexture = @convention(c) (WGPUCommandEncoder?, UnsafePointer?, UnsafePointer?, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToBuffer: + * > @copydoc wgpuCommandEncoderCopyTextureToBuffer + */ +public typealias WGPUProcCommandEncoderCopyTextureToBuffer = @convention(c) (WGPUCommandEncoder?, UnsafePointer?, UnsafePointer?, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToTexture: + * > @copydoc wgpuCommandEncoderCopyTextureToTexture + */ +public typealias WGPUProcCommandEncoderCopyTextureToTexture = @convention(c) (WGPUCommandEncoder?, UnsafePointer?, UnsafePointer?, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderFinish: + * > @copydoc wgpuCommandEncoderFinish + */ +public typealias WGPUProcCommandEncoderFinish = @convention(c) (WGPUCommandEncoder?, UnsafePointer?) -> WGPUCommandBuffer? + +/** + * Proc pointer type for @ref wgpuCommandEncoderInsertDebugMarker: + * > @copydoc wgpuCommandEncoderInsertDebugMarker + */ +public typealias WGPUProcCommandEncoderInsertDebugMarker = @convention(c) (WGPUCommandEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderPopDebugGroup: + * > @copydoc wgpuCommandEncoderPopDebugGroup + */ +public typealias WGPUProcCommandEncoderPopDebugGroup = @convention(c) (WGPUCommandEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderPushDebugGroup: + * > @copydoc wgpuCommandEncoderPushDebugGroup + */ +public typealias WGPUProcCommandEncoderPushDebugGroup = @convention(c) (WGPUCommandEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderResolveQuerySet: + * > @copydoc wgpuCommandEncoderResolveQuerySet + */ +public typealias WGPUProcCommandEncoderResolveQuerySet = @convention(c) (WGPUCommandEncoder?, WGPUQuerySet?, UInt32, UInt32, WGPUBuffer?, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderSetLabel: + * > @copydoc wgpuCommandEncoderSetLabel + */ +public typealias WGPUProcCommandEncoderSetLabel = @convention(c) (WGPUCommandEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderWriteTimestamp: + * > @copydoc wgpuCommandEncoderWriteTimestamp + */ +public typealias WGPUProcCommandEncoderWriteTimestamp = @convention(c) (WGPUCommandEncoder?, WGPUQuerySet?, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderAddRef: + * > @copydoc wgpuCommandEncoderAddRef + */ +public typealias WGPUProcCommandEncoderAddRef = @convention(c) (WGPUCommandEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuCommandEncoderRelease: + * > @copydoc wgpuCommandEncoderRelease + */ +public typealias WGPUProcCommandEncoderRelease = @convention(c) (WGPUCommandEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroups: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroups + */ +public typealias WGPUProcComputePassEncoderDispatchWorkgroups = @convention(c) (WGPUComputePassEncoder?, UInt32, UInt32, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroupsIndirect: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroupsIndirect + */ +public typealias WGPUProcComputePassEncoderDispatchWorkgroupsIndirect = @convention(c) (WGPUComputePassEncoder?, WGPUBuffer?, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderEnd: + * > @copydoc wgpuComputePassEncoderEnd + */ +public typealias WGPUProcComputePassEncoderEnd = @convention(c) (WGPUComputePassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderInsertDebugMarker: + * > @copydoc wgpuComputePassEncoderInsertDebugMarker + */ +public typealias WGPUProcComputePassEncoderInsertDebugMarker = @convention(c) (WGPUComputePassEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderPopDebugGroup: + * > @copydoc wgpuComputePassEncoderPopDebugGroup + */ +public typealias WGPUProcComputePassEncoderPopDebugGroup = @convention(c) (WGPUComputePassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderPushDebugGroup: + * > @copydoc wgpuComputePassEncoderPushDebugGroup + */ +public typealias WGPUProcComputePassEncoderPushDebugGroup = @convention(c) (WGPUComputePassEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetBindGroup: + * > @copydoc wgpuComputePassEncoderSetBindGroup + */ +public typealias WGPUProcComputePassEncoderSetBindGroup = @convention(c, cType: "void (*)(WGPUComputePassEncoder, uint32_t, WGPUBindGroup, size_t, const uint32_t *)") (WGPUComputePassEncoder?, UInt32, WGPUBindGroup?, Int, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetLabel: + * > @copydoc wgpuComputePassEncoderSetLabel + */ +public typealias WGPUProcComputePassEncoderSetLabel = @convention(c) (WGPUComputePassEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetPipeline: + * > @copydoc wgpuComputePassEncoderSetPipeline + */ +public typealias WGPUProcComputePassEncoderSetPipeline = @convention(c) (WGPUComputePassEncoder?, WGPUComputePipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderAddRef: + * > @copydoc wgpuComputePassEncoderAddRef + */ +public typealias WGPUProcComputePassEncoderAddRef = @convention(c) (WGPUComputePassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePassEncoderRelease: + * > @copydoc wgpuComputePassEncoderRelease + */ +public typealias WGPUProcComputePassEncoderRelease = @convention(c) (WGPUComputePassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePipelineGetBindGroupLayout: + * > @copydoc wgpuComputePipelineGetBindGroupLayout + */ +public typealias WGPUProcComputePipelineGetBindGroupLayout = @convention(c) (WGPUComputePipeline?, UInt32) -> WGPUBindGroupLayout? + +/** + * Proc pointer type for @ref wgpuComputePipelineSetLabel: + * > @copydoc wgpuComputePipelineSetLabel + */ +public typealias WGPUProcComputePipelineSetLabel = @convention(c) (WGPUComputePipeline?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuComputePipelineAddRef: + * > @copydoc wgpuComputePipelineAddRef + */ +public typealias WGPUProcComputePipelineAddRef = @convention(c) (WGPUComputePipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuComputePipelineRelease: + * > @copydoc wgpuComputePipelineRelease + */ +public typealias WGPUProcComputePipelineRelease = @convention(c) (WGPUComputePipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroup: + * > @copydoc wgpuDeviceCreateBindGroup + */ +public typealias WGPUProcDeviceCreateBindGroup = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUBindGroup? + +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroupLayout: + * > @copydoc wgpuDeviceCreateBindGroupLayout + */ +public typealias WGPUProcDeviceCreateBindGroupLayout = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUBindGroupLayout? + +/** + * Proc pointer type for @ref wgpuDeviceCreateBuffer: + * > @copydoc wgpuDeviceCreateBuffer + */ +public typealias WGPUProcDeviceCreateBuffer = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUBuffer? + +/** + * Proc pointer type for @ref wgpuDeviceCreateCommandEncoder: + * > @copydoc wgpuDeviceCreateCommandEncoder + */ +public typealias WGPUProcDeviceCreateCommandEncoder = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUCommandEncoder? + +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipeline: + * > @copydoc wgpuDeviceCreateComputePipeline + */ +public typealias WGPUProcDeviceCreateComputePipeline = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUComputePipeline? + +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipelineAsync: + * > @copydoc wgpuDeviceCreateComputePipelineAsync + */ +public typealias WGPUProcDeviceCreateComputePipelineAsync = @convention(c) (WGPUDevice?, UnsafePointer?, WGPUCreateComputePipelineAsyncCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuDeviceCreatePipelineLayout: + * > @copydoc wgpuDeviceCreatePipelineLayout + */ +public typealias WGPUProcDeviceCreatePipelineLayout = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUPipelineLayout? + +/** + * Proc pointer type for @ref wgpuDeviceCreateQuerySet: + * > @copydoc wgpuDeviceCreateQuerySet + */ +public typealias WGPUProcDeviceCreateQuerySet = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUQuerySet? + +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderBundleEncoder: + * > @copydoc wgpuDeviceCreateRenderBundleEncoder + */ +public typealias WGPUProcDeviceCreateRenderBundleEncoder = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPURenderBundleEncoder? + +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipeline: + * > @copydoc wgpuDeviceCreateRenderPipeline + */ +public typealias WGPUProcDeviceCreateRenderPipeline = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPURenderPipeline? + +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipelineAsync: + * > @copydoc wgpuDeviceCreateRenderPipelineAsync + */ +public typealias WGPUProcDeviceCreateRenderPipelineAsync = @convention(c) (WGPUDevice?, UnsafePointer?, WGPUCreateRenderPipelineAsyncCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuDeviceCreateSampler: + * > @copydoc wgpuDeviceCreateSampler + */ +public typealias WGPUProcDeviceCreateSampler = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUSampler? + +/** + * Proc pointer type for @ref wgpuDeviceCreateShaderModule: + * > @copydoc wgpuDeviceCreateShaderModule + */ +public typealias WGPUProcDeviceCreateShaderModule = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUShaderModule? + +/** + * Proc pointer type for @ref wgpuDeviceCreateTexture: + * > @copydoc wgpuDeviceCreateTexture + */ +public typealias WGPUProcDeviceCreateTexture = @convention(c) (WGPUDevice?, UnsafePointer?) -> WGPUTexture? + +/** + * Proc pointer type for @ref wgpuDeviceDestroy: + * > @copydoc wgpuDeviceDestroy + */ +public typealias WGPUProcDeviceDestroy = @convention(c) (WGPUDevice?) -> Void + +/** + * Proc pointer type for @ref wgpuDeviceGetAdapterInfo: + * > @copydoc wgpuDeviceGetAdapterInfo + */ +public typealias WGPUProcDeviceGetAdapterInfo = @convention(c) (WGPUDevice?, UnsafeMutablePointer?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuDeviceGetFeatures: + * > @copydoc wgpuDeviceGetFeatures + */ +public typealias WGPUProcDeviceGetFeatures = @convention(c) (WGPUDevice?, UnsafeMutablePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuDeviceGetLimits: + * > @copydoc wgpuDeviceGetLimits + */ +public typealias WGPUProcDeviceGetLimits = @convention(c) (WGPUDevice?, UnsafeMutablePointer?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuDeviceGetLostFuture: + * > @copydoc wgpuDeviceGetLostFuture + */ +public typealias WGPUProcDeviceGetLostFuture = @convention(c) (WGPUDevice?) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuDeviceGetQueue: + * > @copydoc wgpuDeviceGetQueue + */ +public typealias WGPUProcDeviceGetQueue = @convention(c) (WGPUDevice?) -> WGPUQueue? + +/** + * Proc pointer type for @ref wgpuDeviceHasFeature: + * > @copydoc wgpuDeviceHasFeature + */ +public typealias WGPUProcDeviceHasFeature = @convention(c) (WGPUDevice?, WGPUFeatureName) -> WGPUBool + +/** + * Proc pointer type for @ref wgpuDevicePopErrorScope: + * > @copydoc wgpuDevicePopErrorScope + */ +public typealias WGPUProcDevicePopErrorScope = @convention(c) (WGPUDevice?, WGPUPopErrorScopeCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuDevicePushErrorScope: + * > @copydoc wgpuDevicePushErrorScope + */ +public typealias WGPUProcDevicePushErrorScope = @convention(c) (WGPUDevice?, WGPUErrorFilter) -> Void + +/** + * Proc pointer type for @ref wgpuDeviceSetLabel: + * > @copydoc wgpuDeviceSetLabel + */ +public typealias WGPUProcDeviceSetLabel = @convention(c) (WGPUDevice?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuDeviceAddRef: + * > @copydoc wgpuDeviceAddRef + */ +public typealias WGPUProcDeviceAddRef = @convention(c) (WGPUDevice?) -> Void + +/** + * Proc pointer type for @ref wgpuDeviceRelease: + * > @copydoc wgpuDeviceRelease + */ +public typealias WGPUProcDeviceRelease = @convention(c) (WGPUDevice?) -> Void + +/** + * Proc pointer type for @ref wgpuInstanceCreateSurface: + * > @copydoc wgpuInstanceCreateSurface + */ +public typealias WGPUProcInstanceCreateSurface = @convention(c) (WGPUInstance?, UnsafePointer?) -> WGPUSurface? + +/** + * Proc pointer type for @ref wgpuInstanceGetWGSLLanguageFeatures: + * > @copydoc wgpuInstanceGetWGSLLanguageFeatures + */ +public typealias WGPUProcInstanceGetWGSLLanguageFeatures = @convention(c) (WGPUInstance?, UnsafeMutablePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuInstanceHasWGSLLanguageFeature: + * > @copydoc wgpuInstanceHasWGSLLanguageFeature + */ +public typealias WGPUProcInstanceHasWGSLLanguageFeature = @convention(c) (WGPUInstance?, WGPUWGSLLanguageFeatureName) -> WGPUBool + +/** + * Proc pointer type for @ref wgpuInstanceProcessEvents: + * > @copydoc wgpuInstanceProcessEvents + */ +public typealias WGPUProcInstanceProcessEvents = @convention(c) (WGPUInstance?) -> Void + +/** + * Proc pointer type for @ref wgpuInstanceRequestAdapter: + * > @copydoc wgpuInstanceRequestAdapter + */ +public typealias WGPUProcInstanceRequestAdapter = @convention(c) (WGPUInstance?, UnsafePointer?, WGPURequestAdapterCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuInstanceWaitAny: + * > @copydoc wgpuInstanceWaitAny + */ +public typealias WGPUProcInstanceWaitAny = @convention(c, cType: "WGPUWaitStatus (*)(WGPUInstance, size_t, WGPUFutureWaitInfo *, uint64_t)") (WGPUInstance?, Int, UnsafeMutablePointer?, UInt64) -> WGPUWaitStatus + +/** + * Proc pointer type for @ref wgpuInstanceAddRef: + * > @copydoc wgpuInstanceAddRef + */ +public typealias WGPUProcInstanceAddRef = @convention(c) (WGPUInstance?) -> Void + +/** + * Proc pointer type for @ref wgpuInstanceRelease: + * > @copydoc wgpuInstanceRelease + */ +public typealias WGPUProcInstanceRelease = @convention(c) (WGPUInstance?) -> Void + +/** + * Proc pointer type for @ref wgpuPipelineLayoutSetLabel: + * > @copydoc wgpuPipelineLayoutSetLabel + */ +public typealias WGPUProcPipelineLayoutSetLabel = @convention(c) (WGPUPipelineLayout?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuPipelineLayoutAddRef: + * > @copydoc wgpuPipelineLayoutAddRef + */ +public typealias WGPUProcPipelineLayoutAddRef = @convention(c) (WGPUPipelineLayout?) -> Void + +/** + * Proc pointer type for @ref wgpuPipelineLayoutRelease: + * > @copydoc wgpuPipelineLayoutRelease + */ +public typealias WGPUProcPipelineLayoutRelease = @convention(c) (WGPUPipelineLayout?) -> Void + +/** + * Proc pointer type for @ref wgpuQuerySetDestroy: + * > @copydoc wgpuQuerySetDestroy + */ +public typealias WGPUProcQuerySetDestroy = @convention(c) (WGPUQuerySet?) -> Void + +/** + * Proc pointer type for @ref wgpuQuerySetGetCount: + * > @copydoc wgpuQuerySetGetCount + */ +public typealias WGPUProcQuerySetGetCount = @convention(c) (WGPUQuerySet?) -> UInt32 + +/** + * Proc pointer type for @ref wgpuQuerySetGetType: + * > @copydoc wgpuQuerySetGetType + */ +public typealias WGPUProcQuerySetGetType = @convention(c) (WGPUQuerySet?) -> WGPUQueryType + +/** + * Proc pointer type for @ref wgpuQuerySetSetLabel: + * > @copydoc wgpuQuerySetSetLabel + */ +public typealias WGPUProcQuerySetSetLabel = @convention(c) (WGPUQuerySet?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuQuerySetAddRef: + * > @copydoc wgpuQuerySetAddRef + */ +public typealias WGPUProcQuerySetAddRef = @convention(c) (WGPUQuerySet?) -> Void + +/** + * Proc pointer type for @ref wgpuQuerySetRelease: + * > @copydoc wgpuQuerySetRelease + */ +public typealias WGPUProcQuerySetRelease = @convention(c) (WGPUQuerySet?) -> Void + +/** + * Proc pointer type for @ref wgpuQueueOnSubmittedWorkDone: + * > @copydoc wgpuQueueOnSubmittedWorkDone + */ +public typealias WGPUProcQueueOnSubmittedWorkDone = @convention(c) (WGPUQueue?, WGPUQueueWorkDoneCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuQueueSetLabel: + * > @copydoc wgpuQueueSetLabel + */ +public typealias WGPUProcQueueSetLabel = @convention(c) (WGPUQueue?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuQueueSubmit: + * > @copydoc wgpuQueueSubmit + */ +public typealias WGPUProcQueueSubmit = @convention(c, cType: "void (*)(WGPUQueue, size_t, const WGPUCommandBuffer *)") (WGPUQueue?, Int, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuQueueWriteBuffer: + * > @copydoc wgpuQueueWriteBuffer + */ +public typealias WGPUProcQueueWriteBuffer = @convention(c, cType: "void (*)(WGPUQueue, WGPUBuffer, uint64_t, const void *, size_t)") (WGPUQueue?, WGPUBuffer?, UInt64, UnsafeRawPointer?, Int) -> Void + +/** + * Proc pointer type for @ref wgpuQueueWriteTexture: + * > @copydoc wgpuQueueWriteTexture + */ +public typealias WGPUProcQueueWriteTexture = @convention(c, cType: "void (*)(WGPUQueue, const WGPUTexelCopyTextureInfo *, const void *, size_t, const WGPUTexelCopyBufferLayout *, const WGPUExtent3D *)") (WGPUQueue?, UnsafePointer?, UnsafeRawPointer?, Int, UnsafePointer?, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuQueueAddRef: + * > @copydoc wgpuQueueAddRef + */ +public typealias WGPUProcQueueAddRef = @convention(c) (WGPUQueue?) -> Void + +/** + * Proc pointer type for @ref wgpuQueueRelease: + * > @copydoc wgpuQueueRelease + */ +public typealias WGPUProcQueueRelease = @convention(c) (WGPUQueue?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleSetLabel: + * > @copydoc wgpuRenderBundleSetLabel + */ +public typealias WGPUProcRenderBundleSetLabel = @convention(c) (WGPURenderBundle?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleAddRef: + * > @copydoc wgpuRenderBundleAddRef + */ +public typealias WGPUProcRenderBundleAddRef = @convention(c) (WGPURenderBundle?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleRelease: + * > @copydoc wgpuRenderBundleRelease + */ +public typealias WGPUProcRenderBundleRelease = @convention(c) (WGPURenderBundle?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDraw: + * > @copydoc wgpuRenderBundleEncoderDraw + */ +public typealias WGPUProcRenderBundleEncoderDraw = @convention(c) (WGPURenderBundleEncoder?, UInt32, UInt32, UInt32, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexed: + * > @copydoc wgpuRenderBundleEncoderDrawIndexed + */ +public typealias WGPUProcRenderBundleEncoderDrawIndexed = @convention(c) (WGPURenderBundleEncoder?, UInt32, UInt32, UInt32, Int32, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndexedIndirect + */ +public typealias WGPUProcRenderBundleEncoderDrawIndexedIndirect = @convention(c) (WGPURenderBundleEncoder?, WGPUBuffer?, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndirect + */ +public typealias WGPUProcRenderBundleEncoderDrawIndirect = @convention(c) (WGPURenderBundleEncoder?, WGPUBuffer?, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderFinish: + * > @copydoc wgpuRenderBundleEncoderFinish + */ +public typealias WGPUProcRenderBundleEncoderFinish = @convention(c) (WGPURenderBundleEncoder?, UnsafePointer?) -> WGPURenderBundle? + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderInsertDebugMarker: + * > @copydoc wgpuRenderBundleEncoderInsertDebugMarker + */ +public typealias WGPUProcRenderBundleEncoderInsertDebugMarker = @convention(c) (WGPURenderBundleEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPopDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPopDebugGroup + */ +public typealias WGPUProcRenderBundleEncoderPopDebugGroup = @convention(c) (WGPURenderBundleEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPushDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPushDebugGroup + */ +public typealias WGPUProcRenderBundleEncoderPushDebugGroup = @convention(c) (WGPURenderBundleEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetBindGroup: + * > @copydoc wgpuRenderBundleEncoderSetBindGroup + */ +public typealias WGPUProcRenderBundleEncoderSetBindGroup = @convention(c, cType: "void (*)(WGPURenderBundleEncoder, uint32_t, WGPUBindGroup, size_t, const uint32_t *)") (WGPURenderBundleEncoder?, UInt32, WGPUBindGroup?, Int, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetIndexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetIndexBuffer + */ +public typealias WGPUProcRenderBundleEncoderSetIndexBuffer = @convention(c) (WGPURenderBundleEncoder?, WGPUBuffer?, WGPUIndexFormat, UInt64, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetLabel: + * > @copydoc wgpuRenderBundleEncoderSetLabel + */ +public typealias WGPUProcRenderBundleEncoderSetLabel = @convention(c) (WGPURenderBundleEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetPipeline: + * > @copydoc wgpuRenderBundleEncoderSetPipeline + */ +public typealias WGPUProcRenderBundleEncoderSetPipeline = @convention(c) (WGPURenderBundleEncoder?, WGPURenderPipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetVertexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetVertexBuffer + */ +public typealias WGPUProcRenderBundleEncoderSetVertexBuffer = @convention(c) (WGPURenderBundleEncoder?, UInt32, WGPUBuffer?, UInt64, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderAddRef: + * > @copydoc wgpuRenderBundleEncoderAddRef + */ +public typealias WGPUProcRenderBundleEncoderAddRef = @convention(c) (WGPURenderBundleEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderRelease: + * > @copydoc wgpuRenderBundleEncoderRelease + */ +public typealias WGPUProcRenderBundleEncoderRelease = @convention(c) (WGPURenderBundleEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderBeginOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderBeginOcclusionQuery + */ +public typealias WGPUProcRenderPassEncoderBeginOcclusionQuery = @convention(c) (WGPURenderPassEncoder?, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDraw: + * > @copydoc wgpuRenderPassEncoderDraw + */ +public typealias WGPUProcRenderPassEncoderDraw = @convention(c) (WGPURenderPassEncoder?, UInt32, UInt32, UInt32, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexed: + * > @copydoc wgpuRenderPassEncoderDrawIndexed + */ +public typealias WGPUProcRenderPassEncoderDrawIndexed = @convention(c) (WGPURenderPassEncoder?, UInt32, UInt32, UInt32, Int32, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndexedIndirect + */ +public typealias WGPUProcRenderPassEncoderDrawIndexedIndirect = @convention(c) (WGPURenderPassEncoder?, WGPUBuffer?, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndirect + */ +public typealias WGPUProcRenderPassEncoderDrawIndirect = @convention(c) (WGPURenderPassEncoder?, WGPUBuffer?, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEnd: + * > @copydoc wgpuRenderPassEncoderEnd + */ +public typealias WGPUProcRenderPassEncoderEnd = @convention(c) (WGPURenderPassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEndOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderEndOcclusionQuery + */ +public typealias WGPUProcRenderPassEncoderEndOcclusionQuery = @convention(c) (WGPURenderPassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderExecuteBundles: + * > @copydoc wgpuRenderPassEncoderExecuteBundles + */ +public typealias WGPUProcRenderPassEncoderExecuteBundles = @convention(c, cType: "void (*)(WGPURenderPassEncoder, size_t, const WGPURenderBundle *)") (WGPURenderPassEncoder?, Int, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderInsertDebugMarker: + * > @copydoc wgpuRenderPassEncoderInsertDebugMarker + */ +public typealias WGPUProcRenderPassEncoderInsertDebugMarker = @convention(c) (WGPURenderPassEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPopDebugGroup: + * > @copydoc wgpuRenderPassEncoderPopDebugGroup + */ +public typealias WGPUProcRenderPassEncoderPopDebugGroup = @convention(c) (WGPURenderPassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPushDebugGroup: + * > @copydoc wgpuRenderPassEncoderPushDebugGroup + */ +public typealias WGPUProcRenderPassEncoderPushDebugGroup = @convention(c) (WGPURenderPassEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBindGroup: + * > @copydoc wgpuRenderPassEncoderSetBindGroup + */ +public typealias WGPUProcRenderPassEncoderSetBindGroup = @convention(c, cType: "void (*)(WGPURenderPassEncoder, uint32_t, WGPUBindGroup, size_t, const uint32_t *)") (WGPURenderPassEncoder?, UInt32, WGPUBindGroup?, Int, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBlendConstant: + * > @copydoc wgpuRenderPassEncoderSetBlendConstant + */ +public typealias WGPUProcRenderPassEncoderSetBlendConstant = @convention(c) (WGPURenderPassEncoder?, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetIndexBuffer: + * > @copydoc wgpuRenderPassEncoderSetIndexBuffer + */ +public typealias WGPUProcRenderPassEncoderSetIndexBuffer = @convention(c) (WGPURenderPassEncoder?, WGPUBuffer?, WGPUIndexFormat, UInt64, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetLabel: + * > @copydoc wgpuRenderPassEncoderSetLabel + */ +public typealias WGPUProcRenderPassEncoderSetLabel = @convention(c) (WGPURenderPassEncoder?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetPipeline: + * > @copydoc wgpuRenderPassEncoderSetPipeline + */ +public typealias WGPUProcRenderPassEncoderSetPipeline = @convention(c) (WGPURenderPassEncoder?, WGPURenderPipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetScissorRect: + * > @copydoc wgpuRenderPassEncoderSetScissorRect + */ +public typealias WGPUProcRenderPassEncoderSetScissorRect = @convention(c) (WGPURenderPassEncoder?, UInt32, UInt32, UInt32, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetStencilReference: + * > @copydoc wgpuRenderPassEncoderSetStencilReference + */ +public typealias WGPUProcRenderPassEncoderSetStencilReference = @convention(c) (WGPURenderPassEncoder?, UInt32) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetVertexBuffer: + * > @copydoc wgpuRenderPassEncoderSetVertexBuffer + */ +public typealias WGPUProcRenderPassEncoderSetVertexBuffer = @convention(c) (WGPURenderPassEncoder?, UInt32, WGPUBuffer?, UInt64, UInt64) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetViewport: + * > @copydoc wgpuRenderPassEncoderSetViewport + */ +public typealias WGPUProcRenderPassEncoderSetViewport = @convention(c) (WGPURenderPassEncoder?, Float, Float, Float, Float, Float, Float) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderAddRef: + * > @copydoc wgpuRenderPassEncoderAddRef + */ +public typealias WGPUProcRenderPassEncoderAddRef = @convention(c) (WGPURenderPassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPassEncoderRelease: + * > @copydoc wgpuRenderPassEncoderRelease + */ +public typealias WGPUProcRenderPassEncoderRelease = @convention(c) (WGPURenderPassEncoder?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPipelineGetBindGroupLayout: + * > @copydoc wgpuRenderPipelineGetBindGroupLayout + */ +public typealias WGPUProcRenderPipelineGetBindGroupLayout = @convention(c) (WGPURenderPipeline?, UInt32) -> WGPUBindGroupLayout? + +/** + * Proc pointer type for @ref wgpuRenderPipelineSetLabel: + * > @copydoc wgpuRenderPipelineSetLabel + */ +public typealias WGPUProcRenderPipelineSetLabel = @convention(c) (WGPURenderPipeline?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPipelineAddRef: + * > @copydoc wgpuRenderPipelineAddRef + */ +public typealias WGPUProcRenderPipelineAddRef = @convention(c) (WGPURenderPipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuRenderPipelineRelease: + * > @copydoc wgpuRenderPipelineRelease + */ +public typealias WGPUProcRenderPipelineRelease = @convention(c) (WGPURenderPipeline?) -> Void + +/** + * Proc pointer type for @ref wgpuSamplerSetLabel: + * > @copydoc wgpuSamplerSetLabel + */ +public typealias WGPUProcSamplerSetLabel = @convention(c) (WGPUSampler?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuSamplerAddRef: + * > @copydoc wgpuSamplerAddRef + */ +public typealias WGPUProcSamplerAddRef = @convention(c) (WGPUSampler?) -> Void + +/** + * Proc pointer type for @ref wgpuSamplerRelease: + * > @copydoc wgpuSamplerRelease + */ +public typealias WGPUProcSamplerRelease = @convention(c) (WGPUSampler?) -> Void + +/** + * Proc pointer type for @ref wgpuShaderModuleGetCompilationInfo: + * > @copydoc wgpuShaderModuleGetCompilationInfo + */ +public typealias WGPUProcShaderModuleGetCompilationInfo = @convention(c) (WGPUShaderModule?, WGPUCompilationInfoCallbackInfo) -> WGPUFuture + +/** + * Proc pointer type for @ref wgpuShaderModuleSetLabel: + * > @copydoc wgpuShaderModuleSetLabel + */ +public typealias WGPUProcShaderModuleSetLabel = @convention(c) (WGPUShaderModule?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuShaderModuleAddRef: + * > @copydoc wgpuShaderModuleAddRef + */ +public typealias WGPUProcShaderModuleAddRef = @convention(c) (WGPUShaderModule?) -> Void + +/** + * Proc pointer type for @ref wgpuShaderModuleRelease: + * > @copydoc wgpuShaderModuleRelease + */ +public typealias WGPUProcShaderModuleRelease = @convention(c) (WGPUShaderModule?) -> Void + +/** + * Proc pointer type for @ref wgpuSupportedFeaturesFreeMembers: + * > @copydoc wgpuSupportedFeaturesFreeMembers + */ +public typealias WGPUProcSupportedFeaturesFreeMembers = @convention(c) (WGPUSupportedFeatures) -> Void + +/** + * Proc pointer type for @ref wgpuSupportedInstanceFeaturesFreeMembers: + * > @copydoc wgpuSupportedInstanceFeaturesFreeMembers + */ +public typealias WGPUProcSupportedInstanceFeaturesFreeMembers = @convention(c) (WGPUSupportedInstanceFeatures) -> Void + +/** + * Proc pointer type for @ref wgpuSupportedWGSLLanguageFeaturesFreeMembers: + * > @copydoc wgpuSupportedWGSLLanguageFeaturesFreeMembers + */ +public typealias WGPUProcSupportedWGSLLanguageFeaturesFreeMembers = @convention(c) (WGPUSupportedWGSLLanguageFeatures) -> Void + +/** + * Proc pointer type for @ref wgpuSurfaceConfigure: + * > @copydoc wgpuSurfaceConfigure + */ +public typealias WGPUProcSurfaceConfigure = @convention(c) (WGPUSurface?, UnsafePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuSurfaceGetCapabilities: + * > @copydoc wgpuSurfaceGetCapabilities + */ +public typealias WGPUProcSurfaceGetCapabilities = @convention(c) (WGPUSurface?, WGPUAdapter?, UnsafeMutablePointer?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuSurfaceGetCurrentTexture: + * > @copydoc wgpuSurfaceGetCurrentTexture + */ +public typealias WGPUProcSurfaceGetCurrentTexture = @convention(c) (WGPUSurface?, UnsafeMutablePointer?) -> Void + +/** + * Proc pointer type for @ref wgpuSurfacePresent: + * > @copydoc wgpuSurfacePresent + */ +public typealias WGPUProcSurfacePresent = @convention(c) (WGPUSurface?) -> WGPUStatus + +/** + * Proc pointer type for @ref wgpuSurfaceSetLabel: + * > @copydoc wgpuSurfaceSetLabel + */ +public typealias WGPUProcSurfaceSetLabel = @convention(c) (WGPUSurface?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuSurfaceUnconfigure: + * > @copydoc wgpuSurfaceUnconfigure + */ +public typealias WGPUProcSurfaceUnconfigure = @convention(c) (WGPUSurface?) -> Void + +/** + * Proc pointer type for @ref wgpuSurfaceAddRef: + * > @copydoc wgpuSurfaceAddRef + */ +public typealias WGPUProcSurfaceAddRef = @convention(c) (WGPUSurface?) -> Void + +/** + * Proc pointer type for @ref wgpuSurfaceRelease: + * > @copydoc wgpuSurfaceRelease + */ +public typealias WGPUProcSurfaceRelease = @convention(c) (WGPUSurface?) -> Void + +/** + * Proc pointer type for @ref wgpuSurfaceCapabilitiesFreeMembers: + * > @copydoc wgpuSurfaceCapabilitiesFreeMembers + */ +public typealias WGPUProcSurfaceCapabilitiesFreeMembers = @convention(c) (WGPUSurfaceCapabilities) -> Void + +/** + * Proc pointer type for @ref wgpuTextureCreateView: + * > @copydoc wgpuTextureCreateView + */ +public typealias WGPUProcTextureCreateView = @convention(c) (WGPUTexture?, UnsafePointer?) -> WGPUTextureView? + +/** + * Proc pointer type for @ref wgpuTextureDestroy: + * > @copydoc wgpuTextureDestroy + */ +public typealias WGPUProcTextureDestroy = @convention(c) (WGPUTexture?) -> Void + +/** + * Proc pointer type for @ref wgpuTextureGetDepthOrArrayLayers: + * > @copydoc wgpuTextureGetDepthOrArrayLayers + */ +public typealias WGPUProcTextureGetDepthOrArrayLayers = @convention(c) (WGPUTexture?) -> UInt32 + +/** + * Proc pointer type for @ref wgpuTextureGetDimension: + * > @copydoc wgpuTextureGetDimension + */ +public typealias WGPUProcTextureGetDimension = @convention(c) (WGPUTexture?) -> WGPUTextureDimension + +/** + * Proc pointer type for @ref wgpuTextureGetFormat: + * > @copydoc wgpuTextureGetFormat + */ +public typealias WGPUProcTextureGetFormat = @convention(c) (WGPUTexture?) -> WGPUTextureFormat + +/** + * Proc pointer type for @ref wgpuTextureGetHeight: + * > @copydoc wgpuTextureGetHeight + */ +public typealias WGPUProcTextureGetHeight = @convention(c) (WGPUTexture?) -> UInt32 + +/** + * Proc pointer type for @ref wgpuTextureGetMipLevelCount: + * > @copydoc wgpuTextureGetMipLevelCount + */ +public typealias WGPUProcTextureGetMipLevelCount = @convention(c) (WGPUTexture?) -> UInt32 + +/** + * Proc pointer type for @ref wgpuTextureGetSampleCount: + * > @copydoc wgpuTextureGetSampleCount + */ +public typealias WGPUProcTextureGetSampleCount = @convention(c) (WGPUTexture?) -> UInt32 + +/** + * Proc pointer type for @ref wgpuTextureGetUsage: + * > @copydoc wgpuTextureGetUsage + */ +public typealias WGPUProcTextureGetUsage = @convention(c) (WGPUTexture?) -> WGPUTextureUsage + +/** + * Proc pointer type for @ref wgpuTextureGetWidth: + * > @copydoc wgpuTextureGetWidth + */ +public typealias WGPUProcTextureGetWidth = @convention(c) (WGPUTexture?) -> UInt32 + +/** + * Proc pointer type for @ref wgpuTextureSetLabel: + * > @copydoc wgpuTextureSetLabel + */ +public typealias WGPUProcTextureSetLabel = @convention(c) (WGPUTexture?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuTextureAddRef: + * > @copydoc wgpuTextureAddRef + */ +public typealias WGPUProcTextureAddRef = @convention(c) (WGPUTexture?) -> Void + +/** + * Proc pointer type for @ref wgpuTextureRelease: + * > @copydoc wgpuTextureRelease + */ +public typealias WGPUProcTextureRelease = @convention(c) (WGPUTexture?) -> Void + +/** + * Proc pointer type for @ref wgpuTextureViewSetLabel: + * > @copydoc wgpuTextureViewSetLabel + */ +public typealias WGPUProcTextureViewSetLabel = @convention(c) (WGPUTextureView?, WGPUStringView) -> Void + +/** + * Proc pointer type for @ref wgpuTextureViewAddRef: + * > @copydoc wgpuTextureViewAddRef + */ +public typealias WGPUProcTextureViewAddRef = @convention(c) (WGPUTextureView?) -> Void + +/** + * Proc pointer type for @ref wgpuTextureViewRelease: + * > @copydoc wgpuTextureViewRelease + */ +public typealias WGPUProcTextureViewRelease = @convention(c) (WGPUTextureView?) -> Void + +extension WGPUInstanceImpl { + + /** + * \defgroup GlobalFunctions Global Functions + * \brief Functions that are not specific to an object. + * + * @{ + */ + /** + * Create a WGPUInstance + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public /*not inherited*/ init!(descriptor: UnsafePointer?) + + /** + * \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. + */ + public func createSurface(descriptor: UnsafePointer) -> WGPUSurface! + + /** + * Get the list of @ref WGPUWGSLLanguageFeatureName values supported by the instance. + */ + public func getwgslLanguageFeatures(features: UnsafeMutablePointer) + + public func haswgslLanguageFeature(feature: WGPUWGSLLanguageFeatureName) -> WGPUBool + + /** + * Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with @ref WGPUCallbackMode_AllowProcessEvents. + * + * See @ref Process-Events for more information. + */ + public func processEvents() + + public func requestAdapter(options: UnsafePointer, callbackInfo: WGPURequestAdapterCallbackInfo) -> WGPUFuture + + /** + * 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. + */ + public func waitAny(futureCount: Int, futures: UnsafeMutablePointer, timeoutNS: UInt64) -> WGPUWaitStatus + + public func addRef() + + public func release() +} + +/** + * Get the list of @ref WGPUInstanceFeatureName values supported by the instance. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +public func wgpuGetInstanceFeatures(_ features: UnsafeMutablePointer) + +/** + * Get the limits supported by the instance. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +public func wgpuGetInstanceLimits(_ limits: UnsafeMutablePointer) -> WGPUStatus + +/** + * Check whether a particular @ref WGPUInstanceFeatureName is supported by the instance. + */ +public func wgpuHasInstanceFeature(_ feature: WGPUInstanceFeatureName) -> WGPUBool + +/** + * Returns the "procedure address" (function pointer) of the named function. + * The result must be cast to the appropriate proc pointer type. + */ +public func wgpuGetProcAddress(_ procName: WGPUStringView) -> WGPUProc! + +extension WGPUAdapterImpl { + + /** + * \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. + */ + public func getFeatures(features: UnsafeMutablePointer) + + /** + * @param info + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ + public func getInfo(info: UnsafeMutablePointer) -> WGPUStatus + + /** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ + public func getLimits(limits: UnsafeMutablePointer) -> WGPUStatus + + public func hasFeature(feature: WGPUFeatureName) -> WGPUBool + + public func requestDevice(descriptor: UnsafePointer, callbackInfo: WGPURequestDeviceCallbackInfo) -> WGPUFuture + + public func addRef() + + public func release() +} + +/** + * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods + * \brief Functions whose first argument has type WGPUAdapterInfo. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +public func wgpuAdapterInfoFreeMembers(_ adapterInfo: WGPUAdapterInfo) + +extension WGPUBindGroupImpl { + + /** + * \defgroup WGPUBindGroupMethods WGPUBindGroup methods + * \brief Functions whose first argument has type WGPUBindGroup. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUBindGroupLayoutImpl { + + /** + * \defgroup WGPUBindGroupLayoutMethods WGPUBindGroupLayout methods + * \brief Functions whose first argument has type WGPUBindGroupLayout. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUBufferImpl { + + /** + * \defgroup WGPUBufferMethods WGPUBuffer methods + * \brief Functions whose first argument has type WGPUBuffer. + * + * @{ + */ + public func destroy() + + public var mapState: WGPUBufferMapState { get } + + public var size: UInt64 { get } + + public var usage: WGPUBufferUsage { get } + + /** + * @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`. + */ + public func mapAsync(mode: WGPUMapMode, offset: Int, size: Int, callbackInfo: WGPUBufferMapCallbackInfo) -> WGPUFuture + + /** + * 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. + */ + public func readMappedRange(offset: Int, data: UnsafeMutableRawPointer, size: Int) -> WGPUStatus + + public func setLabel(label: WGPUStringView) + + public func unmap() + + /** + * 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. + */ + public func writeMappedRange(offset: Int, data: UnsafeRawPointer, size: Int) -> WGPUStatus + + public func addRef() + + public func release() +} + +/** + * 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. + */ +public func wgpuBufferGetConstMappedRange(_ buffer: WGPUBuffer!, _ offset: Int, _ size: Int) -> UnsafeRawPointer! + +/** + * 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. + */ +public func wgpuBufferGetMappedRange(_ buffer: WGPUBuffer!, _ offset: Int, _ size: Int) -> UnsafeMutableRawPointer! + +extension WGPUCommandBufferImpl { + + /** + * \defgroup WGPUCommandBufferMethods WGPUCommandBuffer methods + * \brief Functions whose first argument has type WGPUCommandBuffer. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUCommandEncoderImpl { + + /** + * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods + * \brief Functions whose first argument has type WGPUCommandEncoder. + * + * @{ + */ + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func beginComputePass(descriptor: UnsafePointer) -> WGPUComputePassEncoder! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func beginRenderPass(descriptor: UnsafePointer) -> WGPURenderPassEncoder! + + public func clearBuffer(buffer: WGPUBuffer!, offset: UInt64, size: UInt64) + + public func copyBufferToBuffer(source: WGPUBuffer!, sourceOffset: UInt64, destination: WGPUBuffer!, destinationOffset: UInt64, size: UInt64) + + public func copyBufferToTexture(source: UnsafePointer, destination: UnsafePointer, copySize: UnsafePointer) + + public func copyTextureToBuffer(source: UnsafePointer, destination: UnsafePointer, copySize: UnsafePointer) + + public func copyTextureToTexture(source: UnsafePointer, destination: UnsafePointer, copySize: UnsafePointer) + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func finish(descriptor: UnsafePointer) -> WGPUCommandBuffer! + + public func insertDebugMarker(markerLabel: WGPUStringView) + + public func popDebugGroup() + + public func pushDebugGroup(groupLabel: WGPUStringView) + + public func resolveQuerySet(querySet: WGPUQuerySet!, firstQuery: UInt32, queryCount: UInt32, destination: WGPUBuffer!, destinationOffset: UInt64) + + public func setLabel(label: WGPUStringView) + + public func writeTimestamp(querySet: WGPUQuerySet!, queryIndex: UInt32) + + public func addRef() + + public func release() +} + +extension WGPUComputePassEncoderImpl { + + /** + * \defgroup WGPUComputePassEncoderMethods WGPUComputePassEncoder methods + * \brief Functions whose first argument has type WGPUComputePassEncoder. + * + * @{ + */ + public func dispatchWorkgroups(workgroupCountX: UInt32, workgroupCountY: UInt32, workgroupCountZ: UInt32) + + public func dispatchWorkgroupsIndirect(indirectBuffer: WGPUBuffer!, indirectOffset: UInt64) + + public func end() + + public func insertDebugMarker(markerLabel: WGPUStringView) + + public func popDebugGroup() + + public func pushDebugGroup(groupLabel: WGPUStringView) + + public func setBindGroup(groupIndex: UInt32, group: WGPUBindGroup!, dynamicOffsetCount: Int, dynamicOffsets: UnsafePointer) + + public func setLabel(label: WGPUStringView) + + public func setPipeline(pipeline: WGPUComputePipeline!) + + public func addRef() + + public func release() +} + +extension WGPUComputePipelineImpl { + + /** + * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods + * \brief Functions whose first argument has type WGPUComputePipeline. + * + * @{ + */ + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func getbindGroupLayout(groupIndex: UInt32) -> WGPUBindGroupLayout! + + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUDeviceImpl { + + /** + * \defgroup WGPUDeviceMethods WGPUDevice methods + * \brief Functions whose first argument has type WGPUDevice. + * + * @{ + */ + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createBindGroup(descriptor: UnsafePointer) -> WGPUBindGroup! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createBindGroupLayout(descriptor: UnsafePointer) -> WGPUBindGroupLayout! + + /** + * TODO + * + * If @ref WGPUBufferDescriptor::mappedAtCreation is `true` and the mapping allocation fails, + * returns `NULL`. + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createBuffer(descriptor: UnsafePointer) -> WGPUBuffer? + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createCommandEncoder(descriptor: UnsafePointer) -> WGPUCommandEncoder! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createComputePipeline(descriptor: UnsafePointer) -> WGPUComputePipeline! + + public func createComputePipelineAsync(descriptor: UnsafePointer, callbackInfo: WGPUCreateComputePipelineAsyncCallbackInfo) -> WGPUFuture + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createPipelineLayout(descriptor: UnsafePointer) -> WGPUPipelineLayout! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createQuerySet(descriptor: UnsafePointer) -> WGPUQuerySet! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createRenderBundleEncoder(descriptor: UnsafePointer) -> WGPURenderBundleEncoder! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createRenderPipeline(descriptor: UnsafePointer) -> WGPURenderPipeline! + + public func createRenderPipelineAsync(descriptor: UnsafePointer, callbackInfo: WGPUCreateRenderPipelineAsyncCallbackInfo) -> WGPUFuture + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createSampler(descriptor: UnsafePointer) -> WGPUSampler! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createShaderModule(descriptor: UnsafePointer) -> WGPUShaderModule! + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createTexture(descriptor: UnsafePointer) -> WGPUTexture! + + public func destroy() + + /** + * @param adapterInfo + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ + public func getAdapterInfo(adapterInfo: UnsafeMutablePointer) -> WGPUStatus + + /** + * Get the list of @ref WGPUFeatureName values supported by the device. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ + public func getFeatures(features: UnsafeMutablePointer) + + /** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ + public func getLimits(limits: UnsafeMutablePointer) -> WGPUStatus + + /** + * @returns + * The @ref WGPUFuture for the device-lost event of the device. + */ + public var lostFuture: WGPUFuture { get } + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public var queue: WGPUQueue! { get } + + public func hasFeature(feature: WGPUFeatureName) -> WGPUBool + + /** + * Pops an error scope to the current thread's error scope stack, + * asynchronously returning the result. See @ref ErrorScopes. + */ + public func popErrorScope(callbackInfo: WGPUPopErrorScopeCallbackInfo) -> WGPUFuture + + /** + * Pushes an error scope to the current thread's error scope stack. + * See @ref ErrorScopes. + */ + public func pushErrorScope(filter: WGPUErrorFilter) + + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUPipelineLayoutImpl { + + /** + * \defgroup WGPUPipelineLayoutMethods WGPUPipelineLayout methods + * \brief Functions whose first argument has type WGPUPipelineLayout. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUQuerySetImpl { + + /** + * \defgroup WGPUQuerySetMethods WGPUQuerySet methods + * \brief Functions whose first argument has type WGPUQuerySet. + * + * @{ + */ + public func destroy() + + public var count: UInt32 { get } + + public var type: WGPUQueryType { get } + + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUQueueImpl { + + /** + * \defgroup WGPUQueueMethods WGPUQueue methods + * \brief Functions whose first argument has type WGPUQueue. + * + * @{ + */ + public func onsubmittedWorkDone(callbackInfo: WGPUQueueWorkDoneCallbackInfo) -> WGPUFuture + + public func setLabel(label: WGPUStringView) + + public func submit(commandCount: Int, commands: UnsafePointer) + + /** + * Produces a @ref DeviceError both content-timeline (`size` alignment) and device-timeline + * errors defined by the WebGPU specification. + */ + public func writeBuffer(buffer: WGPUBuffer!, bufferOffset: UInt64, data: UnsafeRawPointer, size: Int) + + public func writeTexture(destination: UnsafePointer, data: UnsafeRawPointer, dataSize: Int, dataLayout: UnsafePointer, writeSize: UnsafePointer) + + public func addRef() + + public func release() +} + +extension WGPURenderBundleImpl { + + /** + * \defgroup WGPURenderBundleMethods WGPURenderBundle methods + * \brief Functions whose first argument has type WGPURenderBundle. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPURenderBundleEncoderImpl { + + /** + * \defgroup WGPURenderBundleEncoderMethods WGPURenderBundleEncoder methods + * \brief Functions whose first argument has type WGPURenderBundleEncoder. + * + * @{ + */ + public func draw(vertexCount: UInt32, instanceCount: UInt32, firstVertex: UInt32, firstInstance: UInt32) + + public func drawIndexed(indexCount: UInt32, instanceCount: UInt32, firstIndex: UInt32, baseVertex: Int32, firstInstance: UInt32) + + public func drawIndexedIndirect(indirectBuffer: WGPUBuffer!, indirectOffset: UInt64) + + public func drawIndirect(indirectBuffer: WGPUBuffer!, indirectOffset: UInt64) + + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func finish(descriptor: UnsafePointer) -> WGPURenderBundle! + + public func insertDebugMarker(markerLabel: WGPUStringView) + + public func popDebugGroup() + + public func pushDebugGroup(groupLabel: WGPUStringView) + + public func setBindGroup(groupIndex: UInt32, group: WGPUBindGroup!, dynamicOffsetCount: Int, dynamicOffsets: UnsafePointer) + + public func setIndexBuffer(buffer: WGPUBuffer!, format: WGPUIndexFormat, offset: UInt64, size: UInt64) + + public func setLabel(label: WGPUStringView) + + public func setPipeline(pipeline: WGPURenderPipeline!) + + public func setVertexBuffer(slot: UInt32, buffer: WGPUBuffer!, offset: UInt64, size: UInt64) + + public func addRef() + + public func release() +} + +extension WGPURenderPassEncoderImpl { + + /** + * \defgroup WGPURenderPassEncoderMethods WGPURenderPassEncoder methods + * \brief Functions whose first argument has type WGPURenderPassEncoder. + * + * @{ + */ + public func beginOcclusionQuery(queryIndex: UInt32) + + public func draw(vertexCount: UInt32, instanceCount: UInt32, firstVertex: UInt32, firstInstance: UInt32) + + public func drawIndexed(indexCount: UInt32, instanceCount: UInt32, firstIndex: UInt32, baseVertex: Int32, firstInstance: UInt32) + + public func drawIndexedIndirect(indirectBuffer: WGPUBuffer!, indirectOffset: UInt64) + + public func drawIndirect(indirectBuffer: WGPUBuffer!, indirectOffset: UInt64) + + public func end() + + public func endOcclusionQuery() + + public func executeBundles(bundleCount: Int, bundles: UnsafePointer) + + public func insertDebugMarker(markerLabel: WGPUStringView) + + public func popDebugGroup() + + public func pushDebugGroup(groupLabel: WGPUStringView) + + public func setBindGroup(groupIndex: UInt32, group: WGPUBindGroup!, dynamicOffsetCount: Int, dynamicOffsets: UnsafePointer) + + /** + * @param color + * The RGBA blend constant. Represents an `f32` color using @ref DoubleAsSupertype. + */ + public func setBlendConstant(color: UnsafePointer) + + public func setIndexBuffer(buffer: WGPUBuffer!, format: WGPUIndexFormat, offset: UInt64, size: UInt64) + + public func setLabel(label: WGPUStringView) + + public func setPipeline(pipeline: WGPURenderPipeline!) + + public func setScissorRect(_ x: UInt32, _ y: UInt32, width: UInt32, height: UInt32) + + public func setStencilReference(reference: UInt32) + + public func setVertexBuffer(slot: UInt32, buffer: WGPUBuffer!, offset: UInt64, size: UInt64) + + /** + * TODO + * + * If any argument is non-finite, produces a @ref NonFiniteFloatValueError. + */ + public func setViewport(_ x: Float, _ y: Float, width: Float, height: Float, minDepth: Float, maxDepth: Float) + + public func addRef() + + public func release() +} + +extension WGPURenderPipelineImpl { + + /** + * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods + * \brief Functions whose first argument has type WGPURenderPipeline. + * + * @{ + */ + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func getbindGroupLayout(groupIndex: UInt32) -> WGPUBindGroupLayout! + + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUSamplerImpl { + + /** + * \defgroup WGPUSamplerMethods WGPUSampler methods + * \brief Functions whose first argument has type WGPUSampler. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUShaderModuleImpl { + + /** + * \defgroup WGPUShaderModuleMethods WGPUShaderModule methods + * \brief Functions whose first argument has type WGPUShaderModule. + * + * @{ + */ + public func getCompilationInfo(callbackInfo: WGPUCompilationInfoCallbackInfo) -> WGPUFuture + + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +/** + * \defgroup WGPUSupportedFeaturesMethods WGPUSupportedFeatures methods + * \brief Functions whose first argument has type WGPUSupportedFeatures. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +public func wgpuSupportedFeaturesFreeMembers(_ supportedFeatures: WGPUSupportedFeatures) + +/** + * \defgroup WGPUSupportedInstanceFeaturesMethods WGPUSupportedInstanceFeatures methods + * \brief Functions whose first argument has type WGPUSupportedInstanceFeatures. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +public func wgpuSupportedInstanceFeaturesFreeMembers(_ supportedInstanceFeatures: WGPUSupportedInstanceFeatures) + +/** + * \defgroup WGPUSupportedWGSLLanguageFeaturesMethods WGPUSupportedWGSLLanguageFeatures methods + * \brief Functions whose first argument has type WGPUSupportedWGSLLanguageFeatures. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +public func wgpuSupportedWGSLLanguageFeaturesFreeMembers(_ supportedWGSLLanguageFeatures: WGPUSupportedWGSLLanguageFeatures) + +extension WGPUSurfaceImpl { + + /** + * \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. + */ + public func configure(config: UnsafePointer) + + /** + * 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. + */ + public func getCapabilities(adapter: WGPUAdapter!, capabilities: UnsafeMutablePointer) -> WGPUStatus + + /** + * 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. + */ + public func getCurrentTexture(surfaceTexture: UnsafeMutablePointer) + + /** + * 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. + */ + public func present() -> WGPUStatus + + /** + * Modifies the label used to refer to `surface`. + * + * @param label + * The new label. + */ + public func setLabel(label: WGPUStringView) + + /** + * Removes the configuration for `surface`. + * See @ref Surface-Configuration for more details. + */ + public func unconfigure() + + public func addRef() + + public func release() +} + +/** + * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods + * \brief Functions whose first argument has type WGPUSurfaceCapabilities. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +public func wgpuSurfaceCapabilitiesFreeMembers(_ surfaceCapabilities: WGPUSurfaceCapabilities) + +extension WGPUTextureImpl { + + /** + * \defgroup WGPUTextureMethods WGPUTexture methods + * \brief Functions whose first argument has type WGPUTexture. + * + * @{ + */ + /** + * @returns + * This value is @ref ReturnedWithOwnership. + */ + public func createView(descriptor: UnsafePointer) -> WGPUTextureView! + + public func destroy() + + public var depthOrArrayLayers: UInt32 { get } + + public var dimension: WGPUTextureDimension { get } + + public var format: WGPUTextureFormat { get } + + public var height: UInt32 { get } + + public var mipLevelCount: UInt32 { get } + + public var sampleCount: UInt32 { get } + + public var usage: WGPUTextureUsage { get } + + public var width: UInt32 { get } + + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} + +extension WGPUTextureViewImpl { + + /** + * \defgroup WGPUTextureViewMethods WGPUTextureView methods + * \brief Functions whose first argument has type WGPUTextureView. + * + * @{ + */ + public func setLabel(label: WGPUStringView) + + public func addRef() + + public func release() +} diff --git a/blog/improving-usability-of-c-libraries-in-swift/webgpu_apinotes.swift b/blog/improving-usability-of-c-libraries-in-swift/webgpu_apinotes.swift new file mode 100644 index 000000000..0fd5b61c1 --- /dev/null +++ b/blog/improving-usability-of-c-libraries-in-swift/webgpu_apinotes.swift @@ -0,0 +1,341 @@ +#! swift -enable-bare-slash-regex + +/** + * Script to process the common [WebGPU header](https://github.com/webgpu-native/webgpu-headers) + * to produce a Swift-compatible "API notes" file that makes the use of WebGPU + * C API easier and safer in Swift. + * + * The resulting API notes file improves the Swift view of the WebGPU C API + * in the following ways: + * + * - WebGPU's reference-counted "object" types (like WGPUInstance) + * are imported as Swift classes. Swift will automatically handle + * the reference counting, making calls to the appropriate + * wgpu*AddRef and wgpu*Release functions. + * - WebGPU functions that operate on a particular object type are imported + * as members of the corresponding class. For example, + * wgpuInstanceCreateSurface will become WGPUInstance.createSurface(). + * - WebGPU "Get" functions that retrieve a single value are imported as + * computed properties. For example, wgpuBufferGetMapState becomes a + * property WGPUBuffer.mapState. + * - WebGPU's enum types are imported as Swift enum types, with each + * enumerator being imported as a case. + * - WebGPU's flag set types are imported as Swift structs that act as + * option sets, with each option as a static member of the type. + * + * Usage: + * swift -enable-bare-slash-regex apinotes.swift < webgpu.h > WebGPU.apinotes + * + * This source file is part of the Swift.org open source project + * + * Copyright (c) 2024 Apple Inc. and the Swift project authors + * Licensed under Apache License v2.0 with Runtime Library Exception + * + * See https://swift.org/LICENSE.txt for license information + * See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors + */ + +extension StringProtocol { + // Replace a leading "WGPU" with "wgpu" in the given string. + var lowercaseWebGPUPrefix: String { + if starts(with: "WGPU") { + return "wgpu" + String(dropFirst(4)) + } + + return String(self) + } + + // Replace a leading "wgpu" with "WGPU" in the given string. + var uppercaseWebGPUPrefix: String { + if starts(with: "wgpu") { + return "WGPU" + String(dropFirst(4)) + } + + return String(self) + } + + /// Return this string with the initialism lowercased. + var lowercasingInitialism: String { + var numUppercased = 0 + for c in self { + if c.isUppercase { + numUppercased += 1 + } + } + + return String(prefix(numUppercased)).lowercased() + String(dropFirst(numUppercased)) + } +} + +extension String { + /// Whether a type with this name requires a nullability annotation. + func typeRequiresNullability(importedTypes: Set) -> Bool { + if contains("*") { + return true + } + + if importedTypes.contains(self) { + return true + } + + return false + } +} + +/// A function parameter in the webgpu header. +struct Parameter { + var type: String + var name: String + var nullable: Bool + + /// The name that the parameter should have in Swift. + /// + /// This function applies some simple heuristics to deal with poor + /// or missing names in webgpu.h. + var swiftName: String { + if name.count < 2 { + return "_" + } + + return name + } + + func requiresNullability(importedTypes: Set) -> Bool { + nullable || type.typeRequiresNullability(importedTypes: importedTypes) + } +} + +/// A function in the webgpu header +struct Function { + var name: String + var resultType: String + var returnsRetained: Bool + var nullableResult: Bool + var parameters: [Parameter] + + /// If this is a method of a type, the name of that type. + var enclosingType: String? { + guard let selfParameter = parameters.first, + name.starts(with: selfParameter.type.lowercaseWebGPUPrefix) else { + return nil + } + + return selfParameter.type + } + + /// If this function should have a special Swift name, produce that name. + /// + /// This function applies various heuristics to map WebGPU functions + /// to their appropriate Swift spellings. + func swiftName(importedTypes: Set) -> String? { + // Special cases + switch name { + case "wgpuCreateInstance": return "WGPUInstanceImpl.init(descriptor:)" + default: break + } + + guard let selfType = enclosingType, importedTypes.contains(selfType) else { + return nil + } + + let unprefixedName = name.dropFirst(selfType.count) + + // If this has the shape of a getter, map it to a property getter. + let baseName: String + var namePrefix: String? + if parameters.count == 1 && unprefixedName.starts(with: "Get") && resultType != "void" { + baseName = unprefixedName.dropFirst(3).lowercasingInitialism + namePrefix = "getter:" + } else { + baseName = unprefixedName.lowercasingInitialism + namePrefix = nil + } + + let parameterNameString = "self:" + parameters.dropFirst().map { $0.swiftName + ":" }.joined() + return "\(namePrefix ?? "")\(selfType)Impl.\(baseName)(\(parameterNameString))" + } + + /// Whether we should annotate this function. + func shouldAnnotate(importedTypes: Set) -> Bool { + returnsRetained || swiftName(importedTypes: importedTypes) != nil || + nullableResult || resultType.typeRequiresNullability(importedTypes: importedTypes) || + parameters.contains { + $0.requiresNullability(importedTypes: importedTypes) + } + } +} + +// Regular expressions to match particular entities in the generated webgpu.h. + +// Enum definitions, marked by WGPU_ENUM_ATTRIBUTE. +let enumMatcher = /} (?\w+?) WGPU_ENUM_ATTRIBUTE/ + +// Flag set definitions. +let flagSetMatcher = /typedef WGPUFlags (?\w+?);/ + +// Global constant definitions. +let globalConstantMatcher = /static const (?\w+?) (?\w+?)_(?\w+?) =/ + +// Object definitions, marked by WGPU_OBJECT_ATTRIBUTE. +let objectMatcher = /typedef struct (?\w+?)\* (?\w+?) WGPU_OBJECT_ATTRIBUTE;/ + +// Function declarations, marked by WGPU_FUNCTION_ATTRIBUTE +let functionMatcher = /WGPU_EXPORT (?WGPU_NULLABLE ?)?(?\w+?) (?\w+?)\((?.*\)?) WGPU_FUNCTION_ATTRIBUTE;/ +let parameterMatcher = /((?WGPU_NULLABLE ?)?(?[^),]+?)) (?\w+?)[),]/ + +// Extract information about the various declarations in the header. +var enums: Set = [] +var flagSets: Set = [] +var objectTypes: Set = [] +var functions: [Function] = [] +var globalConstants: [(typename: String, name: String)] = [] + +var nextReturnsRetained = false +while let line = readLine() { + if line.contains("This value is @ref ReturnedWithOwnership") { + nextReturnsRetained = true + continue + } + + if let matchedEnum = line.firstMatch(of: enumMatcher) { + enums.insert(String(matchedEnum.name)) + nextReturnsRetained = false + continue + } + + if let matchedFlagSet = line.firstMatch(of: flagSetMatcher) { + flagSets.insert(String(matchedFlagSet.name)) + nextReturnsRetained = false + continue + } + + if let matchedGlobalConstant = line.firstMatch(of: globalConstantMatcher) { + if matchedGlobalConstant.type == matchedGlobalConstant.typename { + globalConstants.append( + (typename: String(matchedGlobalConstant.type), + name: String(matchedGlobalConstant.name)) + ) + } + continue + } + + if let matchedObject = line.firstMatch(of: objectMatcher) { + assert(matchedObject.implName == matchedObject.name + "Impl") + objectTypes.insert(String(matchedObject.name)) + nextReturnsRetained = false + continue + } + + if let matchedFunction = line.firstMatch(of: functionMatcher) { + let parameters = matchedFunction.parameters.matches(of: parameterMatcher).map { match in + Parameter( + type: String(match.type), + name: String(match.name), + nullable: match.nullable != nil, + ) + } + + functions.append(Function( + name: String(matchedFunction.name), + resultType: String(matchedFunction.resultType), + returnsRetained: nextReturnsRetained, + nullableResult: matchedFunction.nullableResult != nil, + parameters: parameters + )) + + nextReturnsRetained = false + continue + } +} + +// APINotes YAML header +print(""" + --- + Name: WebGPU + """) + +// All "tags" (structs, enums, etc.). +print("Tags:") + +// WebGPU enum types import as Swift enums. +for enumName in enums.sorted() { + print(""" + - Name: \(enumName) + EnumExtensibility: closed + """) +} + +// WebGPU object types import as Swift foreign reference types. +for objectTypeName in objectTypes.sorted() { + let methodPrefix = objectTypeName.lowercaseWebGPUPrefix + print(""" + - Name: \(objectTypeName)Impl + SwiftImportAs: reference + SwiftReleaseOp: \(methodPrefix)Release + SwiftRetainOp: \(methodPrefix)AddRef + """) +} + +// All typedefs (option sets, etc.). +print("Typedefs:") +for flagSetName in flagSets.sorted() { + print(""" + - Name: \(flagSetName) + SwiftWrapper: struct + """) +} + +// Functions can be imported as methods, properties, or initializers. +print(""" + Functions: + """) +for function in functions.sorted(by: { $0.name < $1.name }) { + guard function.shouldAnnotate(importedTypes: objectTypes) else { + continue + } + + print(""" + - Name: \(function.name) + """) + if let swiftName = function.swiftName(importedTypes: objectTypes) { + print(""" + SwiftName: \(swiftName) + """) + } + if function.returnsRetained { + print(""" + SwiftReturnOwnership: retained + """) + } + if function.nullableResult { + print(""" + ResultType: "\(function.resultType) _Nullable" + """) + } + if function.parameters.contains(where: { $0.requiresNullability(importedTypes: objectTypes) }) { + print(""" + Parameters: + """) + for (index, param) in function.parameters.enumerated() { + guard param.requiresNullability(importedTypes: objectTypes) else { continue } + + print(""" + - Position: \(index) + Type: "\(param.type) \(param.nullable ? "_Nullable" : "_Nonnull")" + """) + } + } +} + +// Globals can be imported as static properties, if we know the type. +print(""" + Globals: + """) +for (typename, name) in globalConstants { + guard flagSets.contains(typename) else { continue } + + print(""" + - Name: \(typename)_\(name) + SwiftName: \(typename).\(name.lowercasingInitialism) + """) +}