From 8af03e30605908f91cda66164423bbf8025a5312 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 14:28:56 +0200 Subject: [PATCH 01/19] wgpu/lib: Update headers to v24.0.0 --- wgpu/lib/webgpu.h | 3006 ++++++++++++++++++++++++++++++++++++--------- wgpu/lib/wgpu.h | 138 +-- 2 files changed, 2457 insertions(+), 687 deletions(-) diff --git a/wgpu/lib/webgpu.h b/wgpu/lib/webgpu.h index c219585..084ac1b 100644 --- a/wgpu/lib/webgpu.h +++ b/wgpu/lib/webgpu.h @@ -1,6 +1,6 @@ /** * Copyright 2019-2023 WebGPU-Native developers - * + * * SPDX-License-Identifier: BSD-3-Clause */ @@ -8,7 +8,7 @@ /** * \mainpage - * + * * **Important:** *This documentation is a Work In Progress.* * * This is the home of WebGPU C API specification. We define here the standard @@ -55,42 +55,91 @@ #include #include +#define _wgpu_COMMA , +#if defined(__cplusplus) +# if __cplusplus >= 201103L +# define _wgpu_MAKE_INIT_STRUCT(type, value) (type value) +# else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +# endif +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define _wgpu_MAKE_INIT_STRUCT(type, value) ((type) value) +#else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +#endif + /** * \defgroup Constants * \brief Constants. - * + * * @{ */ -#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL) -#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL) -#define WGPU_DEPTH_SLICE_UNDEFINED (0xffffffffUL) -#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL) -#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL) -#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL) -#define WGPU_QUERY_SET_INDEX_UNDEFINED (0xffffffffUL) +#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX) +#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX) +#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) +#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) +#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX) +#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX) +#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX) #define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) -#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) +#define WGPU_WHOLE_SIZE (UINT64_MAX) /** @} */ /** - * \defgroup Typedefs - * \brief Utility typedefs. - * + * \defgroup UtilityTypes Utility Types + * * @{ */ -typedef uint32_t WGPUFlags; +typedef uint64_t WGPUFlags; typedef uint32_t WGPUBool; +/** + * Nullable value defining a pointer+length view into a UTF-8 encoded string. + * + * Values passed into the API may use the special length value @ref WGPU_STRLEN + * to indicate a null-terminated string. + * Non-null values passed out of the API (for example as callback arguments) + * always provide an explicit length and **may or may not be null-terminated**. + * + * Some inputs to the API accept null values. Those which do not accept null + * values "default" to the empty string when null values are passed. + * + * Values are encoded as follows: + * - `{NULL, WGPU_STRLEN}`: the null value. + * - `{non_null_pointer, WGPU_STRLEN}`: a null-terminated string view. + * - `{any, 0}`: the empty string. + * - `{NULL, non_zero_length}`: not allowed (null dereference). + * - `{non_null_pointer, non_zero_length}`: an explictly-sized string view with + * size `non_zero_length` (in bytes). + * + * For info on how this is used in various places, see \ref Strings. + */ +typedef struct WGPUStringView { + char const * WGPU_NULLABLE data; + size_t length; +} WGPUStringView; + +/** + * Sentinel value used in @ref WGPUStringView to indicate that the pointer + * is to a null-terminated string, rather than an explicitly-sized string. + */ +#define WGPU_STRLEN SIZE_MAX + +#define WGPU_STRING_VIEW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStringView, { \ + /*.data=*/NULL _wgpu_COMMA \ + /*.length=*/WGPU_STRLEN _wgpu_COMMA \ +}) + /** @} */ /** * \defgroup Objects * \brief Opaque, non-dispatchable handles to WebGPU objects. - * + * * @{ */ typedef struct WGPUAdapterImpl* WGPUAdapter WGPU_OBJECT_ATTRIBUTE; @@ -112,6 +161,9 @@ typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder WGPU_OBJECT_ATTR typedef struct WGPURenderPipelineImpl* WGPURenderPipeline WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUSamplerImpl* WGPUSampler WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUShaderModuleImpl* WGPUShaderModule WGPU_OBJECT_ATTRIBUTE; +/** + * An object used to continuously present image data to the user, see @ref Surfaces for more details. + */ typedef struct WGPUSurfaceImpl* WGPUSurface WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE; @@ -131,43 +183,43 @@ struct WGPUCompilationMessage; struct WGPUComputePassTimestampWrites; struct WGPUConstantEntry; struct WGPUExtent3D; -struct WGPUInstanceDescriptor; +struct WGPUFuture; +struct WGPUInstanceCapabilities; struct WGPULimits; struct WGPUMultisampleState; struct WGPUOrigin3D; struct WGPUPipelineLayoutDescriptor; -struct WGPUPrimitiveDepthClipControl; struct WGPUPrimitiveState; struct WGPUQuerySetDescriptor; struct WGPUQueueDescriptor; struct WGPURenderBundleDescriptor; struct WGPURenderBundleEncoderDescriptor; struct WGPURenderPassDepthStencilAttachment; -struct WGPURenderPassDescriptorMaxDrawCount; +struct WGPURenderPassMaxDrawCount; struct WGPURenderPassTimestampWrites; struct WGPURequestAdapterOptions; struct WGPUSamplerBindingLayout; struct WGPUSamplerDescriptor; -struct WGPUShaderModuleCompilationHint; -struct WGPUShaderModuleSPIRVDescriptor; -struct WGPUShaderModuleWGSLDescriptor; +struct WGPUShaderModuleDescriptor; +struct WGPUShaderSourceSPIRV; +struct WGPUShaderSourceWGSL; struct WGPUStencilFaceState; struct WGPUStorageTextureBindingLayout; +struct WGPUSupportedFeatures; +struct WGPUSupportedWGSLLanguageFeatures; struct WGPUSurfaceCapabilities; struct WGPUSurfaceConfiguration; struct WGPUSurfaceDescriptor; -struct WGPUSurfaceDescriptorFromAndroidNativeWindow; -struct WGPUSurfaceDescriptorFromCanvasHTMLSelector; -struct WGPUSurfaceDescriptorFromMetalLayer; -struct WGPUSurfaceDescriptorFromWaylandSurface; -struct WGPUSurfaceDescriptorFromWindowsHWND; -struct WGPUSurfaceDescriptorFromXcbWindow; -struct WGPUSurfaceDescriptorFromXlibWindow; +struct WGPUSurfaceSourceAndroidNativeWindow; +struct WGPUSurfaceSourceMetalLayer; +struct WGPUSurfaceSourceWaylandSurface; +struct WGPUSurfaceSourceWindowsHWND; +struct WGPUSurfaceSourceXCBWindow; +struct WGPUSurfaceSourceXlibWindow; struct WGPUSurfaceTexture; +struct WGPUTexelCopyBufferLayout; struct WGPUTextureBindingLayout; -struct WGPUTextureDataLayout; struct WGPUTextureViewDescriptor; -struct WGPUUncapturedErrorCallbackInfo; struct WGPUVertexAttribute; struct WGPUBindGroupDescriptor; struct WGPUBindGroupLayoutEntry; @@ -175,47 +227,67 @@ struct WGPUBlendState; struct WGPUCompilationInfo; struct WGPUComputePassDescriptor; struct WGPUDepthStencilState; -struct WGPUImageCopyBuffer; -struct WGPUImageCopyTexture; +struct WGPUDeviceDescriptor; +struct WGPUFutureWaitInfo; +struct WGPUInstanceDescriptor; struct WGPUProgrammableStageDescriptor; struct WGPURenderPassColorAttachment; -struct WGPURequiredLimits; -struct WGPUShaderModuleDescriptor; -struct WGPUSupportedLimits; +struct WGPUTexelCopyBufferInfo; +struct WGPUTexelCopyTextureInfo; struct WGPUTextureDescriptor; struct WGPUVertexBufferLayout; struct WGPUBindGroupLayoutDescriptor; struct WGPUColorTargetState; struct WGPUComputePipelineDescriptor; -struct WGPUDeviceDescriptor; struct WGPURenderPassDescriptor; struct WGPUVertexState; struct WGPUFragmentState; struct WGPURenderPipelineDescriptor; +// Callback info structure forward declarations +struct WGPUBufferMapCallbackInfo; +struct WGPUCompilationInfoCallbackInfo; +struct WGPUCreateComputePipelineAsyncCallbackInfo; +struct WGPUCreateRenderPipelineAsyncCallbackInfo; +struct WGPUDeviceLostCallbackInfo; +struct WGPUPopErrorScopeCallbackInfo; +struct WGPUQueueWorkDoneCallbackInfo; +struct WGPURequestAdapterCallbackInfo; +struct WGPURequestDeviceCallbackInfo; +struct WGPUUncapturedErrorCallbackInfo; + /** * \defgroup Enumerations * \brief Enums. - * + * * @{ */ typedef enum WGPUAdapterType { - WGPUAdapterType_DiscreteGPU = 0x00000000, - WGPUAdapterType_IntegratedGPU = 0x00000001, - WGPUAdapterType_CPU = 0x00000002, - WGPUAdapterType_Unknown = 0x00000003, + WGPUAdapterType_DiscreteGPU = 0x00000001, + WGPUAdapterType_IntegratedGPU = 0x00000002, + WGPUAdapterType_CPU = 0x00000003, + WGPUAdapterType_Unknown = 0x00000004, WGPUAdapterType_Force32 = 0x7FFFFFFF } WGPUAdapterType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUAddressMode { - WGPUAddressMode_Repeat = 0x00000000, - WGPUAddressMode_MirrorRepeat = 0x00000001, - WGPUAddressMode_ClampToEdge = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUAddressMode_Undefined = 0x00000000, + WGPUAddressMode_ClampToEdge = 0x00000001, + WGPUAddressMode_Repeat = 0x00000002, + WGPUAddressMode_MirrorRepeat = 0x00000003, WGPUAddressMode_Force32 = 0x7FFFFFFF } WGPUAddressMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBackendType { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUBackendType_Undefined = 0x00000000, WGPUBackendType_Null = 0x00000001, WGPUBackendType_WebGPU = 0x00000002, @@ -229,165 +301,277 @@ typedef enum WGPUBackendType { } WGPUBackendType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendFactor { - WGPUBlendFactor_Zero = 0x00000000, - WGPUBlendFactor_One = 0x00000001, - WGPUBlendFactor_Src = 0x00000002, - WGPUBlendFactor_OneMinusSrc = 0x00000003, - WGPUBlendFactor_SrcAlpha = 0x00000004, - WGPUBlendFactor_OneMinusSrcAlpha = 0x00000005, - WGPUBlendFactor_Dst = 0x00000006, - WGPUBlendFactor_OneMinusDst = 0x00000007, - WGPUBlendFactor_DstAlpha = 0x00000008, - WGPUBlendFactor_OneMinusDstAlpha = 0x00000009, - WGPUBlendFactor_SrcAlphaSaturated = 0x0000000A, - WGPUBlendFactor_Constant = 0x0000000B, - WGPUBlendFactor_OneMinusConstant = 0x0000000C, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBlendFactor_Undefined = 0x00000000, + WGPUBlendFactor_Zero = 0x00000001, + WGPUBlendFactor_One = 0x00000002, + WGPUBlendFactor_Src = 0x00000003, + WGPUBlendFactor_OneMinusSrc = 0x00000004, + WGPUBlendFactor_SrcAlpha = 0x00000005, + WGPUBlendFactor_OneMinusSrcAlpha = 0x00000006, + WGPUBlendFactor_Dst = 0x00000007, + WGPUBlendFactor_OneMinusDst = 0x00000008, + WGPUBlendFactor_DstAlpha = 0x00000009, + WGPUBlendFactor_OneMinusDstAlpha = 0x0000000A, + WGPUBlendFactor_SrcAlphaSaturated = 0x0000000B, + WGPUBlendFactor_Constant = 0x0000000C, + WGPUBlendFactor_OneMinusConstant = 0x0000000D, + WGPUBlendFactor_Src1 = 0x0000000E, + WGPUBlendFactor_OneMinusSrc1 = 0x0000000F, + WGPUBlendFactor_Src1Alpha = 0x00000010, + WGPUBlendFactor_OneMinusSrc1Alpha = 0x00000011, WGPUBlendFactor_Force32 = 0x7FFFFFFF } WGPUBlendFactor WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendOperation { - WGPUBlendOperation_Add = 0x00000000, - WGPUBlendOperation_Subtract = 0x00000001, - WGPUBlendOperation_ReverseSubtract = 0x00000002, - WGPUBlendOperation_Min = 0x00000003, - WGPUBlendOperation_Max = 0x00000004, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBlendOperation_Undefined = 0x00000000, + WGPUBlendOperation_Add = 0x00000001, + WGPUBlendOperation_Subtract = 0x00000002, + WGPUBlendOperation_ReverseSubtract = 0x00000003, + WGPUBlendOperation_Min = 0x00000004, + WGPUBlendOperation_Max = 0x00000005, WGPUBlendOperation_Force32 = 0x7FFFFFFF } WGPUBlendOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBufferBindingType { - WGPUBufferBindingType_Undefined = 0x00000000, - WGPUBufferBindingType_Uniform = 0x00000001, - WGPUBufferBindingType_Storage = 0x00000002, - WGPUBufferBindingType_ReadOnlyStorage = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUBufferBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUBufferBindingType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBufferBindingType_Undefined = 0x00000001, + WGPUBufferBindingType_Uniform = 0x00000002, + WGPUBufferBindingType_Storage = 0x00000003, + WGPUBufferBindingType_ReadOnlyStorage = 0x00000004, WGPUBufferBindingType_Force32 = 0x7FFFFFFF } WGPUBufferBindingType WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUBufferMapAsyncStatus { - WGPUBufferMapAsyncStatus_Success = 0x00000000, - WGPUBufferMapAsyncStatus_ValidationError = 0x00000001, - WGPUBufferMapAsyncStatus_Unknown = 0x00000002, - WGPUBufferMapAsyncStatus_DeviceLost = 0x00000003, - WGPUBufferMapAsyncStatus_DestroyedBeforeCallback = 0x00000004, - WGPUBufferMapAsyncStatus_UnmappedBeforeCallback = 0x00000005, - WGPUBufferMapAsyncStatus_MappingAlreadyPending = 0x00000006, - WGPUBufferMapAsyncStatus_OffsetOutOfRange = 0x00000007, - WGPUBufferMapAsyncStatus_SizeOutOfRange = 0x00000008, - WGPUBufferMapAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUBufferMapAsyncStatus WGPU_ENUM_ATTRIBUTE; - typedef enum WGPUBufferMapState { - WGPUBufferMapState_Unmapped = 0x00000000, - WGPUBufferMapState_Pending = 0x00000001, - WGPUBufferMapState_Mapped = 0x00000002, + WGPUBufferMapState_Unmapped = 0x00000001, + WGPUBufferMapState_Pending = 0x00000002, + WGPUBufferMapState_Mapped = 0x00000003, WGPUBufferMapState_Force32 = 0x7FFFFFFF } WGPUBufferMapState WGPU_ENUM_ATTRIBUTE; +/** + * The callback mode controls how a callback for an asynchronous operation may be fired. See @ref Asynchronous-Operations for how these are used. + */ +typedef enum WGPUCallbackMode { + /** + * `0x00000001`. + * Callbacks created with `WGPUCallbackMode_WaitAnyOnly`: + * - fire when the asynchronous operation's future is passed to a call to `::wgpuInstanceWaitAny` + * AND the operation has already completed or it completes inside the call to `::wgpuInstanceWaitAny`. + */ + WGPUCallbackMode_WaitAnyOnly = 0x00000001, + /** + * `0x00000002`. + * Callbacks created with `WGPUCallbackMode_AllowProcessEvents`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_WaitAnyOnly` + * - fire inside a call to `::wgpuInstanceProcessEvents` if the asynchronous operation is complete. + */ + WGPUCallbackMode_AllowProcessEvents = 0x00000002, + /** + * `0x00000003`. + * Callbacks created with `WGPUCallbackMode_AllowSpontaneous`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_AllowProcessEvents` + * - **may** fire spontaneously on an arbitrary or application thread, when the WebGPU implementations discovers that the asynchronous operation is complete. + * + * Implementations _should_ fire spontaneous callbacks as soon as possible. + * + * @note Because spontaneous callbacks may fire at an arbitrary time on an arbitrary thread, applications should take extra care when acquiring locks or mutating state inside the callback. It undefined behavior to re-entrantly call into the webgpu.h API if the callback fires while inside the callstack of another webgpu.h function that is not `wgpuInstanceWaitAny` or `wgpuInstanceProcessEvents`. + */ + WGPUCallbackMode_AllowSpontaneous = 0x00000003, + WGPUCallbackMode_Force32 = 0x7FFFFFFF +} WGPUCallbackMode WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUCompareFunction { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUCompareFunction_Undefined = 0x00000000, WGPUCompareFunction_Never = 0x00000001, WGPUCompareFunction_Less = 0x00000002, - WGPUCompareFunction_LessEqual = 0x00000003, - WGPUCompareFunction_Greater = 0x00000004, - WGPUCompareFunction_GreaterEqual = 0x00000005, - WGPUCompareFunction_Equal = 0x00000006, - WGPUCompareFunction_NotEqual = 0x00000007, + WGPUCompareFunction_Equal = 0x00000003, + WGPUCompareFunction_LessEqual = 0x00000004, + WGPUCompareFunction_Greater = 0x00000005, + WGPUCompareFunction_NotEqual = 0x00000006, + WGPUCompareFunction_GreaterEqual = 0x00000007, WGPUCompareFunction_Always = 0x00000008, WGPUCompareFunction_Force32 = 0x7FFFFFFF } WGPUCompareFunction WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationInfoRequestStatus { - WGPUCompilationInfoRequestStatus_Success = 0x00000000, - WGPUCompilationInfoRequestStatus_Error = 0x00000001, - WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000002, - WGPUCompilationInfoRequestStatus_Unknown = 0x00000003, + WGPUCompilationInfoRequestStatus_Success = 0x00000001, + WGPUCompilationInfoRequestStatus_InstanceDropped = 0x00000002, + WGPUCompilationInfoRequestStatus_Error = 0x00000003, + WGPUCompilationInfoRequestStatus_Unknown = 0x00000004, WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF } WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationMessageType { - WGPUCompilationMessageType_Error = 0x00000000, - WGPUCompilationMessageType_Warning = 0x00000001, - WGPUCompilationMessageType_Info = 0x00000002, + WGPUCompilationMessageType_Error = 0x00000001, + WGPUCompilationMessageType_Warning = 0x00000002, + WGPUCompilationMessageType_Info = 0x00000003, WGPUCompilationMessageType_Force32 = 0x7FFFFFFF } WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE; +/** + * Describes how frames are composited with other contents on the screen when `::wgpuSurfacePresent` is called. + */ typedef enum WGPUCompositeAlphaMode { + /** + * `0x00000000`. + * Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between @ref WGPUCompositeAlphaMode_Opaque or @ref WGPUCompositeAlphaMode_Inherit. + */ WGPUCompositeAlphaMode_Auto = 0x00000000, + /** + * `0x00000001`. + * The alpha component of the image is ignored and teated as if it is always 1.0. + */ WGPUCompositeAlphaMode_Opaque = 0x00000001, + /** + * `0x00000002`. + * The alpha component is respected and non-alpha components are assumed to be already multiplied with the alpha component. For example, (0.5, 0, 0, 0.5) is semi-transparent bright red. + */ WGPUCompositeAlphaMode_Premultiplied = 0x00000002, + /** + * `0x00000003`. + * The alpha component is respected and non-alpha components are assumed to NOT be already multiplied with the alpha component. For example, (1.0, 0, 0, 0.5) is semi-transparent bright red. + */ WGPUCompositeAlphaMode_Unpremultiplied = 0x00000003, + /** + * `0x00000004`. + * The handling of the alpha component is unknown to WebGPU and should be handled by the application using system-specific APIs. This mode may be unavailable (for example on Wasm). + */ WGPUCompositeAlphaMode_Inherit = 0x00000004, WGPUCompositeAlphaMode_Force32 = 0x7FFFFFFF } WGPUCompositeAlphaMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCreatePipelineAsyncStatus { - WGPUCreatePipelineAsyncStatus_Success = 0x00000000, - WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001, - WGPUCreatePipelineAsyncStatus_InternalError = 0x00000002, - WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000003, - WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000004, + WGPUCreatePipelineAsyncStatus_Success = 0x00000001, + WGPUCreatePipelineAsyncStatus_InstanceDropped = 0x00000002, + WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000003, + WGPUCreatePipelineAsyncStatus_InternalError = 0x00000004, WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF } WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCullMode { - WGPUCullMode_None = 0x00000000, - WGPUCullMode_Front = 0x00000001, - WGPUCullMode_Back = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUCullMode_Undefined = 0x00000000, + WGPUCullMode_None = 0x00000001, + WGPUCullMode_Front = 0x00000002, + WGPUCullMode_Back = 0x00000003, WGPUCullMode_Force32 = 0x7FFFFFFF } WGPUCullMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUDeviceLostReason { WGPUDeviceLostReason_Unknown = 0x00000001, WGPUDeviceLostReason_Destroyed = 0x00000002, + WGPUDeviceLostReason_InstanceDropped = 0x00000003, + WGPUDeviceLostReason_FailedCreation = 0x00000004, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF } WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorFilter { - WGPUErrorFilter_Validation = 0x00000000, - WGPUErrorFilter_OutOfMemory = 0x00000001, - WGPUErrorFilter_Internal = 0x00000002, + WGPUErrorFilter_Validation = 0x00000001, + WGPUErrorFilter_OutOfMemory = 0x00000002, + WGPUErrorFilter_Internal = 0x00000003, WGPUErrorFilter_Force32 = 0x7FFFFFFF } WGPUErrorFilter WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorType { - WGPUErrorType_NoError = 0x00000000, - WGPUErrorType_Validation = 0x00000001, - WGPUErrorType_OutOfMemory = 0x00000002, - WGPUErrorType_Internal = 0x00000003, - WGPUErrorType_Unknown = 0x00000004, - WGPUErrorType_DeviceLost = 0x00000005, + WGPUErrorType_NoError = 0x00000001, + WGPUErrorType_Validation = 0x00000002, + WGPUErrorType_OutOfMemory = 0x00000003, + WGPUErrorType_Internal = 0x00000004, + WGPUErrorType_Unknown = 0x00000005, WGPUErrorType_Force32 = 0x7FFFFFFF } WGPUErrorType WGPU_ENUM_ATTRIBUTE; +/** + * See @ref WGPURequestAdapterOptions::featureLevel. + */ +typedef enum WGPUFeatureLevel { + /** + * `0x00000001`. + * "Compatibility" profile which can be supported on OpenGL ES 3.1. + */ + WGPUFeatureLevel_Compatibility = 0x00000001, + /** + * `0x00000002`. + * "Core" profile which can be supported on Vulkan/Metal/D3D12. + */ + WGPUFeatureLevel_Core = 0x00000002, + WGPUFeatureLevel_Force32 = 0x7FFFFFFF +} WGPUFeatureLevel WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUFeatureName { WGPUFeatureName_Undefined = 0x00000000, WGPUFeatureName_DepthClipControl = 0x00000001, WGPUFeatureName_Depth32FloatStencil8 = 0x00000002, WGPUFeatureName_TimestampQuery = 0x00000003, WGPUFeatureName_TextureCompressionBC = 0x00000004, - WGPUFeatureName_TextureCompressionETC2 = 0x00000005, - WGPUFeatureName_TextureCompressionASTC = 0x00000006, - WGPUFeatureName_IndirectFirstInstance = 0x00000007, - WGPUFeatureName_ShaderF16 = 0x00000008, - WGPUFeatureName_RG11B10UfloatRenderable = 0x00000009, - WGPUFeatureName_BGRA8UnormStorage = 0x0000000A, - WGPUFeatureName_Float32Filterable = 0x0000000B, + WGPUFeatureName_TextureCompressionBCSliced3D = 0x00000005, + WGPUFeatureName_TextureCompressionETC2 = 0x00000006, + WGPUFeatureName_TextureCompressionASTC = 0x00000007, + WGPUFeatureName_TextureCompressionASTCSliced3D = 0x00000008, + WGPUFeatureName_IndirectFirstInstance = 0x00000009, + WGPUFeatureName_ShaderF16 = 0x0000000A, + WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000B, + WGPUFeatureName_BGRA8UnormStorage = 0x0000000C, + WGPUFeatureName_Float32Filterable = 0x0000000D, + WGPUFeatureName_Float32Blendable = 0x0000000E, + WGPUFeatureName_ClipDistances = 0x0000000F, + WGPUFeatureName_DualSourceBlending = 0x00000010, WGPUFeatureName_Force32 = 0x7FFFFFFF } WGPUFeatureName WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFilterMode { - WGPUFilterMode_Nearest = 0x00000000, - WGPUFilterMode_Linear = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFilterMode_Undefined = 0x00000000, + WGPUFilterMode_Nearest = 0x00000001, + WGPUFilterMode_Linear = 0x00000002, WGPUFilterMode_Force32 = 0x7FFFFFFF } WGPUFilterMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFrontFace { - WGPUFrontFace_CCW = 0x00000000, - WGPUFrontFace_CW = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFrontFace_Undefined = 0x00000000, + WGPUFrontFace_CCW = 0x00000001, + WGPUFrontFace_CW = 0x00000002, WGPUFrontFace_Force32 = 0x7FFFFFFF } WGPUFrontFace WGPU_ENUM_ATTRIBUTE; typedef enum WGPUIndexFormat { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUIndexFormat_Undefined = 0x00000000, WGPUIndexFormat_Uint16 = 0x00000001, WGPUIndexFormat_Uint32 = 0x00000002, @@ -395,147 +579,318 @@ typedef enum WGPUIndexFormat { } WGPUIndexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPULoadOp { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPULoadOp_Undefined = 0x00000000, - WGPULoadOp_Clear = 0x00000001, - WGPULoadOp_Load = 0x00000002, + WGPULoadOp_Load = 0x00000001, + WGPULoadOp_Clear = 0x00000002, WGPULoadOp_Force32 = 0x7FFFFFFF } WGPULoadOp WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUMapAsyncStatus { + WGPUMapAsyncStatus_Success = 0x00000001, + WGPUMapAsyncStatus_InstanceDropped = 0x00000002, + WGPUMapAsyncStatus_Error = 0x00000003, + WGPUMapAsyncStatus_Aborted = 0x00000004, + WGPUMapAsyncStatus_Unknown = 0x00000005, + WGPUMapAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUMapAsyncStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUMipmapFilterMode { - WGPUMipmapFilterMode_Nearest = 0x00000000, - WGPUMipmapFilterMode_Linear = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUMipmapFilterMode_Undefined = 0x00000000, + WGPUMipmapFilterMode_Nearest = 0x00000001, + WGPUMipmapFilterMode_Linear = 0x00000002, WGPUMipmapFilterMode_Force32 = 0x7FFFFFFF } WGPUMipmapFilterMode WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUOptionalBool { + WGPUOptionalBool_False = 0x00000000, + WGPUOptionalBool_True = 0x00000001, + WGPUOptionalBool_Undefined = 0x00000002, + WGPUOptionalBool_Force32 = 0x7FFFFFFF +} WGPUOptionalBool WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUPopErrorScopeStatus { + /** + * `0x00000001`. + * The error scope stack was successfully popped and a result was reported. + */ + WGPUPopErrorScopeStatus_Success = 0x00000001, + WGPUPopErrorScopeStatus_InstanceDropped = 0x00000002, + /** + * `0x00000003`. + * The error scope stack could not be popped, because it was empty. + */ + WGPUPopErrorScopeStatus_EmptyStack = 0x00000003, + WGPUPopErrorScopeStatus_Force32 = 0x7FFFFFFF +} WGPUPopErrorScopeStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUPowerPreference { + /** + * `0x00000000`. + * No preference. (See also @ref SentinelValues.) + */ WGPUPowerPreference_Undefined = 0x00000000, WGPUPowerPreference_LowPower = 0x00000001, WGPUPowerPreference_HighPerformance = 0x00000002, WGPUPowerPreference_Force32 = 0x7FFFFFFF } WGPUPowerPreference WGPU_ENUM_ATTRIBUTE; +/** + * Describes when and in which order frames are presented on the screen when `::wgpuSurfacePresent` is called. + */ typedef enum WGPUPresentMode { - WGPUPresentMode_Fifo = 0x00000000, - WGPUPresentMode_FifoRelaxed = 0x00000001, - WGPUPresentMode_Immediate = 0x00000002, - WGPUPresentMode_Mailbox = 0x00000003, + /** + * `0x00000000`. + * Present mode is not specified. Use the default. + */ + WGPUPresentMode_Undefined = 0x00000000, + /** + * `0x00000001`. + * The presentation of the image to the user waits for the next vertical blanking period to update in a first-in, first-out manner. + * Tearing cannot be observed and frame-loop will be limited to the display's refresh rate. + * This is the only mode that's always available. + */ + WGPUPresentMode_Fifo = 0x00000001, + /** + * `0x00000002`. + * The presentation of the image to the user tries to wait for the next vertical blanking period but may decide to not wait if a frame is presented late. + * Tearing can sometimes be observed but late-frame don't produce a full-frame stutter in the presentation. + * This is still a first-in, first-out mechanism so a frame-loop will be limited to the display's refresh rate. + */ + WGPUPresentMode_FifoRelaxed = 0x00000002, + /** + * `0x00000003`. + * The presentation of the image to the user is updated immediately without waiting for a vertical blank. + * Tearing can be observed but latency is minimized. + */ + WGPUPresentMode_Immediate = 0x00000003, + /** + * `0x00000004`. + * The presentation of the image to the user waits for the next vertical blanking period to update to the latest provided image. + * Tearing cannot be observed and a frame-loop is not limited to the display's refresh rate. + */ + WGPUPresentMode_Mailbox = 0x00000004, WGPUPresentMode_Force32 = 0x7FFFFFFF } WGPUPresentMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPrimitiveTopology { - WGPUPrimitiveTopology_PointList = 0x00000000, - WGPUPrimitiveTopology_LineList = 0x00000001, - WGPUPrimitiveTopology_LineStrip = 0x00000002, - WGPUPrimitiveTopology_TriangleList = 0x00000003, - WGPUPrimitiveTopology_TriangleStrip = 0x00000004, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUPrimitiveTopology_Undefined = 0x00000000, + WGPUPrimitiveTopology_PointList = 0x00000001, + WGPUPrimitiveTopology_LineList = 0x00000002, + WGPUPrimitiveTopology_LineStrip = 0x00000003, + WGPUPrimitiveTopology_TriangleList = 0x00000004, + WGPUPrimitiveTopology_TriangleStrip = 0x00000005, WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF } WGPUPrimitiveTopology WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueryType { - WGPUQueryType_Occlusion = 0x00000000, - WGPUQueryType_Timestamp = 0x00000001, + WGPUQueryType_Occlusion = 0x00000001, + WGPUQueryType_Timestamp = 0x00000002, WGPUQueryType_Force32 = 0x7FFFFFFF } WGPUQueryType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueueWorkDoneStatus { - WGPUQueueWorkDoneStatus_Success = 0x00000000, - WGPUQueueWorkDoneStatus_Error = 0x00000001, - WGPUQueueWorkDoneStatus_Unknown = 0x00000002, - WGPUQueueWorkDoneStatus_DeviceLost = 0x00000003, + WGPUQueueWorkDoneStatus_Success = 0x00000001, + WGPUQueueWorkDoneStatus_InstanceDropped = 0x00000002, + WGPUQueueWorkDoneStatus_Error = 0x00000003, + WGPUQueueWorkDoneStatus_Unknown = 0x00000004, WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF } WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestAdapterStatus { - WGPURequestAdapterStatus_Success = 0x00000000, - WGPURequestAdapterStatus_Unavailable = 0x00000001, - WGPURequestAdapterStatus_Error = 0x00000002, - WGPURequestAdapterStatus_Unknown = 0x00000003, + WGPURequestAdapterStatus_Success = 0x00000001, + WGPURequestAdapterStatus_InstanceDropped = 0x00000002, + WGPURequestAdapterStatus_Unavailable = 0x00000003, + WGPURequestAdapterStatus_Error = 0x00000004, + WGPURequestAdapterStatus_Unknown = 0x00000005, WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF } WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestDeviceStatus { - WGPURequestDeviceStatus_Success = 0x00000000, - WGPURequestDeviceStatus_Error = 0x00000001, - WGPURequestDeviceStatus_Unknown = 0x00000002, + WGPURequestDeviceStatus_Success = 0x00000001, + WGPURequestDeviceStatus_InstanceDropped = 0x00000002, + WGPURequestDeviceStatus_Error = 0x00000003, + WGPURequestDeviceStatus_Unknown = 0x00000004, WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF } WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSType { - WGPUSType_Invalid = 0x00000000, - WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, - WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, - WGPUSType_SurfaceDescriptorFromXlibWindow = 0x00000003, - WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004, - WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, - WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, - WGPUSType_PrimitiveDepthClipControl = 0x00000007, - WGPUSType_SurfaceDescriptorFromWaylandSurface = 0x00000008, - WGPUSType_SurfaceDescriptorFromAndroidNativeWindow = 0x00000009, - WGPUSType_SurfaceDescriptorFromXcbWindow = 0x0000000A, - WGPUSType_RenderPassDescriptorMaxDrawCount = 0x0000000F, + WGPUSType_ShaderSourceSPIRV = 0x00000001, + WGPUSType_ShaderSourceWGSL = 0x00000002, + WGPUSType_RenderPassMaxDrawCount = 0x00000003, + WGPUSType_SurfaceSourceMetalLayer = 0x00000004, + WGPUSType_SurfaceSourceWindowsHWND = 0x00000005, + WGPUSType_SurfaceSourceXlibWindow = 0x00000006, + WGPUSType_SurfaceSourceWaylandSurface = 0x00000007, + WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008, + WGPUSType_SurfaceSourceXCBWindow = 0x00000009, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSamplerBindingType { - WGPUSamplerBindingType_Undefined = 0x00000000, - WGPUSamplerBindingType_Filtering = 0x00000001, - WGPUSamplerBindingType_NonFiltering = 0x00000002, - WGPUSamplerBindingType_Comparison = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUSamplerBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUSamplerBindingType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUSamplerBindingType_Undefined = 0x00000001, + WGPUSamplerBindingType_Filtering = 0x00000002, + WGPUSamplerBindingType_NonFiltering = 0x00000003, + WGPUSamplerBindingType_Comparison = 0x00000004, WGPUSamplerBindingType_Force32 = 0x7FFFFFFF } WGPUSamplerBindingType WGPU_ENUM_ATTRIBUTE; +/** + * Status code returned (synchronously) from many operations. Generally + * indicates an invalid input like an unknown enum value or @ref OutStructChainError. + * Read the function's documentation for specific error conditions. + */ +typedef enum WGPUStatus { + WGPUStatus_Success = 0x00000001, + WGPUStatus_Error = 0x00000002, + WGPUStatus_Force32 = 0x7FFFFFFF +} WGPUStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUStencilOperation { - WGPUStencilOperation_Keep = 0x00000000, - WGPUStencilOperation_Zero = 0x00000001, - WGPUStencilOperation_Replace = 0x00000002, - WGPUStencilOperation_Invert = 0x00000003, - WGPUStencilOperation_IncrementClamp = 0x00000004, - WGPUStencilOperation_DecrementClamp = 0x00000005, - WGPUStencilOperation_IncrementWrap = 0x00000006, - WGPUStencilOperation_DecrementWrap = 0x00000007, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUStencilOperation_Undefined = 0x00000000, + WGPUStencilOperation_Keep = 0x00000001, + WGPUStencilOperation_Zero = 0x00000002, + WGPUStencilOperation_Replace = 0x00000003, + WGPUStencilOperation_Invert = 0x00000004, + WGPUStencilOperation_IncrementClamp = 0x00000005, + WGPUStencilOperation_DecrementClamp = 0x00000006, + WGPUStencilOperation_IncrementWrap = 0x00000007, + WGPUStencilOperation_DecrementWrap = 0x00000008, WGPUStencilOperation_Force32 = 0x7FFFFFFF } WGPUStencilOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStorageTextureAccess { - WGPUStorageTextureAccess_Undefined = 0x00000000, - WGPUStorageTextureAccess_WriteOnly = 0x00000001, - WGPUStorageTextureAccess_ReadOnly = 0x00000002, - WGPUStorageTextureAccess_ReadWrite = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUStorageTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUStorageTextureAccess_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUStorageTextureAccess_Undefined = 0x00000001, + WGPUStorageTextureAccess_WriteOnly = 0x00000002, + WGPUStorageTextureAccess_ReadOnly = 0x00000003, + WGPUStorageTextureAccess_ReadWrite = 0x00000004, WGPUStorageTextureAccess_Force32 = 0x7FFFFFFF } WGPUStorageTextureAccess WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStoreOp { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUStoreOp_Undefined = 0x00000000, WGPUStoreOp_Store = 0x00000001, WGPUStoreOp_Discard = 0x00000002, WGPUStoreOp_Force32 = 0x7FFFFFFF } WGPUStoreOp WGPU_ENUM_ATTRIBUTE; +/** + * The status enum for `::wgpuSurfaceGetCurrentTexture`. + */ typedef enum WGPUSurfaceGetCurrentTextureStatus { - WGPUSurfaceGetCurrentTextureStatus_Success = 0x00000000, - WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000001, - WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000002, - WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000003, - WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000004, - WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000005, + /** + * `0x00000001`. + * Yay! Everything is good and we can render this frame. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal = 0x00000001, + /** + * `0x00000002`. + * Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal = 0x00000002, + /** + * `0x00000003`. + * Some operation timed out while trying to acquire the frame. + */ + WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000003, + /** + * `0x00000004`. + * The surface is too different to be used, compared to when it was originally created. + */ + WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000004, + /** + * `0x00000005`. + * The connection to whatever owns the surface was lost. + */ + WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000005, + /** + * `0x00000006`. + * The system ran out of memory. + */ + WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000006, + /** + * `0x00000007`. + * The @ref WGPUDevice configured on the @ref WGPUSurface was lost. + */ + WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000007, + /** + * `0x00000008`. + * The surface is not configured, or there was an @ref OutStructChainError. + */ + WGPUSurfaceGetCurrentTextureStatus_Error = 0x00000008, WGPUSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF } WGPUSurfaceGetCurrentTextureStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureAspect { - WGPUTextureAspect_All = 0x00000000, - WGPUTextureAspect_StencilOnly = 0x00000001, - WGPUTextureAspect_DepthOnly = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureAspect_Undefined = 0x00000000, + WGPUTextureAspect_All = 0x00000001, + WGPUTextureAspect_StencilOnly = 0x00000002, + WGPUTextureAspect_DepthOnly = 0x00000003, WGPUTextureAspect_Force32 = 0x7FFFFFFF } WGPUTextureAspect WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureDimension { - WGPUTextureDimension_1D = 0x00000000, - WGPUTextureDimension_2D = 0x00000001, - WGPUTextureDimension_3D = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureDimension_Undefined = 0x00000000, + WGPUTextureDimension_1D = 0x00000001, + WGPUTextureDimension_2D = 0x00000002, + WGPUTextureDimension_3D = 0x00000003, WGPUTextureDimension_Force32 = 0x7FFFFFFF } WGPUTextureDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureFormat { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUTextureFormat_Undefined = 0x00000000, WGPUTextureFormat_R8Unorm = 0x00000001, WGPUTextureFormat_R8Snorm = 0x00000002, @@ -636,16 +991,31 @@ typedef enum WGPUTextureFormat { } WGPUTextureFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureSampleType { - WGPUTextureSampleType_Undefined = 0x00000000, - WGPUTextureSampleType_Float = 0x00000001, - WGPUTextureSampleType_UnfilterableFloat = 0x00000002, - WGPUTextureSampleType_Depth = 0x00000003, - WGPUTextureSampleType_Sint = 0x00000004, - WGPUTextureSampleType_Uint = 0x00000005, + /** + * `0x00000000`. + * Indicates that this @ref WGPUTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUTextureSampleType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureSampleType_Undefined = 0x00000001, + WGPUTextureSampleType_Float = 0x00000002, + WGPUTextureSampleType_UnfilterableFloat = 0x00000003, + WGPUTextureSampleType_Depth = 0x00000004, + WGPUTextureSampleType_Sint = 0x00000005, + WGPUTextureSampleType_Uint = 0x00000006, WGPUTextureSampleType_Force32 = 0x7FFFFFFF } WGPUTextureSampleType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureViewDimension { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUTextureViewDimension_Undefined = 0x00000000, WGPUTextureViewDimension_1D = 0x00000001, WGPUTextureViewDimension_2D = 0x00000002, @@ -657,148 +1027,241 @@ typedef enum WGPUTextureViewDimension { } WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexFormat { - WGPUVertexFormat_Undefined = 0x00000000, - WGPUVertexFormat_Uint8x2 = 0x00000001, - WGPUVertexFormat_Uint8x4 = 0x00000002, - WGPUVertexFormat_Sint8x2 = 0x00000003, - WGPUVertexFormat_Sint8x4 = 0x00000004, - WGPUVertexFormat_Unorm8x2 = 0x00000005, - WGPUVertexFormat_Unorm8x4 = 0x00000006, - WGPUVertexFormat_Snorm8x2 = 0x00000007, - WGPUVertexFormat_Snorm8x4 = 0x00000008, - WGPUVertexFormat_Uint16x2 = 0x00000009, - WGPUVertexFormat_Uint16x4 = 0x0000000A, - WGPUVertexFormat_Sint16x2 = 0x0000000B, - WGPUVertexFormat_Sint16x4 = 0x0000000C, - WGPUVertexFormat_Unorm16x2 = 0x0000000D, - WGPUVertexFormat_Unorm16x4 = 0x0000000E, - WGPUVertexFormat_Snorm16x2 = 0x0000000F, - WGPUVertexFormat_Snorm16x4 = 0x00000010, - WGPUVertexFormat_Float16x2 = 0x00000011, - WGPUVertexFormat_Float16x4 = 0x00000012, - WGPUVertexFormat_Float32 = 0x00000013, - WGPUVertexFormat_Float32x2 = 0x00000014, - WGPUVertexFormat_Float32x3 = 0x00000015, - WGPUVertexFormat_Float32x4 = 0x00000016, - WGPUVertexFormat_Uint32 = 0x00000017, - WGPUVertexFormat_Uint32x2 = 0x00000018, - WGPUVertexFormat_Uint32x3 = 0x00000019, - WGPUVertexFormat_Uint32x4 = 0x0000001A, - WGPUVertexFormat_Sint32 = 0x0000001B, - WGPUVertexFormat_Sint32x2 = 0x0000001C, - WGPUVertexFormat_Sint32x3 = 0x0000001D, - WGPUVertexFormat_Sint32x4 = 0x0000001E, + WGPUVertexFormat_Uint8 = 0x00000001, + WGPUVertexFormat_Uint8x2 = 0x00000002, + WGPUVertexFormat_Uint8x4 = 0x00000003, + WGPUVertexFormat_Sint8 = 0x00000004, + WGPUVertexFormat_Sint8x2 = 0x00000005, + WGPUVertexFormat_Sint8x4 = 0x00000006, + WGPUVertexFormat_Unorm8 = 0x00000007, + WGPUVertexFormat_Unorm8x2 = 0x00000008, + WGPUVertexFormat_Unorm8x4 = 0x00000009, + WGPUVertexFormat_Snorm8 = 0x0000000A, + WGPUVertexFormat_Snorm8x2 = 0x0000000B, + WGPUVertexFormat_Snorm8x4 = 0x0000000C, + WGPUVertexFormat_Uint16 = 0x0000000D, + WGPUVertexFormat_Uint16x2 = 0x0000000E, + WGPUVertexFormat_Uint16x4 = 0x0000000F, + WGPUVertexFormat_Sint16 = 0x00000010, + WGPUVertexFormat_Sint16x2 = 0x00000011, + WGPUVertexFormat_Sint16x4 = 0x00000012, + WGPUVertexFormat_Unorm16 = 0x00000013, + WGPUVertexFormat_Unorm16x2 = 0x00000014, + WGPUVertexFormat_Unorm16x4 = 0x00000015, + WGPUVertexFormat_Snorm16 = 0x00000016, + WGPUVertexFormat_Snorm16x2 = 0x00000017, + WGPUVertexFormat_Snorm16x4 = 0x00000018, + WGPUVertexFormat_Float16 = 0x00000019, + WGPUVertexFormat_Float16x2 = 0x0000001A, + WGPUVertexFormat_Float16x4 = 0x0000001B, + WGPUVertexFormat_Float32 = 0x0000001C, + WGPUVertexFormat_Float32x2 = 0x0000001D, + WGPUVertexFormat_Float32x3 = 0x0000001E, + WGPUVertexFormat_Float32x4 = 0x0000001F, + WGPUVertexFormat_Uint32 = 0x00000020, + WGPUVertexFormat_Uint32x2 = 0x00000021, + WGPUVertexFormat_Uint32x3 = 0x00000022, + WGPUVertexFormat_Uint32x4 = 0x00000023, + WGPUVertexFormat_Sint32 = 0x00000024, + WGPUVertexFormat_Sint32x2 = 0x00000025, + WGPUVertexFormat_Sint32x3 = 0x00000026, + WGPUVertexFormat_Sint32x4 = 0x00000027, + WGPUVertexFormat_Unorm10_10_10_2 = 0x00000028, + WGPUVertexFormat_Unorm8x4BGRA = 0x00000029, WGPUVertexFormat_Force32 = 0x7FFFFFFF } WGPUVertexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexStepMode { - WGPUVertexStepMode_Vertex = 0x00000000, - WGPUVertexStepMode_Instance = 0x00000001, - WGPUVertexStepMode_VertexBufferNotUsed = 0x00000002, + /** + * `0x00000000`. + * This @ref WGPUVertexBufferLayout is a "hole" in the @ref WGPUVertexState `buffers` array. + * (See also @ref SentinelValues.) + */ + WGPUVertexStepMode_VertexBufferNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUVertexStepMode_Undefined = 0x00000001, + WGPUVertexStepMode_Vertex = 0x00000002, + WGPUVertexStepMode_Instance = 0x00000003, WGPUVertexStepMode_Force32 = 0x7FFFFFFF } WGPUVertexStepMode WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUWGSLFeatureName { - WGPUWGSLFeatureName_Undefined = 0x00000000, - WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, - WGPUWGSLFeatureName_Packed4x8IntegerDotProduct = 0x00000002, - WGPUWGSLFeatureName_UnrestrictedPointerParameters = 0x00000003, - WGPUWGSLFeatureName_PointerCompositeAccess = 0x00000004, - WGPUWGSLFeatureName_Force32 = 0x7FFFFFFF -} WGPUWGSLFeatureName WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUWGSLLanguageFeatureName { + WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, + WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct = 0x00000002, + WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters = 0x00000003, + WGPUWGSLLanguageFeatureName_PointerCompositeAccess = 0x00000004, + WGPUWGSLLanguageFeatureName_Force32 = 0x7FFFFFFF +} WGPUWGSLLanguageFeatureName WGPU_ENUM_ATTRIBUTE; + +/** + * Status returned from a call to ::wgpuInstanceWaitAny. + */ +typedef enum WGPUWaitStatus { + /** + * `0x00000001`. + * At least one WGPUFuture completed successfully. + */ + WGPUWaitStatus_Success = 0x00000001, + /** + * `0x00000002`. + * No WGPUFutures completed within the timeout. + */ + WGPUWaitStatus_TimedOut = 0x00000002, + /** + * `0x00000003`. + * A @ref Timed-Wait was performed when WGPUInstanceFeatures::timedWaitAnyEnable is false. + */ + WGPUWaitStatus_UnsupportedTimeout = 0x00000003, + /** + * `0x00000004`. + * The number of futures waited on in a @ref Timed-Wait is greater than the supported WGPUInstanceFeatures::timedWaitAnyMaxCount. + */ + WGPUWaitStatus_UnsupportedCount = 0x00000004, + /** + * `0x00000005`. + * An invalid wait was performed with @ref Mixed-Sources. + */ + WGPUWaitStatus_UnsupportedMixedSources = 0x00000005, + WGPUWaitStatus_Force32 = 0x7FFFFFFF +} WGPUWaitStatus WGPU_ENUM_ATTRIBUTE; /** @} */ /** * \defgroup Bitflags - * \brief Enum used as bit flags. - * + * \brief Type and constant definitions for bitflag types. + * * @{ */ -typedef enum WGPUBufferUsage { - WGPUBufferUsage_None = 0x00000000, - WGPUBufferUsage_MapRead = 0x00000001, - WGPUBufferUsage_MapWrite = 0x00000002, - WGPUBufferUsage_CopySrc = 0x00000004, - WGPUBufferUsage_CopyDst = 0x00000008, - WGPUBufferUsage_Index = 0x00000010, - WGPUBufferUsage_Vertex = 0x00000020, - WGPUBufferUsage_Uniform = 0x00000040, - WGPUBufferUsage_Storage = 0x00000080, - WGPUBufferUsage_Indirect = 0x00000100, - WGPUBufferUsage_QueryResolve = 0x00000200, - WGPUBufferUsage_Force32 = 0x7FFFFFFF -} WGPUBufferUsage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUBufferUsageFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUColorWriteMask { - WGPUColorWriteMask_None = 0x00000000, - WGPUColorWriteMask_Red = 0x00000001, - WGPUColorWriteMask_Green = 0x00000002, - WGPUColorWriteMask_Blue = 0x00000004, - WGPUColorWriteMask_Alpha = 0x00000008, - WGPUColorWriteMask_All = WGPUColorWriteMask_None | WGPUColorWriteMask_Red | WGPUColorWriteMask_Green | WGPUColorWriteMask_Blue | WGPUColorWriteMask_Alpha, - WGPUColorWriteMask_Force32 = 0x7FFFFFFF -} WGPUColorWriteMask WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUColorWriteMaskFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUMapMode { - WGPUMapMode_None = 0x00000000, - WGPUMapMode_Read = 0x00000001, - WGPUMapMode_Write = 0x00000002, - WGPUMapMode_Force32 = 0x7FFFFFFF -} WGPUMapMode WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUMapModeFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUShaderStage { - WGPUShaderStage_None = 0x00000000, - WGPUShaderStage_Vertex = 0x00000001, - WGPUShaderStage_Fragment = 0x00000002, - WGPUShaderStage_Compute = 0x00000004, - WGPUShaderStage_Force32 = 0x7FFFFFFF -} WGPUShaderStage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUShaderStageFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUTextureUsage { - WGPUTextureUsage_None = 0x00000000, - WGPUTextureUsage_CopySrc = 0x00000001, - WGPUTextureUsage_CopyDst = 0x00000002, - WGPUTextureUsage_TextureBinding = 0x00000004, - WGPUTextureUsage_StorageBinding = 0x00000008, - WGPUTextureUsage_RenderAttachment = 0x00000010, - WGPUTextureUsage_Force32 = 0x7FFFFFFF -} WGPUTextureUsage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUTextureUsageFlags WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUBufferUsage; +static const WGPUBufferUsage WGPUBufferUsage_None = 0x0000000000000000; +static const WGPUBufferUsage WGPUBufferUsage_MapRead = 0x0000000000000001; +static const WGPUBufferUsage WGPUBufferUsage_MapWrite = 0x0000000000000002; +static const WGPUBufferUsage WGPUBufferUsage_CopySrc = 0x0000000000000004; +static const WGPUBufferUsage WGPUBufferUsage_CopyDst = 0x0000000000000008; +static const WGPUBufferUsage WGPUBufferUsage_Index = 0x0000000000000010; +static const WGPUBufferUsage WGPUBufferUsage_Vertex = 0x0000000000000020; +static const WGPUBufferUsage WGPUBufferUsage_Uniform = 0x0000000000000040; +static const WGPUBufferUsage WGPUBufferUsage_Storage = 0x0000000000000080; +static const WGPUBufferUsage WGPUBufferUsage_Indirect = 0x0000000000000100; +static const WGPUBufferUsage WGPUBufferUsage_QueryResolve = 0x0000000000000200; + +typedef WGPUFlags WGPUColorWriteMask; +static const WGPUColorWriteMask WGPUColorWriteMask_None = 0x0000000000000000; +static const WGPUColorWriteMask WGPUColorWriteMask_Red = 0x0000000000000001; +static const WGPUColorWriteMask WGPUColorWriteMask_Green = 0x0000000000000002; +static const WGPUColorWriteMask WGPUColorWriteMask_Blue = 0x0000000000000004; +static const WGPUColorWriteMask WGPUColorWriteMask_Alpha = 0x0000000000000008; +static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F /* Red | Green | Blue | Alpha */; + +typedef WGPUFlags WGPUMapMode; +static const WGPUMapMode WGPUMapMode_None = 0x0000000000000000; +static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001; +static const WGPUMapMode WGPUMapMode_Write = 0x0000000000000002; + +typedef WGPUFlags WGPUShaderStage; +static const WGPUShaderStage WGPUShaderStage_None = 0x0000000000000000; +static const WGPUShaderStage WGPUShaderStage_Vertex = 0x0000000000000001; +static const WGPUShaderStage WGPUShaderStage_Fragment = 0x0000000000000002; +static const WGPUShaderStage WGPUShaderStage_Compute = 0x0000000000000004; + +typedef WGPUFlags WGPUTextureUsage; +static const WGPUTextureUsage WGPUTextureUsage_None = 0x0000000000000000; +static const WGPUTextureUsage WGPUTextureUsage_CopySrc = 0x0000000000000001; +static const WGPUTextureUsage WGPUTextureUsage_CopyDst = 0x0000000000000002; +static const WGPUTextureUsage WGPUTextureUsage_TextureBinding = 0x0000000000000004; +static const WGPUTextureUsage WGPUTextureUsage_StorageBinding = 0x0000000000000008; +static const WGPUTextureUsage WGPUTextureUsage_RenderAttachment = 0x0000000000000010; /** @} */ typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup Callbacks * \brief Callbacks through which asynchronous functions return. - * + * * @{ */ - -typedef void (*WGPUAdapterRequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUBufferMapAsyncCallback)(WGPUBufferMapAsyncStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUInstanceRequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUQueueOnSubmittedWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUShaderModuleGetCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; - +/** + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUBufferMapCallback)(WGPUMapAsyncStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param compilationInfo + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * Reference to the device which was lost. If, and only if, the `reason` is @ref WGPUDeviceLostReason_FailedCreation, this is a non-null pointer to a null @ref WGPUDevice. + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUDeviceLostCallback)(WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param status + * See @ref WGPUPopErrorScopeStatus. + * + * @param type + * The type of the error caught by the scope, or @ref WGPUErrorType_NoError if there was none. + * If the `status` is not @ref WGPUPopErrorScopeStatus_Success, this is @ref WGPUErrorType_NoError. + * + * @param message + * If the `type` is not @ref WGPUErrorType_NoError, this is a non-empty @ref LocalizableHumanReadableMessageString; + * otherwise, this is an empty string. + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUPopErrorScopeCallback)(WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param adapter + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUUncapturedErrorCallback)(WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; /** @} */ /** * \defgroup ChainedStructures Chained Structures * \brief Structures used to extend descriptors. - * + * * @{ */ @@ -818,15 +1281,115 @@ typedef struct WGPUChainedStructOut { /** * \defgroup Structures * \brief Descriptors and other transparent structures. - * + * + * @{ + */ + + /** + * \defgroup WGPUCallbackInfo + * \brief Callback info structures that are used in asynchronous functions. + * * @{ */ +typedef struct WGPUBufferMapCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUBufferMapCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUBufferMapCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCompilationInfoCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCompilationInfoCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCompilationInfoCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateComputePipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCreateComputePipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateComputePipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateRenderPipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCreateRenderPipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateRenderPipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUDeviceLostCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUDeviceLostCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUDeviceLostCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUPopErrorScopeCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUPopErrorScopeCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUPopErrorScopeCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUQueueWorkDoneCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUQueueWorkDoneCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUQueueWorkDoneCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestAdapterCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPURequestAdapterCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestAdapterCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestDeviceCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPURequestDeviceCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestDeviceCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUUncapturedErrorCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUUncapturedErrorCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** @} */ + typedef struct WGPUAdapterInfo { WGPUChainedStructOut * nextInChain; - char const * vendor; - char const * architecture; - char const * device; - char const * description; + /** + * This is an \ref OutputString. + */ + WGPUStringView vendor; + /** + * This is an \ref OutputString. + */ + WGPUStringView architecture; + /** + * This is an \ref OutputString. + */ + WGPUStringView device; + /** + * This is an \ref OutputString. + */ + WGPUStringView description; WGPUBackendType backendType; WGPUAdapterType adapterType; uint32_t vendorID; @@ -858,8 +1421,11 @@ typedef struct WGPUBufferBindingLayout { typedef struct WGPUBufferDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - WGPUBufferUsageFlags usage; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + WGPUBufferUsage usage; uint64_t size; WGPUBool mappedAtCreation; } WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -873,25 +1439,48 @@ typedef struct WGPUColor { typedef struct WGPUCommandBufferDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUCommandBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCommandEncoderDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUCommandEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCompilationMessage { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * message; + /** + * A @ref LocalizableHumanReadableMessageString. + * + * This is an \ref OutputString. + */ + WGPUStringView message; + /** + * Severity level of the message. + */ WGPUCompilationMessageType type; + /** + * Line number where the message is attached, starting at 1. + */ uint64_t lineNum; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + */ uint64_t linePos; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + */ uint64_t offset; + /** + * Length in UTF-8 code units (bytes) of the span the message corresponds to. + */ uint64_t length; - uint64_t utf16LinePos; - uint64_t utf16Offset; - uint64_t utf16Length; } WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePassTimestampWrites { @@ -902,7 +1491,10 @@ typedef struct WGPUComputePassTimestampWrites { typedef struct WGPUConstantEntry { WGPUChainedStruct const * nextInChain; - char const * key; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView key; double value; } WGPUConstantEntry WGPU_STRUCTURE_ATTRIBUTE; @@ -912,11 +1504,35 @@ typedef struct WGPUExtent3D { uint32_t depthOrArrayLayers; } WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUInstanceDescriptor { - WGPUChainedStruct const * nextInChain; -} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Opaque handle to an asynchronous operation. See @ref Asynchronous-Operations for more information. + */ +typedef struct WGPUFuture { + /** + * Opaque id of the @ref WGPUFuture + */ + uint64_t id; +} WGPUFuture WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Features enabled on the WGPUInstance + */ +typedef struct WGPUInstanceCapabilities { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut * nextInChain; + /** + * Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + WGPUBool timedWaitAnyEnable; + /** + * The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + size_t timedWaitAnyMaxCount; +} WGPUInstanceCapabilities WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPULimits { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut * nextInChain; uint32_t maxTextureDimension1D; uint32_t maxTextureDimension2D; uint32_t maxTextureDimension3D; @@ -939,7 +1555,6 @@ typedef struct WGPULimits { uint64_t maxBufferSize; uint32_t maxVertexAttributes; uint32_t maxVertexBufferArrayStride; - uint32_t maxInterStageShaderComponents; uint32_t maxInterStageShaderVariables; uint32_t maxColorAttachments; uint32_t maxColorAttachmentBytesPerSample; @@ -966,44 +1581,55 @@ typedef struct WGPUOrigin3D { typedef struct WGPUPipelineLayoutDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t bindGroupLayoutCount; WGPUBindGroupLayout const * bindGroupLayouts; } WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUPrimitiveDepthClipControl { - WGPUChainedStruct chain; - WGPUBool unclippedDepth; -} WGPUPrimitiveDepthClipControl WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUPrimitiveState { WGPUChainedStruct const * nextInChain; WGPUPrimitiveTopology topology; WGPUIndexFormat stripIndexFormat; WGPUFrontFace frontFace; WGPUCullMode cullMode; + WGPUBool unclippedDepth; } WGPUPrimitiveState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQuerySetDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUQueryType type; uint32_t count; } WGPUQuerySetDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQueueDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUQueueDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPURenderBundleDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleEncoderDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t colorFormatCount; WGPUTextureFormat const * colorFormats; WGPUTextureFormat depthStencilFormat; @@ -1024,10 +1650,10 @@ typedef struct WGPURenderPassDepthStencilAttachment { WGPUBool stencilReadOnly; } WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURenderPassDescriptorMaxDrawCount { +typedef struct WGPURenderPassMaxDrawCount { WGPUChainedStruct chain; uint64_t maxDrawCount; -} WGPURenderPassDescriptorMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; +} WGPURenderPassMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassTimestampWrites { WGPUQuerySet querySet; @@ -1037,10 +1663,28 @@ typedef struct WGPURenderPassTimestampWrites { typedef struct WGPURequestAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE WGPUSurface compatibleSurface; + /** + * "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + * + * Implementations may ignore @ref WGPUFeatureLevel_Compatibility and provide @ref WGPUFeatureLevel_Core instead. @ref WGPUFeatureLevel_Core is the default in the JS API, but in C, this field is **required** (must not be undefined). + */ + WGPUFeatureLevel featureLevel; WGPUPowerPreference powerPreference; - WGPUBackendType backendType; + /** + * If true, requires the adapter to be a "fallback" adapter as defined by the JS spec. + * If this is not possible, the request returns null. + */ WGPUBool forceFallbackAdapter; + /** + * If set, requires the adapter to have a particular backend type. + * If this is not possible, the request returns null. + */ + WGPUBackendType backendType; + /** + * If set, requires the adapter to be able to output to a particular surface. + * If this is not possible, the request returns null. + */ + WGPU_NULLABLE WGPUSurface compatibleSurface; } WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSamplerBindingLayout { @@ -1050,7 +1694,10 @@ typedef struct WGPUSamplerBindingLayout { typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUAddressMode addressModeU; WGPUAddressMode addressModeV; WGPUAddressMode addressModeW; @@ -1063,22 +1710,27 @@ typedef struct WGPUSamplerDescriptor { uint16_t maxAnisotropy; } WGPUSamplerDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleCompilationHint { +typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; - char const * entryPoint; - WGPUPipelineLayout layout; -} WGPUShaderModuleCompilationHint WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; +} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleSPIRVDescriptor { +typedef struct WGPUShaderSourceSPIRV { WGPUChainedStruct chain; uint32_t codeSize; uint32_t const * code; -} WGPUShaderModuleSPIRVDescriptor WGPU_STRUCTURE_ATTRIBUTE; +} WGPUShaderSourceSPIRV WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleWGSLDescriptor { +typedef struct WGPUShaderSourceWGSL { WGPUChainedStruct chain; - char const * code; -} WGPUShaderModuleWGSLDescriptor WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView code; +} WGPUShaderSourceWGSL WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUStencilFaceState { WGPUCompareFunction compare; @@ -1094,80 +1746,207 @@ typedef struct WGPUStorageTextureBindingLayout { WGPUTextureViewDimension viewDimension; } WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUSupportedFeatures { + size_t featureCount; + WGPUFeatureName const * features; +} WGPUSupportedFeatures WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUSupportedWGSLLanguageFeatures { + size_t featureCount; + WGPUWGSLLanguageFeatureName const * features; +} WGPUSupportedWGSLLanguageFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Filled by `::wgpuSurfaceGetCapabilities` with what's supported for `::wgpuSurfaceConfigure` for a pair of @ref WGPUSurface and @ref WGPUAdapter. + */ typedef struct WGPUSurfaceCapabilities { WGPUChainedStructOut * nextInChain; - WGPUTextureUsageFlags usages; + /** + * The bit set of supported @ref WGPUTextureUsage bits. + * Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + */ + WGPUTextureUsage usages; + /** + * A list of supported @ref WGPUTextureFormat values, in order of preference. + */ size_t formatCount; WGPUTextureFormat const * formats; + /** + * A list of supported @ref WGPUPresentMode values. + * Guaranteed to contain @ref WGPUPresentMode_Fifo. + */ size_t presentModeCount; WGPUPresentMode const * presentModes; + /** + * A list of supported @ref WGPUCompositeAlphaMode values. + * @ref WGPUCompositeAlphaMode_Auto will be an alias for the first element and will never be present in this array. + */ size_t alphaModeCount; WGPUCompositeAlphaMode const * alphaModes; } WGPUSurfaceCapabilities WGPU_STRUCTURE_ATTRIBUTE; +/** + * Options to `::wgpuSurfaceConfigure` for defining how a @ref WGPUSurface will be rendered to and presented to the user. + * See @ref Surface-Configuration for more details. + */ typedef struct WGPUSurfaceConfiguration { WGPUChainedStruct const * nextInChain; + /** + * The @ref WGPUDevice to use to render to surface's textures. + */ WGPUDevice device; + /** + * The @ref WGPUTextureFormat of the surface's textures. + */ WGPUTextureFormat format; - WGPUTextureUsageFlags usage; + /** + * The @ref WGPUTextureUsage of the surface's textures. + */ + WGPUTextureUsage usage; + /** + * The width of the surface's textures. + */ + uint32_t width; + /** + * The height of the surface's textures. + */ + uint32_t height; + /** + * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + */ size_t viewFormatCount; WGPUTextureFormat const * viewFormats; + /** + * How the surface's frames will be composited on the screen. + */ WGPUCompositeAlphaMode alphaMode; - uint32_t width; - uint32_t height; + /** + * When and in which order the surface's frames will be shown on the screen. Defaults to @ref WGPUPresentMode_Fifo. + */ WGPUPresentMode presentMode; } WGPUSurfaceConfiguration WGPU_STRUCTURE_ATTRIBUTE; +/** + * The root descriptor for the creation of an @ref WGPUSurface with `::wgpuInstanceCreateSurface`. + * It isn't sufficient by itself and must have one of the `WGPUSurfaceSource*` in its chain. + * See @ref Surface-Creation for more details. + */ typedef struct WGPUSurfaceDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * Label used to refer to the object. + * + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromAndroidNativeWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). + */ +typedef struct WGPUSurfaceSourceAndroidNativeWindow { WGPUChainedStruct chain; + /** + * The pointer to the [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window) that will be wrapped by the @ref WGPUSurface. + */ void * window; -} WGPUSurfaceDescriptorFromAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; - -typedef struct WGPUSurfaceDescriptorFromCanvasHTMLSelector { - WGPUChainedStruct chain; - char const * selector; -} WGPUSurfaceDescriptorFromCanvasHTMLSelector WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromMetalLayer { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). + */ +typedef struct WGPUSurfaceSourceMetalLayer { WGPUChainedStruct chain; + /** + * The pointer to the [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc) that will be wrapped by the @ref WGPUSurface. + */ void * layer; -} WGPUSurfaceDescriptorFromMetalLayer WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceMetalLayer WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromWaylandSurface { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [Wayland](https://wayland.freedesktop.org/) [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface). + */ +typedef struct WGPUSurfaceSourceWaylandSurface { WGPUChainedStruct chain; + /** + * A [`wl_display`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_display) for this Wayland instance. + */ void * display; + /** + * A [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface) that will be wrapped by the @ref WGPUSurface + */ void * surface; -} WGPUSurfaceDescriptorFromWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromWindowsHWND { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a Windows [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd). + */ +typedef struct WGPUSurfaceSourceWindowsHWND { WGPUChainedStruct chain; + /** + * The [`HINSTANCE`](https://learn.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point) for this application. + * Most commonly `GetModuleHandle(nullptr)`. + */ void * hinstance; + /** + * The [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd) that will be wrapped by the @ref WGPUSurface. + */ void * hwnd; -} WGPUSurfaceDescriptorFromWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromXcbWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. + */ +typedef struct WGPUSurfaceSourceXCBWindow { WGPUChainedStruct chain; + /** + * The `xcb_connection_t` for the connection to the X server. + */ void * connection; + /** + * The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + */ uint32_t window; -} WGPUSurfaceDescriptorFromXcbWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceXCBWindow WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromXlibWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. + */ +typedef struct WGPUSurfaceSourceXlibWindow { WGPUChainedStruct chain; + /** + * A pointer to the [`Display`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Opening_the_Display) connected to the X server. + */ void * display; + /** + * The [`Window`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Creating_Windows) that will be wrapped by the @ref WGPUSurface. + */ uint64_t window; -} WGPUSurfaceDescriptorFromXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +/** + * Queried each frame from a @ref WGPUSurface to get a @ref WGPUTexture to render to along with some metadata. + * See @ref Surface-Presenting for more details. + */ typedef struct WGPUSurfaceTexture { + WGPUChainedStructOut * nextInChain; + /** + * The @ref WGPUTexture representing the frame that will be shown on the surface. + * It is @ref ReturnedWithOwnership from @ref wgpuSurfaceGetCurrentTexture. + */ WGPUTexture texture; - WGPUBool suboptimal; + /** + * Whether the call to `::wgpuSurfaceGetCurrentTexture` succeeded and a hint as to why it might not have. + */ WGPUSurfaceGetCurrentTextureStatus status; } WGPUSurfaceTexture WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyBufferLayout { + uint64_t offset; + uint32_t bytesPerRow; + uint32_t rowsPerImage; +} WGPUTexelCopyBufferLayout WGPU_STRUCTURE_ATTRIBUTE; + typedef struct WGPUTextureBindingLayout { WGPUChainedStruct const * nextInChain; WGPUTextureSampleType sampleType; @@ -1175,16 +1954,12 @@ typedef struct WGPUTextureBindingLayout { WGPUBool multisampled; } WGPUTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUTextureDataLayout { - WGPUChainedStruct const * nextInChain; - uint64_t offset; - uint32_t bytesPerRow; - uint32_t rowsPerImage; -} WGPUTextureDataLayout WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUTextureViewDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUTextureFormat format; WGPUTextureViewDimension dimension; uint32_t baseMipLevel; @@ -1192,14 +1967,9 @@ typedef struct WGPUTextureViewDescriptor { uint32_t baseArrayLayer; uint32_t arrayLayerCount; WGPUTextureAspect aspect; + WGPUTextureUsage usage; } WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUUncapturedErrorCallbackInfo { - WGPUChainedStruct const * nextInChain; - WGPUErrorCallback callback; - void * userdata; -} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUVertexAttribute { WGPUVertexFormat format; uint64_t offset; @@ -1208,7 +1978,10 @@ typedef struct WGPUVertexAttribute { typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUBindGroupLayout layout; size_t entryCount; WGPUBindGroupEntry const * entries; @@ -1217,7 +1990,7 @@ typedef struct WGPUBindGroupDescriptor { typedef struct WGPUBindGroupLayoutEntry { WGPUChainedStruct const * nextInChain; uint32_t binding; - WGPUShaderStageFlags visibility; + WGPUShaderStage visibility; WGPUBufferBindingLayout buffer; WGPUSamplerBindingLayout sampler; WGPUTextureBindingLayout texture; @@ -1237,14 +2010,17 @@ typedef struct WGPUCompilationInfo { typedef struct WGPUComputePassDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUComputePassTimestampWrites const * timestampWrites; } WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUDepthStencilState { WGPUChainedStruct const * nextInChain; WGPUTextureFormat format; - WGPUBool depthWriteEnabled; + WGPUOptionalBool depthWriteEnabled; WGPUCompareFunction depthCompare; WGPUStencilFaceState stencilFront; WGPUStencilFaceState stencilBack; @@ -1255,24 +2031,49 @@ typedef struct WGPUDepthStencilState { float depthBiasClamp; } WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUImageCopyBuffer { +typedef struct WGPUDeviceDescriptor { WGPUChainedStruct const * nextInChain; - WGPUTextureDataLayout layout; - WGPUBuffer buffer; -} WGPUImageCopyBuffer WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + size_t requiredFeatureCount; + WGPUFeatureName const * requiredFeatures; + WGPU_NULLABLE WGPULimits const * requiredLimits; + WGPUQueueDescriptor defaultQueue; + WGPUDeviceLostCallbackInfo deviceLostCallbackInfo; + WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; +} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Struct holding a future to wait on, and a `completed` boolean flag. + */ +typedef struct WGPUFutureWaitInfo { + /** + * The future to wait on. + */ + WGPUFuture future; + /** + * Whether or not the future completed. + */ + WGPUBool completed; +} WGPUFutureWaitInfo WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUImageCopyTexture { +typedef struct WGPUInstanceDescriptor { WGPUChainedStruct const * nextInChain; - WGPUTexture texture; - uint32_t mipLevel; - WGPUOrigin3D origin; - WGPUTextureAspect aspect; -} WGPUImageCopyTexture WGPU_STRUCTURE_ATTRIBUTE; + /** + * Instance features to enable + */ + WGPUInstanceCapabilities features; +} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUProgrammableStageDescriptor { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; } WGPUProgrammableStageDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -1287,27 +2088,25 @@ typedef struct WGPURenderPassColorAttachment { WGPUColor clearValue; } WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURequiredLimits { - WGPUChainedStruct const * nextInChain; - WGPULimits limits; -} WGPURequiredLimits WGPU_STRUCTURE_ATTRIBUTE; - -typedef struct WGPUShaderModuleDescriptor { - WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - size_t hintCount; - WGPUShaderModuleCompilationHint const * hints; -} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyBufferInfo { + WGPUTexelCopyBufferLayout layout; + WGPUBuffer buffer; +} WGPUTexelCopyBufferInfo WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSupportedLimits { - WGPUChainedStructOut * nextInChain; - WGPULimits limits; -} WGPUSupportedLimits WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyTextureInfo { + WGPUTexture texture; + uint32_t mipLevel; + WGPUOrigin3D origin; + WGPUTextureAspect aspect; +} WGPUTexelCopyTextureInfo WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - WGPUTextureUsageFlags usage; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + WGPUTextureUsage usage; WGPUTextureDimension dimension; WGPUExtent3D size; WGPUTextureFormat format; @@ -1318,48 +2117,55 @@ typedef struct WGPUTextureDescriptor { } WGPUTextureDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexBufferLayout { - uint64_t arrayStride; + /** + * The step mode for the vertex buffer. If @ref WGPUVertexStepMode_VertexBufferNotUsed, + * indicates a "hole" in the parent @ref WGPUVertexState `buffers` array: + * the pipeline does not use a vertex buffer at this `location`. + */ WGPUVertexStepMode stepMode; + uint64_t arrayStride; size_t attributeCount; WGPUVertexAttribute const * attributes; } WGPUVertexBufferLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t entryCount; WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUColorTargetState { WGPUChainedStruct const * nextInChain; + /** + * The texture format of the target. If @ref WGPUTextureFormat_Undefined, + * indicates a "hole" in the parent @ref WGPUFragmentState `targets` array: + * the pipeline does not output a value at this `location`. + */ WGPUTextureFormat format; WGPU_NULLABLE WGPUBlendState const * blend; - WGPUColorWriteMaskFlags writeMask; + WGPUColorWriteMask writeMask; } WGPUColorTargetState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePipelineDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUPipelineLayout layout; WGPUProgrammableStageDescriptor compute; } WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUDeviceDescriptor { - WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - size_t requiredFeatureCount; - WGPUFeatureName const * requiredFeatures; - WGPU_NULLABLE WGPURequiredLimits const * requiredLimits; - WGPUQueueDescriptor defaultQueue; - WGPUDeviceLostCallback deviceLostCallback; - void * deviceLostUserdata; - WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; -} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPURenderPassDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t colorAttachmentCount; WGPURenderPassColorAttachment const * colorAttachments; WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; @@ -1370,7 +2176,10 @@ typedef struct WGPURenderPassDescriptor { typedef struct WGPUVertexState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; size_t bufferCount; @@ -1380,7 +2189,10 @@ typedef struct WGPUVertexState { typedef struct WGPUFragmentState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; size_t targetCount; @@ -1389,7 +2201,10 @@ typedef struct WGPUFragmentState { typedef struct WGPURenderPipelineDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUPipelineLayout layout; WGPUVertexState vertex; WGPUPrimitiveState primitive; @@ -1406,236 +2221,1007 @@ extern "C" { #if !defined(WGPU_SKIP_PROCS) +/** + * Proc pointer type for @ref wgpuCreateInstance: + * > @copydoc wgpuCreateInstance + */ typedef WGPUInstance (*WGPUProcCreateInstance)(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetInstanceCapabilities: + * > @copydoc wgpuGetInstanceCapabilities + */ +typedef WGPUStatus (*WGPUProcGetInstanceCapabilities)(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetProcAddress: + * > @copydoc wgpuGetProcAddress + */ +typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; // Procs of Adapter -typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetFeatures: + * > @copydoc wgpuAdapterGetFeatures + */ +typedef void (*WGPUProcAdapterGetFeatures)(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetInfo: + * > @copydoc wgpuAdapterGetInfo + */ +typedef WGPUStatus (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetLimits: + * > @copydoc wgpuAdapterGetLimits + */ +typedef WGPUStatus (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterHasFeature: + * > @copydoc wgpuAdapterHasFeature + */ typedef WGPUBool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterReference)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterRequestDevice: + * > @copydoc wgpuAdapterRequestDevice + */ +typedef WGPUFuture (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterAddRef. + * > @copydoc wgpuAdapterAddRef + */ +typedef void (*WGPUProcAdapterAddRef)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterRelease. + * > @copydoc wgpuAdapterRelease + */ typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; // Procs of AdapterInfo +/** + * Proc pointer type for @ref wgpuAdapterInfoFreeMembers: + * > @copydoc wgpuAdapterInfoFreeMembers + */ typedef void (*WGPUProcAdapterInfoFreeMembers)(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroup -typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupSetLabel: + * > @copydoc wgpuBindGroupSetLabel + */ +typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupAddRef. + * > @copydoc wgpuBindGroupAddRef + */ +typedef void (*WGPUProcBindGroupAddRef)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupRelease. + * > @copydoc wgpuBindGroupRelease + */ typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroupLayout -typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutSetLabel: + * > @copydoc wgpuBindGroupLayoutSetLabel + */ +typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutAddRef. + * > @copydoc wgpuBindGroupLayoutAddRef + */ +typedef void (*WGPUProcBindGroupLayoutAddRef)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutRelease. + * > @copydoc wgpuBindGroupLayoutRelease + */ typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of Buffer +/** + * Proc pointer type for @ref wgpuBufferDestroy: + * > @copydoc wgpuBufferDestroy + */ typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetConstMappedRange: + * > @copydoc wgpuBufferGetConstMappedRange + */ typedef void const * (*WGPUProcBufferGetConstMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetMapState: + * > @copydoc wgpuBufferGetMapState + */ typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetMappedRange: + * > @copydoc wgpuBufferGetMappedRange + */ typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetSize: + * > @copydoc wgpuBufferGetSize + */ typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBufferUsageFlags (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; - -// Procs of CommandBuffer -typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandBufferReference)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetUsage: + * > @copydoc wgpuBufferGetUsage + */ +typedef WGPUBufferUsage (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferMapAsync: + * > @copydoc wgpuBufferMapAsync + */ +typedef WGPUFuture (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferSetLabel: + * > @copydoc wgpuBufferSetLabel + */ +typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferUnmap: + * > @copydoc wgpuBufferUnmap + */ +typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferAddRef. + * > @copydoc wgpuBufferAddRef + */ +typedef void (*WGPUProcBufferAddRef)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferRelease. + * > @copydoc wgpuBufferRelease + */ +typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; + +// Procs of CommandBuffer +/** + * Proc pointer type for @ref wgpuCommandBufferSetLabel: + * > @copydoc wgpuCommandBufferSetLabel + */ +typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferAddRef. + * > @copydoc wgpuCommandBufferAddRef + */ +typedef void (*WGPUProcCommandBufferAddRef)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferRelease. + * > @copydoc wgpuCommandBufferRelease + */ typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; // Procs of CommandEncoder +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginComputePass: + * > @copydoc wgpuCommandEncoderBeginComputePass + */ typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginRenderPass: + * > @copydoc wgpuCommandEncoderBeginRenderPass + */ typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderClearBuffer: + * > @copydoc wgpuCommandEncoderClearBuffer + */ typedef void (*WGPUProcCommandEncoderClearBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToBuffer: + * > @copydoc wgpuCommandEncoderCopyBufferToBuffer + */ typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToTexture: + * > @copydoc wgpuCommandEncoderCopyBufferToTexture + */ +typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToBuffer: + * > @copydoc wgpuCommandEncoderCopyTextureToBuffer + */ +typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToTexture: + * > @copydoc wgpuCommandEncoderCopyTextureToTexture + */ +typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderFinish: + * > @copydoc wgpuCommandEncoderFinish + */ typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderInsertDebugMarker: + * > @copydoc wgpuCommandEncoderInsertDebugMarker + */ +typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderPopDebugGroup: + * > @copydoc wgpuCommandEncoderPopDebugGroup + */ typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderPushDebugGroup: + * > @copydoc wgpuCommandEncoderPushDebugGroup + */ +typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderResolveQuerySet: + * > @copydoc wgpuCommandEncoderResolveQuerySet + */ typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderSetLabel: + * > @copydoc wgpuCommandEncoderSetLabel + */ +typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderWriteTimestamp: + * > @copydoc wgpuCommandEncoderWriteTimestamp + */ typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderAddRef. + * > @copydoc wgpuCommandEncoderAddRef + */ +typedef void (*WGPUProcCommandEncoderAddRef)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderRelease. + * > @copydoc wgpuCommandEncoderRelease + */ typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePassEncoder +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroups: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroups + */ typedef void (*WGPUProcComputePassEncoderDispatchWorkgroups)(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroupsIndirect: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroupsIndirect + */ typedef void (*WGPUProcComputePassEncoderDispatchWorkgroupsIndirect)(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderEnd: + * > @copydoc wgpuComputePassEncoderEnd + */ typedef void (*WGPUProcComputePassEncoderEnd)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderInsertDebugMarker: + * > @copydoc wgpuComputePassEncoderInsertDebugMarker + */ +typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderPopDebugGroup: + * > @copydoc wgpuComputePassEncoderPopDebugGroup + */ typedef void (*WGPUProcComputePassEncoderPopDebugGroup)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderPushDebugGroup: + * > @copydoc wgpuComputePassEncoderPushDebugGroup + */ +typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetBindGroup: + * > @copydoc wgpuComputePassEncoderSetBindGroup + */ typedef void (*WGPUProcComputePassEncoderSetBindGroup)(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetLabel: + * > @copydoc wgpuComputePassEncoderSetLabel + */ +typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetPipeline: + * > @copydoc wgpuComputePassEncoderSetPipeline + */ typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderReference)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderAddRef. + * > @copydoc wgpuComputePassEncoderAddRef + */ +typedef void (*WGPUProcComputePassEncoderAddRef)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderRelease. + * > @copydoc wgpuComputePassEncoderRelease + */ typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePipeline +/** + * Proc pointer type for @ref wgpuComputePipelineGetBindGroupLayout: + * > @copydoc wgpuComputePipelineGetBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePipelineReference)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineSetLabel: + * > @copydoc wgpuComputePipelineSetLabel + */ +typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineAddRef. + * > @copydoc wgpuComputePipelineAddRef + */ +typedef void (*WGPUProcComputePipelineAddRef)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineRelease. + * > @copydoc wgpuComputePipelineRelease + */ typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Device +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroup: + * > @copydoc wgpuDeviceCreateBindGroup + */ typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroupLayout: + * > @copydoc wgpuDeviceCreateBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateBuffer: + * > @copydoc wgpuDeviceCreateBuffer + */ typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateCommandEncoder: + * > @copydoc wgpuDeviceCreateCommandEncoder + */ typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipeline: + * > @copydoc wgpuDeviceCreateComputePipeline + */ typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipelineAsync: + * > @copydoc wgpuDeviceCreateComputePipelineAsync + */ +typedef WGPUFuture (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreatePipelineLayout: + * > @copydoc wgpuDeviceCreatePipelineLayout + */ typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateQuerySet: + * > @copydoc wgpuDeviceCreateQuerySet + */ typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderBundleEncoder: + * > @copydoc wgpuDeviceCreateRenderBundleEncoder + */ typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipeline: + * > @copydoc wgpuDeviceCreateRenderPipeline + */ typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipelineAsync: + * > @copydoc wgpuDeviceCreateRenderPipelineAsync + */ +typedef WGPUFuture (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateSampler: + * > @copydoc wgpuDeviceCreateSampler + */ typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateShaderModule: + * > @copydoc wgpuDeviceCreateShaderModule + */ typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateTexture: + * > @copydoc wgpuDeviceCreateTexture + */ typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceDestroy: + * > @copydoc wgpuDeviceDestroy + */ typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetAdapterInfo: + * > @copydoc wgpuDeviceGetAdapterInfo + */ +typedef WGPUAdapterInfo (*WGPUProcDeviceGetAdapterInfo)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetFeatures: + * > @copydoc wgpuDeviceGetFeatures + */ +typedef void (*WGPUProcDeviceGetFeatures)(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetLimits: + * > @copydoc wgpuDeviceGetLimits + */ +typedef WGPUStatus (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetLostFuture: + * > @copydoc wgpuDeviceGetLostFuture + */ +typedef WGPUFuture (*WGPUProcDeviceGetLostFuture)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetQueue: + * > @copydoc wgpuDeviceGetQueue + */ typedef WGPUQueue (*WGPUProcDeviceGetQueue)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceHasFeature: + * > @copydoc wgpuDeviceHasFeature + */ typedef WGPUBool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDevicePopErrorScope: + * > @copydoc wgpuDevicePopErrorScope + */ +typedef WGPUFuture (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDevicePushErrorScope: + * > @copydoc wgpuDevicePushErrorScope + */ typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceReference)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceSetLabel: + * > @copydoc wgpuDeviceSetLabel + */ +typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceAddRef. + * > @copydoc wgpuDeviceAddRef + */ +typedef void (*WGPUProcDeviceAddRef)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceRelease. + * > @copydoc wgpuDeviceRelease + */ typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; // Procs of Instance +/** + * Proc pointer type for @ref wgpuInstanceCreateSurface: + * > @copydoc wgpuInstanceCreateSurface + */ typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceGetWGSLLanguageFeatures: + * > @copydoc wgpuInstanceGetWGSLLanguageFeatures + */ +typedef WGPUStatus (*WGPUProcInstanceGetWGSLLanguageFeatures)(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceHasWGSLLanguageFeature: + * > @copydoc wgpuInstanceHasWGSLLanguageFeature + */ +typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceProcessEvents: + * > @copydoc wgpuInstanceProcessEvents + */ typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceReference)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceRequestAdapter: + * > @copydoc wgpuInstanceRequestAdapter + */ +typedef WGPUFuture (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceWaitAny: + * > @copydoc wgpuInstanceWaitAny + */ +typedef WGPUWaitStatus (*WGPUProcInstanceWaitAny)(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceAddRef. + * > @copydoc wgpuInstanceAddRef + */ +typedef void (*WGPUProcInstanceAddRef)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceRelease. + * > @copydoc wgpuInstanceRelease + */ typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; // Procs of PipelineLayout -typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutSetLabel: + * > @copydoc wgpuPipelineLayoutSetLabel + */ +typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutAddRef. + * > @copydoc wgpuPipelineLayoutAddRef + */ +typedef void (*WGPUProcPipelineLayoutAddRef)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutRelease. + * > @copydoc wgpuPipelineLayoutRelease + */ typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of QuerySet +/** + * Proc pointer type for @ref wgpuQuerySetDestroy: + * > @copydoc wgpuQuerySetDestroy + */ typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetGetCount: + * > @copydoc wgpuQuerySetGetCount + */ typedef uint32_t (*WGPUProcQuerySetGetCount)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetGetType: + * > @copydoc wgpuQuerySetGetType + */ typedef WGPUQueryType (*WGPUProcQuerySetGetType)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQuerySetReference)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetSetLabel: + * > @copydoc wgpuQuerySetSetLabel + */ +typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetAddRef. + * > @copydoc wgpuQuerySetAddRef + */ +typedef void (*WGPUProcQuerySetAddRef)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetRelease. + * > @copydoc wgpuQuerySetRelease + */ typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Procs of Queue -typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueOnSubmittedWorkDone: + * > @copydoc wgpuQueueOnSubmittedWorkDone + */ +typedef WGPUFuture (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueSetLabel: + * > @copydoc wgpuQueueSetLabel + */ +typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueSubmit: + * > @copydoc wgpuQueueSubmit + */ typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueWriteBuffer: + * > @copydoc wgpuQueueWriteBuffer + */ typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueReference)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueWriteTexture: + * > @copydoc wgpuQueueWriteTexture + */ +typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueAddRef. + * > @copydoc wgpuQueueAddRef + */ +typedef void (*WGPUProcQueueAddRef)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueRelease. + * > @copydoc wgpuQueueRelease + */ typedef void (*WGPUProcQueueRelease)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundle -typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleReference)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleSetLabel: + * > @copydoc wgpuRenderBundleSetLabel + */ +typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleAddRef. + * > @copydoc wgpuRenderBundleAddRef + */ +typedef void (*WGPUProcRenderBundleAddRef)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleRelease. + * > @copydoc wgpuRenderBundleRelease + */ typedef void (*WGPUProcRenderBundleRelease)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundleEncoder +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDraw: + * > @copydoc wgpuRenderBundleEncoderDraw + */ typedef void (*WGPUProcRenderBundleEncoderDraw)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexed: + * > @copydoc wgpuRenderBundleEncoderDrawIndexed + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndexed)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndexedIndirect + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndexedIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndirect + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderFinish: + * > @copydoc wgpuRenderBundleEncoderFinish + */ typedef WGPURenderBundle (*WGPUProcRenderBundleEncoderFinish)(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderInsertDebugMarker: + * > @copydoc wgpuRenderBundleEncoderInsertDebugMarker + */ +typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPopDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPopDebugGroup + */ typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPushDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPushDebugGroup + */ +typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetBindGroup: + * > @copydoc wgpuRenderBundleEncoderSetBindGroup + */ typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetIndexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetIndexBuffer + */ typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetLabel: + * > @copydoc wgpuRenderBundleEncoderSetLabel + */ +typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetPipeline: + * > @copydoc wgpuRenderBundleEncoderSetPipeline + */ typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetVertexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetVertexBuffer + */ typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderAddRef. + * > @copydoc wgpuRenderBundleEncoderAddRef + */ +typedef void (*WGPUProcRenderBundleEncoderAddRef)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderRelease. + * > @copydoc wgpuRenderBundleEncoderRelease + */ typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPassEncoder +/** + * Proc pointer type for @ref wgpuRenderPassEncoderBeginOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderBeginOcclusionQuery + */ typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDraw: + * > @copydoc wgpuRenderPassEncoderDraw + */ typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexed: + * > @copydoc wgpuRenderPassEncoderDrawIndexed + */ typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndexedIndirect + */ typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndirect + */ typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEnd: + * > @copydoc wgpuRenderPassEncoderEnd + */ typedef void (*WGPUProcRenderPassEncoderEnd)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEndOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderEndOcclusionQuery + */ typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderExecuteBundles: + * > @copydoc wgpuRenderPassEncoderExecuteBundles + */ typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderInsertDebugMarker: + * > @copydoc wgpuRenderPassEncoderInsertDebugMarker + */ +typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPopDebugGroup: + * > @copydoc wgpuRenderPassEncoderPopDebugGroup + */ typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPushDebugGroup: + * > @copydoc wgpuRenderPassEncoderPushDebugGroup + */ +typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBindGroup: + * > @copydoc wgpuRenderPassEncoderSetBindGroup + */ typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBlendConstant: + * > @copydoc wgpuRenderPassEncoderSetBlendConstant + */ typedef void (*WGPUProcRenderPassEncoderSetBlendConstant)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetIndexBuffer: + * > @copydoc wgpuRenderPassEncoderSetIndexBuffer + */ typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetLabel: + * > @copydoc wgpuRenderPassEncoderSetLabel + */ +typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetPipeline: + * > @copydoc wgpuRenderPassEncoderSetPipeline + */ typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetScissorRect: + * > @copydoc wgpuRenderPassEncoderSetScissorRect + */ typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetStencilReference: + * > @copydoc wgpuRenderPassEncoderSetStencilReference + */ typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetVertexBuffer: + * > @copydoc wgpuRenderPassEncoderSetVertexBuffer + */ typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetViewport: + * > @copydoc wgpuRenderPassEncoderSetViewport + */ typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderReference)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderAddRef. + * > @copydoc wgpuRenderPassEncoderAddRef + */ +typedef void (*WGPUProcRenderPassEncoderAddRef)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderRelease. + * > @copydoc wgpuRenderPassEncoderRelease + */ typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPipeline +/** + * Proc pointer type for @ref wgpuRenderPipelineGetBindGroupLayout: + * > @copydoc wgpuRenderPipelineGetBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPipelineReference)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineSetLabel: + * > @copydoc wgpuRenderPipelineSetLabel + */ +typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineAddRef. + * > @copydoc wgpuRenderPipelineAddRef + */ +typedef void (*WGPUProcRenderPipelineAddRef)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineRelease. + * > @copydoc wgpuRenderPipelineRelease + */ typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Sampler -typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerSetLabel: + * > @copydoc wgpuSamplerSetLabel + */ +typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerAddRef. + * > @copydoc wgpuSamplerAddRef + */ +typedef void (*WGPUProcSamplerAddRef)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerRelease. + * > @copydoc wgpuSamplerRelease + */ typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Procs of ShaderModule -typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleGetCompilationInfo: + * > @copydoc wgpuShaderModuleGetCompilationInfo + */ +typedef WGPUFuture (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleSetLabel: + * > @copydoc wgpuShaderModuleSetLabel + */ +typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleAddRef. + * > @copydoc wgpuShaderModuleAddRef + */ +typedef void (*WGPUProcShaderModuleAddRef)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleRelease. + * > @copydoc wgpuShaderModuleRelease + */ typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +// Procs of SupportedFeatures +/** + * Proc pointer type for @ref wgpuSupportedFeaturesFreeMembers: + * > @copydoc wgpuSupportedFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedFeaturesFreeMembers)(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; + +// Procs of SupportedWGSLLanguageFeatures +/** + * Proc pointer type for @ref wgpuSupportedWGSLLanguageFeaturesFreeMembers: + * > @copydoc wgpuSupportedWGSLLanguageFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedWGSLLanguageFeaturesFreeMembers)(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; + // Procs of Surface +/** + * Proc pointer type for @ref wgpuSurfaceConfigure: + * > @copydoc wgpuSurfaceConfigure + */ typedef void (*WGPUProcSurfaceConfigure)(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceGetCapabilities: + * > @copydoc wgpuSurfaceGetCapabilities + */ +typedef WGPUStatus (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceGetCurrentTexture: + * > @copydoc wgpuSurfaceGetCurrentTexture + */ typedef void (*WGPUProcSurfaceGetCurrentTexture)(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfacePresent: + * > @copydoc wgpuSurfacePresent + */ +typedef WGPUStatus (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceSetLabel: + * > @copydoc wgpuSurfaceSetLabel + */ +typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceUnconfigure: + * > @copydoc wgpuSurfaceUnconfigure + */ typedef void (*WGPUProcSurfaceUnconfigure)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceAddRef. + * > @copydoc wgpuSurfaceAddRef + */ +typedef void (*WGPUProcSurfaceAddRef)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceRelease. + * > @copydoc wgpuSurfaceRelease + */ typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; // Procs of SurfaceCapabilities +/** + * Proc pointer type for @ref wgpuSurfaceCapabilitiesFreeMembers: + * > @copydoc wgpuSurfaceCapabilitiesFreeMembers + */ typedef void (*WGPUProcSurfaceCapabilitiesFreeMembers)(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; // Procs of Texture +/** + * Proc pointer type for @ref wgpuTextureCreateView: + * > @copydoc wgpuTextureCreateView + */ typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureDestroy: + * > @copydoc wgpuTextureDestroy + */ typedef void (*WGPUProcTextureDestroy)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetDepthOrArrayLayers: + * > @copydoc wgpuTextureGetDepthOrArrayLayers + */ typedef uint32_t (*WGPUProcTextureGetDepthOrArrayLayers)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetDimension: + * > @copydoc wgpuTextureGetDimension + */ typedef WGPUTextureDimension (*WGPUProcTextureGetDimension)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetFormat: + * > @copydoc wgpuTextureGetFormat + */ typedef WGPUTextureFormat (*WGPUProcTextureGetFormat)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetHeight: + * > @copydoc wgpuTextureGetHeight + */ typedef uint32_t (*WGPUProcTextureGetHeight)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetMipLevelCount: + * > @copydoc wgpuTextureGetMipLevelCount + */ typedef uint32_t (*WGPUProcTextureGetMipLevelCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetSampleCount: + * > @copydoc wgpuTextureGetSampleCount + */ typedef uint32_t (*WGPUProcTextureGetSampleCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUTextureUsageFlags (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetUsage: + * > @copydoc wgpuTextureGetUsage + */ +typedef WGPUTextureUsage (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetWidth: + * > @copydoc wgpuTextureGetWidth + */ typedef uint32_t (*WGPUProcTextureGetWidth)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureReference)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureSetLabel: + * > @copydoc wgpuTextureSetLabel + */ +typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureAddRef. + * > @copydoc wgpuTextureAddRef + */ +typedef void (*WGPUProcTextureAddRef)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureRelease. + * > @copydoc wgpuTextureRelease + */ typedef void (*WGPUProcTextureRelease)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; // Procs of TextureView -typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureViewReference)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewSetLabel: + * > @copydoc wgpuTextureViewSetLabel + */ +typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewAddRef. + * > @copydoc wgpuTextureViewAddRef + */ +typedef void (*WGPUProcTextureViewAddRef)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewRelease. + * > @copydoc wgpuTextureViewRelease + */ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; #endif // !defined(WGPU_SKIP_PROCS) @@ -1644,11 +3230,28 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUN /** * \defgroup GlobalFunctions Global Functions * \brief Functions that are not specific to an object. - * + * * @{ */ +/** + * Create a WGPUInstance + */ WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; +/** + * Query the supported instance capabilities. + * + * @param capabilities + * The supported instance capabilities + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuGetInstanceCapabilities(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns the "procedure address" (function pointer) of the named function. + * The result must be cast to the appropriate proc pointer type. + */ +WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1656,22 +3259,39 @@ WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName /** * \defgroup Methods * \brief Functions that are relative to a specific object. - * + * * @{ */ /** * \defgroup WGPUAdapterMethods WGPUAdapter methods * \brief Functions whose first argument has type WGPUAdapter. - * + * * @{ */ -WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUFeatureName values supported by the adapter. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuAdapterGetFeatures(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param info + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuAdapterGetLimits(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterAddRef(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1680,9 +3300,12 @@ WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods * \brief Functions whose first argument has type WGPUAdapterInfo. - * + * * @{ */ +/** + * Frees array members of WGPUAdapterInfo which were allocated by the API. + */ WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1691,11 +3314,11 @@ WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FU /** * \defgroup WGPUBindGroupMethods WGPUBindGroup methods * \brief Functions whose first argument has type WGPUBindGroup. - * + * * @{ */ -WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupAddRef(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1704,11 +3327,11 @@ WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATT /** * \defgroup WGPUBindGroupLayoutMethods WGPUBindGroupLayout methods * \brief Functions whose first argument has type WGPUBindGroupLayout. - * + * * @{ */ -WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutAddRef(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1717,19 +3340,49 @@ WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) /** * \defgroup WGPUBufferMethods WGPUBuffer methods * \brief Functions whose first argument has type WGPUBuffer. - * + * * @{ */ WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. The returned pointer is valid for exactly this many bytes. + * + * @returns + * Returns a const pointer to beginning of the mapped range. + * It must not be written; writing to this range causes undefined behavior. + * Returns `NULL` with @ref ImplementationDefinedLogging if: + * + * - There is any content-timeline error as defined in the WebGPU specification for `getMappedRange()` (alignments, overlaps, etc.) + * **except** for overlaps with other *const* ranges, which are allowed in C. + * (JS does not allow this because const ranges do not exist.) + */ WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. The returned pointer is valid for exactly this many bytes. + * + * @returns + * Returns a mutable pointer to beginning of the mapped range. + * Returns `NULL` with @ref ImplementationDefinedLogging if: + * + * - There is any content-timeline error as defined in the WebGPU specification for `getMappedRange()` (alignments, overlaps, etc.) + * - The buffer is not mapped with @ref WGPUMapMode_Write. + */ WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferAddRef(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1738,11 +3391,11 @@ WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup WGPUCommandBufferMethods WGPUCommandBuffer methods * \brief Functions whose first argument has type WGPUCommandBuffer. - * + * * @{ */ -WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferAddRef(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1751,24 +3404,24 @@ WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_ /** * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods * \brief Functions whose first argument has type WGPUCommandEncoder. - * + * * @{ */ WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderAddRef(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1777,19 +3430,19 @@ WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WG /** * \defgroup WGPUComputePassEncoderMethods WGPUComputePassEncoder methods * \brief Functions whose first argument has type WGPUComputePassEncoder. - * + * * @{ */ WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderAddRef(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1798,12 +3451,12 @@ WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePas /** * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods * \brief Functions whose first argument has type WGPUComputePipeline. - * + * * @{ */ WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineAddRef(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1812,7 +3465,7 @@ WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) /** * \defgroup WGPUDeviceMethods WGPUDevice methods * \brief Functions whose first argument has type WGPUDevice. - * + * * @{ */ WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1820,24 +3473,40 @@ WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice devic WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUAdapterInfo wgpuDeviceGetAdapterInfo(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUFeatureName values supported by the device. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuDeviceGetFeatures(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuDeviceGetLimits(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * The @ref WGPUFuture for the device-lost event of the device. + */ +WGPU_EXPORT WGPUFuture wgpuDeviceGetLostFuture(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceAddRef(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1846,14 +3515,38 @@ WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup WGPUInstanceMethods WGPUInstance methods * \brief Functions whose first argument has type WGPUInstance. - * + * * @{ */ +/** + * Creates a @ref WGPUSurface, see @ref Surface-Creation for more details. + * + * @param descriptor + * The description of the @ref WGPUSurface to create. + * + * @returns + * A new @ref WGPUSurface for this descriptor (or an error @ref WGPUSurface). + */ WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUWGSLLanguageFeatureName values supported by the instance. + */ +WGPU_EXPORT WGPUStatus wgpuInstanceGetWGSLLanguageFeatures(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with `::WGPUCallbackMode_AllowProcessEvents`. + * + * See @ref Process-Events for more information. + */ WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Wait for at least one WGPUFuture in `futures` to complete, and call callbacks of the respective completed asynchronous operations. + * + * See @ref Wait-Any for more information. + */ +WGPU_EXPORT WGPUWaitStatus wgpuInstanceWaitAny(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceAddRef(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1862,11 +3555,11 @@ WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIB /** * \defgroup WGPUPipelineLayoutMethods WGPUPipelineLayout methods * \brief Functions whose first argument has type WGPUPipelineLayout. - * + * * @{ */ -WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutAddRef(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1875,14 +3568,14 @@ WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WG /** * \defgroup WGPUQuerySetMethods WGPUQuerySet methods * \brief Functions whose first argument has type WGPUQuerySet. - * + * * @{ */ WGPU_EXPORT void wgpuQuerySetDestroy(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetAddRef(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1891,15 +3584,19 @@ WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIB /** * \defgroup WGPUQueueMethods WGPUQueue methods * \brief Functions whose first argument has type WGPUQueue. - * + * * @{ */ -WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +/** + * Produces a @ref DeviceError both content-timeline (`size` alignment) and device-timeline + * errors defined by the WebGPU specification. + */ WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueAddRef(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1908,11 +3605,11 @@ WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup WGPURenderBundleMethods WGPURenderBundle methods * \brief Functions whose first argument has type WGPURenderBundle. - * + * * @{ */ -WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleReference(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleAddRef(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1921,7 +3618,7 @@ WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUN /** * \defgroup WGPURenderBundleEncoderMethods WGPURenderBundleEncoder methods * \brief Functions whose first argument has type WGPURenderBundleEncoder. - * + * * @{ */ WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; @@ -1929,15 +3626,15 @@ WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder rend WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderAddRef(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1946,7 +3643,7 @@ WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBu /** * \defgroup WGPURenderPassEncoderMethods WGPURenderPassEncoder methods * \brief Functions whose first argument has type WGPURenderPassEncoder. - * + * * @{ */ WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; @@ -1957,19 +3654,19 @@ WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderP WGPU_EXPORT void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderAddRef(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1978,12 +3675,12 @@ WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEn /** * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods * \brief Functions whose first argument has type WGPURenderPipeline. - * + * * @{ */ WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineAddRef(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1992,11 +3689,11 @@ WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WG /** * \defgroup WGPUSamplerMethods WGPUSampler methods * \brief Functions whose first argument has type WGPUSampler. - * + * * @{ */ -WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerAddRef(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2005,30 +3702,108 @@ WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUShaderModuleMethods WGPUShaderModule methods * \brief Functions whose first argument has type WGPUShaderModule. - * + * * @{ */ -WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleAddRef(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; /** @} */ +/** + * \defgroup WGPUSupportedFeaturesMethods WGPUSupportedFeatures methods + * \brief Functions whose first argument has type WGPUSupportedFeatures. + * + * @{ + */ +/** + * Frees array members of WGPUSupportedFeatures which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUSupportedWGSLLanguageFeaturesMethods WGPUSupportedWGSLLanguageFeatures methods + * \brief Functions whose first argument has type WGPUSupportedWGSLLanguageFeatures. + * + * @{ + */ +/** + * Frees array members of WGPUSupportedWGSLLanguageFeatures which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedWGSLLanguageFeaturesFreeMembers(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + /** * \defgroup WGPUSurfaceMethods WGPUSurface methods * \brief Functions whose first argument has type WGPUSurface. - * + * * @{ */ +/** + * Configures parameters for rendering to `surface`. + * Produces a @ref DeviceError for all content-timeline errors defined by the WebGPU specification. + * + * See @ref Surface-Configuration for more details. + * + * @param config + * The new configuration to use. + */ WGPU_EXPORT void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Provides information on how `adapter` is able to use `surface`. + * See @ref Surface-Capabilities for more details. + * + * @param adapter + * The @ref WGPUAdapter to get capabilities for presenting to this @ref WGPUSurface. + * + * @param capabilities + * The structure to fill capabilities in. + * It may contain memory allocations so `::wgpuSurfaceCapabilitiesFreeMembers` must be called to avoid memory leaks. + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns the @ref WGPUTexture to render to `surface` this frame along with metadata on the frame. + * Returns `NULL` and @ref WGPUSurfaceGetCurrentTextureStatus_Error if the surface is not configured. + * + * See @ref Surface-Presenting for more details. + * + * @param surfaceTexture + * The structure to fill the @ref WGPUTexture and metadata in. + */ WGPU_EXPORT void wgpuSurfaceGetCurrentTexture(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Shows `surface`'s current texture to the user. + * See @ref Surface-Presenting for more details. + * + * @returns + * Returns @ref WGPUStatus_Error if the surface doesn't have a current texture. + */ +WGPU_EXPORT WGPUStatus wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Modifies the label used to refer to `surface`. + * + * @param label + * The new label. + */ +WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Removes the configuration for `surface`. + * See @ref Surface-Configuration for more details. + */ WGPU_EXPORT void wgpuSurfaceUnconfigure(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceAddRef(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2037,9 +3812,12 @@ WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods * \brief Functions whose first argument has type WGPUSurfaceCapabilities. - * + * * @{ */ +/** + * Frees array members of WGPUSurfaceCapabilities which were allocated by the API. + */ WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2048,7 +3826,7 @@ WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surf /** * \defgroup WGPUTextureMethods WGPUTexture methods * \brief Functions whose first argument has type WGPUTexture. - * + * * @{ */ WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -2059,10 +3837,10 @@ WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) WGPU_FUN WGPU_EXPORT uint32_t wgpuTextureGetHeight(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureReference(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureAddRef(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2071,11 +3849,11 @@ WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUTextureViewMethods WGPUTextureView methods * \brief Functions whose first argument has type WGPUTextureView. - * + * * @{ */ -WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureViewReference(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewAddRef(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2088,4 +3866,4 @@ WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView) WGPU_FUNCTI } // extern "C" #endif -#endif // WEBGPU_H_ \ No newline at end of file +#endif // WEBGPU_H_ diff --git a/wgpu/lib/wgpu.h b/wgpu/lib/wgpu.h index 938c853..6cee9d1 100644 --- a/wgpu/lib/wgpu.h +++ b/wgpu/lib/wgpu.h @@ -6,10 +6,9 @@ typedef enum WGPUNativeSType { // Start at 0003 since that's allocated range for wgpu-native WGPUSType_DeviceExtras = 0x00030001, - WGPUSType_RequiredLimitsExtras = 0x00030002, + WGPUSType_NativeLimits = 0x00030002, WGPUSType_PipelineLayoutExtras = 0x00030003, WGPUSType_ShaderModuleGLSLDescriptor = 0x00030004, - WGPUSType_SupportedLimitsExtras = 0x00030005, WGPUSType_InstanceExtras = 0x00030006, WGPUSType_BindGroupEntryExtras = 0x00030007, WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, @@ -31,8 +30,6 @@ typedef enum WGPUNativeFeature { WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B, WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C, - // TODO: requires wgpu.h api change - // WGPUNativeFeature_TimestampQueryInsidePasses = 0x0003000D, WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E, WGPUNativeFeature_BufferBindingArray = 0x0003000F, WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010, @@ -43,17 +40,21 @@ typedef enum WGPUNativeFeature { // WGPUNativeFeature_PolygonModePoint = 0x00030014, // WGPUNativeFeature_ConservativeRasterization = 0x00030015, // WGPUNativeFeature_ClearTexture = 0x00030016, - // WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, + WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, // WGPUNativeFeature_Multiview = 0x00030018, WGPUNativeFeature_VertexAttribute64bit = 0x00030019, - WGPUNativeFeature_ShaderUnusedVertexOutput = 0x0003001A, - WGPUNativeFeature_TextureFormatNv12 = 0x0003001B, - WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001C, - WGPUNativeFeature_RayQuery = 0x0003001D, - WGPUNativeFeature_ShaderF64 = 0x0003001E, - WGPUNativeFeature_ShaderI16 = 0x0003001F, - WGPUNativeFeature_ShaderPrimitiveIndex = 0x00030020, - WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030021, + WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, + WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001B, + WGPUNativeFeature_RayQuery = 0x0003001C, + WGPUNativeFeature_ShaderF64 = 0x0003001D, + WGPUNativeFeature_ShaderI16 = 0x0003001E, + WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F, + WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, + WGPUNativeFeature_Subgroup = 0x00030021, + WGPUNativeFeature_SubgroupVertex = 0x00030022, + WGPUNativeFeature_SubgroupBarrier = 0x00030023, + WGPUNativeFeature_TimestampQueryInsideEncoders = 0x00030024, + WGPUNativeFeature_TimestampQueryInsidePasses = 0x00030025, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; @@ -67,30 +68,26 @@ typedef enum WGPULogLevel { WGPULogLevel_Force32 = 0x7FFFFFFF } WGPULogLevel; -typedef enum WGPUInstanceBackend { - WGPUInstanceBackend_All = 0x00000000, - WGPUInstanceBackend_Vulkan = 1 << 0, - WGPUInstanceBackend_GL = 1 << 1, - WGPUInstanceBackend_Metal = 1 << 2, - WGPUInstanceBackend_DX12 = 1 << 3, - WGPUInstanceBackend_DX11 = 1 << 4, - WGPUInstanceBackend_BrowserWebGPU = 1 << 5, - WGPUInstanceBackend_Primary = WGPUInstanceBackend_Vulkan | WGPUInstanceBackend_Metal | - WGPUInstanceBackend_DX12 | - WGPUInstanceBackend_BrowserWebGPU, - WGPUInstanceBackend_Secondary = WGPUInstanceBackend_GL | WGPUInstanceBackend_DX11, - WGPUInstanceBackend_Force32 = 0x7FFFFFFF -} WGPUInstanceBackend; -typedef WGPUFlags WGPUInstanceBackendFlags; - -typedef enum WGPUInstanceFlag { - WGPUInstanceFlag_Default = 0x00000000, - WGPUInstanceFlag_Debug = 1 << 0, - WGPUInstanceFlag_Validation = 1 << 1, - WGPUInstanceFlag_DiscardHalLabels = 1 << 2, - WGPUInstanceFlag_Force32 = 0x7FFFFFFF -} WGPUInstanceFlag; -typedef WGPUFlags WGPUInstanceFlags; +typedef WGPUFlags WGPUInstanceBackend; +static const WGPUInstanceBackend WGPUInstanceBackend_All = 0x00000000; +static const WGPUInstanceBackend WGPUInstanceBackend_Vulkan = 1 << 0; +static const WGPUInstanceBackend WGPUInstanceBackend_GL = 1 << 1; +static const WGPUInstanceBackend WGPUInstanceBackend_Metal = 1 << 2; +static const WGPUInstanceBackend WGPUInstanceBackend_DX12 = 1 << 3; +static const WGPUInstanceBackend WGPUInstanceBackend_DX11 = 1 << 4; +static const WGPUInstanceBackend WGPUInstanceBackend_BrowserWebGPU = 1 << 5; +// Vulkan, Metal, DX12 and BrowserWebGPU +static const WGPUInstanceBackend WGPUInstanceBackend_Primary = (1 << 0) | (1 << 2) | (1 << 3) | (1 << 5); +// GL and DX11 +static const WGPUInstanceBackend WGPUInstanceBackend_Secondary = (1 << 1) | (1 << 4); +static const WGPUInstanceBackend WGPUInstanceBackend_Force32 = 0x7FFFFFFF; + +typedef WGPUFlags WGPUInstanceFlag; +static const WGPUInstanceFlag WGPUInstanceFlag_Default = 0x00000000; +static const WGPUInstanceFlag WGPUInstanceFlag_Debug = 1 << 0; +static const WGPUInstanceFlag WGPUInstanceFlag_Validation = 1 << 1; +static const WGPUInstanceFlag WGPUInstanceFlag_DiscardHalLabels = 1 << 2; +static const WGPUInstanceFlag WGPUInstanceFlag_Force32 = 0x7FFFFFFF; typedef enum WGPUDx12Compiler { WGPUDx12Compiler_Undefined = 0x00000000, @@ -123,36 +120,28 @@ typedef enum WGPUNativeQueryType { typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; - WGPUInstanceBackendFlags backends; - WGPUInstanceFlags flags; + WGPUInstanceBackend backends; + WGPUInstanceFlag flags; WGPUDx12Compiler dx12ShaderCompiler; WGPUGles3MinorVersion gles3MinorVersion; - const char * dxilPath; - const char * dxcPath; + WGPUStringView dxilPath; + WGPUStringView dxcPath; } WGPUInstanceExtras; typedef struct WGPUDeviceExtras { WGPUChainedStruct chain; - const char * tracePath; + WGPUStringView tracePath; } WGPUDeviceExtras; typedef struct WGPUNativeLimits { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut chain; uint32_t maxPushConstantSize; uint32_t maxNonSamplerBindings; } WGPUNativeLimits; -typedef struct WGPURequiredLimitsExtras { - WGPUChainedStruct chain; - WGPUNativeLimits limits; -} WGPURequiredLimitsExtras; - -typedef struct WGPUSupportedLimitsExtras { - WGPUChainedStructOut chain; - WGPUNativeLimits limits; -} WGPUSupportedLimitsExtras; - typedef struct WGPUPushConstantRange { - WGPUShaderStageFlags stages; + WGPUShaderStage stages; uint32_t start; uint32_t end; } WGPUPushConstantRange; @@ -165,29 +154,29 @@ typedef struct WGPUPipelineLayoutExtras { typedef uint64_t WGPUSubmissionIndex; -typedef struct WGPUWrappedSubmissionIndex { - WGPUQueue queue; - WGPUSubmissionIndex submissionIndex; -} WGPUWrappedSubmissionIndex; - typedef struct WGPUShaderDefine { - char const * name; - char const * value; + WGPUStringView name; + WGPUStringView value; } WGPUShaderDefine; typedef struct WGPUShaderModuleGLSLDescriptor { WGPUChainedStruct chain; WGPUShaderStage stage; - char const * code; + WGPUStringView code; uint32_t defineCount; WGPUShaderDefine * defines; } WGPUShaderModuleGLSLDescriptor; +typedef struct WGPUShaderModuleDescriptorSpirV { + WGPUStringView label; + uint32_t sourceSize; + uint32_t const * source; +} WGPUShaderModuleDescriptorSpirV; + typedef struct WGPURegistryReport { size_t numAllocated; size_t numKeptFromUser; size_t numReleasedFromUser; - size_t numError; size_t elementSize; } WGPURegistryReport; @@ -203,6 +192,7 @@ typedef struct WGPUHubReport { WGPURegistryReport renderBundles; WGPURegistryReport renderPipelines; WGPURegistryReport computePipelines; + WGPURegistryReport pipelineCaches; WGPURegistryReport querySets; WGPURegistryReport buffers; WGPURegistryReport textures; @@ -212,16 +202,12 @@ typedef struct WGPUHubReport { typedef struct WGPUGlobalReport { WGPURegistryReport surfaces; - WGPUBackendType backendType; - WGPUHubReport vulkan; - WGPUHubReport metal; - WGPUHubReport dx12; - WGPUHubReport gl; + WGPUHubReport hub; } WGPUGlobalReport; typedef struct WGPUInstanceEnumerateAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPUInstanceBackendFlags backends; + WGPUInstanceBackend backends; } WGPUInstanceEnumerateAdapterOptions; typedef struct WGPUBindGroupEntryExtras { @@ -247,10 +233,10 @@ typedef struct WGPUQuerySetDescriptorExtras { typedef struct WGPUSurfaceConfigurationExtras { WGPUChainedStruct chain; - WGPUBool desiredMaximumFrameLatency; + uint32_t desiredMaximumFrameLatency; } WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; -typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata); +typedef void (*WGPULogCallback)(WGPULogLevel level, WGPUStringView message, void * userdata); typedef enum WGPUNativeTextureFormat { // From Features::TEXTURE_FORMAT_16BIT_NORM @@ -274,7 +260,8 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUIn WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex); +WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * wrappedSubmissionIndex); +WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); @@ -282,7 +269,9 @@ void wgpuSetLogLevel(WGPULogLevel level); uint32_t wgpuGetVersion(void); -void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuComputePassEncoderSetPushConstants(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuRenderBundleEncoderSetPushConstants(WGPURenderBundleEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); @@ -295,8 +284,11 @@ void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder com void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); +void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + #ifdef __cplusplus } // extern "C" #endif -#endif \ No newline at end of file +#endif From bc605b550ce20870f3f3b6d0849ae323f3109e73 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 14:53:49 +0200 Subject: [PATCH 02/19] wgpu/adapter: Update --- wgpu/adapter.go | 118 ++++++++++++++++++++++++------------------------ wgpu/common.go | 13 ++---- 2 files changed, 63 insertions(+), 68 deletions(-) diff --git a/wgpu/adapter.go b/wgpu/adapter.go index d3039b0..4f52f9d 100644 --- a/wgpu/adapter.go +++ b/wgpu/adapter.go @@ -22,63 +22,61 @@ type Adapter struct { ref C.WGPUAdapter } -func (p *Adapter) EnumerateFeatures() []FeatureName { - size := C.wgpuAdapterEnumerateFeatures(p.ref, nil) +func (p *Adapter) GetFeatures() []FeatureName { + size := C.wgpuAdapterGetFeatures(p.ref, nil) if size == 0 { return nil } features := make([]FeatureName, size) - C.wgpuAdapterEnumerateFeatures(p.ref, (*C.WGPUFeatureName)(unsafe.Pointer(&features[0]))) + C.wgpuAdapterGetFeatures(p.ref, (*C.WGPUFeatureName)(unsafe.Pointer(&features[0]))) return features } -func (p *Adapter) GetLimits() SupportedLimits { - var supportedLimits C.WGPUSupportedLimits - - extras := (*C.WGPUSupportedLimitsExtras)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSupportedLimitsExtras{})))) - defer C.free(unsafe.Pointer(extras)) - supportedLimits.nextInChain = (*C.WGPUChainedStructOut)(unsafe.Pointer(extras)) - - C.wgpuAdapterGetLimits(p.ref, &supportedLimits) - - limits := supportedLimits.limits - return SupportedLimits{ - Limits{ - MaxTextureDimension1D: uint32(limits.maxTextureDimension1D), - MaxTextureDimension2D: uint32(limits.maxTextureDimension2D), - MaxTextureDimension3D: uint32(limits.maxTextureDimension3D), - MaxTextureArrayLayers: uint32(limits.maxTextureArrayLayers), - MaxBindGroups: uint32(limits.maxBindGroups), - MaxBindingsPerBindGroup: uint32(limits.maxBindingsPerBindGroup), - MaxDynamicUniformBuffersPerPipelineLayout: uint32(limits.maxDynamicUniformBuffersPerPipelineLayout), - MaxDynamicStorageBuffersPerPipelineLayout: uint32(limits.maxDynamicStorageBuffersPerPipelineLayout), - MaxSampledTexturesPerShaderStage: uint32(limits.maxSampledTexturesPerShaderStage), - MaxSamplersPerShaderStage: uint32(limits.maxSamplersPerShaderStage), - MaxStorageBuffersPerShaderStage: uint32(limits.maxStorageBuffersPerShaderStage), - MaxStorageTexturesPerShaderStage: uint32(limits.maxStorageTexturesPerShaderStage), - MaxUniformBuffersPerShaderStage: uint32(limits.maxUniformBuffersPerShaderStage), - MaxUniformBufferBindingSize: uint64(limits.maxUniformBufferBindingSize), - MaxStorageBufferBindingSize: uint64(limits.maxStorageBufferBindingSize), - MinUniformBufferOffsetAlignment: uint32(limits.minUniformBufferOffsetAlignment), - MinStorageBufferOffsetAlignment: uint32(limits.minStorageBufferOffsetAlignment), - MaxVertexBuffers: uint32(limits.maxVertexBuffers), - MaxBufferSize: uint64(limits.maxBufferSize), - MaxVertexAttributes: uint32(limits.maxVertexAttributes), - MaxVertexBufferArrayStride: uint32(limits.maxVertexBufferArrayStride), - MaxInterStageShaderComponents: uint32(limits.maxInterStageShaderComponents), - MaxInterStageShaderVariables: uint32(limits.maxInterStageShaderVariables), - MaxColorAttachments: uint32(limits.maxColorAttachments), - MaxColorAttachmentBytesPerSample: uint32(limits.maxColorAttachmentBytesPerSample), - MaxComputeWorkgroupStorageSize: uint32(limits.maxComputeWorkgroupStorageSize), - MaxComputeInvocationsPerWorkgroup: uint32(limits.maxComputeInvocationsPerWorkgroup), - MaxComputeWorkgroupSizeX: uint32(limits.maxComputeWorkgroupSizeX), - MaxComputeWorkgroupSizeY: uint32(limits.maxComputeWorkgroupSizeY), - MaxComputeWorkgroupSizeZ: uint32(limits.maxComputeWorkgroupSizeZ), - MaxComputeWorkgroupsPerDimension: uint32(limits.maxComputeWorkgroupsPerDimension), - - MaxPushConstantSize: uint32(extras.limits.maxPushConstantSize), - }, +func (p *Adapter) GetLimits() Limits { + var limits C.WGPULimits + + nativeLimits := (*C.WGPUNativeLimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUNativeLimits{})))) + defer C.free(unsafe.Pointer(nativeLimits)) + limits.nextInChain = (*C.WGPUChainedStructOut)(unsafe.Pointer(nativeLimits)) + + C.wgpuAdapterGetLimits(p.ref, &limits) + + return Limits{ + MaxTextureDimension1D: uint32(limits.maxTextureDimension1D), + MaxTextureDimension2D: uint32(limits.maxTextureDimension2D), + MaxTextureDimension3D: uint32(limits.maxTextureDimension3D), + MaxTextureArrayLayers: uint32(limits.maxTextureArrayLayers), + MaxBindGroups: uint32(limits.maxBindGroups), + MaxBindingsPerBindGroup: uint32(limits.maxBindingsPerBindGroup), + MaxDynamicUniformBuffersPerPipelineLayout: uint32(limits.maxDynamicUniformBuffersPerPipelineLayout), + MaxDynamicStorageBuffersPerPipelineLayout: uint32(limits.maxDynamicStorageBuffersPerPipelineLayout), + MaxSampledTexturesPerShaderStage: uint32(limits.maxSampledTexturesPerShaderStage), + MaxSamplersPerShaderStage: uint32(limits.maxSamplersPerShaderStage), + MaxStorageBuffersPerShaderStage: uint32(limits.maxStorageBuffersPerShaderStage), + MaxStorageTexturesPerShaderStage: uint32(limits.maxStorageTexturesPerShaderStage), + MaxUniformBuffersPerShaderStage: uint32(limits.maxUniformBuffersPerShaderStage), + MaxUniformBufferBindingSize: uint64(limits.maxUniformBufferBindingSize), + MaxStorageBufferBindingSize: uint64(limits.maxStorageBufferBindingSize), + MinUniformBufferOffsetAlignment: uint32(limits.minUniformBufferOffsetAlignment), + MinStorageBufferOffsetAlignment: uint32(limits.minStorageBufferOffsetAlignment), + MaxVertexBuffers: uint32(limits.maxVertexBuffers), + MaxBufferSize: uint64(limits.maxBufferSize), + MaxVertexAttributes: uint32(limits.maxVertexAttributes), + MaxVertexBufferArrayStride: uint32(limits.maxVertexBufferArrayStride), + MaxInterStageShaderComponents: uint32(limits.maxInterStageShaderComponents), + MaxInterStageShaderVariables: uint32(limits.maxInterStageShaderVariables), + MaxColorAttachments: uint32(limits.maxColorAttachments), + MaxColorAttachmentBytesPerSample: uint32(limits.maxColorAttachmentBytesPerSample), + MaxComputeWorkgroupStorageSize: uint32(limits.maxComputeWorkgroupStorageSize), + MaxComputeInvocationsPerWorkgroup: uint32(limits.maxComputeInvocationsPerWorkgroup), + MaxComputeWorkgroupSizeX: uint32(limits.maxComputeWorkgroupSizeX), + MaxComputeWorkgroupSizeY: uint32(limits.maxComputeWorkgroupSizeY), + MaxComputeWorkgroupSizeZ: uint32(limits.maxComputeWorkgroupSizeZ), + MaxComputeWorkgroupsPerDimension: uint32(limits.maxComputeWorkgroupsPerDimension), + + MaxPushConstantSize: uint32(nativeLimits.limits.maxPushConstantSize), + MaxNonSamplerBindings: uint32(nativeLimits.maxNonSamplerBindings), } } @@ -154,10 +152,10 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { } if descriptor.RequiredLimits != nil { - requiredLimits := (*C.WGPURequiredLimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPURequiredLimits{})))) + requiredLimits := (*C.WGPULimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPULimits{})))) defer C.free(unsafe.Pointer(requiredLimits)) - l := descriptor.RequiredLimits.Limits + l := descriptor.RequiredLimits requiredLimits.limits = C.WGPULimits{ maxTextureDimension1D: C.uint32_t(l.MaxTextureDimension1D), maxTextureDimension2D: C.uint32_t(l.MaxTextureDimension2D), @@ -192,14 +190,15 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { } desc.requiredLimits = requiredLimits - requiredLimitsExtras := (*C.WGPURequiredLimitsExtras)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPURequiredLimitsExtras{})))) - defer C.free(unsafe.Pointer(requiredLimitsExtras)) + nativeLimits := (*C.WGPUNativeLimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUNativeLimits{})))) + defer C.free(unsafe.Pointer(nativeLimits)) - requiredLimitsExtras.chain.next = nil - requiredLimitsExtras.chain.sType = C.WGPUSType_RequiredLimitsExtras - requiredLimitsExtras.limits.maxPushConstantSize = C.uint32_t(l.MaxPushConstantSize) + nativeLimits.chain.next = nil + nativeLimits.chain.sType = C.WGPUSType_NativeLimits + nativeLimits.maxPushConstantSize = C.uint32_t(l.MaxPushConstantSize) + nativeLimits.maxNonSamplerBindings = C.uint32_t(l.MaxNonSamplerBindings) - desc.requiredLimits.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(requiredLimitsExtras)) + desc.requiredLimits.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(nativeLimits)) } if descriptor.DeviceLostCallback != nil { @@ -233,7 +232,10 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { device = d } handle := cgo.NewHandle(cb) - C.wgpuAdapterRequestDevice(p.ref, desc, C.WGPUAdapterRequestDeviceCallback(C.gowebgpu_request_device_callback_c), unsafe.Pointer(&handle)) + C.wgpuAdapterRequestDevice(p.ref, desc, C.WGPURequestDeviceCallbackInfo{ + callback: C.gowebgpu_request_device_callback_c, + userdata1: unsafe.Pointer(&handle), + }) if status != RequestDeviceStatusSuccess { return nil, errors.New("failed to request device") diff --git a/wgpu/common.go b/wgpu/common.go index 224ff07..443bc4e 100644 --- a/wgpu/common.go +++ b/wgpu/common.go @@ -53,11 +53,8 @@ type Limits struct { MaxComputeWorkgroupSizeZ uint32 MaxComputeWorkgroupsPerDimension uint32 - MaxPushConstantSize uint32 -} - -type SupportedLimits struct { - Limits Limits + MaxPushConstantSize uint32 + MaxNonSamplerBindings uint32 } // Color as described: @@ -131,14 +128,10 @@ type ShaderModuleWGSLDescriptor struct { Code string } -type RequiredLimits struct { - Limits Limits -} - type DeviceDescriptor struct { Label string RequiredFeatures []FeatureName - RequiredLimits *RequiredLimits + RequiredLimits *Limits DeviceLostCallback DeviceLostCallback TracePath string } From a2e33fb4f3e216459a61b580697aa5bb3106fc93 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 15:05:36 +0200 Subject: [PATCH 03/19] wgpu/buffer: Update --- wgpu/buffer.go | 36 +++++++++++++++++++++++++----------- wgpu/enums.go | 40 ++++++++++++++++++++-------------------- wgpu/wgpu_c_cb.go | 2 +- 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/wgpu/buffer.go b/wgpu/buffer.go index d817bec..e019cab 100644 --- a/wgpu/buffer.go +++ b/wgpu/buffer.go @@ -7,19 +7,31 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); -extern void gowebgpu_buffer_map_callback_c(WGPUBufferMapAsyncStatus status, void *userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); +extern void gowebgpu_buffer_map_callback_c(WGPUMapAsyncStatus status, void *userdata); -static inline void gowebgpu_buffer_map_async(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, void * userdata, WGPUDevice device, void * error_userdata) { +static inline void gowebgpu_buffer_map_async(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callback, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); - wgpuBufferMapAsync(buffer, mode, offset, size, callback, userdata); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + wgpuBufferMapAsync(buffer, mode, offset, size, callback); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_buffer_unmap(WGPUBuffer buffer, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuBufferUnmap(buffer); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_buffer_release(WGPUBuffer buffer, WGPUDevice device) { @@ -58,13 +70,13 @@ func (p *Buffer) GetUsage() BufferUsage { } //export gowebgpu_buffer_map_callback_go -func gowebgpu_buffer_map_callback_go(status C.WGPUBufferMapAsyncStatus, userdata unsafe.Pointer) { +func gowebgpu_buffer_map_callback_go(status C.WGPUMapAsyncStatus, userdata unsafe.Pointer) { handle := *(*cgo.Handle)(userdata) defer handle.Delete() cb, ok := handle.Value().(BufferMapCallback) if ok { - cb(BufferMapAsyncStatus(status)) + cb(MapAsyncStatus(status)) } } @@ -79,11 +91,13 @@ func (p *Buffer) MapAsync(mode MapMode, offset uint64, size uint64, callback Buf C.gowebgpu_buffer_map_async( p.ref, - C.WGPUMapModeFlags(mode), + C.WGPUMapMode(mode), C.size_t(offset), C.size_t(size), - (C.WGPUBufferMapAsyncCallback)(C.gowebgpu_buffer_map_callback_c), - unsafe.Pointer(&callbackHandle), + C.WGPUBufferMapCallbackInfo{ + callback: C.gowebgpu_buffer_map_callback_c, + userdata1: unsafe.Pointer(&callbackHandle), + }, p.deviceRef, unsafe.Pointer(&errorCallbackHandle), ) diff --git a/wgpu/enums.go b/wgpu/enums.go index f8b0e78..4efc911 100644 --- a/wgpu/enums.go +++ b/wgpu/enums.go @@ -188,39 +188,39 @@ func (v BufferBindingType) String() string { } } -type BufferMapAsyncStatus uint32 +type MapAsyncStatus uint32 const ( - BufferMapAsyncStatusSuccess BufferMapAsyncStatus = 0x00000000 - BufferMapAsyncStatusValidationError BufferMapAsyncStatus = 0x00000001 - BufferMapAsyncStatusUnknown BufferMapAsyncStatus = 0x00000002 - BufferMapAsyncStatusDeviceLost BufferMapAsyncStatus = 0x00000003 - BufferMapAsyncStatusDestroyedBeforeCallback BufferMapAsyncStatus = 0x00000004 - BufferMapAsyncStatusUnmappedBeforeCallback BufferMapAsyncStatus = 0x00000005 - BufferMapAsyncStatusMappingAlreadyPending BufferMapAsyncStatus = 0x00000006 - BufferMapAsyncStatusOffsetOutOfRange BufferMapAsyncStatus = 0x00000007 - BufferMapAsyncStatusSizeOutOfRange BufferMapAsyncStatus = 0x00000008 + MapAsyncStatusSuccess MapAsyncStatus = 0x00000000 + MapAsyncStatusValidationError MapAsyncStatus = 0x00000001 + MapAsyncStatusUnknown MapAsyncStatus = 0x00000002 + MapAsyncStatusDeviceLost MapAsyncStatus = 0x00000003 + MapAsyncStatusDestroyedBeforeCallback MapAsyncStatus = 0x00000004 + MapAsyncStatusUnmappedBeforeCallback MapAsyncStatus = 0x00000005 + MapAsyncStatusMappingAlreadyPending MapAsyncStatus = 0x00000006 + MapAsyncStatusOffsetOutOfRange MapAsyncStatus = 0x00000007 + MapAsyncStatusSizeOutOfRange MapAsyncStatus = 0x00000008 ) -func (v BufferMapAsyncStatus) String() string { +func (v MapAsyncStatus) String() string { switch v { - case BufferMapAsyncStatusSuccess: + case MapAsyncStatusSuccess: return "success" - case BufferMapAsyncStatusValidationError: + case MapAsyncStatusValidationError: return "validation-error" - case BufferMapAsyncStatusUnknown: + case MapAsyncStatusUnknown: return "unknown" - case BufferMapAsyncStatusDeviceLost: + case MapAsyncStatusDeviceLost: return "device-lost" - case BufferMapAsyncStatusDestroyedBeforeCallback: + case MapAsyncStatusDestroyedBeforeCallback: return "destroyed-before-callback" - case BufferMapAsyncStatusUnmappedBeforeCallback: + case MapAsyncStatusUnmappedBeforeCallback: return "unmapped-before-callback" - case BufferMapAsyncStatusMappingAlreadyPending: + case MapAsyncStatusMappingAlreadyPending: return "mapping-already-pending" - case BufferMapAsyncStatusOffsetOutOfRange: + case MapAsyncStatusOffsetOutOfRange: return "offset-out-of-range" - case BufferMapAsyncStatusSizeOutOfRange: + case MapAsyncStatusSizeOutOfRange: return "size-out-of-range" default: return "" diff --git a/wgpu/wgpu_c_cb.go b/wgpu/wgpu_c_cb.go index 5aa2a53..134554d 100644 --- a/wgpu/wgpu_c_cb.go +++ b/wgpu/wgpu_c_cb.go @@ -26,7 +26,7 @@ void gowebgpu_device_lost_callback_c(WGPUDeviceLostReason reason, char const * m gowebgpu_device_lost_callback_go(reason, message, userdata); } -void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata) { +void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2) { if (type == WGPUErrorType_NoError) { return; } From 29bd2e71f36b3baee7ebc2b7c1f315afa2f5ab97 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 15:58:34 +0200 Subject: [PATCH 04/19] wgpu/command_encoder: Update --- wgpu/command_encoder.go | 135 ++++++++++++++++++++++++++++++---------- 1 file changed, 101 insertions(+), 34 deletions(-) diff --git a/wgpu/command_encoder.go b/wgpu/command_encoder.go index c03a5af..9c57aae 100644 --- a/wgpu/command_encoder.go +++ b/wgpu/command_encoder.go @@ -7,74 +7,141 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); static inline void gowebgpu_command_encoder_clear_buffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderClearBuffer(commandEncoder, buffer, offset, size); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderCopyBufferToBuffer(commandEncoder, source, sourceOffset, destination, destinationOffset, size); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } -static inline void gowebgpu_command_encoder_copy_buffer_to_texture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize, WGPUDevice device, void * error_userdata) { +static inline void gowebgpu_command_encoder_copy_buffer_to_texture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderCopyBufferToTexture(commandEncoder, source, destination, copySize); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } -static inline void gowebgpu_command_encoder_copy_texture_to_buffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize, WGPUDevice device, void * error_userdata) { +static inline void gowebgpu_command_encoder_copy_texture_to_buffer(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderCopyTextureToBuffer(commandEncoder, source, destination, copySize); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } -static inline void gowebgpu_command_encoder_copy_texture_to_texture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize, WGPUDevice device, void * error_userdata) { +static inline void gowebgpu_command_encoder_copy_texture_to_texture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderCopyTextureToTexture(commandEncoder, source, destination, copySize); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline WGPUCommandBuffer gowebgpu_command_encoder_finish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor, WGPUDevice device, void * error_userdata) { WGPUCommandBuffer ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuCommandEncoderFinish(commandEncoder, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } static inline void gowebgpu_command_encoder_insert_debug_marker(WGPUCommandEncoder commandEncoder, char const * markerLabel, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); - wgpuCommandEncoderInsertDebugMarker(commandEncoder, markerLabel); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + wgpuCommandEncoderInsertDebugMarker(commandEncoder, (WGPUStringView) {markerLabel, WGPU_STRLEN}); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_command_encoder_pop_debug_group(WGPUCommandEncoder commandEncoder, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderPopDebugGroup(commandEncoder); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_command_encoder_push_debug_group(WGPUCommandEncoder commandEncoder, char const * groupLabel, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); - wgpuCommandEncoderPushDebugGroup(commandEncoder, groupLabel); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + wgpuCommandEncoderPushDebugGroup(commandEncoder, (WGPUStringView) {groupLabel, WGPU_STRLEN}); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_command_encoder_resolve_query_set(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderResolveQuerySet(commandEncoder, querySet, firstQuery, queryCount, destination, destinationOffset); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_command_encoder_write_timestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuCommandEncoderWriteTimestamp(commandEncoder, querySet, queryIndex); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_command_encoder_release(WGPUCommandEncoder commandEncoder, WGPUDevice device) { @@ -119,7 +186,7 @@ func (p *CommandEncoder) BeginComputePass(descriptor *ComputePassDescriptor) *Co panic("Failed to acquire ComputePassEncoder") } - C.wgpuDeviceReference(p.deviceRef) + C.wgpuDeviceAddRef(p.deviceRef) return &ComputePassEncoder{deviceRef: p.deviceRef, ref: ref} } @@ -188,7 +255,7 @@ func (p *CommandEncoder) BeginRenderPass(descriptor *RenderPassDescriptor) *Rend } ref := C.wgpuCommandEncoderBeginRenderPass(p.ref, &desc) - C.wgpuDeviceReference(p.deviceRef) + C.wgpuDeviceAddRef(p.deviceRef) return &RenderPassEncoder{deviceRef: p.deviceRef, ref: ref} } @@ -230,22 +297,22 @@ func (p *CommandEncoder) CopyBufferToBuffer(source *Buffer, sourceOffset uint64, return } -func (p *CommandEncoder) CopyBufferToTexture(source *ImageCopyBuffer, destination *ImageCopyTexture, copySize *Extent3D) (err error) { - var src C.WGPUImageCopyBuffer +func (p *CommandEncoder) CopyBufferToTexture(source *TexelCopyBufferInfo, destination *TexelCopyTextureInfo, copySize *Extent3D) (err error) { + var src C.WGPUTexelCopyBufferInfo if source != nil { if source.Buffer != nil { src.buffer = source.Buffer.ref } - src.layout = C.WGPUTextureDataLayout{ + src.layout = C.WGPUTexelCopyBufferLayout{ offset: C.uint64_t(source.Layout.Offset), bytesPerRow: C.uint32_t(source.Layout.BytesPerRow), rowsPerImage: C.uint32_t(source.Layout.RowsPerImage), } } - var dst C.WGPUImageCopyTexture + var dst C.WGPUTexelCopyTextureInfo if destination != nil { - dst = C.WGPUImageCopyTexture{ + dst = C.WGPUTexelCopyTextureInfo{ mipLevel: C.uint32_t(destination.MipLevel), origin: C.WGPUOrigin3D{ x: C.uint32_t(destination.Origin.X), @@ -285,10 +352,10 @@ func (p *CommandEncoder) CopyBufferToTexture(source *ImageCopyBuffer, destinatio return } -func (p *CommandEncoder) CopyTextureToBuffer(source *ImageCopyTexture, destination *ImageCopyBuffer, copySize *Extent3D) (err error) { - var src C.WGPUImageCopyTexture +func (p *CommandEncoder) CopyTextureToBuffer(source *TexelCopyTextureInfo, destination *TexelCopyBufferInfo, copySize *Extent3D) (err error) { + var src C.WGPUTexelCopyTextureInfo if source != nil { - src = C.WGPUImageCopyTexture{ + src = C.WGPUTexelCopyTextureInfo{ mipLevel: C.uint32_t(source.MipLevel), origin: C.WGPUOrigin3D{ x: C.uint32_t(source.Origin.X), @@ -302,12 +369,12 @@ func (p *CommandEncoder) CopyTextureToBuffer(source *ImageCopyTexture, destinati } } - var dst C.WGPUImageCopyBuffer + var dst C.WGPUTexelCopyBufferInfo if destination != nil { if destination.Buffer != nil { dst.buffer = destination.Buffer.ref } - dst.layout = C.WGPUTextureDataLayout{ + dst.layout = C.WGPUTexelCopyBufferLayout{ offset: C.uint64_t(destination.Layout.Offset), bytesPerRow: C.uint32_t(destination.Layout.BytesPerRow), rowsPerImage: C.uint32_t(destination.Layout.RowsPerImage), @@ -340,10 +407,10 @@ func (p *CommandEncoder) CopyTextureToBuffer(source *ImageCopyTexture, destinati return } -func (p *CommandEncoder) CopyTextureToTexture(source *ImageCopyTexture, destination *ImageCopyTexture, copySize *Extent3D) (err error) { - var src C.WGPUImageCopyTexture +func (p *CommandEncoder) CopyTextureToTexture(source *TexelCopyTextureInfo, destination *TexelCopyTextureInfo, copySize *Extent3D) (err error) { + var src C.WGPUTexelCopyTextureInfo if source != nil { - src = C.WGPUImageCopyTexture{ + src = C.WGPUTexelCopyTextureInfo{ mipLevel: C.uint32_t(source.MipLevel), origin: C.WGPUOrigin3D{ x: C.uint32_t(source.Origin.X), @@ -357,9 +424,9 @@ func (p *CommandEncoder) CopyTextureToTexture(source *ImageCopyTexture, destinat } } - var dst C.WGPUImageCopyTexture + var dst C.WGPUTexelCopyTextureInfo if destination != nil { - dst = C.WGPUImageCopyTexture{ + dst = C.WGPUTexelCopyTextureInfo{ mipLevel: C.uint32_t(destination.MipLevel), origin: C.WGPUOrigin3D{ x: C.uint32_t(destination.Origin.X), From f7d67836b842f67eb9ce3264878b0d2ebe885ec3 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 15:59:19 +0200 Subject: [PATCH 05/19] wgpu/compute_pass_encoder: Update --- wgpu/compute_pass_encoder.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wgpu/compute_pass_encoder.go b/wgpu/compute_pass_encoder.go index d2030d1..25cd133 100644 --- a/wgpu/compute_pass_encoder.go +++ b/wgpu/compute_pass_encoder.go @@ -7,12 +7,18 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); static inline void gowebgpu_compute_pass_encoder_end(WGPUComputePassEncoder computePassEncoder, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuComputePassEncoderEnd(computePassEncoder); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_compute_pass_encoder_release(WGPUComputePassEncoder computePassEncoder, WGPUDevice device) { From 0f2a518a9326b24a98cddd52472bae44a50b2a68 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:16:18 +0200 Subject: [PATCH 06/19] wgpu/device: Update non shader-related stuff --- wgpu/adapter.go | 2 +- wgpu/common.go | 11 +-- wgpu/device.go | 227 +++++++++++++++++++++++++++++++----------------- 3 files changed, 151 insertions(+), 89 deletions(-) diff --git a/wgpu/adapter.go b/wgpu/adapter.go index 4f52f9d..f4dbc2e 100644 --- a/wgpu/adapter.go +++ b/wgpu/adapter.go @@ -75,7 +75,7 @@ func (p *Adapter) GetLimits() Limits { MaxComputeWorkgroupSizeZ: uint32(limits.maxComputeWorkgroupSizeZ), MaxComputeWorkgroupsPerDimension: uint32(limits.maxComputeWorkgroupsPerDimension), - MaxPushConstantSize: uint32(nativeLimits.limits.maxPushConstantSize), + MaxPushConstantSize: uint32(nativeLimits.maxPushConstantSize), MaxNonSamplerBindings: uint32(nativeLimits.maxNonSamplerBindings), } } diff --git a/wgpu/common.go b/wgpu/common.go index 443bc4e..9249386 100644 --- a/wgpu/common.go +++ b/wgpu/common.go @@ -79,7 +79,7 @@ type SurfaceConfiguration struct { ViewFormats []TextureFormat } -type ImageCopyTexture struct { +type TexelCopyTextureInfo struct { Texture *Texture MipLevel uint32 Origin Origin3D @@ -165,7 +165,7 @@ type BufferInitDescriptor struct { Usage BufferUsage } -type BufferMapCallback func(BufferMapAsyncStatus) +type BufferMapCallback func(MapAsyncStatus) type QueueWorkDoneCallback func(QueueWorkDoneStatus) @@ -234,14 +234,9 @@ type CommandBufferDescriptor struct { Label string } -type WrappedSubmissionIndex struct { - Queue *Queue - SubmissionIndex SubmissionIndex -} - type SubmissionIndex uint64 -type ImageCopyBuffer struct { +type TexelCopyBufferInfo struct { Layout TextureDataLayout Buffer *Buffer } diff --git a/wgpu/device.go b/wgpu/device.go index ee04827..278fb08 100644 --- a/wgpu/device.go +++ b/wgpu/device.go @@ -7,13 +7,20 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); static inline WGPUBindGroup gowebgpu_device_create_bind_group(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor, void * error_userdata) { WGPUBindGroup ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateBindGroup(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -21,7 +28,14 @@ static inline WGPUBindGroupLayout gowebgpu_device_create_bind_group_layout(WGPUD WGPUBindGroupLayout ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateBindGroupLayout(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -29,7 +43,14 @@ static inline WGPUBuffer gowebgpu_device_create_buffer(WGPUDevice device, WGPUBu WGPUBuffer ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateBuffer(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -37,7 +58,14 @@ static inline WGPUCommandEncoder gowebgpu_device_create_command_encoder(WGPUDevi WGPUCommandEncoder ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateCommandEncoder(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -45,7 +73,14 @@ static inline WGPUComputePipeline gowebgpu_device_create_compute_pipeline(WGPUDe WGPUComputePipeline ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateComputePipeline(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -53,7 +88,14 @@ static inline WGPUPipelineLayout gowebgpu_device_create_pipeline_layout(WGPUDevi WGPUPipelineLayout ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreatePipelineLayout(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -61,7 +103,14 @@ static inline WGPUQuerySet gowebgpu_device_create_query_set(WGPUDevice device, W WGPUQuerySet ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateQuerySet(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -69,7 +118,14 @@ static inline WGPURenderPipeline gowebgpu_device_create_render_pipeline(WGPUDevi WGPURenderPipeline ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateRenderPipeline(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -77,7 +133,14 @@ static inline WGPUSampler gowebgpu_device_create_sampler(WGPUDevice device, WGPU WGPUSampler ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateSampler(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -85,7 +148,14 @@ static inline WGPUShaderModule gowebgpu_device_create_shader_module(WGPUDevice d WGPUShaderModule ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateShaderModule(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -93,7 +163,14 @@ static inline WGPUTexture gowebgpu_device_create_texture(WGPUDevice device, WGPU WGPUTexture ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuDeviceCreateTexture(device, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } @@ -242,7 +319,7 @@ func (p *Device) CreateBindGroupLayout(descriptor *BindGroupLayoutDescriptor) (* entriesSlice[i] = C.WGPUBindGroupLayoutEntry{ nextInChain: nil, binding: C.uint32_t(v.Binding), - visibility: C.WGPUShaderStageFlags(v.Visibility), + visibility: C.WGPUShaderStage(v.Visibility), buffer: C.WGPUBufferBindingLayout{ nextInChain: nil, _type: C.WGPUBufferBindingType(v.Buffer.Type), @@ -304,7 +381,7 @@ func (p *Device) CreateBuffer(descriptor *BufferDescriptor) (*Buffer, error) { desc.label = label } - desc.usage = C.WGPUBufferUsageFlags(descriptor.Usage) + desc.usage = C.WGPUBufferUsage(descriptor.Usage) desc.size = C.uint64_t(descriptor.Size) desc.mappedAtCreation = cBool(descriptor.MappedAtCreation) } @@ -326,7 +403,7 @@ func (p *Device) CreateBuffer(descriptor *BufferDescriptor) (*Buffer, error) { return nil, err } - C.wgpuDeviceReference(p.ref) + C.wgpuDeviceAddRef(p.ref) return &Buffer{deviceRef: p.ref, ref: ref}, nil } @@ -359,7 +436,7 @@ func (p *Device) CreateCommandEncoder(descriptor *CommandEncoderDescriptor) (*Co return nil, err } - C.wgpuDeviceReference(p.ref) + C.wgpuDeviceAddRef(p.ref) return &CommandEncoder{deviceRef: p.ref, ref: ref}, nil } @@ -475,7 +552,7 @@ func (p *Device) CreatePipelineLayout(descriptor *PipelineLayoutDescriptor) (*Pi for i, v := range descriptor.PushConstantRanges { pushConstantRangesSlice[i] = C.WGPUPushConstantRange{ - stages: C.WGPUShaderStageFlags(v.Stages), + stages: C.WGPUShaderStage(v.Stages), start: C.uint32_t(v.Start), end: C.uint32_t(v.End), } @@ -832,7 +909,7 @@ func (p *Device) CreateRenderPipeline(descriptor *RenderPipelineDescriptor) (*Re for i, v := range fragment.Targets { target := C.WGPUColorTargetState{ format: C.WGPUTextureFormat(v.Format), - writeMask: C.WGPUColorWriteMaskFlags(v.WriteMask), + writeMask: C.WGPUColorWriteMask(v.WriteMask), } if v.Blend != nil { @@ -863,7 +940,7 @@ func (p *Device) CreateRenderPipeline(descriptor *RenderPipelineDescriptor) (*Re frag.targets = nil } frag.constantCount = 0 // note: crashes on linux arm64 without setting this to 0 - frag.constants = nil // even though wgpu doesn't even support it. + frag.constants = nil // even though wgpu doesn't even support it. desc.fragment = frag } @@ -1076,7 +1153,7 @@ func (p *Device) CreateTexture(descriptor *TextureDescriptor) (*Texture, error) if descriptor != nil { desc = C.WGPUTextureDescriptor{ - usage: C.WGPUTextureUsageFlags(descriptor.Usage), + usage: C.WGPUTextureUsage(descriptor.Usage), dimension: C.WGPUTextureDimension(descriptor.Dimension), size: C.WGPUExtent3D{ width: C.uint32_t(descriptor.Size.Width), @@ -1113,72 +1190,70 @@ func (p *Device) CreateTexture(descriptor *TextureDescriptor) (*Texture, error) return nil, err } - C.wgpuDeviceReference(p.ref) + C.wgpuDeviceAddRef(p.ref) return &Texture{deviceRef: p.ref, ref: ref}, nil } -func (p *Device) EnumerateFeatures() []FeatureName { - size := C.wgpuDeviceEnumerateFeatures(p.ref, nil) +func (p *Device) GetFeatures() []FeatureName { + size := C.wgpuDeviceGetFeatures(p.ref, nil) if size == 0 { return nil } features := make([]FeatureName, size) - C.wgpuDeviceEnumerateFeatures(p.ref, (*C.WGPUFeatureName)(unsafe.Pointer(&features[0]))) + C.wgpuDeviceGetFeatures(p.ref, (*C.WGPUFeatureName)(unsafe.Pointer(&features[0]))) return features } -func (p *Device) GetLimits() SupportedLimits { - var supportedLimits C.WGPUSupportedLimits - - extras := (*C.WGPUSupportedLimitsExtras)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSupportedLimitsExtras{})))) - defer C.free(unsafe.Pointer(extras)) - supportedLimits.nextInChain = (*C.WGPUChainedStructOut)(unsafe.Pointer(extras)) - - C.wgpuDeviceGetLimits(p.ref, &supportedLimits) - - limits := supportedLimits.limits - return SupportedLimits{ - Limits{ - MaxTextureDimension1D: uint32(limits.maxTextureDimension1D), - MaxTextureDimension2D: uint32(limits.maxTextureDimension2D), - MaxTextureDimension3D: uint32(limits.maxTextureDimension3D), - MaxTextureArrayLayers: uint32(limits.maxTextureArrayLayers), - MaxBindGroups: uint32(limits.maxBindGroups), - MaxBindingsPerBindGroup: uint32(limits.maxBindingsPerBindGroup), - MaxDynamicUniformBuffersPerPipelineLayout: uint32(limits.maxDynamicUniformBuffersPerPipelineLayout), - MaxDynamicStorageBuffersPerPipelineLayout: uint32(limits.maxDynamicStorageBuffersPerPipelineLayout), - MaxSampledTexturesPerShaderStage: uint32(limits.maxSampledTexturesPerShaderStage), - MaxSamplersPerShaderStage: uint32(limits.maxSamplersPerShaderStage), - MaxStorageBuffersPerShaderStage: uint32(limits.maxStorageBuffersPerShaderStage), - MaxStorageTexturesPerShaderStage: uint32(limits.maxStorageTexturesPerShaderStage), - MaxUniformBuffersPerShaderStage: uint32(limits.maxUniformBuffersPerShaderStage), - MaxUniformBufferBindingSize: uint64(limits.maxUniformBufferBindingSize), - MaxStorageBufferBindingSize: uint64(limits.maxStorageBufferBindingSize), - MinUniformBufferOffsetAlignment: uint32(limits.minUniformBufferOffsetAlignment), - MinStorageBufferOffsetAlignment: uint32(limits.minStorageBufferOffsetAlignment), - MaxVertexBuffers: uint32(limits.maxVertexBuffers), - MaxBufferSize: uint64(limits.maxBufferSize), - MaxVertexAttributes: uint32(limits.maxVertexAttributes), - MaxVertexBufferArrayStride: uint32(limits.maxVertexBufferArrayStride), - MaxInterStageShaderComponents: uint32(limits.maxInterStageShaderComponents), - MaxInterStageShaderVariables: uint32(limits.maxInterStageShaderVariables), - MaxColorAttachments: uint32(limits.maxColorAttachments), - MaxComputeWorkgroupStorageSize: uint32(limits.maxComputeWorkgroupStorageSize), - MaxComputeInvocationsPerWorkgroup: uint32(limits.maxComputeInvocationsPerWorkgroup), - MaxComputeWorkgroupSizeX: uint32(limits.maxComputeWorkgroupSizeX), - MaxComputeWorkgroupSizeY: uint32(limits.maxComputeWorkgroupSizeY), - MaxComputeWorkgroupSizeZ: uint32(limits.maxComputeWorkgroupSizeZ), - MaxComputeWorkgroupsPerDimension: uint32(limits.maxComputeWorkgroupsPerDimension), - - MaxPushConstantSize: uint32(extras.limits.maxPushConstantSize), - }, +func (p *Device) GetLimits() Limits { + var limits C.WGPULimits + + nativeLimits := (*C.WGPUNativeLimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUNativeLimits{})))) + defer C.free(unsafe.Pointer(&nativeLimits)) + limits.nextInChain = (*C.WGPUChainedStructOut)(unsafe.Pointer(&nativeLimits)) + + C.wgpuDeviceGetLimits(p.ref, &limits) + + return Limits{ + MaxTextureDimension1D: uint32(limits.maxTextureDimension1D), + MaxTextureDimension2D: uint32(limits.maxTextureDimension2D), + MaxTextureDimension3D: uint32(limits.maxTextureDimension3D), + MaxTextureArrayLayers: uint32(limits.maxTextureArrayLayers), + MaxBindGroups: uint32(limits.maxBindGroups), + MaxBindingsPerBindGroup: uint32(limits.maxBindingsPerBindGroup), + MaxDynamicUniformBuffersPerPipelineLayout: uint32(limits.maxDynamicUniformBuffersPerPipelineLayout), + MaxDynamicStorageBuffersPerPipelineLayout: uint32(limits.maxDynamicStorageBuffersPerPipelineLayout), + MaxSampledTexturesPerShaderStage: uint32(limits.maxSampledTexturesPerShaderStage), + MaxSamplersPerShaderStage: uint32(limits.maxSamplersPerShaderStage), + MaxStorageBuffersPerShaderStage: uint32(limits.maxStorageBuffersPerShaderStage), + MaxStorageTexturesPerShaderStage: uint32(limits.maxStorageTexturesPerShaderStage), + MaxUniformBuffersPerShaderStage: uint32(limits.maxUniformBuffersPerShaderStage), + MaxUniformBufferBindingSize: uint64(limits.maxUniformBufferBindingSize), + MaxStorageBufferBindingSize: uint64(limits.maxStorageBufferBindingSize), + MinUniformBufferOffsetAlignment: uint32(limits.minUniformBufferOffsetAlignment), + MinStorageBufferOffsetAlignment: uint32(limits.minStorageBufferOffsetAlignment), + MaxVertexBuffers: uint32(limits.maxVertexBuffers), + MaxBufferSize: uint64(limits.maxBufferSize), + MaxVertexAttributes: uint32(limits.maxVertexAttributes), + MaxVertexBufferArrayStride: uint32(limits.maxVertexBufferArrayStride), + MaxInterStageShaderComponents: uint32(limits.maxInterStageShaderComponents), + MaxInterStageShaderVariables: uint32(limits.maxInterStageShaderVariables), + MaxColorAttachments: uint32(limits.maxColorAttachments), + MaxComputeWorkgroupStorageSize: uint32(limits.maxComputeWorkgroupStorageSize), + MaxComputeInvocationsPerWorkgroup: uint32(limits.maxComputeInvocationsPerWorkgroup), + MaxComputeWorkgroupSizeX: uint32(limits.maxComputeWorkgroupSizeX), + MaxComputeWorkgroupSizeY: uint32(limits.maxComputeWorkgroupSizeY), + MaxComputeWorkgroupSizeZ: uint32(limits.maxComputeWorkgroupSizeZ), + MaxComputeWorkgroupsPerDimension: uint32(limits.maxComputeWorkgroupsPerDimension), + + MaxPushConstantSize: uint32(nativeLimits.maxPushConstantSize), + MaxNonSamplerBindings: uint32(nativeLimits.maxNonSamplerBindings), } } func (p *Device) GetQueue() *Queue { ref := C.wgpuDeviceGetQueue(p.ref) - C.wgpuDeviceReference(p.ref) + C.wgpuDeviceAddRef(p.ref) return &Queue{deviceRef: p.ref, ref: ref} } @@ -1187,14 +1262,6 @@ func (p *Device) HasFeature(feature FeatureName) bool { return goBool(hasFeature) } -func (p *Device) Poll(wait bool, wrappedSubmissionIndex *WrappedSubmissionIndex) (queueEmpty bool) { - var index *C.WGPUWrappedSubmissionIndex - if wrappedSubmissionIndex != nil { - index = &C.WGPUWrappedSubmissionIndex{ - queue: wrappedSubmissionIndex.Queue.ref, - submissionIndex: C.WGPUSubmissionIndex(wrappedSubmissionIndex.SubmissionIndex), - } - } - - return goBool(C.wgpuDevicePoll(p.ref, cBool(wait), index)) +func (p *Device) Poll(wait bool, submissionIndex uint64) (queueEmpty bool) { + return goBool(C.wgpuDevicePoll(p.ref, cBool(wait), submissionIndex)) } From a6b0edefd53af1f4bd3584020963edc7f0829728 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:31:48 +0200 Subject: [PATCH 07/19] wgpu/device: Update shader-related stuff --- wgpu/common.go | 6 ++++- wgpu/device.go | 58 ++++++++++++++++++++++++------------------------- wgpu/lib/wgpu.h | 13 +++-------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/wgpu/common.go b/wgpu/common.go index 9249386..6b87dd6 100644 --- a/wgpu/common.go +++ b/wgpu/common.go @@ -124,10 +124,14 @@ type SurfaceCapabilities struct { AlphaModes []CompositeAlphaMode } -type ShaderModuleWGSLDescriptor struct { +type ShaderSourceWGSL struct { Code string } +type ShaderSourceSPIRV struct { + Code []byte +} + type DeviceDescriptor struct { Label string RequiredFeatures []FeatureName diff --git a/wgpu/device.go b/wgpu/device.go index 278fb08..d1c7010 100644 --- a/wgpu/device.go +++ b/wgpu/device.go @@ -1011,21 +1011,17 @@ func (p *Device) CreateSampler(descriptor *SamplerDescriptor) (*Sampler, error) return &Sampler{ref}, nil } -type ShaderModuleSPIRVDescriptor struct { - Code []byte -} - -type ShaderModuleGLSLDescriptor struct { +type ShaderSourceGLSL struct { Code string Defines map[string]string ShaderStage ShaderStage } type ShaderModuleDescriptor struct { - Label string - SPIRVDescriptor *ShaderModuleSPIRVDescriptor - WGSLDescriptor *ShaderModuleWGSLDescriptor - GLSLDescriptor *ShaderModuleGLSLDescriptor + Label string + SPIRVSource *ShaderSourceSPIRV + WGSLSource *ShaderSourceWGSL + GLSLSource *ShaderSourceGLSL } func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*ShaderModule, error) { @@ -1040,13 +1036,13 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader } switch { - case descriptor.SPIRVDescriptor != nil: - spirv := (*C.WGPUShaderModuleSPIRVDescriptor)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderModuleSPIRVDescriptor{})))) + case descriptor.SPIRVSource != nil: + spirv := (*C.WGPUShaderSourceSPIRV)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderSourceSPIRV{})))) defer C.free(unsafe.Pointer(spirv)) - codeSize := len(descriptor.SPIRVDescriptor.Code) + codeSize := len(descriptor.SPIRVSource.Code) if codeSize > 0 { - code := C.CBytes(descriptor.SPIRVDescriptor.Code) + code := C.CBytes(descriptor.SPIRVSource.Code) defer C.free(code) spirv.codeSize = C.uint32_t(codeSize) @@ -1057,42 +1053,46 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader } spirv.chain.next = nil - spirv.chain.sType = C.WGPUSType_ShaderModuleSPIRVDescriptor + spirv.chain.sType = C.WGPUSType_ShaderSourceSPIRV desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(spirv)) - case descriptor.WGSLDescriptor != nil: - wgsl := (*C.WGPUShaderModuleWGSLDescriptor)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderModuleWGSLDescriptor{})))) + case descriptor.WGSLSource != nil: + wgsl := (*C.WGPUShaderSourceWGSL)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderSourceWGSL{})))) defer C.free(unsafe.Pointer(wgsl)) - if descriptor.WGSLDescriptor.Code != "" { - code := C.CString(descriptor.WGSLDescriptor.Code) + if descriptor.WGSLSource.Code != "" { + code := C.CString(descriptor.WGSLSource.Code) defer C.free(unsafe.Pointer(code)) - wgsl.code = code + wgsl.code.data = code + wgsl.code.length = C.WGPU_STRLEN } else { wgsl.code = nil + wgsl.code.length = 0 } wgsl.chain.next = nil - wgsl.chain.sType = C.WGPUSType_ShaderModuleWGSLDescriptor + wgsl.chain.sType = C.WGPUSType_ShaderSourceWGSL desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(wgsl)) - case descriptor.GLSLDescriptor != nil: - glsl := (*C.WGPUShaderModuleGLSLDescriptor)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderModuleGLSLDescriptor{})))) + case descriptor.GLSLSource != nil: + glsl := (*C.WGPUShaderSourceGLSL)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderSourceGLSL{})))) defer C.free(unsafe.Pointer(glsl)) - if descriptor.GLSLDescriptor.Code != "" { - code := C.CString(descriptor.GLSLDescriptor.Code) + if descriptor.GLSLSource.Code != "" { + code := C.CString(descriptor.GLSLSource.Code) defer C.free(unsafe.Pointer(code)) - glsl.code = code + glsl.code.data = code + glsl.code.length = C.WGPU_STRLEN } else { glsl.code = nil + glsl.code.length = 0 } - defineCount := len(descriptor.GLSLDescriptor.Defines) + defineCount := len(descriptor.GLSLSource.Defines) if defineCount > 0 { shaderDefines := C.malloc(C.size_t(unsafe.Sizeof(C.WGPUShaderDefine{})) * C.size_t(defineCount)) defer C.free(shaderDefines) @@ -1100,7 +1100,7 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader shaderDefinesSlice := unsafe.Slice((*C.WGPUShaderDefine)(shaderDefines), defineCount) index := 0 - for name, value := range descriptor.GLSLDescriptor.Defines { + for name, value := range descriptor.GLSLSource.Defines { namePtr := C.CString(name) defer C.free(unsafe.Pointer(namePtr)) valuePtr := C.CString(value) @@ -1120,9 +1120,9 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader glsl.defines = nil } - glsl.stage = C.WGPUShaderStage(descriptor.GLSLDescriptor.ShaderStage) + glsl.stage = C.WGPUShaderStage(descriptor.GLSLSource.ShaderStage) glsl.chain.next = nil - glsl.chain.sType = C.WGPUSType_ShaderModuleGLSLDescriptor + glsl.chain.sType = C.WGPUSType_ShaderSourceGLSL desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(glsl)) } diff --git a/wgpu/lib/wgpu.h b/wgpu/lib/wgpu.h index 6cee9d1..f26befc 100644 --- a/wgpu/lib/wgpu.h +++ b/wgpu/lib/wgpu.h @@ -8,7 +8,7 @@ typedef enum WGPUNativeSType { WGPUSType_DeviceExtras = 0x00030001, WGPUSType_NativeLimits = 0x00030002, WGPUSType_PipelineLayoutExtras = 0x00030003, - WGPUSType_ShaderModuleGLSLDescriptor = 0x00030004, + WGPUSType_ShaderSourceGLSL = 0x00030004, WGPUSType_InstanceExtras = 0x00030006, WGPUSType_BindGroupEntryExtras = 0x00030007, WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, @@ -159,19 +159,13 @@ typedef struct WGPUShaderDefine { WGPUStringView value; } WGPUShaderDefine; -typedef struct WGPUShaderModuleGLSLDescriptor { +typedef struct WGPUShaderSourceGLSL { WGPUChainedStruct chain; WGPUShaderStage stage; WGPUStringView code; uint32_t defineCount; WGPUShaderDefine * defines; -} WGPUShaderModuleGLSLDescriptor; - -typedef struct WGPUShaderModuleDescriptorSpirV { - WGPUStringView label; - uint32_t sourceSize; - uint32_t const * source; -} WGPUShaderModuleDescriptorSpirV; +} WGPUShaderSourceGLSL; typedef struct WGPURegistryReport { size_t numAllocated; @@ -261,7 +255,6 @@ WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount // Returns true if the queue is empty, or false if there are more queue submissions still in flight. WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * wrappedSubmissionIndex); -WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); From 9a258f9863525fb6b1c2ac2dde80a82a20caaed1 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:37:02 +0200 Subject: [PATCH 08/19] wgpu/instance: Update --- wgpu/instance.go | 57 +++++++++++++++++++++++++----------------------- wgpu/lib/wgpu.h | 2 +- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/wgpu/instance.go b/wgpu/instance.go index 46de657..484409c 100644 --- a/wgpu/instance.go +++ b/wgpu/instance.go @@ -30,7 +30,7 @@ func CreateInstance(descriptor *InstanceDescriptor) *Instance { instanceExtras.chain.next = nil instanceExtras.chain.sType = C.WGPUSType_InstanceExtras - instanceExtras.backends = C.WGPUInstanceBackendFlags(descriptor.Backends) + instanceExtras.backends = C.WGPUInstanceBackend(descriptor.Backends) instanceExtras.dx12ShaderCompiler = C.WGPUDx12Compiler(descriptor.Dx12ShaderCompiler) if descriptor.DxilPath != "" { @@ -56,43 +56,43 @@ func CreateInstance(descriptor *InstanceDescriptor) *Instance { return &Instance{ref} } -type SurfaceDescriptorFromWindowsHWND struct { +type SurfaceSourceWindowsHWND struct { Hinstance unsafe.Pointer Hwnd unsafe.Pointer } -type SurfaceDescriptorFromXcbWindow struct { +type SurfaceSourceXcbWindow struct { Connection unsafe.Pointer Window uint32 } -type SurfaceDescriptorFromXlibWindow struct { +type SurfaceSourceXlibWindow struct { Display unsafe.Pointer Window uint32 } -type SurfaceDescriptorFromMetalLayer struct { +type SurfaceSourceMetalLayer struct { Layer unsafe.Pointer } -type SurfaceDescriptorFromWaylandSurface struct { +type SurfaceSourceWaylandSurface struct { Display unsafe.Pointer Surface unsafe.Pointer } -type SurfaceDescriptorFromAndroidNativeWindow struct { +type SurfaceSourceAndroidNativeWindow struct { Window unsafe.Pointer } type SurfaceDescriptor struct { Label string - WindowsHWND *SurfaceDescriptorFromWindowsHWND - XcbWindow *SurfaceDescriptorFromXcbWindow - XlibWindow *SurfaceDescriptorFromXlibWindow - MetalLayer *SurfaceDescriptorFromMetalLayer - WaylandSurface *SurfaceDescriptorFromWaylandSurface - AndroidNativeWindow *SurfaceDescriptorFromAndroidNativeWindow + WindowsHWND *SurfaceSourceWindowsHWND + XcbWindow *SurfaceSourceXcbWindow + XlibWindow *SurfaceSourceXlibWindow + MetalLayer *SurfaceSourceMetalLayer + WaylandSurface *SurfaceSourceWaylandSurface + AndroidNativeWindow *SurfaceSourceAndroidNativeWindow } func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { @@ -107,11 +107,11 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { } if descriptor.WindowsHWND != nil { - windowsHWND := (*C.WGPUSurfaceDescriptorFromWindowsHWND)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceDescriptorFromWindowsHWND{})))) + windowsHWND := (*C.WGPUSurfaceSourceWindowsHWND)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceSourceWindowsHWND{})))) defer C.free(unsafe.Pointer(windowsHWND)) windowsHWND.chain.next = nil - windowsHWND.chain.sType = C.WGPUSType_SurfaceDescriptorFromWindowsHWND + windowsHWND.chain.sType = C.WGPUSType_SurfaceSourceWindowsHWND windowsHWND.hinstance = descriptor.WindowsHWND.Hinstance windowsHWND.hwnd = descriptor.WindowsHWND.Hwnd @@ -119,11 +119,11 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { } if descriptor.XcbWindow != nil { - xcbWindow := (*C.WGPUSurfaceDescriptorFromXcbWindow)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceDescriptorFromXcbWindow{})))) + xcbWindow := (*C.WGPUSurfaceSourceXCBWindow)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceSourceXCBWindow{})))) defer C.free(unsafe.Pointer(xcbWindow)) xcbWindow.chain.next = nil - xcbWindow.chain.sType = C.WGPUSType_SurfaceDescriptorFromXcbWindow + xcbWindow.chain.sType = C.WGPUSType_SurfaceSourceXCBWindow xcbWindow.connection = descriptor.XcbWindow.Connection xcbWindow.window = C.uint32_t(descriptor.XcbWindow.Window) @@ -131,11 +131,11 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { } if descriptor.XlibWindow != nil { - xlibWindow := (*C.WGPUSurfaceDescriptorFromXlibWindow)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceDescriptorFromXlibWindow{})))) + xlibWindow := (*C.WGPUSurfaceSourceXlibWindow)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceSourceXlibWindow{})))) defer C.free(unsafe.Pointer(xlibWindow)) xlibWindow.chain.next = nil - xlibWindow.chain.sType = C.WGPUSType_SurfaceDescriptorFromXlibWindow + xlibWindow.chain.sType = C.WGPUSType_SurfaceSourceXlibWindow xlibWindow.display = descriptor.XlibWindow.Display xlibWindow.window = C.uint64_t(descriptor.XlibWindow.Window) @@ -143,22 +143,22 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { } if descriptor.MetalLayer != nil { - metalLayer := (*C.WGPUSurfaceDescriptorFromMetalLayer)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceDescriptorFromMetalLayer{})))) + metalLayer := (*C.WGPUSurfaceSourceMetalLayer)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceSourceMetalLayer{})))) defer C.free(unsafe.Pointer(metalLayer)) metalLayer.chain.next = nil - metalLayer.chain.sType = C.WGPUSType_SurfaceDescriptorFromMetalLayer + metalLayer.chain.sType = C.WGPUSType_SurfaceSourceMetalLayer metalLayer.layer = descriptor.MetalLayer.Layer desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(metalLayer)) } if descriptor.WaylandSurface != nil { - waylandSurface := (*C.WGPUSurfaceDescriptorFromWaylandSurface)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceDescriptorFromWaylandSurface{})))) + waylandSurface := (*C.WGPUSurfaceSourceWaylandSurface)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceSourceWaylandSurface{})))) defer C.free(unsafe.Pointer(waylandSurface)) waylandSurface.chain.next = nil - waylandSurface.chain.sType = C.WGPUSType_SurfaceDescriptorFromWaylandSurface + waylandSurface.chain.sType = C.WGPUSType_SurfaceSourceWaylandSurface waylandSurface.display = descriptor.WaylandSurface.Display waylandSurface.surface = descriptor.WaylandSurface.Surface @@ -166,11 +166,11 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { } if descriptor.AndroidNativeWindow != nil { - androidNativeWindow := (*C.WGPUSurfaceDescriptorFromAndroidNativeWindow)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceDescriptorFromAndroidNativeWindow{})))) + androidNativeWindow := (*C.WGPUSurfaceSourceAndroidNativeWindow)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUSurfaceSourceAndroidNativeWindow{})))) defer C.free(unsafe.Pointer(androidNativeWindow)) androidNativeWindow.chain.next = nil - androidNativeWindow.chain.sType = C.WGPUSType_SurfaceDescriptorFromAndroidNativeWindow + androidNativeWindow.chain.sType = C.WGPUSType_SurfaceSourceAndroidNativeWindow androidNativeWindow.window = descriptor.AndroidNativeWindow.Window desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(androidNativeWindow)) @@ -219,7 +219,10 @@ func (p *Instance) RequestAdapter(options *RequestAdapterOptions) (*Adapter, err adapter = a } handle := cgo.NewHandle(cb) - C.wgpuInstanceRequestAdapter(p.ref, opts, C.WGPUInstanceRequestAdapterCallback(C.gowebgpu_request_adapter_callback_c), unsafe.Pointer(&handle)) + C.wgpuInstanceRequestAdapter(p.ref, opts, C.WGPURequestAdapterCallbackInfo{ + callback: C.gowebgpu_request_adapter_callback_c, + userdata1: unsafe.Pointer(&handle), + }) if status != RequestAdapterStatusSuccess { return nil, errors.New("failed to request adapter") @@ -231,7 +234,7 @@ func (p *Instance) EnumerateAdapters(options *InstanceEnumerateAdapterOptons) [] var opts *C.WGPUInstanceEnumerateAdapterOptions if options != nil { opts = &C.WGPUInstanceEnumerateAdapterOptions{ - backends: C.WGPUInstanceBackendFlags(options.Backends), + backends: C.WGPUInstanceBackend(options.Backends), } } diff --git a/wgpu/lib/wgpu.h b/wgpu/lib/wgpu.h index f26befc..d518ced 100644 --- a/wgpu/lib/wgpu.h +++ b/wgpu/lib/wgpu.h @@ -254,7 +254,7 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUIn WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * wrappedSubmissionIndex); +WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * submissionIndex); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); From efd9502f88f8c214976d5627c273c16560040e2b Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:40:56 +0200 Subject: [PATCH 09/19] wgpu/queue: Update --- wgpu/common.go | 4 ++-- wgpu/queue.go | 35 +++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/wgpu/common.go b/wgpu/common.go index 6b87dd6..7865822 100644 --- a/wgpu/common.go +++ b/wgpu/common.go @@ -86,7 +86,7 @@ type TexelCopyTextureInfo struct { Aspect TextureAspect } -type TextureDataLayout struct { +type TexelCopyBufferLayout struct { Offset uint64 BytesPerRow uint32 RowsPerImage uint32 @@ -241,7 +241,7 @@ type CommandBufferDescriptor struct { type SubmissionIndex uint64 type TexelCopyBufferInfo struct { - Layout TextureDataLayout + Layout TexelCopyBufferLayout Buffer *Buffer } diff --git a/wgpu/queue.go b/wgpu/queue.go index cbde757..27eefb8 100644 --- a/wgpu/queue.go +++ b/wgpu/queue.go @@ -7,19 +7,31 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); extern void gowebgpu_queue_work_done_callback_c(WGPUQueueWorkDoneStatus status, void * userdata); static inline void gowebgpu_queue_write_buffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuQueueWriteBuffer(queue, buffer, bufferOffset, data, size); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } -static inline void gowebgpu_queue_write_texture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize, WGPUDevice device, void * error_userdata) { +static inline void gowebgpu_queue_write_texture(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuQueueWriteTexture(queue, destination, data, dataSize, dataLayout, writeSize); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_queue_release(WGPUQueue queue, WGPUDevice device) { @@ -54,7 +66,10 @@ func gowebgpu_queue_work_done_callback_go(status C.WGPUQueueWorkDoneStatus, user func (p *Queue) OnSubmittedWorkDone(callback QueueWorkDoneCallback) { handle := cgo.NewHandle(callback) - C.wgpuQueueOnSubmittedWorkDone(p.ref, C.WGPUQueueOnSubmittedWorkDoneCallback(C.gowebgpu_queue_work_done_callback_c), unsafe.Pointer(&handle)) + C.wgpuQueueOnSubmittedWorkDone(p.ref, C.WGPUQueueWorkDoneCallbackInfo{ + callback: C.gowebgpu_queue_work_done_callback_c, + userdata1: unsafe.Pointer(&handle), + }) } func (p *Queue) Submit(commands ...*CommandBuffer) (submissionIndex SubmissionIndex) { @@ -113,10 +128,10 @@ func (p *Queue) WriteBuffer(buffer *Buffer, bufferOffset uint64, data []byte) (e return } -func (p *Queue) WriteTexture(destination *ImageCopyTexture, data []byte, dataLayout *TextureDataLayout, writeSize *Extent3D) (err error) { - var dst C.WGPUImageCopyTexture +func (p *Queue) WriteTexture(destination *TexelCopyTextureInfo, data []byte, dataLayout *TexelCopyBufferLayout, writeSize *Extent3D) (err error) { + var dst C.WGPUTexelCopyTextureInfo if destination != nil { - dst = C.WGPUImageCopyTexture{ + dst = C.WGPUTexelCopyTextureInfo{ mipLevel: C.uint32_t(destination.MipLevel), origin: C.WGPUOrigin3D{ x: C.uint32_t(destination.Origin.X), @@ -130,9 +145,9 @@ func (p *Queue) WriteTexture(destination *ImageCopyTexture, data []byte, dataLay } } - var layout C.WGPUTextureDataLayout + var layout C.WGPUTexelCopyBufferLayout if dataLayout != nil { - layout = C.WGPUTextureDataLayout{ + layout = C.WGPUTexelCopyBufferLayout{ offset: C.uint64_t(dataLayout.Offset), bytesPerRow: C.uint32_t(dataLayout.BytesPerRow), rowsPerImage: C.uint32_t(dataLayout.RowsPerImage), From 658d6f93fdeee365d0ec07f68372d5b47968b643 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:42:03 +0200 Subject: [PATCH 10/19] wgpu/render_pass_encoder: Update --- wgpu/render_pass_encoder.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wgpu/render_pass_encoder.go b/wgpu/render_pass_encoder.go index fa2603b..958d3d1 100644 --- a/wgpu/render_pass_encoder.go +++ b/wgpu/render_pass_encoder.go @@ -7,12 +7,18 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); static inline void gowebgpu_render_pass_encoder_end(WGPURenderPassEncoder renderPassEncoder, WGPUDevice device, void * error_userdata) { wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuRenderPassEncoderEnd(renderPassEncoder); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); } static inline void gowebgpu_render_pass_encoder_release(WGPURenderPassEncoder renderPassEncoder, WGPUDevice device) { @@ -213,7 +219,7 @@ func (p *RenderPassEncoder) SetPushConstants(stages ShaderStage, offset uint32, if size == 0 { C.wgpuRenderPassEncoderSetPushConstants( p.ref, - C.WGPUShaderStageFlags(stages), + C.WGPUShaderStage(stages), C.uint32_t(offset), 0, nil, @@ -223,7 +229,7 @@ func (p *RenderPassEncoder) SetPushConstants(stages ShaderStage, offset uint32, C.wgpuRenderPassEncoderSetPushConstants( p.ref, - C.WGPUShaderStageFlags(stages), + C.WGPUShaderStage(stages), C.uint32_t(offset), C.uint32_t(size), unsafe.Pointer(&data[0]), From 0ac4a40c8cb87169065f3cb06cec6900ca87f652 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:42:57 +0200 Subject: [PATCH 11/19] wgpu/surface: Update --- wgpu/surface.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wgpu/surface.go b/wgpu/surface.go index 156e299..910642c 100644 --- a/wgpu/surface.go +++ b/wgpu/surface.go @@ -7,13 +7,20 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); static inline WGPUTexture gowebgpu_surface_get_current_texture(WGPUSurface surface, WGPUDevice device, void * error_userdata) { WGPUSurfaceTexture ref; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); wgpuSurfaceGetCurrentTexture(surface, &ref); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref.texture; } @@ -79,7 +86,7 @@ func (p *Surface) Configure(adapter *Adapter, device *Device, config *SurfaceCon cfg = &C.WGPUSurfaceConfiguration{ device: p.deviceRef, format: C.WGPUTextureFormat(config.Format), - usage: C.WGPUTextureUsageFlags(config.Usage), + usage: C.WGPUTextureUsage(config.Usage), alphaMode: C.WGPUCompositeAlphaMode(config.AlphaMode), width: C.uint32_t(config.Width), height: C.uint32_t(config.Height), From ab6914d783b1d5cacda93efe2e3f9357b3e65c1e Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:43:35 +0200 Subject: [PATCH 12/19] wgpu/texture: Update --- wgpu/texture.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wgpu/texture.go b/wgpu/texture.go index 6cbab18..31b15bd 100644 --- a/wgpu/texture.go +++ b/wgpu/texture.go @@ -7,13 +7,20 @@ package wgpu #include #include "./lib/wgpu.h" -extern void gowebgpu_error_callback_c(WGPUErrorType type, char const * message, void * userdata); +extern void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, void * userdata, void * userdata2); static inline WGPUTextureView gowebgpu_texture_create_view(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor, WGPUDevice device, void * error_userdata) { WGPUTextureView ref = NULL; wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation); ref = wgpuTextureCreateView(texture, descriptor); - wgpuDevicePopErrorScope(device, gowebgpu_error_callback_c, error_userdata); + + WGPUPopErrorScopeCallbackInfo const err_cb = { + .callback = gowebgpu_error_callback_c, + .userdata1 = error_userdata, + }; + + wgpuDevicePopErrorScope(device, err_cb); + return ref; } From ad70c32bdc1787cf19bf8489fdad670c5fddbab8 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 16:46:21 +0200 Subject: [PATCH 13/19] wgpu/wgpu_c_cb: Update --- wgpu/device.go | 4 ++-- wgpu/wgpu_c_cb.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wgpu/device.go b/wgpu/device.go index d1c7010..1b180db 100644 --- a/wgpu/device.go +++ b/wgpu/device.go @@ -189,11 +189,11 @@ type Device struct { type errorCallback func(typ ErrorType, message string) //export gowebgpu_error_callback_go -func gowebgpu_error_callback_go(_type C.WGPUErrorType, message *C.char, userdata unsafe.Pointer) { +func gowebgpu_error_callback_go(_type C.WGPUErrorType, message *C.WGPUStringView, userdata unsafe.Pointer) { handle := *(*cgo.Handle)(userdata) cb, ok := handle.Value().(errorCallback) if ok { - cb(ErrorType(_type), C.GoString(message)) + cb(ErrorType(_type), C.GoStringN(message.data, message.length)) } } diff --git a/wgpu/wgpu_c_cb.go b/wgpu/wgpu_c_cb.go index 134554d..70615d9 100644 --- a/wgpu/wgpu_c_cb.go +++ b/wgpu/wgpu_c_cb.go @@ -6,8 +6,8 @@ package wgpu #include "./lib/wgpu.h" -void gowebgpu_buffer_map_callback_c(WGPUBufferMapAsyncStatus status, void *userdata) { - extern void gowebgpu_buffer_map_callback_go(WGPUBufferMapAsyncStatus status, void *userdata); +void gowebgpu_buffer_map_callback_c(WGPUMapAsyncStatus status, void *userdata) { + extern void gowebgpu_buffer_map_callback_go(WGPUMapAsyncStatus status, void *userdata); gowebgpu_buffer_map_callback_go(status, userdata); } @@ -31,7 +31,7 @@ void gowebgpu_error_callback_c(enum WGPUPopErrorScopeStatus status, WGPUErrorTyp return; } - extern void gowebgpu_error_callback_go(WGPUErrorType type, char const * message, void * userdata); + extern void gowebgpu_error_callback_go(WGPUErrorType type, WGPUStringView message, void * userdata); gowebgpu_error_callback_go(type, message, userdata); } From 47a4d6e447617a11357008387fe72babc90c2997 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 17:22:54 +0200 Subject: [PATCH 14/19] wgpu: Update/fix last remaining stuff --- wgpu/adapter.go | 57 ++++++++++++----------- wgpu/buffer.go | 2 +- wgpu/command_encoder.go | 7 +-- wgpu/common.go | 16 +++---- wgpu/compute_pass_encoder.go | 10 +++- wgpu/device.go | 88 +++++++++++++++++++++++------------ wgpu/instance.go | 38 ++++++--------- wgpu/queue.go | 2 +- wgpu/render_bundle_encoder.go | 12 +++-- wgpu/render_pass_encoder.go | 10 +++- wgpu/texture.go | 3 +- wgpu/texture_ext.go | 4 +- 12 files changed, 146 insertions(+), 103 deletions(-) diff --git a/wgpu/adapter.go b/wgpu/adapter.go index f4dbc2e..6824902 100644 --- a/wgpu/adapter.go +++ b/wgpu/adapter.go @@ -23,13 +23,17 @@ type Adapter struct { } func (p *Adapter) GetFeatures() []FeatureName { - size := C.wgpuAdapterGetFeatures(p.ref, nil) - if size == 0 { - return nil + var supportedFeatures C.WGPUSupportedFeatures + C.wgpuAdapterGetFeatures(p.ref, (*C.WGPUSupportedFeatures)(unsafe.Pointer(&supportedFeatures))) + defer C.free(unsafe.Pointer(supportedFeatures.features)) + + features := make([]FeatureName, supportedFeatures.featureCount) + + for i := range int(supportedFeatures.featureCount) { + offset := uintptr(i) * unsafe.Sizeof(C.WGPUFeatureName(0)) + features[i] = FeatureName(*(*C.WGPUFeatureName)(unsafe.Pointer(uintptr(unsafe.Pointer(supportedFeatures.features)) + offset))) } - features := make([]FeatureName, size) - C.wgpuAdapterGetFeatures(p.ref, (*C.WGPUFeatureName)(unsafe.Pointer(&features[0]))) return features } @@ -64,7 +68,6 @@ func (p *Adapter) GetLimits() Limits { MaxBufferSize: uint64(limits.maxBufferSize), MaxVertexAttributes: uint32(limits.maxVertexAttributes), MaxVertexBufferArrayStride: uint32(limits.maxVertexBufferArrayStride), - MaxInterStageShaderComponents: uint32(limits.maxInterStageShaderComponents), MaxInterStageShaderVariables: uint32(limits.maxInterStageShaderVariables), MaxColorAttachments: uint32(limits.maxColorAttachments), MaxColorAttachmentBytesPerSample: uint32(limits.maxColorAttachmentBytesPerSample), @@ -86,14 +89,14 @@ func (p *Adapter) GetInfo() AdapterInfo { C.wgpuAdapterGetInfo(p.ref, &info) return AdapterInfo{ - VendorId: uint32(info.vendorID), - VendorName: C.GoString(info.vendor), - Architecture: C.GoString(info.architecture), - DeviceId: uint32(info.deviceID), - Name: C.GoString(info.device), - DriverDescription: C.GoString(info.description), - AdapterType: AdapterType(info.adapterType), - BackendType: BackendType(info.backendType), + Vendor: C.GoStringN(info.vendor.data, C.int(info.vendor.length)), + Architecture: C.GoStringN(info.architecture.data, C.int(info.architecture.length)), + Device: C.GoStringN(info.device.data, C.int(info.device.length)), + Description: C.GoStringN(info.description.data, C.int(info.description.length)), + AdapterType: AdapterType(info.adapterType), + BackendType: BackendType(info.backendType), + VendorId: uint32(info.vendorID), + DeviceId: uint32(info.deviceID), } } @@ -136,7 +139,8 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } requiredFeatureCount := len(descriptor.RequiredFeatures) @@ -152,11 +156,9 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { } if descriptor.RequiredLimits != nil { - requiredLimits := (*C.WGPULimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPULimits{})))) - defer C.free(unsafe.Pointer(requiredLimits)) - l := descriptor.RequiredLimits - requiredLimits.limits = C.WGPULimits{ + + requiredLimits := C.WGPULimits{ maxTextureDimension1D: C.uint32_t(l.MaxTextureDimension1D), maxTextureDimension2D: C.uint32_t(l.MaxTextureDimension2D), maxTextureDimension3D: C.uint32_t(l.MaxTextureDimension3D), @@ -178,7 +180,6 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { maxBufferSize: C.uint64_t(l.MaxBufferSize), maxVertexAttributes: C.uint32_t(l.MaxVertexAttributes), maxVertexBufferArrayStride: C.uint32_t(l.MaxVertexBufferArrayStride), - maxInterStageShaderComponents: C.uint32_t(l.MaxInterStageShaderComponents), maxInterStageShaderVariables: C.uint32_t(l.MaxInterStageShaderVariables), maxColorAttachments: C.uint32_t(l.MaxColorAttachments), maxComputeWorkgroupStorageSize: C.uint32_t(l.MaxComputeWorkgroupStorageSize), @@ -188,7 +189,8 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { maxComputeWorkgroupSizeZ: C.uint32_t(l.MaxComputeWorkgroupSizeZ), maxComputeWorkgroupsPerDimension: C.uint32_t(l.MaxComputeWorkgroupsPerDimension), } - desc.requiredLimits = requiredLimits + + desc.requiredLimits = &requiredLimits nativeLimits := (*C.WGPUNativeLimits)(C.malloc(C.size_t(unsafe.Sizeof(C.WGPUNativeLimits{})))) defer C.free(unsafe.Pointer(nativeLimits)) @@ -198,14 +200,16 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { nativeLimits.maxPushConstantSize = C.uint32_t(l.MaxPushConstantSize) nativeLimits.maxNonSamplerBindings = C.uint32_t(l.MaxNonSamplerBindings) - desc.requiredLimits.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(nativeLimits)) + desc.requiredLimits.nextInChain = (*C.WGPUChainedStructOut)(unsafe.Pointer(nativeLimits)) } if descriptor.DeviceLostCallback != nil { handle := cgo.NewHandle(descriptor.DeviceLostCallback) - desc.deviceLostCallback = C.WGPUDeviceLostCallback(C.gowebgpu_device_lost_callback_c) - desc.deviceLostUserdata = unsafe.Pointer(&handle) + desc.deviceLostCallbackInfo = C.WGPUDeviceLostCallbackInfo{ + callback: C.WGPUDeviceLostCallback(C.gowebgpu_device_lost_callback_c), + userdata1: unsafe.Pointer(&handle), + } } if descriptor.TracePath != "" { @@ -218,7 +222,8 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { tracePath := C.CString(descriptor.TracePath) defer C.free(unsafe.Pointer(tracePath)) - deviceExtras.tracePath = tracePath + deviceExtras.tracePath.data = tracePath + deviceExtras.tracePath.length = C.WGPU_STRLEN desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(deviceExtras)) } @@ -233,7 +238,7 @@ func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) { } handle := cgo.NewHandle(cb) C.wgpuAdapterRequestDevice(p.ref, desc, C.WGPURequestDeviceCallbackInfo{ - callback: C.gowebgpu_request_device_callback_c, + callback: C.WGPURequestDeviceCallback(C.gowebgpu_request_device_callback_c), userdata1: unsafe.Pointer(&handle), }) diff --git a/wgpu/buffer.go b/wgpu/buffer.go index e019cab..0f2fe15 100644 --- a/wgpu/buffer.go +++ b/wgpu/buffer.go @@ -95,7 +95,7 @@ func (p *Buffer) MapAsync(mode MapMode, offset uint64, size uint64, callback Buf C.size_t(offset), C.size_t(size), C.WGPUBufferMapCallbackInfo{ - callback: C.gowebgpu_buffer_map_callback_c, + callback: C.WGPUBufferMapCallback(C.gowebgpu_buffer_map_callback_c), userdata1: unsafe.Pointer(&callbackHandle), }, p.deviceRef, diff --git a/wgpu/command_encoder.go b/wgpu/command_encoder.go index 9c57aae..f348f27 100644 --- a/wgpu/command_encoder.go +++ b/wgpu/command_encoder.go @@ -177,7 +177,7 @@ func (p *CommandEncoder) BeginComputePass(descriptor *ComputePassDescriptor) *Co defer C.free(unsafe.Pointer(label)) desc = &C.WGPUComputePassDescriptor{ - label: label, + label: C.WGPUStringView{data: label, length: C.WGPU_STRLEN}, } } @@ -198,7 +198,8 @@ func (p *CommandEncoder) BeginRenderPass(descriptor *RenderPassDescriptor) *Rend label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } colorAttachmentCount := len(descriptor.ColorAttachments) @@ -474,7 +475,7 @@ func (p *CommandEncoder) Finish(descriptor *CommandBufferDescriptor) (*CommandBu defer C.free(unsafe.Pointer(label)) desc = &C.WGPUCommandBufferDescriptor{ - label: label, + label: C.WGPUStringView{data: label, length: C.WGPU_STRLEN}, } } diff --git a/wgpu/common.go b/wgpu/common.go index 7865822..076ea5f 100644 --- a/wgpu/common.go +++ b/wgpu/common.go @@ -246,14 +246,14 @@ type TexelCopyBufferInfo struct { } type AdapterInfo struct { - VendorId uint32 - VendorName string - Architecture string - DeviceId uint32 - Name string - DriverDescription string - AdapterType AdapterType - BackendType BackendType + Vendor string + Architecture string + Device string + Description string + AdapterType AdapterType + BackendType BackendType + VendorId uint32 + DeviceId uint32 } type SamplerDescriptor struct { diff --git a/wgpu/compute_pass_encoder.go b/wgpu/compute_pass_encoder.go index 25cd133..34112af 100644 --- a/wgpu/compute_pass_encoder.go +++ b/wgpu/compute_pass_encoder.go @@ -70,7 +70,10 @@ func (p *ComputePassEncoder) InsertDebugMarker(markerLabel string) { markerLabelStr := C.CString(markerLabel) defer C.free(unsafe.Pointer(markerLabelStr)) - C.wgpuComputePassEncoderInsertDebugMarker(p.ref, markerLabelStr) + C.wgpuComputePassEncoderInsertDebugMarker(p.ref, C.WGPUStringView{ + data: markerLabelStr, + length: C.WGPU_STRLEN, + }) } func (p *ComputePassEncoder) PopDebugGroup() { @@ -81,7 +84,10 @@ func (p *ComputePassEncoder) PushDebugGroup(groupLabel string) { groupLabelStr := C.CString(groupLabel) defer C.free(unsafe.Pointer(groupLabelStr)) - C.wgpuComputePassEncoderPushDebugGroup(p.ref, groupLabelStr) + C.wgpuComputePassEncoderPushDebugGroup(p.ref, C.WGPUStringView{ + data: groupLabelStr, + length: C.WGPU_STRLEN, + }) } func (p *ComputePassEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32) { diff --git a/wgpu/device.go b/wgpu/device.go index 1b180db..1db9be2 100644 --- a/wgpu/device.go +++ b/wgpu/device.go @@ -193,7 +193,7 @@ func gowebgpu_error_callback_go(_type C.WGPUErrorType, message *C.WGPUStringView handle := *(*cgo.Handle)(userdata) cb, ok := handle.Value().(errorCallback) if ok { - cb(ErrorType(_type), C.GoStringN(message.data, message.length)) + cb(ErrorType(_type), C.GoStringN(message.data, C.int(message.length))) } } @@ -207,7 +207,8 @@ func (p *Device) CreateBindGroup(descriptor *BindGroupDescriptor) (*BindGroup, e label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } if descriptor.Layout != nil { @@ -305,7 +306,8 @@ func (p *Device) CreateBindGroupLayout(descriptor *BindGroupLayoutDescriptor) (* label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } entryCount := len(descriptor.Entries) @@ -378,7 +380,8 @@ func (p *Device) CreateBuffer(descriptor *BufferDescriptor) (*Buffer, error) { label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } desc.usage = C.WGPUBufferUsage(descriptor.Usage) @@ -415,7 +418,10 @@ func (p *Device) CreateCommandEncoder(descriptor *CommandEncoderDescriptor) (*Co defer C.free(unsafe.Pointer(label)) desc = &C.WGPUCommandEncoderDescriptor{ - label: label, + label: C.WGPUStringView{ + data: label, + length: C.WGPU_STRLEN, + }, } } @@ -459,7 +465,8 @@ func (p *Device) CreateComputePipeline(descriptor *ComputePipelineDescriptor) (* label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } if descriptor.Layout != nil { @@ -474,7 +481,8 @@ func (p *Device) CreateComputePipeline(descriptor *ComputePipelineDescriptor) (* entryPoint := C.CString(descriptor.Compute.EntryPoint) defer C.free(unsafe.Pointer(entryPoint)) - compute.entryPoint = entryPoint + compute.entryPoint.data = entryPoint + compute.entryPoint.length = C.WGPU_STRLEN } desc.compute = compute } @@ -519,7 +527,8 @@ func (p *Device) CreatePipelineLayout(descriptor *PipelineLayoutDescriptor) (*Pi label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } bindGroupLayoutCount := len(descriptor.BindGroupLayouts) @@ -601,7 +610,9 @@ func (p *Device) CreateQuerySet(descriptor *QuerySetDescriptor) (*QuerySet, erro if descriptor.Label != "" { label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } desc._type = C.WGPUQueryType(descriptor.Type) @@ -657,7 +668,9 @@ func (p *Device) CreateRenderBundleEncoder(descriptor *RenderBundleEncoderDescri if descriptor.Label != "" { label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } colorFormatCount := len(descriptor.ColorFormats) @@ -744,9 +757,17 @@ type StencilFaceState struct { PassOp StencilOperation } +type OptionalBool uint32 + +const ( + False OptionalBool = C.WGPUOptionalBool_False + True OptionalBool = C.WGPUOptionalBool_True + Undefined OptionalBool = C.WGPUOptionalBool_Undefined +) + type DepthStencilState struct { Format TextureFormat - DepthWriteEnabled bool + DepthWriteEnabled OptionalBool DepthCompare CompareFunction StencilFront StencilFaceState StencilBack StencilFaceState @@ -771,7 +792,8 @@ func (p *Device) CreateRenderPipeline(descriptor *RenderPipelineDescriptor) (*Re label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } if descriptor.Layout != nil { @@ -792,7 +814,8 @@ func (p *Device) CreateRenderPipeline(descriptor *RenderPipelineDescriptor) (*Re entryPoint := C.CString(vertex.EntryPoint) defer C.free(unsafe.Pointer(entryPoint)) - vert.entryPoint = entryPoint + vert.entryPoint.data = entryPoint + vert.entryPoint.length = C.WGPU_STRLEN } bufferCount := len(vertex.Buffers) @@ -852,7 +875,7 @@ func (p *Device) CreateRenderPipeline(descriptor *RenderPipelineDescriptor) (*Re ds.nextInChain = nil ds.format = C.WGPUTextureFormat(depthStencil.Format) - ds.depthWriteEnabled = cBool(depthStencil.DepthWriteEnabled) + ds.depthWriteEnabled = C.WGPUOptionalBool(depthStencil.DepthWriteEnabled) ds.depthCompare = C.WGPUCompareFunction(depthStencil.DepthCompare) ds.stencilFront = C.WGPUStencilFaceState{ compare: C.WGPUCompareFunction(depthStencil.StencilFront.Compare), @@ -892,7 +915,8 @@ func (p *Device) CreateRenderPipeline(descriptor *RenderPipelineDescriptor) (*Re entryPoint := C.CString(fragment.EntryPoint) defer C.free(unsafe.Pointer(entryPoint)) - frag.entryPoint = entryPoint + frag.entryPoint.data = entryPoint + frag.entryPoint.length = C.WGPU_STRLEN } if fragment.Module != nil { @@ -987,7 +1011,8 @@ func (p *Device) CreateSampler(descriptor *SamplerDescriptor) (*Sampler, error) label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } } @@ -1032,7 +1057,8 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } switch { @@ -1068,7 +1094,7 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader wgsl.code.data = code wgsl.code.length = C.WGPU_STRLEN } else { - wgsl.code = nil + wgsl.code.data = nil wgsl.code.length = 0 } @@ -1088,7 +1114,7 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader glsl.code.data = code glsl.code.length = C.WGPU_STRLEN } else { - glsl.code = nil + glsl.code.data = nil glsl.code.length = 0 } @@ -1107,8 +1133,8 @@ func (p *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*Shader defer C.free(unsafe.Pointer(valuePtr)) shaderDefinesSlice[index] = C.WGPUShaderDefine{ - name: namePtr, - value: valuePtr, + name: C.WGPUStringView{data: namePtr, length: C.WGPU_STRLEN}, + value: C.WGPUStringView{data: valuePtr, length: C.WGPU_STRLEN}, } index++ } @@ -1169,7 +1195,8 @@ func (p *Device) CreateTexture(descriptor *TextureDescriptor) (*Texture, error) label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } } @@ -1195,13 +1222,17 @@ func (p *Device) CreateTexture(descriptor *TextureDescriptor) (*Texture, error) } func (p *Device) GetFeatures() []FeatureName { - size := C.wgpuDeviceGetFeatures(p.ref, nil) - if size == 0 { - return nil + var supportedFeatures C.WGPUSupportedFeatures + C.wgpuDeviceGetFeatures(p.ref, (*C.WGPUSupportedFeatures)(unsafe.Pointer(&supportedFeatures))) + defer C.free(unsafe.Pointer(supportedFeatures.features)) + + features := make([]FeatureName, supportedFeatures.featureCount) + + for i := range int(supportedFeatures.featureCount) { + offset := uintptr(i) * unsafe.Sizeof(C.WGPUFeatureName(0)) + features[i] = FeatureName(*(*C.WGPUFeatureName)(unsafe.Pointer(uintptr(unsafe.Pointer(supportedFeatures.features)) + offset))) } - features := make([]FeatureName, size) - C.wgpuDeviceGetFeatures(p.ref, (*C.WGPUFeatureName)(unsafe.Pointer(&features[0]))) return features } @@ -1236,7 +1267,6 @@ func (p *Device) GetLimits() Limits { MaxBufferSize: uint64(limits.maxBufferSize), MaxVertexAttributes: uint32(limits.maxVertexAttributes), MaxVertexBufferArrayStride: uint32(limits.maxVertexBufferArrayStride), - MaxInterStageShaderComponents: uint32(limits.maxInterStageShaderComponents), MaxInterStageShaderVariables: uint32(limits.maxInterStageShaderVariables), MaxColorAttachments: uint32(limits.maxColorAttachments), MaxComputeWorkgroupStorageSize: uint32(limits.maxComputeWorkgroupStorageSize), @@ -1263,5 +1293,5 @@ func (p *Device) HasFeature(feature FeatureName) bool { } func (p *Device) Poll(wait bool, submissionIndex uint64) (queueEmpty bool) { - return goBool(C.wgpuDevicePoll(p.ref, cBool(wait), submissionIndex)) + return goBool(C.wgpuDevicePoll(p.ref, cBool(wait), (*C.WGPUSubmissionIndex)(unsafe.Pointer(&submissionIndex)))) } diff --git a/wgpu/instance.go b/wgpu/instance.go index 484409c..3d0ea4d 100644 --- a/wgpu/instance.go +++ b/wgpu/instance.go @@ -36,13 +36,17 @@ func CreateInstance(descriptor *InstanceDescriptor) *Instance { if descriptor.DxilPath != "" { dxilPath := C.CString(descriptor.DxilPath) defer C.free(unsafe.Pointer(dxilPath)) - instanceExtras.dxilPath = dxilPath + + instanceExtras.dxilPath.data = dxilPath + instanceExtras.dxilPath.length = C.WGPU_STRLEN } if descriptor.DxcPath != "" { dxcPath := C.CString(descriptor.DxcPath) defer C.free(unsafe.Pointer(dxcPath)) - instanceExtras.dxcPath = dxcPath + + instanceExtras.dxcPath.data = dxcPath + instanceExtras.dxcPath.length = C.WGPU_STRLEN } desc.nextInChain = (*C.WGPUChainedStruct)(unsafe.Pointer(instanceExtras)) @@ -103,7 +107,8 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } if descriptor.WindowsHWND != nil { @@ -220,7 +225,7 @@ func (p *Instance) RequestAdapter(options *RequestAdapterOptions) (*Adapter, err } handle := cgo.NewHandle(cb) C.wgpuInstanceRequestAdapter(p.ref, opts, C.WGPURequestAdapterCallbackInfo{ - callback: C.gowebgpu_request_adapter_callback_c, + callback: C.WGPURequestAdapterCallback(C.gowebgpu_request_adapter_callback_c), userdata1: unsafe.Pointer(&handle), }) @@ -257,7 +262,6 @@ type RegistryReport struct { NumAllocated uint64 NumKeptFromUser uint64 NumReleasedFromUser uint64 - NumError uint64 ElementSize uint64 } @@ -272,6 +276,7 @@ type HubReport struct { RenderBundles RegistryReport RenderPipelines RegistryReport ComputePipelines RegistryReport + PipelineCaches RegistryReport QuerySets RegistryReport Buffers RegistryReport Textures RegistryReport @@ -281,11 +286,7 @@ type HubReport struct { type GlobalReport struct { Surfaces RegistryReport - Vulkan *HubReport - Metal *HubReport - Dx12 *HubReport - Dx11 *HubReport - Gl *HubReport + Hub *HubReport } func (p *Instance) GenerateReport() GlobalReport { @@ -297,7 +298,6 @@ func (p *Instance) GenerateReport() GlobalReport { NumAllocated: uint64(creport.numAllocated), NumKeptFromUser: uint64(creport.numKeptFromUser), NumReleasedFromUser: uint64(creport.numReleasedFromUser), - NumError: uint64(creport.numError), ElementSize: uint64(creport.elementSize), } } @@ -314,6 +314,7 @@ func (p *Instance) GenerateReport() GlobalReport { RenderBundles: mapRegistryReport(creport.renderBundles), RenderPipelines: mapRegistryReport(creport.renderPipelines), ComputePipelines: mapRegistryReport(creport.computePipelines), + PipelineCaches: mapRegistryReport(creport.pipelineCaches), QuerySets: mapRegistryReport(creport.querySets), Buffers: mapRegistryReport(creport.buffers), Textures: mapRegistryReport(creport.textures), @@ -324,20 +325,7 @@ func (p *Instance) GenerateReport() GlobalReport { report := GlobalReport{ Surfaces: mapRegistryReport(r.surfaces), - } - - switch r.backendType { - case C.WGPUBackendType_Vulkan: - report.Vulkan = mapHubReport(r.vulkan) - case C.WGPUBackendType_Metal: - report.Metal = mapHubReport(r.metal) - case C.WGPUBackendType_D3D12: - report.Dx12 = mapHubReport(r.dx12) - // TODO: no longer present in C API - // case C.WGPUBackendType_D3D11: - // report.Dx11 = mapHubReport(r.dx11) - case C.WGPUBackendType_OpenGL: - report.Gl = mapHubReport(r.gl) + Hub: mapHubReport(r.hub), } return report diff --git a/wgpu/queue.go b/wgpu/queue.go index 27eefb8..023fba2 100644 --- a/wgpu/queue.go +++ b/wgpu/queue.go @@ -67,7 +67,7 @@ func (p *Queue) OnSubmittedWorkDone(callback QueueWorkDoneCallback) { handle := cgo.NewHandle(callback) C.wgpuQueueOnSubmittedWorkDone(p.ref, C.WGPUQueueWorkDoneCallbackInfo{ - callback: C.gowebgpu_queue_work_done_callback_c, + callback: C.WGPUQueueWorkDoneCallback(C.gowebgpu_queue_work_done_callback_c), userdata1: unsafe.Pointer(&handle), }) } diff --git a/wgpu/render_bundle_encoder.go b/wgpu/render_bundle_encoder.go index 50fbed3..408a6d5 100644 --- a/wgpu/render_bundle_encoder.go +++ b/wgpu/render_bundle_encoder.go @@ -64,7 +64,7 @@ func (p *RenderBundleEncoder) Finish(descriptor *RenderBundleDescriptor) *Render defer C.free(unsafe.Pointer(label)) desc = &C.WGPURenderBundleDescriptor{ - label: label, + label: C.WGPUStringView{data: label, length: C.WGPU_STRLEN}, } } @@ -79,7 +79,10 @@ func (p *RenderBundleEncoder) InsertDebugMarker(markerLabel string) { markerLabelStr := C.CString(markerLabel) defer C.free(unsafe.Pointer(markerLabelStr)) - C.wgpuRenderBundleEncoderInsertDebugMarker(p.ref, markerLabelStr) + C.wgpuRenderBundleEncoderInsertDebugMarker(p.ref, C.WGPUStringView{ + data: markerLabelStr, + length: C.WGPU_STRLEN, + }) } func (p *RenderBundleEncoder) PopDebugGroup() { @@ -90,7 +93,10 @@ func (p *RenderBundleEncoder) PushDebugGroup(groupLabel string) { groupLabelStr := C.CString(groupLabel) defer C.free(unsafe.Pointer(groupLabelStr)) - C.wgpuRenderBundleEncoderPushDebugGroup(p.ref, groupLabelStr) + C.wgpuRenderBundleEncoderPushDebugGroup(p.ref, C.WGPUStringView{ + data: groupLabelStr, + length: C.WGPU_STRLEN, + }) } func (p *RenderBundleEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32) { diff --git a/wgpu/render_pass_encoder.go b/wgpu/render_pass_encoder.go index 958d3d1..7628b7b 100644 --- a/wgpu/render_pass_encoder.go +++ b/wgpu/render_pass_encoder.go @@ -119,7 +119,10 @@ func (p *RenderPassEncoder) InsertDebugMarker(markerLabel string) { markerLabelStr := C.CString(markerLabel) defer C.free(unsafe.Pointer(markerLabelStr)) - C.wgpuRenderPassEncoderInsertDebugMarker(p.ref, markerLabelStr) + C.wgpuRenderPassEncoderInsertDebugMarker(p.ref, C.WGPUStringView{ + data: markerLabelStr, + length: C.WGPU_STRLEN, + }) } func (p *RenderPassEncoder) PopDebugGroup() { @@ -130,7 +133,10 @@ func (p *RenderPassEncoder) PushDebugGroup(groupLabel string) { groupLabelStr := C.CString(groupLabel) defer C.free(unsafe.Pointer(groupLabelStr)) - C.wgpuRenderPassEncoderPushDebugGroup(p.ref, groupLabelStr) + C.wgpuRenderPassEncoderPushDebugGroup(p.ref, C.WGPUStringView{ + data: groupLabelStr, + length: C.WGPU_STRLEN, + }) } func (p *RenderPassEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32) { diff --git a/wgpu/texture.go b/wgpu/texture.go index 31b15bd..314e5fb 100644 --- a/wgpu/texture.go +++ b/wgpu/texture.go @@ -60,7 +60,8 @@ func (p *Texture) CreateView(descriptor *TextureViewDescriptor) (*TextureView, e label := C.CString(descriptor.Label) defer C.free(unsafe.Pointer(label)) - desc.label = label + desc.label.data = label + desc.label.length = C.WGPU_STRLEN } } diff --git a/wgpu/texture_ext.go b/wgpu/texture_ext.go index 0e31eff..b6227eb 100644 --- a/wgpu/texture_ext.go +++ b/wgpu/texture_ext.go @@ -1,7 +1,7 @@ package wgpu -func (p *Texture) AsImageCopy() *ImageCopyTexture { - return &ImageCopyTexture{ +func (p *Texture) AsImageCopy() *TexelCopyTextureInfo { + return &TexelCopyTextureInfo{ Texture: p, MipLevel: 0, Origin: Origin3D{}, From 9da7f2f207bb4f22f665e30f282ae8d156dba6e2 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 17:32:14 +0200 Subject: [PATCH 15/19] wgpu/instance: Fix request adapter callback --- wgpu/instance.go | 4 ++-- wgpu/wgpu_c_cb.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wgpu/instance.go b/wgpu/instance.go index 3d0ea4d..e03c6fd 100644 --- a/wgpu/instance.go +++ b/wgpu/instance.go @@ -192,13 +192,13 @@ func (p *Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface { type requestAdapterCb func(status RequestAdapterStatus, adapter *Adapter, message string) //export gowebgpu_request_adapter_callback_go -func gowebgpu_request_adapter_callback_go(status C.WGPURequestAdapterStatus, adapter C.WGPUAdapter, message *C.char, userdata unsafe.Pointer) { +func gowebgpu_request_adapter_callback_go(status C.WGPURequestAdapterStatus, adapter C.WGPUAdapter, message C.WGPUStringView, userdata unsafe.Pointer) { handle := *(*cgo.Handle)(userdata) defer handle.Delete() cb, ok := handle.Value().(requestAdapterCb) if ok { - cb(RequestAdapterStatus(status), &Adapter{ref: adapter}, C.GoString(message)) + cb(RequestAdapterStatus(status), &Adapter{ref: adapter}, C.GoStringN(message.data, C.int(message.length))) } } diff --git a/wgpu/wgpu_c_cb.go b/wgpu/wgpu_c_cb.go index 70615d9..9015662 100644 --- a/wgpu/wgpu_c_cb.go +++ b/wgpu/wgpu_c_cb.go @@ -11,9 +11,9 @@ void gowebgpu_buffer_map_callback_c(WGPUMapAsyncStatus status, void *userdata) { gowebgpu_buffer_map_callback_go(status, userdata); } -void gowebgpu_request_adapter_callback_c(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, void *userdata) { - extern void gowebgpu_request_adapter_callback_go(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, void *userdata); - gowebgpu_request_adapter_callback_go(status, adapter, message, userdata); +void gowebgpu_request_adapter_callback_c(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, void *userdata1, void *userdata2) { + extern void gowebgpu_request_adapter_callback_go(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, void *userdata); + gowebgpu_request_adapter_callback_go(status, adapter, message, userdata1); } void gowebgpu_request_device_callback_c(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, void *userdata) { From 587e191d66d324fadef91ffcc70a8875c8a1bd79 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 17:33:11 +0200 Subject: [PATCH 16/19] wgpuglfw: Fix on Darwin --- examples/triangle/main.go | 4 ++-- wgpuglfw/surface_darwin.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/triangle/main.go b/examples/triangle/main.go index dc48b40..081881f 100644 --- a/examples/triangle/main.go +++ b/examples/triangle/main.go @@ -72,8 +72,8 @@ func InitState[T interface{ GetSize() (int, int) }](window T, sd *wgpu.SurfaceDe s.queue = s.device.GetQueue() shader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{ - Label: "shader.wgsl", - WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{Code: shader}, + Label: "shader.wgsl", + WGSLSource: &wgpu.ShaderSourceWGSL{Code: shader}, }) if err != nil { return s, err diff --git a/wgpuglfw/surface_darwin.go b/wgpuglfw/surface_darwin.go index 9addc6d..67dc398 100644 --- a/wgpuglfw/surface_darwin.go +++ b/wgpuglfw/surface_darwin.go @@ -31,7 +31,7 @@ import "C" func GetSurfaceDescriptor(w *glfw.Window) *wgpu.SurfaceDescriptor { return &wgpu.SurfaceDescriptor{ - MetalLayer: &wgpu.SurfaceDescriptorFromMetalLayer{ + MetalLayer: &wgpu.SurfaceSourceMetalLayer{ Layer: unsafe.Pointer(C.metalLayerFromNSWindow((C.CFTypeRef)(unsafe.Pointer(w.GetCocoaWindow())))), }, } From 0e954089c2dbbf27ce7cbdb830c1138572bb03c2 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 17:47:00 +0200 Subject: [PATCH 17/19] enums: Update all of them --- wgpu/device.go | 8 - wgpu/enums.go | 980 +++++++++++++++++++++++++++---------------------- 2 files changed, 543 insertions(+), 445 deletions(-) diff --git a/wgpu/device.go b/wgpu/device.go index 1db9be2..caf95df 100644 --- a/wgpu/device.go +++ b/wgpu/device.go @@ -757,14 +757,6 @@ type StencilFaceState struct { PassOp StencilOperation } -type OptionalBool uint32 - -const ( - False OptionalBool = C.WGPUOptionalBool_False - True OptionalBool = C.WGPUOptionalBool_True - Undefined OptionalBool = C.WGPUOptionalBool_Undefined -) - type DepthStencilState struct { Format TextureFormat DepthWriteEnabled OptionalBool diff --git a/wgpu/enums.go b/wgpu/enums.go index 4efc911..75c1d08 100644 --- a/wgpu/enums.go +++ b/wgpu/enums.go @@ -5,10 +5,10 @@ package wgpu type AdapterType uint32 const ( - AdapterTypeDiscreteGPU AdapterType = 0x00000000 - AdapterTypeIntegratedGPU AdapterType = 0x00000001 - AdapterTypeCPU AdapterType = 0x00000002 - AdapterTypeUnknown AdapterType = 0x00000003 + AdapterTypeDiscreteGPU AdapterType = 0x00000001 + AdapterTypeIntegratedGPU AdapterType = 0x00000002 + AdapterTypeCPU AdapterType = 0x00000003 + AdapterTypeUnknown AdapterType = 0x00000004 ) func (v AdapterType) String() string { @@ -29,19 +29,22 @@ func (v AdapterType) String() string { type AddressMode uint32 const ( - AddressModeRepeat AddressMode = 0x00000000 - AddressModeMirrorRepeat AddressMode = 0x00000001 - AddressModeClampToEdge AddressMode = 0x00000002 + AddressModeUndefined AddressMode = 0x00000000 + AddressModeClampToEdge AddressMode = 0x00000001 + AddressModeRepeat AddressMode = 0x00000002 + AddressModeMirrorRepeat AddressMode = 0x00000003 ) func (v AddressMode) String() string { switch v { + case AddressModeUndefined: + return "undefined" + case AddressModeClampToEdge: + return "clamp-to-edge" case AddressModeRepeat: return "repeat" case AddressModeMirrorRepeat: return "mirror-repeat" - case AddressModeClampToEdge: - return "clamp-to-edge" default: return "" } @@ -89,23 +92,30 @@ func (v BackendType) String() string { type BlendFactor uint32 const ( - BlendFactorZero BlendFactor = 0x00000000 - BlendFactorOne BlendFactor = 0x00000001 - BlendFactorSrc BlendFactor = 0x00000002 - BlendFactorOneMinusSrc BlendFactor = 0x00000003 - BlendFactorSrcAlpha BlendFactor = 0x00000004 - BlendFactorOneMinusSrcAlpha BlendFactor = 0x00000005 - BlendFactorDst BlendFactor = 0x00000006 - BlendFactorOneMinusDst BlendFactor = 0x00000007 - BlendFactorDstAlpha BlendFactor = 0x00000008 - BlendFactorOneMinusDstAlpha BlendFactor = 0x00000009 - BlendFactorSrcAlphaSaturated BlendFactor = 0x0000000A - BlendFactorConstant BlendFactor = 0x0000000B - BlendFactorOneMinusConstant BlendFactor = 0x0000000C + BlendFactorUndefined BlendFactor = 0x00000000 + BlendFactorZero BlendFactor = 0x00000001 + BlendFactorOne BlendFactor = 0x00000002 + BlendFactorSrc BlendFactor = 0x00000003 + BlendFactorOneMinusSrc BlendFactor = 0x00000004 + BlendFactorSrcAlpha BlendFactor = 0x00000005 + BlendFactorOneMinusSrcAlpha BlendFactor = 0x00000006 + BlendFactorDst BlendFactor = 0x00000007 + BlendFactorOneMinusDst BlendFactor = 0x00000008 + BlendFactorDstAlpha BlendFactor = 0x00000009 + BlendFactorOneMinusDstAlpha BlendFactor = 0x0000000A + BlendFactorSrcAlphaSaturated BlendFactor = 0x0000000B + BlendFactorConstant BlendFactor = 0x0000000C + BlendFactorOneMinusConstant BlendFactor = 0x0000000D + BlendFactorSrc1 BlendFactor = 0x0000000E + BlendFactorOneMinusSrc1 BlendFactor = 0x0000000F + BlendFactorSrc1Alpha BlendFactor = 0x00000010 + BlendFactorOneMinusSrc1Alpha BlendFactor = 0x00000011 ) func (v BlendFactor) String() string { switch v { + case BlendFactorUndefined: + return "undefined" case BlendFactorZero: return "zero" case BlendFactorOne: @@ -132,6 +142,14 @@ func (v BlendFactor) String() string { return "constant" case BlendFactorOneMinusConstant: return "one-minus-constant" + case BlendFactorSrc1: + return "src1" + case BlendFactorOneMinusSrc1: + return "one-minus-src1" + case BlendFactorSrc1Alpha: + return "src1alpha" + case BlendFactorOneMinusSrc1Alpha: + return "one-minus-src1alpha" default: return "" } @@ -140,15 +158,18 @@ func (v BlendFactor) String() string { type BlendOperation uint32 const ( - BlendOperationAdd BlendOperation = 0x00000000 - BlendOperationSubtract BlendOperation = 0x00000001 - BlendOperationReverseSubtract BlendOperation = 0x00000002 - BlendOperationMin BlendOperation = 0x00000003 - BlendOperationMax BlendOperation = 0x00000004 + BlendOperationUndefined BlendOperation = 0x00000000 + BlendOperationAdd BlendOperation = 0x00000001 + BlendOperationSubtract BlendOperation = 0x00000002 + BlendOperationReverseSubtract BlendOperation = 0x00000003 + BlendOperationMin BlendOperation = 0x00000004 + BlendOperationMax BlendOperation = 0x00000005 ) func (v BlendOperation) String() string { switch v { + case BlendOperationUndefined: + return "undefined" case BlendOperationAdd: return "add" case BlendOperationSubtract: @@ -167,14 +188,17 @@ func (v BlendOperation) String() string { type BufferBindingType uint32 const ( - BufferBindingTypeUndefined BufferBindingType = 0x00000000 - BufferBindingTypeUniform BufferBindingType = 0x00000001 - BufferBindingTypeStorage BufferBindingType = 0x00000002 - BufferBindingTypeReadOnlyStorage BufferBindingType = 0x00000003 + BufferBindingTypeBindingNotUsed BufferBindingType = 0x00000000 + BufferBindingTypeUndefined BufferBindingType = 0x00000001 + BufferBindingTypeUniform BufferBindingType = 0x00000002 + BufferBindingTypeStorage BufferBindingType = 0x00000003 + BufferBindingTypeReadOnlyStorage BufferBindingType = 0x00000004 ) func (v BufferBindingType) String() string { switch v { + case BufferBindingTypeBindingNotUsed: + return "binding-not-used" case BufferBindingTypeUndefined: return "undefined" case BufferBindingTypeUniform: @@ -188,51 +212,12 @@ func (v BufferBindingType) String() string { } } -type MapAsyncStatus uint32 - -const ( - MapAsyncStatusSuccess MapAsyncStatus = 0x00000000 - MapAsyncStatusValidationError MapAsyncStatus = 0x00000001 - MapAsyncStatusUnknown MapAsyncStatus = 0x00000002 - MapAsyncStatusDeviceLost MapAsyncStatus = 0x00000003 - MapAsyncStatusDestroyedBeforeCallback MapAsyncStatus = 0x00000004 - MapAsyncStatusUnmappedBeforeCallback MapAsyncStatus = 0x00000005 - MapAsyncStatusMappingAlreadyPending MapAsyncStatus = 0x00000006 - MapAsyncStatusOffsetOutOfRange MapAsyncStatus = 0x00000007 - MapAsyncStatusSizeOutOfRange MapAsyncStatus = 0x00000008 -) - -func (v MapAsyncStatus) String() string { - switch v { - case MapAsyncStatusSuccess: - return "success" - case MapAsyncStatusValidationError: - return "validation-error" - case MapAsyncStatusUnknown: - return "unknown" - case MapAsyncStatusDeviceLost: - return "device-lost" - case MapAsyncStatusDestroyedBeforeCallback: - return "destroyed-before-callback" - case MapAsyncStatusUnmappedBeforeCallback: - return "unmapped-before-callback" - case MapAsyncStatusMappingAlreadyPending: - return "mapping-already-pending" - case MapAsyncStatusOffsetOutOfRange: - return "offset-out-of-range" - case MapAsyncStatusSizeOutOfRange: - return "size-out-of-range" - default: - return "" - } -} - type BufferMapState uint32 const ( - BufferMapStateUnmapped BufferMapState = 0x00000000 - BufferMapStatePending BufferMapState = 0x00000001 - BufferMapStateMapped BufferMapState = 0x00000002 + BufferMapStateUnmapped BufferMapState = 0x00000001 + BufferMapStatePending BufferMapState = 0x00000002 + BufferMapStateMapped BufferMapState = 0x00000003 ) func (v BufferMapState) String() string { @@ -248,76 +233,22 @@ func (v BufferMapState) String() string { } } -type BufferUsage uint32 - -const ( - BufferUsageNone BufferUsage = 0x00000000 - BufferUsageMapRead BufferUsage = 0x00000001 - BufferUsageMapWrite BufferUsage = 0x00000002 - BufferUsageCopySrc BufferUsage = 0x00000004 - BufferUsageCopyDst BufferUsage = 0x00000008 - BufferUsageIndex BufferUsage = 0x00000010 - BufferUsageVertex BufferUsage = 0x00000020 - BufferUsageUniform BufferUsage = 0x00000040 - BufferUsageStorage BufferUsage = 0x00000080 - BufferUsageIndirect BufferUsage = 0x00000100 - BufferUsageQueryResolve BufferUsage = 0x00000200 -) - -func (v BufferUsage) String() string { - switch v { - case BufferUsageNone: - return "none" - case BufferUsageMapRead: - return "map-read" - case BufferUsageMapWrite: - return "map-write" - case BufferUsageCopySrc: - return "copy-src" - case BufferUsageCopyDst: - return "copy-dst" - case BufferUsageIndex: - return "index" - case BufferUsageVertex: - return "vertex" - case BufferUsageUniform: - return "uniform" - case BufferUsageStorage: - return "storage" - case BufferUsageIndirect: - return "indirect" - case BufferUsageQueryResolve: - return "query-resolve" - default: - return "" - } -} - -type ColorWriteMask uint32 +type CallbackMode uint32 const ( - ColorWriteMaskNone ColorWriteMask = 0x00000000 - ColorWriteMaskRed ColorWriteMask = 0x00000001 - ColorWriteMaskGreen ColorWriteMask = 0x00000002 - ColorWriteMaskBlue ColorWriteMask = 0x00000004 - ColorWriteMaskAlpha ColorWriteMask = 0x00000008 - ColorWriteMaskAll ColorWriteMask = 0x0000000F + CallbackModeWaitAnyOnly CallbackMode = 0x00000001 + CallbackModeAllowProcessEvents CallbackMode = 0x00000002 + CallbackModeAllowSpontaneous CallbackMode = 0x00000003 ) -func (v ColorWriteMask) String() string { +func (v CallbackMode) String() string { switch v { - case ColorWriteMaskNone: - return "none" - case ColorWriteMaskRed: - return "red" - case ColorWriteMaskGreen: - return "green" - case ColorWriteMaskBlue: - return "blue" - case ColorWriteMaskAlpha: - return "alpha" - case ColorWriteMaskAll: - return "all" + case CallbackModeWaitAnyOnly: + return "wait-any-only" + case CallbackModeAllowProcessEvents: + return "allow-process-events" + case CallbackModeAllowSpontaneous: + return "allow-spontaneous" default: return "" } @@ -329,11 +260,11 @@ const ( CompareFunctionUndefined CompareFunction = 0x00000000 CompareFunctionNever CompareFunction = 0x00000001 CompareFunctionLess CompareFunction = 0x00000002 - CompareFunctionLessEqual CompareFunction = 0x00000003 - CompareFunctionGreater CompareFunction = 0x00000004 - CompareFunctionGreaterEqual CompareFunction = 0x00000005 - CompareFunctionEqual CompareFunction = 0x00000006 - CompareFunctionNotEqual CompareFunction = 0x00000007 + CompareFunctionEqual CompareFunction = 0x00000003 + CompareFunctionLessEqual CompareFunction = 0x00000004 + CompareFunctionGreater CompareFunction = 0x00000005 + CompareFunctionNotEqual CompareFunction = 0x00000006 + CompareFunctionGreaterEqual CompareFunction = 0x00000007 CompareFunctionAlways CompareFunction = 0x00000008 ) @@ -345,16 +276,16 @@ func (v CompareFunction) String() string { return "never" case CompareFunctionLess: return "less" + case CompareFunctionEqual: + return "equal" case CompareFunctionLessEqual: return "less-equal" case CompareFunctionGreater: return "greater" - case CompareFunctionGreaterEqual: - return "greater-equal" - case CompareFunctionEqual: - return "equal" case CompareFunctionNotEqual: return "not-equal" + case CompareFunctionGreaterEqual: + return "greater-equal" case CompareFunctionAlways: return "always" default: @@ -365,20 +296,20 @@ func (v CompareFunction) String() string { type CompilationInfoRequestStatus uint32 const ( - CompilationInfoRequestStatusSuccess CompilationInfoRequestStatus = 0x00000000 - CompilationInfoRequestStatusError CompilationInfoRequestStatus = 0x00000001 - CompilationInfoRequestStatusDeviceLost CompilationInfoRequestStatus = 0x00000002 - CompilationInfoRequestStatusUnknown CompilationInfoRequestStatus = 0x00000003 + CompilationInfoRequestStatusSuccess CompilationInfoRequestStatus = 0x00000001 + CompilationInfoRequestStatusInstanceDropped CompilationInfoRequestStatus = 0x00000002 + CompilationInfoRequestStatusError CompilationInfoRequestStatus = 0x00000003 + CompilationInfoRequestStatusUnknown CompilationInfoRequestStatus = 0x00000004 ) func (v CompilationInfoRequestStatus) String() string { switch v { case CompilationInfoRequestStatusSuccess: return "success" + case CompilationInfoRequestStatusInstanceDropped: + return "instance-dropped" case CompilationInfoRequestStatusError: return "error" - case CompilationInfoRequestStatusDeviceLost: - return "device-lost" case CompilationInfoRequestStatusUnknown: return "unknown" default: @@ -389,9 +320,9 @@ func (v CompilationInfoRequestStatus) String() string { type CompilationMessageType uint32 const ( - CompilationMessageTypeError CompilationMessageType = 0x00000000 - CompilationMessageTypeWarning CompilationMessageType = 0x00000001 - CompilationMessageTypeInfo CompilationMessageType = 0x00000002 + CompilationMessageTypeError CompilationMessageType = 0x00000001 + CompilationMessageTypeWarning CompilationMessageType = 0x00000002 + CompilationMessageTypeInfo CompilationMessageType = 0x00000003 ) func (v CompilationMessageType) String() string { @@ -437,11 +368,10 @@ func (v CompositeAlphaMode) String() string { type CreatePipelineAsyncStatus uint32 const ( - CreatePipelineAsyncStatusSuccess CreatePipelineAsyncStatus = 0x00000000 - CreatePipelineAsyncStatusValidationError CreatePipelineAsyncStatus = 0x00000001 - CreatePipelineAsyncStatusInternalError CreatePipelineAsyncStatus = 0x00000002 - CreatePipelineAsyncStatusDeviceLost CreatePipelineAsyncStatus = 0x00000003 - CreatePipelineAsyncStatusDeviceDestroyed CreatePipelineAsyncStatus = 0x00000004 + CreatePipelineAsyncStatusSuccess CreatePipelineAsyncStatus = 0x00000001 + CreatePipelineAsyncStatusInstanceDropped CreatePipelineAsyncStatus = 0x00000002 + CreatePipelineAsyncStatusValidationError CreatePipelineAsyncStatus = 0x00000003 + CreatePipelineAsyncStatusInternalError CreatePipelineAsyncStatus = 0x00000004 CreatePipelineAsyncStatusUnknown CreatePipelineAsyncStatus = 0x00000005 ) @@ -449,14 +379,12 @@ func (v CreatePipelineAsyncStatus) String() string { switch v { case CreatePipelineAsyncStatusSuccess: return "success" + case CreatePipelineAsyncStatusInstanceDropped: + return "instance-dropped" case CreatePipelineAsyncStatusValidationError: return "validation-error" case CreatePipelineAsyncStatusInternalError: return "internal-error" - case CreatePipelineAsyncStatusDeviceLost: - return "device-lost" - case CreatePipelineAsyncStatusDeviceDestroyed: - return "device-destroyed" case CreatePipelineAsyncStatusUnknown: return "unknown" default: @@ -467,13 +395,16 @@ func (v CreatePipelineAsyncStatus) String() string { type CullMode uint32 const ( - CullModeNone CullMode = 0x00000000 - CullModeFront CullMode = 0x00000001 - CullModeBack CullMode = 0x00000002 + CullModeUndefined CullMode = 0x00000000 + CullModeNone CullMode = 0x00000001 + CullModeFront CullMode = 0x00000002 + CullModeBack CullMode = 0x00000003 ) func (v CullMode) String() string { switch v { + case CullModeUndefined: + return "undefined" case CullModeNone: return "none" case CullModeFront: @@ -488,8 +419,10 @@ func (v CullMode) String() string { type DeviceLostReason uint32 const ( - DeviceLostReasonUnknown DeviceLostReason = 0x00000001 - DeviceLostReasonDestroyed DeviceLostReason = 0x00000002 + DeviceLostReasonUnknown DeviceLostReason = 0x00000001 + DeviceLostReasonDestroyed DeviceLostReason = 0x00000002 + DeviceLostReasonInstanceDropped DeviceLostReason = 0x00000003 + DeviceLostReasonFailedCreation DeviceLostReason = 0x00000004 ) func (v DeviceLostReason) String() string { @@ -498,6 +431,10 @@ func (v DeviceLostReason) String() string { return "unknown" case DeviceLostReasonDestroyed: return "destroyed" + case DeviceLostReasonInstanceDropped: + return "instance-dropped" + case DeviceLostReasonFailedCreation: + return "failed-creation" default: return "" } @@ -527,9 +464,9 @@ func (v Dx12Compiler) String() string { type ErrorFilter uint32 const ( - ErrorFilterValidation ErrorFilter = 0x00000000 - ErrorFilterOutOfMemory ErrorFilter = 0x00000001 - ErrorFilterInternal ErrorFilter = 0x00000002 + ErrorFilterValidation ErrorFilter = 0x00000001 + ErrorFilterOutOfMemory ErrorFilter = 0x00000002 + ErrorFilterInternal ErrorFilter = 0x00000003 ) func (v ErrorFilter) String() string { @@ -548,12 +485,11 @@ func (v ErrorFilter) String() string { type ErrorType uint32 const ( - ErrorTypeNoError ErrorType = 0x00000000 - ErrorTypeValidation ErrorType = 0x00000001 - ErrorTypeOutOfMemory ErrorType = 0x00000002 - ErrorTypeInternal ErrorType = 0x00000003 - ErrorTypeUnknown ErrorType = 0x00000004 - ErrorTypeDeviceLost ErrorType = 0x00000005 + ErrorTypeNoError ErrorType = 0x00000001 + ErrorTypeValidation ErrorType = 0x00000002 + ErrorTypeOutOfMemory ErrorType = 0x00000003 + ErrorTypeInternal ErrorType = 0x00000004 + ErrorTypeUnknown ErrorType = 0x00000005 ) func (v ErrorType) String() string { @@ -568,13 +504,29 @@ func (v ErrorType) String() string { return "internal" case ErrorTypeUnknown: return "unknown" - case ErrorTypeDeviceLost: - return "device-lost" default: return "unknown" } } +type FeatureLevel uint32 + +const ( + FeatureLevelCompatibility FeatureLevel = 0x00000001 + FeatureLevelCore FeatureLevel = 0x00000002 +) + +func (v FeatureLevel) String() string { + switch v { + case FeatureLevelCompatibility: + return "compatibility" + case FeatureLevelCore: + return "core" + default: + return "" + } +} + type FeatureName uint32 const ( @@ -583,13 +535,18 @@ const ( FeatureNameDepth32FloatStencil8 FeatureName = 0x00000002 FeatureNameTimestampQuery FeatureName = 0x00000003 FeatureNameTextureCompressionBC FeatureName = 0x00000004 - FeatureNameTextureCompressionETC2 FeatureName = 0x00000005 - FeatureNameTextureCompressionASTC FeatureName = 0x00000006 - FeatureNameIndirectFirstInstance FeatureName = 0x00000007 - FeatureNameShaderF16 FeatureName = 0x00000008 - FeatureNameRG11B10UfloatRenderable FeatureName = 0x00000009 - FeatureNameBGRA8UnormStorage FeatureName = 0x0000000A - FeatureNameFloat32Filterable FeatureName = 0x0000000B + FeatureNameTextureCompressionBCSliced3D FeatureName = 0x00000005 + FeatureNameTextureCompressionETC2 FeatureName = 0x00000006 + FeatureNameTextureCompressionASTC FeatureName = 0x00000007 + FeatureNameTextureCompressionASTCSliced3D FeatureName = 0x00000008 + FeatureNameIndirectFirstInstance FeatureName = 0x00000009 + FeatureNameShaderF16 FeatureName = 0x0000000A + FeatureNameRG11B10UfloatRenderable FeatureName = 0x0000000B + FeatureNameBGRA8UnormStorage FeatureName = 0x0000000C + FeatureNameFloat32Filterable FeatureName = 0x0000000D + FeatureNameFloat32Blendable FeatureName = 0x0000000E + FeatureNameClipDistances FeatureName = 0x0000000F + FeatureNameDualSourceBlending FeatureName = 0x00000010 NativeFeaturePushConstants FeatureName = 0x00030001 NativeFeatureTextureAdapterSpecificFormatFeatures FeatureName = 0x00030002 NativeFeatureMultiDrawIndirect FeatureName = 0x00030003 @@ -605,15 +562,20 @@ const ( NativeFeatureMappablePrimaryBuffers FeatureName = 0x0003000E NativeFeatureBufferBindingArray FeatureName = 0x0003000F NativeFeatureUniformBufferAndStorageTextureArrayNonUniformIndexing FeatureName = 0x00030010 + NativeFeatureSpirvShaderPassthrough FeatureName = 0x00030017 NativeFeatureVertexAttribute64bit FeatureName = 0x00030019 - NativeFeatureShaderUnusedVertexOutput FeatureName = 0x0003001A - NativeFeatureTextureFormatNv12 FeatureName = 0x0003001B - NativeFeatureRayTracingAccelerationStructure FeatureName = 0x0003001C - NativeFeatureRayQuery FeatureName = 0x0003001D - NativeFeatureShaderF64 FeatureName = 0x0003001E - NativeFeatureShaderI16 FeatureName = 0x0003001F - NativeFeatureShaderPrimitiveIndex FeatureName = 0x00030020 - NativeFeatureShaderEarlyDepthTest FeatureName = 0x00030021 + NativeFeatureTextureFormatNv12 FeatureName = 0x0003001A + NativeFeatureRayTracingAccelerationStructure FeatureName = 0x0003001B + NativeFeatureRayQuery FeatureName = 0x0003001C + NativeFeatureShaderF64 FeatureName = 0x0003001D + NativeFeatureShaderI16 FeatureName = 0x0003001E + NativeFeatureShaderPrimitiveIndex FeatureName = 0x0003001F + NativeFeatureShaderEarlyDepthTest FeatureName = 0x00030020 + NativeFeatureSubgroup FeatureName = 0x00030021 + NativeFeatureSubgroupVertex FeatureName = 0x00030022 + NativeFeatureSubgroupBarrier FeatureName = 0x00030023 + NativeFeatureTimestampQueryInsideEncoders FeatureName = 0x00030024 + NativeFeatureTimestampQueryInsidePasses FeatureName = 0x00030025 ) func (v FeatureName) String() string { @@ -628,10 +590,14 @@ func (v FeatureName) String() string { return "timestamp-query" case FeatureNameTextureCompressionBC: return "texture-compression-bc" + case FeatureNameTextureCompressionBCSliced3D: + return "texture-compression-bc-sliced3d" case FeatureNameTextureCompressionETC2: return "texture-compression-etc2" case FeatureNameTextureCompressionASTC: return "texture-compression-astc" + case FeatureNameTextureCompressionASTCSliced3D: + return "texture-compression-astc-sliced3d" case FeatureNameIndirectFirstInstance: return "indirect-first-instance" case FeatureNameShaderF16: @@ -642,6 +608,12 @@ func (v FeatureName) String() string { return "bgra8unorm-storage" case FeatureNameFloat32Filterable: return "float32filterable" + case FeatureNameFloat32Blendable: + return "float32blendable" + case FeatureNameClipDistances: + return "clip-distances" + case FeatureNameDualSourceBlending: + return "dual-source-blending" case NativeFeaturePushConstants: return "native-feature-push-constants" case NativeFeatureTextureAdapterSpecificFormatFeatures: @@ -672,10 +644,10 @@ func (v FeatureName) String() string { return "native-feature-buffer-binding-array" case NativeFeatureUniformBufferAndStorageTextureArrayNonUniformIndexing: return "native-feature-uniform-buffer-and-storage-texture-array-non-uniform-indexing" + case NativeFeatureSpirvShaderPassthrough: + return "native-feature-spirv-shader-passthrough" case NativeFeatureVertexAttribute64bit: return "native-feature-vertex-attribute64bit" - case NativeFeatureShaderUnusedVertexOutput: - return "native-feature-shader-unused-vertex-output" case NativeFeatureTextureFormatNv12: return "native-feature-texture-format-nv12" case NativeFeatureRayTracingAccelerationStructure: @@ -690,6 +662,16 @@ func (v FeatureName) String() string { return "native-feature-shader-primitive-index" case NativeFeatureShaderEarlyDepthTest: return "native-feature-shader-early-depth-test" + case NativeFeatureSubgroup: + return "native-feature-subgroup" + case NativeFeatureSubgroupVertex: + return "native-feature-subgroup-vertex" + case NativeFeatureSubgroupBarrier: + return "native-feature-subgroup-barrier" + case NativeFeatureTimestampQueryInsideEncoders: + return "native-feature-timestamp-query-inside-encoders" + case NativeFeatureTimestampQueryInsidePasses: + return "native-feature-timestamp-query-inside-passes" default: return "" } @@ -698,12 +680,15 @@ func (v FeatureName) String() string { type FilterMode uint32 const ( - FilterModeNearest FilterMode = 0x00000000 - FilterModeLinear FilterMode = 0x00000001 + FilterModeUndefined FilterMode = 0x00000000 + FilterModeNearest FilterMode = 0x00000001 + FilterModeLinear FilterMode = 0x00000002 ) func (v FilterMode) String() string { switch v { + case FilterModeUndefined: + return "undefined" case FilterModeNearest: return "nearest" case FilterModeLinear: @@ -716,12 +701,15 @@ func (v FilterMode) String() string { type FrontFace uint32 const ( - FrontFaceCCW FrontFace = 0x00000000 - FrontFaceCW FrontFace = 0x00000001 + FrontFaceUndefined FrontFace = 0x00000000 + FrontFaceCCW FrontFace = 0x00000001 + FrontFaceCW FrontFace = 0x00000002 ) func (v FrontFace) String() string { switch v { + case FrontFaceUndefined: + return "undefined" case FrontFaceCCW: return "ccw" case FrontFaceCW: @@ -776,85 +764,22 @@ func (v IndexFormat) String() string { } } -type InstanceBackend uint32 - -const ( - InstanceBackendAll InstanceBackend = 0x00000000 - InstanceBackendVulkan InstanceBackend = 0x00000001 - InstanceBackendGL InstanceBackend = 0x00000002 - InstanceBackendMetal InstanceBackend = 0x00000004 - InstanceBackendDX12 InstanceBackend = 0x00000008 - InstanceBackendDX11 InstanceBackend = 0x00000010 - InstanceBackendSecondary InstanceBackend = 0x00000012 - InstanceBackendBrowserWebGPU InstanceBackend = 0x00000020 - InstanceBackendPrimary InstanceBackend = 0x0000002D -) - -func (v InstanceBackend) String() string { - switch v { - case InstanceBackendAll: - return "all" - case InstanceBackendVulkan: - return "vulkan" - case InstanceBackendGL: - return "gl" - case InstanceBackendMetal: - return "metal" - case InstanceBackendDX12: - return "dx12" - case InstanceBackendDX11: - return "dx11" - case InstanceBackendSecondary: - return "secondary" - case InstanceBackendBrowserWebGPU: - return "browser-web-gpu" - case InstanceBackendPrimary: - return "primary" - default: - return "" - } -} - -type InstanceFlag uint32 - -const ( - InstanceFlagDefault InstanceFlag = 0x00000000 - InstanceFlagDebug InstanceFlag = 0x00000001 - InstanceFlagValidation InstanceFlag = 0x00000002 - InstanceFlagDiscardHalLabels InstanceFlag = 0x00000004 -) - -func (v InstanceFlag) String() string { - switch v { - case InstanceFlagDefault: - return "default" - case InstanceFlagDebug: - return "debug" - case InstanceFlagValidation: - return "validation" - case InstanceFlagDiscardHalLabels: - return "discard-hal-labels" - default: - return "" - } -} - type LoadOp uint32 const ( LoadOpUndefined LoadOp = 0x00000000 - LoadOpClear LoadOp = 0x00000001 - LoadOpLoad LoadOp = 0x00000002 + LoadOpLoad LoadOp = 0x00000001 + LoadOpClear LoadOp = 0x00000002 ) func (v LoadOp) String() string { switch v { case LoadOpUndefined: return "undefined" - case LoadOpClear: - return "clear" case LoadOpLoad: return "load" + case LoadOpClear: + return "clear" default: return "" } @@ -890,22 +815,28 @@ func (v LogLevel) String() string { } } -type MapMode uint32 +type MapAsyncStatus uint32 const ( - MapModeNone MapMode = 0x00000000 - MapModeRead MapMode = 0x00000001 - MapModeWrite MapMode = 0x00000002 + MapAsyncStatusSuccess MapAsyncStatus = 0x00000001 + MapAsyncStatusInstanceDropped MapAsyncStatus = 0x00000002 + MapAsyncStatusError MapAsyncStatus = 0x00000003 + MapAsyncStatusAborted MapAsyncStatus = 0x00000004 + MapAsyncStatusUnknown MapAsyncStatus = 0x00000005 ) -func (v MapMode) String() string { +func (v MapAsyncStatus) String() string { switch v { - case MapModeNone: - return "none" - case MapModeRead: - return "read" - case MapModeWrite: - return "write" + case MapAsyncStatusSuccess: + return "success" + case MapAsyncStatusInstanceDropped: + return "instance-dropped" + case MapAsyncStatusError: + return "error" + case MapAsyncStatusAborted: + return "aborted" + case MapAsyncStatusUnknown: + return "unknown" default: return "" } @@ -914,12 +845,15 @@ func (v MapMode) String() string { type MipmapFilterMode uint32 const ( - MipmapFilterModeNearest MipmapFilterMode = 0x00000000 - MipmapFilterModeLinear MipmapFilterMode = 0x00000001 + MipmapFilterModeUndefined MipmapFilterMode = 0x00000000 + MipmapFilterModeNearest MipmapFilterMode = 0x00000001 + MipmapFilterModeLinear MipmapFilterMode = 0x00000002 ) func (v MipmapFilterMode) String() string { switch v { + case MipmapFilterModeUndefined: + return "undefined" case MipmapFilterModeNearest: return "nearest" case MipmapFilterModeLinear: @@ -975,6 +909,27 @@ func (v NativeTextureFormat) String() string { } } +type OptionalBool uint32 + +const ( + OptionalBoolFalse OptionalBool = 0x00000000 + OptionalBoolTrue OptionalBool = 0x00000001 + OptionalBoolUndefined OptionalBool = 0x00000002 +) + +func (v OptionalBool) String() string { + switch v { + case OptionalBoolFalse: + return "false" + case OptionalBoolTrue: + return "true" + case OptionalBoolUndefined: + return "undefined" + default: + return "" + } +} + type PipelineStatisticName uint32 const ( @@ -1002,6 +957,27 @@ func (v PipelineStatisticName) String() string { } } +type PopErrorScopeStatus uint32 + +const ( + PopErrorScopeStatusSuccess PopErrorScopeStatus = 0x00000001 + PopErrorScopeStatusInstanceDropped PopErrorScopeStatus = 0x00000002 + PopErrorScopeStatusEmptyStack PopErrorScopeStatus = 0x00000003 +) + +func (v PopErrorScopeStatus) String() string { + switch v { + case PopErrorScopeStatusSuccess: + return "success" + case PopErrorScopeStatusInstanceDropped: + return "instance-dropped" + case PopErrorScopeStatusEmptyStack: + return "empty-stack" + default: + return "" + } +} + type PowerPreference uint32 const ( @@ -1026,14 +1002,17 @@ func (v PowerPreference) String() string { type PresentMode uint32 const ( - PresentModeFifo PresentMode = 0x00000000 - PresentModeFifoRelaxed PresentMode = 0x00000001 - PresentModeImmediate PresentMode = 0x00000002 - PresentModeMailbox PresentMode = 0x00000003 + PresentModeUndefined PresentMode = 0x00000000 + PresentModeFifo PresentMode = 0x00000001 + PresentModeFifoRelaxed PresentMode = 0x00000002 + PresentModeImmediate PresentMode = 0x00000003 + PresentModeMailbox PresentMode = 0x00000004 ) func (v PresentMode) String() string { switch v { + case PresentModeUndefined: + return "undefined" case PresentModeFifo: return "fifo" case PresentModeFifoRelaxed: @@ -1050,15 +1029,18 @@ func (v PresentMode) String() string { type PrimitiveTopology uint32 const ( - PrimitiveTopologyPointList PrimitiveTopology = 0x00000000 - PrimitiveTopologyLineList PrimitiveTopology = 0x00000001 - PrimitiveTopologyLineStrip PrimitiveTopology = 0x00000002 - PrimitiveTopologyTriangleList PrimitiveTopology = 0x00000003 - PrimitiveTopologyTriangleStrip PrimitiveTopology = 0x00000004 + PrimitiveTopologyUndefined PrimitiveTopology = 0x00000000 + PrimitiveTopologyPointList PrimitiveTopology = 0x00000001 + PrimitiveTopologyLineList PrimitiveTopology = 0x00000002 + PrimitiveTopologyLineStrip PrimitiveTopology = 0x00000003 + PrimitiveTopologyTriangleList PrimitiveTopology = 0x00000004 + PrimitiveTopologyTriangleStrip PrimitiveTopology = 0x00000005 ) func (v PrimitiveTopology) String() string { switch v { + case PrimitiveTopologyUndefined: + return "undefined" case PrimitiveTopologyPointList: return "point-list" case PrimitiveTopologyLineList: @@ -1077,8 +1059,8 @@ func (v PrimitiveTopology) String() string { type QueryType uint32 const ( - QueryTypeOcclusion QueryType = 0x00000000 - QueryTypeTimestamp QueryType = 0x00000001 + QueryTypeOcclusion QueryType = 0x00000001 + QueryTypeTimestamp QueryType = 0x00000002 ) func (v QueryType) String() string { @@ -1095,22 +1077,22 @@ func (v QueryType) String() string { type QueueWorkDoneStatus uint32 const ( - QueueWorkDoneStatusSuccess QueueWorkDoneStatus = 0x00000000 - QueueWorkDoneStatusError QueueWorkDoneStatus = 0x00000001 - QueueWorkDoneStatusUnknown QueueWorkDoneStatus = 0x00000002 - QueueWorkDoneStatusDeviceLost QueueWorkDoneStatus = 0x00000003 + QueueWorkDoneStatusSuccess QueueWorkDoneStatus = 0x00000001 + QueueWorkDoneStatusInstanceDropped QueueWorkDoneStatus = 0x00000002 + QueueWorkDoneStatusError QueueWorkDoneStatus = 0x00000003 + QueueWorkDoneStatusUnknown QueueWorkDoneStatus = 0x00000004 ) func (v QueueWorkDoneStatus) String() string { switch v { case QueueWorkDoneStatusSuccess: return "success" + case QueueWorkDoneStatusInstanceDropped: + return "instance-dropped" case QueueWorkDoneStatusError: return "error" case QueueWorkDoneStatusUnknown: return "unknown" - case QueueWorkDoneStatusDeviceLost: - return "device-lost" default: return "" } @@ -1119,16 +1101,19 @@ func (v QueueWorkDoneStatus) String() string { type RequestAdapterStatus uint32 const ( - RequestAdapterStatusSuccess RequestAdapterStatus = 0x00000000 - RequestAdapterStatusUnavailable RequestAdapterStatus = 0x00000001 - RequestAdapterStatusError RequestAdapterStatus = 0x00000002 - RequestAdapterStatusUnknown RequestAdapterStatus = 0x00000003 + RequestAdapterStatusSuccess RequestAdapterStatus = 0x00000001 + RequestAdapterStatusInstanceDropped RequestAdapterStatus = 0x00000002 + RequestAdapterStatusUnavailable RequestAdapterStatus = 0x00000003 + RequestAdapterStatusError RequestAdapterStatus = 0x00000004 + RequestAdapterStatusUnknown RequestAdapterStatus = 0x00000005 ) func (v RequestAdapterStatus) String() string { switch v { case RequestAdapterStatusSuccess: return "success" + case RequestAdapterStatusInstanceDropped: + return "instance-dropped" case RequestAdapterStatusUnavailable: return "unavailable" case RequestAdapterStatusError: @@ -1143,15 +1128,18 @@ func (v RequestAdapterStatus) String() string { type RequestDeviceStatus uint32 const ( - RequestDeviceStatusSuccess RequestDeviceStatus = 0x00000000 - RequestDeviceStatusError RequestDeviceStatus = 0x00000001 - RequestDeviceStatusUnknown RequestDeviceStatus = 0x00000002 + RequestDeviceStatusSuccess RequestDeviceStatus = 0x00000001 + RequestDeviceStatusInstanceDropped RequestDeviceStatus = 0x00000002 + RequestDeviceStatusError RequestDeviceStatus = 0x00000003 + RequestDeviceStatusUnknown RequestDeviceStatus = 0x00000004 ) func (v RequestDeviceStatus) String() string { switch v { case RequestDeviceStatusSuccess: return "success" + case RequestDeviceStatusInstanceDropped: + return "instance-dropped" case RequestDeviceStatusError: return "error" case RequestDeviceStatusUnknown: @@ -1164,14 +1152,17 @@ func (v RequestDeviceStatus) String() string { type SamplerBindingType uint32 const ( - SamplerBindingTypeUndefined SamplerBindingType = 0x00000000 - SamplerBindingTypeFiltering SamplerBindingType = 0x00000001 - SamplerBindingTypeNonFiltering SamplerBindingType = 0x00000002 - SamplerBindingTypeComparison SamplerBindingType = 0x00000003 + SamplerBindingTypeBindingNotUsed SamplerBindingType = 0x00000000 + SamplerBindingTypeUndefined SamplerBindingType = 0x00000001 + SamplerBindingTypeFiltering SamplerBindingType = 0x00000002 + SamplerBindingTypeNonFiltering SamplerBindingType = 0x00000003 + SamplerBindingTypeComparison SamplerBindingType = 0x00000004 ) func (v SamplerBindingType) String() string { switch v { + case SamplerBindingTypeBindingNotUsed: + return "binding-not-used" case SamplerBindingTypeUndefined: return "undefined" case SamplerBindingTypeFiltering: @@ -1185,25 +1176,19 @@ func (v SamplerBindingType) String() string { } } -type ShaderStage uint32 +type Status uint32 const ( - ShaderStageNone ShaderStage = 0x00000000 - ShaderStageVertex ShaderStage = 0x00000001 - ShaderStageFragment ShaderStage = 0x00000002 - ShaderStageCompute ShaderStage = 0x00000004 + StatusSuccess Status = 0x00000001 + StatusError Status = 0x00000002 ) -func (v ShaderStage) String() string { +func (v Status) String() string { switch v { - case ShaderStageNone: - return "none" - case ShaderStageVertex: - return "vertex" - case ShaderStageFragment: - return "fragment" - case ShaderStageCompute: - return "compute" + case StatusSuccess: + return "success" + case StatusError: + return "error" default: return "" } @@ -1212,18 +1197,21 @@ func (v ShaderStage) String() string { type StencilOperation uint32 const ( - StencilOperationKeep StencilOperation = 0x00000000 - StencilOperationZero StencilOperation = 0x00000001 - StencilOperationReplace StencilOperation = 0x00000002 - StencilOperationInvert StencilOperation = 0x00000003 - StencilOperationIncrementClamp StencilOperation = 0x00000004 - StencilOperationDecrementClamp StencilOperation = 0x00000005 - StencilOperationIncrementWrap StencilOperation = 0x00000006 - StencilOperationDecrementWrap StencilOperation = 0x00000007 + StencilOperationUndefined StencilOperation = 0x00000000 + StencilOperationKeep StencilOperation = 0x00000001 + StencilOperationZero StencilOperation = 0x00000002 + StencilOperationReplace StencilOperation = 0x00000003 + StencilOperationInvert StencilOperation = 0x00000004 + StencilOperationIncrementClamp StencilOperation = 0x00000005 + StencilOperationDecrementClamp StencilOperation = 0x00000006 + StencilOperationIncrementWrap StencilOperation = 0x00000007 + StencilOperationDecrementWrap StencilOperation = 0x00000008 ) func (v StencilOperation) String() string { switch v { + case StencilOperationUndefined: + return "undefined" case StencilOperationKeep: return "keep" case StencilOperationZero: @@ -1248,14 +1236,17 @@ func (v StencilOperation) String() string { type StorageTextureAccess uint32 const ( - StorageTextureAccessUndefined StorageTextureAccess = 0x00000000 - StorageTextureAccessWriteOnly StorageTextureAccess = 0x00000001 - StorageTextureAccessReadOnly StorageTextureAccess = 0x00000002 - StorageTextureAccessReadWrite StorageTextureAccess = 0x00000003 + StorageTextureAccessBindingNotUsed StorageTextureAccess = 0x00000000 + StorageTextureAccessUndefined StorageTextureAccess = 0x00000001 + StorageTextureAccessWriteOnly StorageTextureAccess = 0x00000002 + StorageTextureAccessReadOnly StorageTextureAccess = 0x00000003 + StorageTextureAccessReadWrite StorageTextureAccess = 0x00000004 ) func (v StorageTextureAccess) String() string { switch v { + case StorageTextureAccessBindingNotUsed: + return "binding-not-used" case StorageTextureAccessUndefined: return "undefined" case StorageTextureAccessWriteOnly: @@ -1293,18 +1284,22 @@ func (v StoreOp) String() string { type SurfaceGetCurrentTextureStatus uint32 const ( - SurfaceGetCurrentTextureStatusSuccess SurfaceGetCurrentTextureStatus = 0x00000000 - SurfaceGetCurrentTextureStatusTimeout SurfaceGetCurrentTextureStatus = 0x00000001 - SurfaceGetCurrentTextureStatusOutdated SurfaceGetCurrentTextureStatus = 0x00000002 - SurfaceGetCurrentTextureStatusLost SurfaceGetCurrentTextureStatus = 0x00000003 - SurfaceGetCurrentTextureStatusOutOfMemory SurfaceGetCurrentTextureStatus = 0x00000004 - SurfaceGetCurrentTextureStatusDeviceLost SurfaceGetCurrentTextureStatus = 0x00000005 + SurfaceGetCurrentTextureStatusSuccessOptimal SurfaceGetCurrentTextureStatus = 0x00000001 + SurfaceGetCurrentTextureStatusSuccessSuboptimal SurfaceGetCurrentTextureStatus = 0x00000002 + SurfaceGetCurrentTextureStatusTimeout SurfaceGetCurrentTextureStatus = 0x00000003 + SurfaceGetCurrentTextureStatusOutdated SurfaceGetCurrentTextureStatus = 0x00000004 + SurfaceGetCurrentTextureStatusLost SurfaceGetCurrentTextureStatus = 0x00000005 + SurfaceGetCurrentTextureStatusOutOfMemory SurfaceGetCurrentTextureStatus = 0x00000006 + SurfaceGetCurrentTextureStatusDeviceLost SurfaceGetCurrentTextureStatus = 0x00000007 + SurfaceGetCurrentTextureStatusError SurfaceGetCurrentTextureStatus = 0x00000008 ) func (v SurfaceGetCurrentTextureStatus) String() string { switch v { - case SurfaceGetCurrentTextureStatusSuccess: - return "success" + case SurfaceGetCurrentTextureStatusSuccessOptimal: + return "success-optimal" + case SurfaceGetCurrentTextureStatusSuccessSuboptimal: + return "success-suboptimal" case SurfaceGetCurrentTextureStatusTimeout: return "timeout" case SurfaceGetCurrentTextureStatusOutdated: @@ -1315,6 +1310,8 @@ func (v SurfaceGetCurrentTextureStatus) String() string { return "out-of-memory" case SurfaceGetCurrentTextureStatusDeviceLost: return "device-lost" + case SurfaceGetCurrentTextureStatusError: + return "error" default: return "" } @@ -1323,13 +1320,16 @@ func (v SurfaceGetCurrentTextureStatus) String() string { type TextureAspect uint32 const ( - TextureAspectAll TextureAspect = 0x00000000 - TextureAspectStencilOnly TextureAspect = 0x00000001 - TextureAspectDepthOnly TextureAspect = 0x00000002 + TextureAspectUndefined TextureAspect = 0x00000000 + TextureAspectAll TextureAspect = 0x00000001 + TextureAspectStencilOnly TextureAspect = 0x00000002 + TextureAspectDepthOnly TextureAspect = 0x00000003 ) func (v TextureAspect) String() string { switch v { + case TextureAspectUndefined: + return "undefined" case TextureAspectAll: return "all" case TextureAspectStencilOnly: @@ -1344,13 +1344,16 @@ func (v TextureAspect) String() string { type TextureDimension uint32 const ( - TextureDimension1D TextureDimension = 0x00000000 - TextureDimension2D TextureDimension = 0x00000001 - TextureDimension3D TextureDimension = 0x00000002 + TextureDimensionUndefined TextureDimension = 0x00000000 + TextureDimension1D TextureDimension = 0x00000001 + TextureDimension2D TextureDimension = 0x00000002 + TextureDimension3D TextureDimension = 0x00000003 ) func (v TextureDimension) String() string { switch v { + case TextureDimensionUndefined: + return "undefined" case TextureDimension1D: return "1d" case TextureDimension2D: @@ -1665,16 +1668,19 @@ func (v TextureFormat) String() string { type TextureSampleType uint32 const ( - TextureSampleTypeUndefined TextureSampleType = 0x00000000 - TextureSampleTypeFloat TextureSampleType = 0x00000001 - TextureSampleTypeUnfilterableFloat TextureSampleType = 0x00000002 - TextureSampleTypeDepth TextureSampleType = 0x00000003 - TextureSampleTypeSint TextureSampleType = 0x00000004 - TextureSampleTypeUint TextureSampleType = 0x00000005 + TextureSampleTypeBindingNotUsed TextureSampleType = 0x00000000 + TextureSampleTypeUndefined TextureSampleType = 0x00000001 + TextureSampleTypeFloat TextureSampleType = 0x00000002 + TextureSampleTypeUnfilterableFloat TextureSampleType = 0x00000003 + TextureSampleTypeDepth TextureSampleType = 0x00000004 + TextureSampleTypeSint TextureSampleType = 0x00000005 + TextureSampleTypeUint TextureSampleType = 0x00000006 ) func (v TextureSampleType) String() string { switch v { + case TextureSampleTypeBindingNotUsed: + return "binding-not-used" case TextureSampleTypeUndefined: return "undefined" case TextureSampleTypeFloat: @@ -1692,36 +1698,6 @@ func (v TextureSampleType) String() string { } } -type TextureUsage uint32 - -const ( - TextureUsageNone TextureUsage = 0x00000000 - TextureUsageCopySrc TextureUsage = 0x00000001 - TextureUsageCopyDst TextureUsage = 0x00000002 - TextureUsageTextureBinding TextureUsage = 0x00000004 - TextureUsageStorageBinding TextureUsage = 0x00000008 - TextureUsageRenderAttachment TextureUsage = 0x00000010 -) - -func (v TextureUsage) String() string { - switch v { - case TextureUsageNone: - return "none" - case TextureUsageCopySrc: - return "copy-src" - case TextureUsageCopyDst: - return "copy-dst" - case TextureUsageTextureBinding: - return "texture-binding" - case TextureUsageStorageBinding: - return "storage-binding" - case TextureUsageRenderAttachment: - return "render-attachment" - default: - return "" - } -} - type TextureViewDimension uint32 const ( @@ -1758,75 +1734,101 @@ func (v TextureViewDimension) String() string { type VertexFormat uint32 const ( - VertexFormatUndefined VertexFormat = 0x00000000 - VertexFormatUint8x2 VertexFormat = 0x00000001 - VertexFormatUint8x4 VertexFormat = 0x00000002 - VertexFormatSint8x2 VertexFormat = 0x00000003 - VertexFormatSint8x4 VertexFormat = 0x00000004 - VertexFormatUnorm8x2 VertexFormat = 0x00000005 - VertexFormatUnorm8x4 VertexFormat = 0x00000006 - VertexFormatSnorm8x2 VertexFormat = 0x00000007 - VertexFormatSnorm8x4 VertexFormat = 0x00000008 - VertexFormatUint16x2 VertexFormat = 0x00000009 - VertexFormatUint16x4 VertexFormat = 0x0000000A - VertexFormatSint16x2 VertexFormat = 0x0000000B - VertexFormatSint16x4 VertexFormat = 0x0000000C - VertexFormatUnorm16x2 VertexFormat = 0x0000000D - VertexFormatUnorm16x4 VertexFormat = 0x0000000E - VertexFormatSnorm16x2 VertexFormat = 0x0000000F - VertexFormatSnorm16x4 VertexFormat = 0x00000010 - VertexFormatFloat16x2 VertexFormat = 0x00000011 - VertexFormatFloat16x4 VertexFormat = 0x00000012 - VertexFormatFloat32 VertexFormat = 0x00000013 - VertexFormatFloat32x2 VertexFormat = 0x00000014 - VertexFormatFloat32x3 VertexFormat = 0x00000015 - VertexFormatFloat32x4 VertexFormat = 0x00000016 - VertexFormatUint32 VertexFormat = 0x00000017 - VertexFormatUint32x2 VertexFormat = 0x00000018 - VertexFormatUint32x3 VertexFormat = 0x00000019 - VertexFormatUint32x4 VertexFormat = 0x0000001A - VertexFormatSint32 VertexFormat = 0x0000001B - VertexFormatSint32x2 VertexFormat = 0x0000001C - VertexFormatSint32x3 VertexFormat = 0x0000001D - VertexFormatSint32x4 VertexFormat = 0x0000001E + VertexFormatUint8 VertexFormat = 0x00000001 + VertexFormatUint8x2 VertexFormat = 0x00000002 + VertexFormatUint8x4 VertexFormat = 0x00000003 + VertexFormatSint8 VertexFormat = 0x00000004 + VertexFormatSint8x2 VertexFormat = 0x00000005 + VertexFormatSint8x4 VertexFormat = 0x00000006 + VertexFormatUnorm8 VertexFormat = 0x00000007 + VertexFormatUnorm8x2 VertexFormat = 0x00000008 + VertexFormatUnorm8x4 VertexFormat = 0x00000009 + VertexFormatSnorm8 VertexFormat = 0x0000000A + VertexFormatSnorm8x2 VertexFormat = 0x0000000B + VertexFormatSnorm8x4 VertexFormat = 0x0000000C + VertexFormatUint16 VertexFormat = 0x0000000D + VertexFormatUint16x2 VertexFormat = 0x0000000E + VertexFormatUint16x4 VertexFormat = 0x0000000F + VertexFormatSint16 VertexFormat = 0x00000010 + VertexFormatSint16x2 VertexFormat = 0x00000011 + VertexFormatSint16x4 VertexFormat = 0x00000012 + VertexFormatUnorm16 VertexFormat = 0x00000013 + VertexFormatUnorm16x2 VertexFormat = 0x00000014 + VertexFormatUnorm16x4 VertexFormat = 0x00000015 + VertexFormatSnorm16 VertexFormat = 0x00000016 + VertexFormatSnorm16x2 VertexFormat = 0x00000017 + VertexFormatSnorm16x4 VertexFormat = 0x00000018 + VertexFormatFloat16 VertexFormat = 0x00000019 + VertexFormatFloat16x2 VertexFormat = 0x0000001A + VertexFormatFloat16x4 VertexFormat = 0x0000001B + VertexFormatFloat32 VertexFormat = 0x0000001C + VertexFormatFloat32x2 VertexFormat = 0x0000001D + VertexFormatFloat32x3 VertexFormat = 0x0000001E + VertexFormatFloat32x4 VertexFormat = 0x0000001F + VertexFormatUint32 VertexFormat = 0x00000020 + VertexFormatUint32x2 VertexFormat = 0x00000021 + VertexFormatUint32x3 VertexFormat = 0x00000022 + VertexFormatUint32x4 VertexFormat = 0x00000023 + VertexFormatSint32 VertexFormat = 0x00000024 + VertexFormatSint32x2 VertexFormat = 0x00000025 + VertexFormatSint32x3 VertexFormat = 0x00000026 + VertexFormatSint32x4 VertexFormat = 0x00000027 + VertexFormatUnorm1010102 VertexFormat = 0x00000028 + VertexFormatUnorm8x4BGRA VertexFormat = 0x00000029 ) func (v VertexFormat) String() string { switch v { - case VertexFormatUndefined: - return "undefined" + case VertexFormatUint8: + return "uint8" case VertexFormatUint8x2: return "uint8x2" case VertexFormatUint8x4: return "uint8x4" + case VertexFormatSint8: + return "sint8" case VertexFormatSint8x2: return "sint8x2" case VertexFormatSint8x4: return "sint8x4" + case VertexFormatUnorm8: + return "unorm8" case VertexFormatUnorm8x2: return "unorm8x2" case VertexFormatUnorm8x4: return "unorm8x4" + case VertexFormatSnorm8: + return "snorm8" case VertexFormatSnorm8x2: return "snorm8x2" case VertexFormatSnorm8x4: return "snorm8x4" + case VertexFormatUint16: + return "uint16" case VertexFormatUint16x2: return "uint16x2" case VertexFormatUint16x4: return "uint16x4" + case VertexFormatSint16: + return "sint16" case VertexFormatSint16x2: return "sint16x2" case VertexFormatSint16x4: return "sint16x4" + case VertexFormatUnorm16: + return "unorm16" case VertexFormatUnorm16x2: return "unorm16x2" case VertexFormatUnorm16x4: return "unorm16x4" + case VertexFormatSnorm16: + return "snorm16" case VertexFormatSnorm16x2: return "snorm16x2" case VertexFormatSnorm16x4: return "snorm16x4" + case VertexFormatFloat16: + return "float16" case VertexFormatFloat16x2: return "float16x2" case VertexFormatFloat16x4: @@ -1855,6 +1857,10 @@ func (v VertexFormat) String() string { return "sint32x3" case VertexFormatSint32x4: return "sint32x4" + case VertexFormatUnorm1010102: + return "unorm1010102" + case VertexFormatUnorm8x4BGRA: + return "unorm8x4bgra" default: return "" } @@ -1863,47 +1869,147 @@ func (v VertexFormat) String() string { type VertexStepMode uint32 const ( - VertexStepModeVertex VertexStepMode = 0x00000000 - VertexStepModeInstance VertexStepMode = 0x00000001 - VertexStepModeVertexBufferNotUsed VertexStepMode = 0x00000002 + VertexStepModeVertexBufferNotUsed VertexStepMode = 0x00000000 + VertexStepModeUndefined VertexStepMode = 0x00000001 + VertexStepModeVertex VertexStepMode = 0x00000002 + VertexStepModeInstance VertexStepMode = 0x00000003 ) func (v VertexStepMode) String() string { switch v { + case VertexStepModeVertexBufferNotUsed: + return "vertex-buffer-not-used" + case VertexStepModeUndefined: + return "undefined" case VertexStepModeVertex: return "vertex" case VertexStepModeInstance: return "instance" - case VertexStepModeVertexBufferNotUsed: - return "vertex-buffer-not-used" default: return "" } } -type WGSLFeatureName uint32 +type WGSLLanguageFeatureName uint32 const ( - WGSLFeatureNameUndefined WGSLFeatureName = 0x00000000 - WGSLFeatureNameReadonlyAndReadwriteStorageTextures WGSLFeatureName = 0x00000001 - WGSLFeatureNamePacked4x8IntegerDotProduct WGSLFeatureName = 0x00000002 - WGSLFeatureNameUnrestrictedPointerParameters WGSLFeatureName = 0x00000003 - WGSLFeatureNamePointerCompositeAccess WGSLFeatureName = 0x00000004 + WGSLLanguageFeatureNameReadonlyAndReadwriteStorageTextures WGSLLanguageFeatureName = 0x00000001 + WGSLLanguageFeatureNamePacked4x8IntegerDotProduct WGSLLanguageFeatureName = 0x00000002 + WGSLLanguageFeatureNameUnrestrictedPointerParameters WGSLLanguageFeatureName = 0x00000003 + WGSLLanguageFeatureNamePointerCompositeAccess WGSLLanguageFeatureName = 0x00000004 ) -func (v WGSLFeatureName) String() string { +func (v WGSLLanguageFeatureName) String() string { switch v { - case WGSLFeatureNameUndefined: - return "undefined" - case WGSLFeatureNameReadonlyAndReadwriteStorageTextures: + case WGSLLanguageFeatureNameReadonlyAndReadwriteStorageTextures: return "readonly-and-readwrite-storage-textures" - case WGSLFeatureNamePacked4x8IntegerDotProduct: + case WGSLLanguageFeatureNamePacked4x8IntegerDotProduct: return "packed4x8integer-dot-product" - case WGSLFeatureNameUnrestrictedPointerParameters: + case WGSLLanguageFeatureNameUnrestrictedPointerParameters: return "unrestricted-pointer-parameters" - case WGSLFeatureNamePointerCompositeAccess: + case WGSLLanguageFeatureNamePointerCompositeAccess: return "pointer-composite-access" default: return "" } } + +type WaitStatus uint32 + +const ( + WaitStatusSuccess WaitStatus = 0x00000001 + WaitStatusTimedOut WaitStatus = 0x00000002 + WaitStatusUnsupportedTimeout WaitStatus = 0x00000003 + WaitStatusUnsupportedCount WaitStatus = 0x00000004 + WaitStatusUnsupportedMixedSources WaitStatus = 0x00000005 +) + +func (v WaitStatus) String() string { + switch v { + case WaitStatusSuccess: + return "success" + case WaitStatusTimedOut: + return "timed-out" + case WaitStatusUnsupportedTimeout: + return "unsupported-timeout" + case WaitStatusUnsupportedCount: + return "unsupported-count" + case WaitStatusUnsupportedMixedSources: + return "unsupported-mixed-sources" + default: + return "" + } +} + +type BufferUsage uint64 +const ( + BufferUsageNone BufferUsage = 0x0000000000000000 + BufferUsageMapRead BufferUsage = 0x0000000000000001 + BufferUsageMapWrite BufferUsage = 0x0000000000000002 + BufferUsageCopySrc BufferUsage = 0x0000000000000004 + BufferUsageCopyDst BufferUsage = 0x0000000000000008 + BufferUsageIndex BufferUsage = 0x0000000000000010 + BufferUsageVertex BufferUsage = 0x0000000000000020 + BufferUsageUniform BufferUsage = 0x0000000000000040 + BufferUsageStorage BufferUsage = 0x0000000000000080 + BufferUsageIndirect BufferUsage = 0x0000000000000100 + BufferUsageQueryResolve BufferUsage = 0x0000000000000200 +) + +type ColorWriteMask uint64 +const ( + ColorWriteMaskNone ColorWriteMask = 0x0000000000000000 + ColorWriteMaskRed ColorWriteMask = 0x0000000000000001 + ColorWriteMaskGreen ColorWriteMask = 0x0000000000000002 + ColorWriteMaskBlue ColorWriteMask = 0x0000000000000004 + ColorWriteMaskAlpha ColorWriteMask = 0x0000000000000008 + ColorWriteMaskAll ColorWriteMask = 0x000000000000000F /* Red | Green | Blue | Alpha */ +) + +type MapMode uint64 +const ( + MapModeNone MapMode = 0x0000000000000000 + MapModeRead MapMode = 0x0000000000000001 + MapModeWrite MapMode = 0x0000000000000002 +) + +type ShaderStage uint64 +const ( + ShaderStageNone ShaderStage = 0x0000000000000000 + ShaderStageVertex ShaderStage = 0x0000000000000001 + ShaderStageFragment ShaderStage = 0x0000000000000002 + ShaderStageCompute ShaderStage = 0x0000000000000004 +) + +type TextureUsage uint64 +const ( + TextureUsageNone TextureUsage = 0x0000000000000000 + TextureUsageCopySrc TextureUsage = 0x0000000000000001 + TextureUsageCopyDst TextureUsage = 0x0000000000000002 + TextureUsageTextureBinding TextureUsage = 0x0000000000000004 + TextureUsageStorageBinding TextureUsage = 0x0000000000000008 + TextureUsageRenderAttachment TextureUsage = 0x0000000000000010 +) + +type InstanceBackend uint32 +const ( + WGPUInstanceBackend_All InstanceBackend = 0x00000000 + WGPUInstanceBackend_Vulkan InstanceBackend = 1 << 0 + WGPUInstanceBackend_GL InstanceBackend = 1 << 1 + WGPUInstanceBackend_Metal InstanceBackend = 1 << 2 + WGPUInstanceBackend_DX12 InstanceBackend = 1 << 3 + WGPUInstanceBackend_DX11 InstanceBackend = 1 << 4 + WGPUInstanceBackend_BrowserWebGPU InstanceBackend = 1 << 5 + WGPUInstanceBackend_Primary InstanceBackend = (1 << 0) | (1 << 2) | (1 << 3) | (1 << 5) + WGPUInstanceBackend_Secondary InstanceBackend = (1 << 1) | (1 << 4) + WGPUInstanceBackend_Force32 InstanceBackend = 0x7FFFFFFF +) + +type InstanceFlag uint32 +const ( + WGPUInstanceFlag_Default InstanceFlag = 0x00000000 + WGPUInstanceFlag_Debug InstanceFlag = 1 << 0 + WGPUInstanceFlag_Validation InstanceFlag = 1 << 1 + WGPUInstanceFlag_DiscardHalLabels InstanceFlag = 1 << 2 + WGPUInstanceFlag_Force32 InstanceFlag = 0x7FFFFFFF +) From 8ef02e1ce63583fa49b37607510f02b0fe453cab Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 17:56:54 +0200 Subject: [PATCH 18/19] wgpu/adapter: Fix request device callback --- wgpu/adapter.go | 4 ++-- wgpu/wgpu_c_cb.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wgpu/adapter.go b/wgpu/adapter.go index 6824902..69d5fa8 100644 --- a/wgpu/adapter.go +++ b/wgpu/adapter.go @@ -108,13 +108,13 @@ func (p *Adapter) HasFeature(feature FeatureName) bool { type requestDeviceCb func(status RequestDeviceStatus, device *Device, message string) //export gowebgpu_request_device_callback_go -func gowebgpu_request_device_callback_go(status C.WGPURequestDeviceStatus, device C.WGPUDevice, message *C.char, userdata unsafe.Pointer) { +func gowebgpu_request_device_callback_go(status C.WGPURequestDeviceStatus, device C.WGPUDevice, message C.WGPUStringView, userdata unsafe.Pointer) { handle := *(*cgo.Handle)(userdata) defer handle.Delete() cb, ok := handle.Value().(requestDeviceCb) if ok { - cb(RequestDeviceStatus(status), &Device{ref: device}, C.GoString(message)) + cb(RequestDeviceStatus(status), &Device{ref: device}, C.GoStringN(message.data, C.int(message.length))) } } diff --git a/wgpu/wgpu_c_cb.go b/wgpu/wgpu_c_cb.go index 9015662..ef133ec 100644 --- a/wgpu/wgpu_c_cb.go +++ b/wgpu/wgpu_c_cb.go @@ -16,9 +16,9 @@ void gowebgpu_request_adapter_callback_c(WGPURequestAdapterStatus status, WGPUAd gowebgpu_request_adapter_callback_go(status, adapter, message, userdata1); } -void gowebgpu_request_device_callback_c(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, void *userdata) { - extern void gowebgpu_request_device_callback_go(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, void *userdata); - gowebgpu_request_device_callback_go(status, device, message, userdata); +void gowebgpu_request_device_callback_c(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, void *userdata1, void *userdata2) { + extern void gowebgpu_request_device_callback_go(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, void *userdata); + gowebgpu_request_device_callback_go(status, device, message, userdata1); } void gowebgpu_device_lost_callback_c(WGPUDeviceLostReason reason, char const * message, void * userdata) { From 4f29428a797bd23d3341424c30da6d26905a6c82 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 2 May 2025 17:58:53 +0200 Subject: [PATCH 19/19] examples: Update --- examples/boids/main.go | 4 ++-- examples/capture/main.go | 10 +++++----- examples/compute/main.go | 10 +++++----- examples/cube/main.go | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/boids/main.go b/examples/boids/main.go index f291f10..787e80b 100644 --- a/examples/boids/main.go +++ b/examples/boids/main.go @@ -110,7 +110,7 @@ func InitState(window *glfw.Window) (s *State, err error) { computeShader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{ Label: "compute.wgsl", - WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{ + WGSLSource: &wgpu.ShaderSourceWGSL{ Code: compute, }, }) @@ -121,7 +121,7 @@ func InitState(window *glfw.Window) (s *State, err error) { drawShader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{ Label: "draw.wgsl", - WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{ + WGSLSource: &wgpu.ShaderSourceWGSL{ Code: draw, }, }) diff --git a/examples/capture/main.go b/examples/capture/main.go index 2a4828b..18be958 100644 --- a/examples/capture/main.go +++ b/examples/capture/main.go @@ -132,9 +132,9 @@ func main() { // Copy the data from the texture to the buffer encoder.CopyTextureToBuffer( texture.AsImageCopy(), - &wgpu.ImageCopyBuffer{ + &wgpu.TexelCopyBufferInfo{ Buffer: outputBuffer, - Layout: wgpu.TextureDataLayout{ + Layout: wgpu.TexelCopyBufferLayout{ Offset: 0, BytesPerRow: uint32(bufferDimensions.paddedBytesPerRow), RowsPerImage: wgpu.CopyStrideUndefined, @@ -151,14 +151,14 @@ func main() { queue.Submit(cmdBuffer) - outputBuffer.MapAsync(wgpu.MapModeRead, 0, bufferSize, func(status wgpu.BufferMapAsyncStatus) { - if status != wgpu.BufferMapAsyncStatusSuccess { + outputBuffer.MapAsync(wgpu.MapModeRead, 0, bufferSize, func(status wgpu.MapAsyncStatus) { + if status != wgpu.MapAsyncStatusSuccess { panic("failed to map buffer") } }) defer outputBuffer.Unmap() - device.Poll(true, nil) + device.Poll(true, 0) data := outputBuffer.GetMappedRange(0, uint(bufferSize)) diff --git a/examples/compute/main.go b/examples/compute/main.go index e37b1ac..fb2c951 100644 --- a/examples/compute/main.go +++ b/examples/compute/main.go @@ -60,7 +60,7 @@ func main() { shaderModule, err := device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{ Label: "shader.wgsl", - WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{ + WGSLSource: &wgpu.ShaderSourceWGSL{ Code: shader, }, }) @@ -141,8 +141,8 @@ func main() { } queue.Submit(cmdBuffer) - var status wgpu.BufferMapAsyncStatus - err = stagingBuffer.MapAsync(wgpu.MapModeRead, 0, size, func(s wgpu.BufferMapAsyncStatus) { + var status wgpu.MapAsyncStatus + err = stagingBuffer.MapAsync(wgpu.MapModeRead, 0, size, func(s wgpu.MapAsyncStatus) { status = s }) if err != nil { @@ -150,9 +150,9 @@ func main() { } defer stagingBuffer.Unmap() - device.Poll(true, nil) + device.Poll(true, 0) - if status != wgpu.BufferMapAsyncStatusSuccess { + if status != wgpu.MapAsyncStatusSuccess { panic(status) } diff --git a/examples/cube/main.go b/examples/cube/main.go index 4acd19e..0945a0f 100644 --- a/examples/cube/main.go +++ b/examples/cube/main.go @@ -243,7 +243,7 @@ func InitState(window *glfw.Window) (s *State, err error) { s.queue.WriteTexture( texture.AsImageCopy(), wgpu.ToBytes(texels[:]), - &wgpu.TextureDataLayout{ + &wgpu.TexelCopyBufferLayout{ Offset: 0, BytesPerRow: texelsSize, RowsPerImage: wgpu.CopyStrideUndefined, @@ -262,8 +262,8 @@ func InitState(window *glfw.Window) (s *State, err error) { } shader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{ - Label: "shader.wgsl", - WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{Code: shader}, + Label: "shader.wgsl", + WGSLSource: &wgpu.ShaderSourceWGSL{Code: shader}, }) if err != nil { return s, err