diff --git a/libs/imgui/backends/imgui_impl_wgpu.cpp b/libs/imgui/backends/imgui_impl_wgpu.cpp index 5a98b7e..8549994 100644 --- a/libs/imgui/backends/imgui_impl_wgpu.cpp +++ b/libs/imgui/backends/imgui_impl_wgpu.cpp @@ -66,11 +66,6 @@ #error Emscripten <4.0.10 with '-sUSE_WEBGPU=1' is not supported anymore. #endif -#if defined IMGUI_IMPL_WEBGPU_BACKEND_DAWN || defined IMGUI_IMPL_WEBGPU_BACKEND_WGVK -// Dawn renamed WGPUProgrammableStageDescriptor to WGPUComputeState (see: https://github.com/webgpu-native/webgpu-headers/pull/413) -// Using type alias until WGPU adopts the same naming convention (#8369) -using WGPUProgrammableStageDescriptor = WGPUComputeState; -#endif // Dear ImGui prototypes from imgui_internal.h extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed); @@ -312,7 +307,7 @@ static void SafeRelease(FrameResources& res) SafeRelease(res.VertexBufferHost); } -static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModuleWGSL(const char* wgsl_source) +static WGPUComputeState ImGui_ImplWGPU_CreateShaderModuleWGSL(const char* wgsl_source) { ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData(); @@ -323,14 +318,14 @@ static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModuleWGSL(con WGPUShaderModuleDescriptor desc = {}; desc.nextInChain = (WGPUChainedStruct*)&wgsl_desc; - WGPUProgrammableStageDescriptor stage_desc = {}; + WGPUComputeState stage_desc = {}; stage_desc.module = wgpuDeviceCreateShaderModule(bd->wgpuDevice, &desc); stage_desc.entryPoint = { "main", WGPU_STRLEN }; return stage_desc; } -static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModuleSPIRV(const void* spirv_binary, size_t spirv_length) +static WGPUComputeState ImGui_ImplWGPU_CreateShaderModuleSPIRV(const void* spirv_binary, size_t spirv_length) { ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData(); @@ -342,7 +337,7 @@ static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModuleSPIRV(co WGPUShaderModuleDescriptor desc = {}; desc.nextInChain = (WGPUChainedStruct*)&spirv_desc; - WGPUProgrammableStageDescriptor stage_desc = {}; + WGPUComputeState stage_desc = {}; stage_desc.module = wgpuDeviceCreateShaderModule(bd->wgpuDevice, &desc); stage_desc.entryPoint = { "main", WGPU_STRLEN }; @@ -741,7 +736,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() graphics_pipeline_desc.layout = wgpuDeviceCreatePipelineLayout(bd->wgpuDevice, &layout_desc); // Create the vertex shader - WGPUProgrammableStageDescriptor vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_vert_wgsl); + WGPUComputeState vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_vert_wgsl); if (!vertex_shader_desc.module) vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleSPIRV(__shader_vert_spirv, sizeof(__shader_vert_spirv)); graphics_pipeline_desc.vertex.module = vertex_shader_desc.module; graphics_pipeline_desc.vertex.entryPoint = vertex_shader_desc.entryPoint; @@ -749,15 +744,9 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() // Vertex input configuration WGPUVertexAttribute attribute_desc[] = { -#if defined IMGUI_IMPL_WEBGPU_BACKEND_DAWN || defined IMGUI_IMPL_WEBGPU_BACKEND_WGVK { nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 }, { nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 }, { nullptr, WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 }, -#else - { WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 }, - { WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 }, - { WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 }, -#endif }; WGPUVertexBufferLayout buffer_layouts[1]; @@ -770,7 +759,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() graphics_pipeline_desc.vertex.buffers = buffer_layouts; // Create the pixel shader - WGPUProgrammableStageDescriptor pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_frag_wgsl); + WGPUComputeState pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_frag_wgsl); if (!pixel_shader_desc.module) pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleSPIRV(__shader_frag_spirv, sizeof(__shader_frag_spirv)); // Create the blending setup @@ -957,24 +946,15 @@ void ImGui_ImplWGPU_NewFrame() bool ImGui_ImplWGPU_IsSurfaceStatusError(WGPUSurfaceGetCurrentTextureStatus status) { -#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK) return (status == WGPUSurfaceGetCurrentTextureStatus_Error); -#else - return (status == WGPUSurfaceGetCurrentTextureStatus_OutOfMemory || status == WGPUSurfaceGetCurrentTextureStatus_DeviceLost); -#endif } bool ImGui_ImplWGPU_IsSurfaceStatusSubOptimal(WGPUSurfaceGetCurrentTextureStatus status) { -#if defined(__EMSCRIPTEN__) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) return (status == WGPUSurfaceGetCurrentTextureStatus_Timeout || status == WGPUSurfaceGetCurrentTextureStatus_Outdated || status == WGPUSurfaceGetCurrentTextureStatus_Lost); -#else - return (status == WGPUSurfaceGetCurrentTextureStatus_Timeout || status == WGPUSurfaceGetCurrentTextureStatus_Outdated || status == WGPUSurfaceGetCurrentTextureStatus_Lost || status == WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal); -#endif } // Helpers to obtain a string -#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK) const char* ImGui_ImplWGPU_GetErrorTypeName(WGPUErrorType type) { switch (type) @@ -997,20 +977,6 @@ const char* ImGui_ImplWGPU_GetDeviceLostReasonName(WGPUDeviceLostReason type) default: return "Unknown"; } } -#elif !defined(__EMSCRIPTEN__) -const char* ImGui_ImplWGPU_GetLogLevelName(WGPULogLevel level) -{ - switch (level) - { - case WGPULogLevel_Error: return "Error"; - case WGPULogLevel_Warn: return "Warn"; - case WGPULogLevel_Info: return "Info"; - case WGPULogLevel_Debug: return "Debug"; - case WGPULogLevel_Trace: return "Trace"; - default: return "Unknown"; - } -} -#endif const char* ImGui_ImplWGPU_GetBackendTypeName(WGPUBackendType type) { diff --git a/libs/wgpu/include/webgpu/webgpu.h b/libs/wgpu/include/webgpu/webgpu.h index db92746..4223519 100644 --- a/libs/wgpu/include/webgpu/webgpu.h +++ b/libs/wgpu/include/webgpu/webgpu.h @@ -13,6 +13,15 @@ * * This is the home of WebGPU C API specification. We define here the standard * `webgpu.h` header that all implementations should provide. + * + * For all details where behavior is not otherwise specified, `webgpu.h` has + * the same behavior as the WebGPU specification for JavaScript on the Web. + * The WebIDL-based Web specification is mapped into C as faithfully (and + * bidirectionally) as practical/possible. + * The working draft of WebGPU can be found at . + * + * The standard include directive for this header is `#include ` + * (if it is provided in a system-wide or toolchain-wide include directory). */ #ifndef WEBGPU_H_ @@ -54,37 +63,103 @@ #include #include +#include #define _wgpu_COMMA , #if defined(__cplusplus) +# define _wgpu_ENUM_ZERO_INIT(type) type(0) +# define _wgpu_STRUCT_ZERO_INIT {} # if __cplusplus >= 201103L # define _wgpu_MAKE_INIT_STRUCT(type, value) (type value) # else # define _wgpu_MAKE_INIT_STRUCT(type, value) value # endif -#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 +# define _wgpu_ENUM_ZERO_INIT(type) (type)0 +# define _wgpu_STRUCT_ZERO_INIT {0} +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define _wgpu_MAKE_INIT_STRUCT(type, value) ((type) value) +# else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +# endif #endif - /** - * \defgroup Constants + * \defgroup Constants Constants * \brief Constants. * * @{ */ -#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX) -#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX) -#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) -#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) -#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX) -#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX) -#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX) -#define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) -#define WGPU_WHOLE_SIZE (UINT64_MAX) +/** + * 'True' value of @ref WGPUBool. + * + * @remark It's not usually necessary to use this, as `true` (from + * `stdbool.h` or C++) casts to the same value. + */ +#define WGPU_TRUE (UINT32_C(1)) +/** + * 'False' value of @ref WGPUBool. + * + * @remark It's not usually necessary to use this, as `false` (from + * `stdbool.h` or C++) casts to the same value. + */ +#define WGPU_FALSE (UINT32_C(0)) +/** + * Indicates no array layer count is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX) +/** + * Indicates no copy stride is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX) +/** + * Indicates no depth clear value is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_DEPTH_CLEAR_VALUE_UNDEFINED (NAN) +/** + * Indicates no depth slice is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) +/** + * For `uint32_t` limits, indicates no limit value is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) +/** + * For `uint64_t` limits, indicates no limit value is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX) +/** + * Indicates no mip level count is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX) +/** + * Indicates no query set index is specified. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX) +/** + * Sentinel value used in @ref WGPUStringView to indicate that the pointer + * is to a null-terminated string, rather than an explicitly-sized string. + */ +#define WGPU_STRLEN (SIZE_MAX) +/** + * Indicates a size extending to the end of the buffer. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) +/** + * Indicates a size extending to the end of the buffer. For more info, + * see @ref SentinelValues and the places that use this sentinel value. + */ +#define WGPU_WHOLE_SIZE (UINT64_MAX) /** @} */ @@ -93,8 +168,6 @@ * * @{ */ -typedef uint64_t WGPUFlags; -typedef uint32_t WGPUBool; /** * Nullable value defining a pointer+length view into a UTF-8 encoded string. @@ -118,26 +191,25 @@ typedef uint32_t WGPUBool; * For info on how this is used in various places, see \ref Strings. */ typedef struct WGPUStringView { - char const * WGPU_NULLABLE data; + WGPU_NULLABLE char const * data; size_t length; -} WGPUStringView; +} WGPUStringView WGPU_STRUCTURE_ATTRIBUTE; /** - * Sentinel value used in @ref WGPUStringView to indicate that the pointer - * is to a null-terminated string, rather than an explicitly-sized string. + * Initializer for @ref WGPUStringView. */ -#define WGPU_STRLEN SIZE_MAX - #define WGPU_STRING_VIEW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStringView, { \ /*.data=*/NULL _wgpu_COMMA \ /*.length=*/WGPU_STRLEN _wgpu_COMMA \ }) +typedef uint64_t WGPUFlags; +typedef uint32_t WGPUBool; /** @} */ /** - * \defgroup Objects + * \defgroup Objects Objects * \brief Opaque, non-dispatchable handles to WebGPU objects. * * @{ @@ -150,7 +222,17 @@ typedef struct WGPUCommandBufferImpl* WGPUCommandBuffer WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUCommandEncoderImpl* WGPUCommandEncoder WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUComputePassEncoderImpl* WGPUComputePassEncoder WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUComputePipelineImpl* WGPUComputePipeline WGPU_OBJECT_ATTRIBUTE; +/** + * TODO + * + * Releasing the last ref to a `WGPUDevice` also calls @ref wgpuDeviceDestroy. + * For more info, see @ref DeviceRelease. + */ typedef struct WGPUDeviceImpl* WGPUDevice WGPU_OBJECT_ATTRIBUTE; +/** + * A sampleable 2D texture that may perform 0-copy YUV sampling internally. Creation of @ref WGPUExternalTexture is extremely implementation-dependent and not defined in this header. + */ +typedef struct WGPUExternalTextureImpl* WGPUExternalTexture WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUInstanceImpl* WGPUInstance WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUQuerySetImpl* WGPUQuerySet WGPU_OBJECT_ATTRIBUTE; @@ -168,26 +250,27 @@ typedef struct WGPUSurfaceImpl* WGPUSurface WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE; - /** @} */ + // Structure forward declarations struct WGPUAdapterInfo; -struct WGPUBindGroupEntry; struct WGPUBlendComponent; struct WGPUBufferBindingLayout; struct WGPUBufferDescriptor; struct WGPUColor; struct WGPUCommandBufferDescriptor; struct WGPUCommandEncoderDescriptor; +struct WGPUCompatibilityModeLimits; struct WGPUCompilationMessage; -struct WGPUComputePassTimestampWrites; struct WGPUConstantEntry; struct WGPUExtent3D; +struct WGPUExternalTextureBindingEntry; +struct WGPUExternalTextureBindingLayout; struct WGPUFuture; -struct WGPUInstanceCapabilities; -struct WGPULimits; +struct WGPUInstanceLimits; struct WGPUMultisampleState; struct WGPUOrigin3D; +struct WGPUPassTimestampWrites; struct WGPUPipelineLayoutDescriptor; struct WGPUPrimitiveState; struct WGPUQuerySetDescriptor; @@ -196,20 +279,19 @@ struct WGPURenderBundleDescriptor; struct WGPURenderBundleEncoderDescriptor; struct WGPURenderPassDepthStencilAttachment; struct WGPURenderPassMaxDrawCount; -struct WGPURenderPassTimestampWrites; -struct WGPURequestAdapterOptions; +struct WGPURequestAdapterWebXROptions; struct WGPUSamplerBindingLayout; struct WGPUSamplerDescriptor; -struct WGPUShaderModuleDescriptor; struct WGPUShaderSourceSPIRV; struct WGPUShaderSourceWGSL; struct WGPUStencilFaceState; struct WGPUStorageTextureBindingLayout; struct WGPUSupportedFeatures; +struct WGPUSupportedInstanceFeatures; struct WGPUSupportedWGSLLanguageFeatures; struct WGPUSurfaceCapabilities; +struct WGPUSurfaceColorManagement; struct WGPUSurfaceConfiguration; -struct WGPUSurfaceDescriptor; struct WGPUSurfaceSourceAndroidNativeWindow; struct WGPUSurfaceSourceMetalLayer; struct WGPUSurfaceSourceWaylandSurface; @@ -219,27 +301,35 @@ struct WGPUSurfaceSourceXlibWindow; struct WGPUSurfaceTexture; struct WGPUTexelCopyBufferLayout; struct WGPUTextureBindingLayout; -struct WGPUTextureViewDescriptor; +struct WGPUTextureBindingViewDimension; +struct WGPUTextureComponentSwizzle; struct WGPUVertexAttribute; -struct WGPUBindGroupDescriptor; +struct WGPUBindGroupEntry; struct WGPUBindGroupLayoutEntry; struct WGPUBlendState; struct WGPUCompilationInfo; struct WGPUComputePassDescriptor; +struct WGPUComputeState; struct WGPUDepthStencilState; -struct WGPUDeviceDescriptor; struct WGPUFutureWaitInfo; struct WGPUInstanceDescriptor; -struct WGPUProgrammableStageDescriptor; +struct WGPULimits; struct WGPURenderPassColorAttachment; +struct WGPURequestAdapterOptions; +struct WGPUShaderModuleDescriptor; +struct WGPUSurfaceDescriptor; struct WGPUTexelCopyBufferInfo; struct WGPUTexelCopyTextureInfo; +struct WGPUTextureComponentSwizzleDescriptor; struct WGPUTextureDescriptor; struct WGPUVertexBufferLayout; +struct WGPUBindGroupDescriptor; struct WGPUBindGroupLayoutDescriptor; struct WGPUColorTargetState; struct WGPUComputePipelineDescriptor; +struct WGPUDeviceDescriptor; struct WGPURenderPassDescriptor; +struct WGPUTextureViewDescriptor; struct WGPUVertexState; struct WGPUFragmentState; struct WGPURenderPipelineDescriptor; @@ -256,13 +346,13 @@ struct WGPURequestAdapterCallbackInfo; struct WGPURequestDeviceCallbackInfo; struct WGPUUncapturedErrorCallbackInfo; - /** - * \defgroup Enumerations + * \defgroup Enumerations Enumerations * \brief Enums. * * @{ */ + typedef enum WGPUAdapterType { WGPUAdapterType_DiscreteGPU = 0x00000001, WGPUAdapterType_IntegratedGPU = 0x00000002, @@ -273,8 +363,7 @@ typedef enum WGPUAdapterType { typedef enum WGPUAddressMode { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUAddressMode_Undefined = 0x00000000, WGPUAddressMode_ClampToEdge = 0x00000001, @@ -285,8 +374,7 @@ typedef enum WGPUAddressMode { typedef enum WGPUBackendType { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUBackendType_Undefined = 0x00000000, WGPUBackendType_Null = 0x00000001, @@ -302,8 +390,7 @@ typedef enum WGPUBackendType { typedef enum WGPUBlendFactor { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUBlendFactor_Undefined = 0x00000000, WGPUBlendFactor_Zero = 0x00000001, @@ -328,8 +415,7 @@ typedef enum WGPUBlendFactor { typedef enum WGPUBlendOperation { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUBlendOperation_Undefined = 0x00000000, WGPUBlendOperation_Add = 0x00000001, @@ -342,15 +428,13 @@ typedef enum WGPUBlendOperation { typedef enum WGPUBufferBindingType { /** - * `0x00000000`. - * Indicates that this @ref WGPUBufferBindingLayout member of + * `0`. 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. + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUBufferBindingType_Undefined = 0x00000001, WGPUBufferBindingType_Uniform = 0x00000002, @@ -371,21 +455,18 @@ typedef enum WGPUBufferMapState { */ 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`. + * - fire when the asynchronous operation's future is passed to a call to @ref wgpuInstanceWaitAny + * AND the operation has already completed or it completes inside the call to @ref wgpuInstanceWaitAny. */ WGPUCallbackMode_WaitAnyOnly = 0x00000001, /** - * `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. + * - fire inside a call to @ref 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. @@ -400,8 +481,7 @@ typedef enum WGPUCallbackMode { typedef enum WGPUCompareFunction { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUCompareFunction_Undefined = 0x00000000, WGPUCompareFunction_Never = 0x00000001, @@ -417,9 +497,10 @@ typedef enum WGPUCompareFunction { typedef enum WGPUCompilationInfoRequestStatus { WGPUCompilationInfoRequestStatus_Success = 0x00000001, - WGPUCompilationInfoRequestStatus_InstanceDropped = 0x00000002, - WGPUCompilationInfoRequestStatus_Error = 0x00000003, - WGPUCompilationInfoRequestStatus_Unknown = 0x00000004, + /** + * See @ref CallbackStatuses. + */ + WGPUCompilationInfoRequestStatus_CallbackCancelled = 0x00000002, WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF } WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; @@ -430,32 +511,59 @@ typedef enum WGPUCompilationMessageType { WGPUCompilationMessageType_Force32 = 0x7FFFFFFF } WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUComponentSwizzle { + /** + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUComponentSwizzle_Undefined = 0x00000000, + /** + * Force its value to 0. + */ + WGPUComponentSwizzle_Zero = 0x00000001, + /** + * Force its value to 1. + */ + WGPUComponentSwizzle_One = 0x00000002, + /** + * Take its value from the red channel of the texture. + */ + WGPUComponentSwizzle_R = 0x00000003, + /** + * Take its value from the green channel of the texture. + */ + WGPUComponentSwizzle_G = 0x00000004, + /** + * Take its value from the blue channel of the texture. + */ + WGPUComponentSwizzle_B = 0x00000005, + /** + * Take its value from the alpha channel of the texture. + */ + WGPUComponentSwizzle_A = 0x00000006, + WGPUComponentSwizzle_Force32 = 0x7FFFFFFF +} WGPUComponentSwizzle WGPU_ENUM_ATTRIBUTE; + /** - * Describes how frames are composited with other contents on the screen when `::wgpuSurfacePresent` is called. + * Describes how frames are composited with other contents on the screen when @ref 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. + * `0`. Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between @ref WGPUCompositeAlphaMode_Opaque or @ref WGPUCompositeAlphaMode_Inherit. */ WGPUCompositeAlphaMode_Auto = 0x00000000, /** - * `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, @@ -464,17 +572,18 @@ typedef enum WGPUCompositeAlphaMode { typedef enum WGPUCreatePipelineAsyncStatus { WGPUCreatePipelineAsyncStatus_Success = 0x00000001, - WGPUCreatePipelineAsyncStatus_InstanceDropped = 0x00000002, + /** + * See @ref CallbackStatuses. + */ + WGPUCreatePipelineAsyncStatus_CallbackCancelled = 0x00000002, WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000003, WGPUCreatePipelineAsyncStatus_InternalError = 0x00000004, - WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF } WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCullMode { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUCullMode_Undefined = 0x00000000, WGPUCullMode_None = 0x00000001, @@ -486,7 +595,10 @@ typedef enum WGPUCullMode { typedef enum WGPUDeviceLostReason { WGPUDeviceLostReason_Unknown = 0x00000001, WGPUDeviceLostReason_Destroyed = 0x00000002, - WGPUDeviceLostReason_InstanceDropped = 0x00000003, + /** + * See @ref CallbackStatuses. + */ + WGPUDeviceLostReason_CallbackCancelled = 0x00000003, WGPUDeviceLostReason_FailedCreation = 0x00000004, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF } WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; @@ -512,43 +624,49 @@ typedef enum WGPUErrorType { */ typedef enum WGPUFeatureLevel { /** - * `0x00000001`. - * "Compatibility" profile which can be supported on OpenGL ES 3.1. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFeatureLevel_Undefined = 0x00000000, + /** + * "Compatibility" profile which can be supported on OpenGL ES 3.1 and D3D11. */ WGPUFeatureLevel_Compatibility = 0x00000001, /** - * `0x00000002`. - * "Core" profile which can be supported on Vulkan/Metal/D3D12. + * "Core" profile which can be supported on Vulkan/Metal/D3D12 (at least). */ WGPUFeatureLevel_Core = 0x00000002, WGPUFeatureLevel_Force32 = 0x7FFFFFFF } WGPUFeatureLevel WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFeatureName { - WGPUFeatureName_Undefined = 0x00000000, - WGPUFeatureName_DepthClipControl = 0x00000001, - WGPUFeatureName_Depth32FloatStencil8 = 0x00000002, - WGPUFeatureName_TimestampQuery = 0x00000003, + WGPUFeatureName_CoreFeaturesAndLimits = 0x00000001, + WGPUFeatureName_DepthClipControl = 0x00000002, + WGPUFeatureName_Depth32FloatStencil8 = 0x00000003, WGPUFeatureName_TextureCompressionBC = 0x00000004, WGPUFeatureName_TextureCompressionBCSliced3D = 0x00000005, WGPUFeatureName_TextureCompressionETC2 = 0x00000006, WGPUFeatureName_TextureCompressionASTC = 0x00000007, WGPUFeatureName_TextureCompressionASTCSliced3D = 0x00000008, - WGPUFeatureName_IndirectFirstInstance = 0x00000009, - WGPUFeatureName_ShaderF16 = 0x0000000A, - WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000B, - WGPUFeatureName_BGRA8UnormStorage = 0x0000000C, - WGPUFeatureName_Float32Filterable = 0x0000000D, - WGPUFeatureName_Float32Blendable = 0x0000000E, - WGPUFeatureName_ClipDistances = 0x0000000F, - WGPUFeatureName_DualSourceBlending = 0x00000010, + WGPUFeatureName_TimestampQuery = 0x00000009, + WGPUFeatureName_IndirectFirstInstance = 0x0000000A, + WGPUFeatureName_ShaderF16 = 0x0000000B, + WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000C, + WGPUFeatureName_BGRA8UnormStorage = 0x0000000D, + WGPUFeatureName_Float32Filterable = 0x0000000E, + WGPUFeatureName_Float32Blendable = 0x0000000F, + WGPUFeatureName_ClipDistances = 0x00000010, + WGPUFeatureName_DualSourceBlending = 0x00000011, + WGPUFeatureName_Subgroups = 0x00000012, + WGPUFeatureName_TextureFormatsTier1 = 0x00000013, + WGPUFeatureName_TextureFormatsTier2 = 0x00000014, + WGPUFeatureName_PrimitiveIndex = 0x00000015, + WGPUFeatureName_TextureComponentSwizzle = 0x00000016, WGPUFeatureName_Force32 = 0x7FFFFFFF } WGPUFeatureName WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFilterMode { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUFilterMode_Undefined = 0x00000000, WGPUFilterMode_Nearest = 0x00000001, @@ -558,8 +676,7 @@ typedef enum WGPUFilterMode { typedef enum WGPUFrontFace { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUFrontFace_Undefined = 0x00000000, WGPUFrontFace_CCW = 0x00000001, @@ -569,8 +686,7 @@ typedef enum WGPUFrontFace { typedef enum WGPUIndexFormat { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUIndexFormat_Undefined = 0x00000000, WGPUIndexFormat_Uint16 = 0x00000001, @@ -578,10 +694,29 @@ typedef enum WGPUIndexFormat { WGPUIndexFormat_Force32 = 0x7FFFFFFF } WGPUIndexFormat WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUInstanceFeatureName { + /** + * Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + WGPUInstanceFeatureName_TimedWaitAny = 0x00000001, + /** + * Enable passing SPIR-V shaders to @ref wgpuDeviceCreateShaderModule, + * via @ref WGPUShaderSourceSPIRV. + */ + WGPUInstanceFeatureName_ShaderSourceSPIRV = 0x00000002, + /** + * Normally, a @ref WGPUAdapter can only create a single device. If this is + * available and enabled, then adapters won't immediately expire when they + * create a device, so can be reused to make multiple devices. They may + * still expire for other reasons. + */ + WGPUInstanceFeatureName_MultipleDevicesPerAdapter = 0x00000003, + WGPUInstanceFeatureName_Force32 = 0x7FFFFFFF +} WGPUInstanceFeatureName WGPU_ENUM_ATTRIBUTE; + typedef enum WGPULoadOp { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPULoadOp_Undefined = 0x00000000, WGPULoadOp_Load = 0x00000001, @@ -591,17 +726,18 @@ typedef enum WGPULoadOp { typedef enum WGPUMapAsyncStatus { WGPUMapAsyncStatus_Success = 0x00000001, - WGPUMapAsyncStatus_InstanceDropped = 0x00000002, + /** + * See @ref CallbackStatuses. + */ + WGPUMapAsyncStatus_CallbackCancelled = 0x00000002, WGPUMapAsyncStatus_Error = 0x00000003, WGPUMapAsyncStatus_Aborted = 0x00000004, - WGPUMapAsyncStatus_Unknown = 0x00000005, WGPUMapAsyncStatus_Force32 = 0x7FFFFFFF } WGPUMapAsyncStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUMipmapFilterMode { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUMipmapFilterMode_Undefined = 0x00000000, WGPUMipmapFilterMode_Nearest = 0x00000001, @@ -610,6 +746,9 @@ typedef enum WGPUMipmapFilterMode { } WGPUMipmapFilterMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUOptionalBool { + /** + * `0`. + */ WGPUOptionalBool_False = 0x00000000, WGPUOptionalBool_True = 0x00000001, WGPUOptionalBool_Undefined = 0x00000002, @@ -618,23 +757,23 @@ typedef enum WGPUOptionalBool { typedef enum WGPUPopErrorScopeStatus { /** - * `0x00000001`. * The error scope stack was successfully popped and a result was reported. */ WGPUPopErrorScopeStatus_Success = 0x00000001, - WGPUPopErrorScopeStatus_InstanceDropped = 0x00000002, /** - * `0x00000003`. + * See @ref CallbackStatuses. + */ + WGPUPopErrorScopeStatus_CallbackCancelled = 0x00000002, + /** * The error scope stack could not be popped, because it was empty. */ - WGPUPopErrorScopeStatus_EmptyStack = 0x00000003, + WGPUPopErrorScopeStatus_Error = 0x00000003, WGPUPopErrorScopeStatus_Force32 = 0x7FFFFFFF } WGPUPopErrorScopeStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPowerPreference { /** - * `0x00000000`. - * No preference. (See also @ref SentinelValues.) + * `0`. No preference. (See also @ref SentinelValues.) */ WGPUPowerPreference_Undefined = 0x00000000, WGPUPowerPreference_LowPower = 0x00000001, @@ -642,37 +781,38 @@ typedef enum WGPUPowerPreference { WGPUPowerPreference_Force32 = 0x7FFFFFFF } WGPUPowerPreference WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUPredefinedColorSpace { + WGPUPredefinedColorSpace_SRGB = 0x00000001, + WGPUPredefinedColorSpace_DisplayP3 = 0x00000002, + WGPUPredefinedColorSpace_Force32 = 0x7FFFFFFF +} WGPUPredefinedColorSpace WGPU_ENUM_ATTRIBUTE; + /** - * Describes when and in which order frames are presented on the screen when `::wgpuSurfacePresent` is called. + * Describes when and in which order frames are presented on the screen when @ref wgpuSurfacePresent is called. */ typedef enum WGPUPresentMode { /** - * `0x00000000`. - * Present mode is not specified. Use the default. + * `0`. 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. */ @@ -682,8 +822,7 @@ typedef enum WGPUPresentMode { typedef enum WGPUPrimitiveTopology { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUPrimitiveTopology_Undefined = 0x00000000, WGPUPrimitiveTopology_PointList = 0x00000001, @@ -702,53 +841,48 @@ typedef enum WGPUQueryType { typedef enum WGPUQueueWorkDoneStatus { WGPUQueueWorkDoneStatus_Success = 0x00000001, - WGPUQueueWorkDoneStatus_InstanceDropped = 0x00000002, + /** + * See @ref CallbackStatuses. + */ + WGPUQueueWorkDoneStatus_CallbackCancelled = 0x00000002, + /** + * There was some deterministic error. (Note this is currently never used, + * but it will be relevant when it's possible to create a queue object.) + */ WGPUQueueWorkDoneStatus_Error = 0x00000003, - WGPUQueueWorkDoneStatus_Unknown = 0x00000004, WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF } WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestAdapterStatus { WGPURequestAdapterStatus_Success = 0x00000001, - WGPURequestAdapterStatus_InstanceDropped = 0x00000002, + /** + * See @ref CallbackStatuses. + */ + WGPURequestAdapterStatus_CallbackCancelled = 0x00000002, WGPURequestAdapterStatus_Unavailable = 0x00000003, WGPURequestAdapterStatus_Error = 0x00000004, - WGPURequestAdapterStatus_Unknown = 0x00000005, WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF } WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestDeviceStatus { WGPURequestDeviceStatus_Success = 0x00000001, - WGPURequestDeviceStatus_InstanceDropped = 0x00000002, + /** + * See @ref CallbackStatuses. + */ + WGPURequestDeviceStatus_CallbackCancelled = 0x00000002, WGPURequestDeviceStatus_Error = 0x00000003, - WGPURequestDeviceStatus_Unknown = 0x00000004, WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF } WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUSType { - WGPUSType_ShaderSourceSPIRV = 0x00000001, - WGPUSType_ShaderSourceWGSL = 0x00000002, - WGPUSType_RenderPassMaxDrawCount = 0x00000003, - WGPUSType_SurfaceSourceMetalLayer = 0x00000004, - WGPUSType_SurfaceSourceWindowsHWND = 0x00000005, - WGPUSType_SurfaceSourceXlibWindow = 0x00000006, - WGPUSType_SurfaceSourceWaylandSurface = 0x00000007, - WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008, - WGPUSType_SurfaceSourceXCBWindow = 0x00000009, - WGPUSType_Force32 = 0x7FFFFFFF -} WGPUSType WGPU_ENUM_ATTRIBUTE; - typedef enum WGPUSamplerBindingType { /** - * `0x00000000`. - * Indicates that this @ref WGPUSamplerBindingLayout member of + * `0`. 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. + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUSamplerBindingType_Undefined = 0x00000001, WGPUSamplerBindingType_Filtering = 0x00000002, @@ -770,8 +904,7 @@ typedef enum WGPUStatus { typedef enum WGPUStencilOperation { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUStencilOperation_Undefined = 0x00000000, WGPUStencilOperation_Keep = 0x00000001, @@ -787,15 +920,13 @@ typedef enum WGPUStencilOperation { typedef enum WGPUStorageTextureAccess { /** - * `0x00000000`. - * Indicates that this @ref WGPUStorageTextureBindingLayout member of + * `0`. 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. + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUStorageTextureAccess_Undefined = 0x00000001, WGPUStorageTextureAccess_WriteOnly = 0x00000002, @@ -806,8 +937,7 @@ typedef enum WGPUStorageTextureAccess { typedef enum WGPUStoreOp { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUStoreOp_Undefined = 0x00000000, WGPUStoreOp_Store = 0x00000001, @@ -815,57 +945,60 @@ typedef enum WGPUStoreOp { WGPUStoreOp_Force32 = 0x7FFFFFFF } WGPUStoreOp WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUSType { + WGPUSType_ShaderSourceSPIRV = 0x00000001, + WGPUSType_ShaderSourceWGSL = 0x00000002, + WGPUSType_RenderPassMaxDrawCount = 0x00000003, + WGPUSType_SurfaceSourceMetalLayer = 0x00000004, + WGPUSType_SurfaceSourceWindowsHWND = 0x00000005, + WGPUSType_SurfaceSourceXlibWindow = 0x00000006, + WGPUSType_SurfaceSourceWaylandSurface = 0x00000007, + WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008, + WGPUSType_SurfaceSourceXCBWindow = 0x00000009, + WGPUSType_SurfaceColorManagement = 0x0000000A, + WGPUSType_RequestAdapterWebXROptions = 0x0000000B, + WGPUSType_TextureComponentSwizzleDescriptor = 0x0000000C, + WGPUSType_ExternalTextureBindingLayout = 0x0000000D, + WGPUSType_ExternalTextureBindingEntry = 0x0000000E, + WGPUSType_CompatibilityModeLimits = 0x0000000F, + WGPUSType_TextureBindingViewDimension = 0x00000010, + WGPUSType_Force32 = 0x7FFFFFFF +} WGPUSType WGPU_ENUM_ATTRIBUTE; + /** - * The status enum for `::wgpuSurfaceGetCurrentTexture`. + * The status enum for @ref wgpuSurfaceGetCurrentTexture. */ typedef enum WGPUSurfaceGetCurrentTextureStatus { /** - * `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. + * The connection to whatever owns the surface was lost, or generally needs to be fully reinitialized. */ WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000005, /** - * `0x00000006`. - * The system ran out of memory. + * There was some deterministic error (for example, the surface is not configured, or there was an @ref OutStructChainError). Should produce @ref ImplementationDefinedLogging containing details. */ - WGPUSurfaceGetCurrentTextureStatus_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_Error = 0x00000006, WGPUSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF } WGPUSurfaceGetCurrentTextureStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureAspect { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUTextureAspect_Undefined = 0x00000000, WGPUTextureAspect_All = 0x00000001, @@ -876,8 +1009,7 @@ typedef enum WGPUTextureAspect { typedef enum WGPUTextureDimension { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUTextureDimension_Undefined = 0x00000000, WGPUTextureDimension_1D = 0x00000001, @@ -888,119 +1020,122 @@ typedef enum WGPUTextureDimension { typedef enum WGPUTextureFormat { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUTextureFormat_Undefined = 0x00000000, WGPUTextureFormat_R8Unorm = 0x00000001, WGPUTextureFormat_R8Snorm = 0x00000002, WGPUTextureFormat_R8Uint = 0x00000003, WGPUTextureFormat_R8Sint = 0x00000004, - WGPUTextureFormat_R16Uint = 0x00000005, - WGPUTextureFormat_R16Sint = 0x00000006, - WGPUTextureFormat_R16Float = 0x00000007, - WGPUTextureFormat_RG8Unorm = 0x00000008, - WGPUTextureFormat_RG8Snorm = 0x00000009, - WGPUTextureFormat_RG8Uint = 0x0000000A, - WGPUTextureFormat_RG8Sint = 0x0000000B, - WGPUTextureFormat_R32Float = 0x0000000C, - WGPUTextureFormat_R32Uint = 0x0000000D, - WGPUTextureFormat_R32Sint = 0x0000000E, - WGPUTextureFormat_RG16Uint = 0x0000000F, - WGPUTextureFormat_RG16Sint = 0x00000010, - WGPUTextureFormat_RG16Float = 0x00000011, - WGPUTextureFormat_RGBA8Unorm = 0x00000012, - WGPUTextureFormat_RGBA8UnormSrgb = 0x00000013, - WGPUTextureFormat_RGBA8Snorm = 0x00000014, - WGPUTextureFormat_RGBA8Uint = 0x00000015, - WGPUTextureFormat_RGBA8Sint = 0x00000016, - WGPUTextureFormat_BGRA8Unorm = 0x00000017, - WGPUTextureFormat_BGRA8UnormSrgb = 0x00000018, - WGPUTextureFormat_RGB10A2Uint = 0x00000019, - WGPUTextureFormat_RGB10A2Unorm = 0x0000001A, - WGPUTextureFormat_RG11B10Ufloat = 0x0000001B, - WGPUTextureFormat_RGB9E5Ufloat = 0x0000001C, - WGPUTextureFormat_RG32Float = 0x0000001D, - WGPUTextureFormat_RG32Uint = 0x0000001E, - WGPUTextureFormat_RG32Sint = 0x0000001F, - WGPUTextureFormat_RGBA16Uint = 0x00000020, - WGPUTextureFormat_RGBA16Sint = 0x00000021, - WGPUTextureFormat_RGBA16Float = 0x00000022, - WGPUTextureFormat_RGBA32Float = 0x00000023, - WGPUTextureFormat_RGBA32Uint = 0x00000024, - WGPUTextureFormat_RGBA32Sint = 0x00000025, - WGPUTextureFormat_Stencil8 = 0x00000026, - WGPUTextureFormat_Depth16Unorm = 0x00000027, - WGPUTextureFormat_Depth24Plus = 0x00000028, - WGPUTextureFormat_Depth24PlusStencil8 = 0x00000029, - WGPUTextureFormat_Depth32Float = 0x0000002A, - WGPUTextureFormat_Depth32FloatStencil8 = 0x0000002B, - WGPUTextureFormat_BC1RGBAUnorm = 0x0000002C, - WGPUTextureFormat_BC1RGBAUnormSrgb = 0x0000002D, - WGPUTextureFormat_BC2RGBAUnorm = 0x0000002E, - WGPUTextureFormat_BC2RGBAUnormSrgb = 0x0000002F, - WGPUTextureFormat_BC3RGBAUnorm = 0x00000030, - WGPUTextureFormat_BC3RGBAUnormSrgb = 0x00000031, - WGPUTextureFormat_BC4RUnorm = 0x00000032, - WGPUTextureFormat_BC4RSnorm = 0x00000033, - WGPUTextureFormat_BC5RGUnorm = 0x00000034, - WGPUTextureFormat_BC5RGSnorm = 0x00000035, - WGPUTextureFormat_BC6HRGBUfloat = 0x00000036, - WGPUTextureFormat_BC6HRGBFloat = 0x00000037, - WGPUTextureFormat_BC7RGBAUnorm = 0x00000038, - WGPUTextureFormat_BC7RGBAUnormSrgb = 0x00000039, - WGPUTextureFormat_ETC2RGB8Unorm = 0x0000003A, - WGPUTextureFormat_ETC2RGB8UnormSrgb = 0x0000003B, - WGPUTextureFormat_ETC2RGB8A1Unorm = 0x0000003C, - WGPUTextureFormat_ETC2RGB8A1UnormSrgb = 0x0000003D, - WGPUTextureFormat_ETC2RGBA8Unorm = 0x0000003E, - WGPUTextureFormat_ETC2RGBA8UnormSrgb = 0x0000003F, - WGPUTextureFormat_EACR11Unorm = 0x00000040, - WGPUTextureFormat_EACR11Snorm = 0x00000041, - WGPUTextureFormat_EACRG11Unorm = 0x00000042, - WGPUTextureFormat_EACRG11Snorm = 0x00000043, - WGPUTextureFormat_ASTC4x4Unorm = 0x00000044, - WGPUTextureFormat_ASTC4x4UnormSrgb = 0x00000045, - WGPUTextureFormat_ASTC5x4Unorm = 0x00000046, - WGPUTextureFormat_ASTC5x4UnormSrgb = 0x00000047, - WGPUTextureFormat_ASTC5x5Unorm = 0x00000048, - WGPUTextureFormat_ASTC5x5UnormSrgb = 0x00000049, - WGPUTextureFormat_ASTC6x5Unorm = 0x0000004A, - WGPUTextureFormat_ASTC6x5UnormSrgb = 0x0000004B, - WGPUTextureFormat_ASTC6x6Unorm = 0x0000004C, - WGPUTextureFormat_ASTC6x6UnormSrgb = 0x0000004D, - WGPUTextureFormat_ASTC8x5Unorm = 0x0000004E, - WGPUTextureFormat_ASTC8x5UnormSrgb = 0x0000004F, - WGPUTextureFormat_ASTC8x6Unorm = 0x00000050, - WGPUTextureFormat_ASTC8x6UnormSrgb = 0x00000051, - WGPUTextureFormat_ASTC8x8Unorm = 0x00000052, - WGPUTextureFormat_ASTC8x8UnormSrgb = 0x00000053, - WGPUTextureFormat_ASTC10x5Unorm = 0x00000054, - WGPUTextureFormat_ASTC10x5UnormSrgb = 0x00000055, - WGPUTextureFormat_ASTC10x6Unorm = 0x00000056, - WGPUTextureFormat_ASTC10x6UnormSrgb = 0x00000057, - WGPUTextureFormat_ASTC10x8Unorm = 0x00000058, - WGPUTextureFormat_ASTC10x8UnormSrgb = 0x00000059, - WGPUTextureFormat_ASTC10x10Unorm = 0x0000005A, - WGPUTextureFormat_ASTC10x10UnormSrgb = 0x0000005B, - WGPUTextureFormat_ASTC12x10Unorm = 0x0000005C, - WGPUTextureFormat_ASTC12x10UnormSrgb = 0x0000005D, - WGPUTextureFormat_ASTC12x12Unorm = 0x0000005E, - WGPUTextureFormat_ASTC12x12UnormSrgb = 0x0000005F, + WGPUTextureFormat_R16Unorm = 0x00000005, + WGPUTextureFormat_R16Snorm = 0x00000006, + WGPUTextureFormat_R16Uint = 0x00000007, + WGPUTextureFormat_R16Sint = 0x00000008, + WGPUTextureFormat_R16Float = 0x00000009, + WGPUTextureFormat_RG8Unorm = 0x0000000A, + WGPUTextureFormat_RG8Snorm = 0x0000000B, + WGPUTextureFormat_RG8Uint = 0x0000000C, + WGPUTextureFormat_RG8Sint = 0x0000000D, + WGPUTextureFormat_R32Float = 0x0000000E, + WGPUTextureFormat_R32Uint = 0x0000000F, + WGPUTextureFormat_R32Sint = 0x00000010, + WGPUTextureFormat_RG16Unorm = 0x00000011, + WGPUTextureFormat_RG16Snorm = 0x00000012, + WGPUTextureFormat_RG16Uint = 0x00000013, + WGPUTextureFormat_RG16Sint = 0x00000014, + WGPUTextureFormat_RG16Float = 0x00000015, + WGPUTextureFormat_RGBA8Unorm = 0x00000016, + WGPUTextureFormat_RGBA8UnormSrgb = 0x00000017, + WGPUTextureFormat_RGBA8Snorm = 0x00000018, + WGPUTextureFormat_RGBA8Uint = 0x00000019, + WGPUTextureFormat_RGBA8Sint = 0x0000001A, + WGPUTextureFormat_BGRA8Unorm = 0x0000001B, + WGPUTextureFormat_BGRA8UnormSrgb = 0x0000001C, + WGPUTextureFormat_RGB10A2Uint = 0x0000001D, + WGPUTextureFormat_RGB10A2Unorm = 0x0000001E, + WGPUTextureFormat_RG11B10Ufloat = 0x0000001F, + WGPUTextureFormat_RGB9E5Ufloat = 0x00000020, + WGPUTextureFormat_RG32Float = 0x00000021, + WGPUTextureFormat_RG32Uint = 0x00000022, + WGPUTextureFormat_RG32Sint = 0x00000023, + WGPUTextureFormat_RGBA16Unorm = 0x00000024, + WGPUTextureFormat_RGBA16Snorm = 0x00000025, + WGPUTextureFormat_RGBA16Uint = 0x00000026, + WGPUTextureFormat_RGBA16Sint = 0x00000027, + WGPUTextureFormat_RGBA16Float = 0x00000028, + WGPUTextureFormat_RGBA32Float = 0x00000029, + WGPUTextureFormat_RGBA32Uint = 0x0000002A, + WGPUTextureFormat_RGBA32Sint = 0x0000002B, + WGPUTextureFormat_Stencil8 = 0x0000002C, + WGPUTextureFormat_Depth16Unorm = 0x0000002D, + WGPUTextureFormat_Depth24Plus = 0x0000002E, + WGPUTextureFormat_Depth24PlusStencil8 = 0x0000002F, + WGPUTextureFormat_Depth32Float = 0x00000030, + WGPUTextureFormat_Depth32FloatStencil8 = 0x00000031, + WGPUTextureFormat_BC1RGBAUnorm = 0x00000032, + WGPUTextureFormat_BC1RGBAUnormSrgb = 0x00000033, + WGPUTextureFormat_BC2RGBAUnorm = 0x00000034, + WGPUTextureFormat_BC2RGBAUnormSrgb = 0x00000035, + WGPUTextureFormat_BC3RGBAUnorm = 0x00000036, + WGPUTextureFormat_BC3RGBAUnormSrgb = 0x00000037, + WGPUTextureFormat_BC4RUnorm = 0x00000038, + WGPUTextureFormat_BC4RSnorm = 0x00000039, + WGPUTextureFormat_BC5RGUnorm = 0x0000003A, + WGPUTextureFormat_BC5RGSnorm = 0x0000003B, + WGPUTextureFormat_BC6HRGBUfloat = 0x0000003C, + WGPUTextureFormat_BC6HRGBFloat = 0x0000003D, + WGPUTextureFormat_BC7RGBAUnorm = 0x0000003E, + WGPUTextureFormat_BC7RGBAUnormSrgb = 0x0000003F, + WGPUTextureFormat_ETC2RGB8Unorm = 0x00000040, + WGPUTextureFormat_ETC2RGB8UnormSrgb = 0x00000041, + WGPUTextureFormat_ETC2RGB8A1Unorm = 0x00000042, + WGPUTextureFormat_ETC2RGB8A1UnormSrgb = 0x00000043, + WGPUTextureFormat_ETC2RGBA8Unorm = 0x00000044, + WGPUTextureFormat_ETC2RGBA8UnormSrgb = 0x00000045, + WGPUTextureFormat_EACR11Unorm = 0x00000046, + WGPUTextureFormat_EACR11Snorm = 0x00000047, + WGPUTextureFormat_EACRG11Unorm = 0x00000048, + WGPUTextureFormat_EACRG11Snorm = 0x00000049, + WGPUTextureFormat_ASTC4x4Unorm = 0x0000004A, + WGPUTextureFormat_ASTC4x4UnormSrgb = 0x0000004B, + WGPUTextureFormat_ASTC5x4Unorm = 0x0000004C, + WGPUTextureFormat_ASTC5x4UnormSrgb = 0x0000004D, + WGPUTextureFormat_ASTC5x5Unorm = 0x0000004E, + WGPUTextureFormat_ASTC5x5UnormSrgb = 0x0000004F, + WGPUTextureFormat_ASTC6x5Unorm = 0x00000050, + WGPUTextureFormat_ASTC6x5UnormSrgb = 0x00000051, + WGPUTextureFormat_ASTC6x6Unorm = 0x00000052, + WGPUTextureFormat_ASTC6x6UnormSrgb = 0x00000053, + WGPUTextureFormat_ASTC8x5Unorm = 0x00000054, + WGPUTextureFormat_ASTC8x5UnormSrgb = 0x00000055, + WGPUTextureFormat_ASTC8x6Unorm = 0x00000056, + WGPUTextureFormat_ASTC8x6UnormSrgb = 0x00000057, + WGPUTextureFormat_ASTC8x8Unorm = 0x00000058, + WGPUTextureFormat_ASTC8x8UnormSrgb = 0x00000059, + WGPUTextureFormat_ASTC10x5Unorm = 0x0000005A, + WGPUTextureFormat_ASTC10x5UnormSrgb = 0x0000005B, + WGPUTextureFormat_ASTC10x6Unorm = 0x0000005C, + WGPUTextureFormat_ASTC10x6UnormSrgb = 0x0000005D, + WGPUTextureFormat_ASTC10x8Unorm = 0x0000005E, + WGPUTextureFormat_ASTC10x8UnormSrgb = 0x0000005F, + WGPUTextureFormat_ASTC10x10Unorm = 0x00000060, + WGPUTextureFormat_ASTC10x10UnormSrgb = 0x00000061, + WGPUTextureFormat_ASTC12x10Unorm = 0x00000062, + WGPUTextureFormat_ASTC12x10UnormSrgb = 0x00000063, + WGPUTextureFormat_ASTC12x12Unorm = 0x00000064, + WGPUTextureFormat_ASTC12x12UnormSrgb = 0x00000065, WGPUTextureFormat_Force32 = 0x7FFFFFFF } WGPUTextureFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureSampleType { /** - * `0x00000000`. - * Indicates that this @ref WGPUTextureBindingLayout member of + * `0`. 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. + * `1`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUTextureSampleType_Undefined = 0x00000001, WGPUTextureSampleType_Float = 0x00000002, @@ -1013,8 +1148,7 @@ typedef enum WGPUTextureSampleType { typedef enum WGPUTextureViewDimension { /** - * `0x00000000`. - * Indicates no value is passed for this argument. See @ref SentinelValues. + * `0`. Indicates no value is passed for this argument. See @ref SentinelValues. */ WGPUTextureViewDimension_Undefined = 0x00000000, WGPUTextureViewDimension_1D = 0x00000001, @@ -1026,6 +1160,12 @@ typedef enum WGPUTextureViewDimension { WGPUTextureViewDimension_Force32 = 0x7FFFFFFF } WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUToneMappingMode { + WGPUToneMappingMode_Standard = 0x00000001, + WGPUToneMappingMode_Extended = 0x00000002, + WGPUToneMappingMode_Force32 = 0x7FFFFFFF +} WGPUToneMappingMode WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUVertexFormat { WGPUVertexFormat_Uint8 = 0x00000001, WGPUVertexFormat_Uint8x2 = 0x00000002, @@ -1073,151 +1213,229 @@ typedef enum WGPUVertexFormat { typedef enum WGPUVertexStepMode { /** - * `0x00000000`. - * This @ref WGPUVertexBufferLayout is a "hole" in the @ref WGPUVertexState `buffers` array. - * (See also @ref SentinelValues.) + * `0`. Indicates no value is passed for this argument. See @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_Undefined = 0x00000000, + WGPUVertexStepMode_Vertex = 0x00000001, + WGPUVertexStepMode_Instance = 0x00000002, WGPUVertexStepMode_Force32 = 0x7FFFFFFF } WGPUVertexStepMode 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. + * The wait operation succeeded, but no WGPUFutures completed within the timeout. */ WGPUWaitStatus_TimedOut = 0x00000002, /** - * `0x00000003`. - * A @ref Timed-Wait was performed when WGPUInstanceFeatures::timedWaitAnyEnable is false. + * The call was invalid for some reason (see @ref Wait-Any). + * Should produce @ref ImplementationDefinedLogging containing details. */ - 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_Error = 0x00000003, WGPUWaitStatus_Force32 = 0x7FFFFFFF } WGPUWaitStatus WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUWGSLLanguageFeatureName { + WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, + WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct = 0x00000002, + WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters = 0x00000003, + WGPUWGSLLanguageFeatureName_PointerCompositeAccess = 0x00000004, + WGPUWGSLLanguageFeatureName_UniformBufferStandardLayout = 0x00000005, + WGPUWGSLLanguageFeatureName_SubgroupId = 0x00000006, + WGPUWGSLLanguageFeatureName_TextureAndSamplerLet = 0x00000007, + WGPUWGSLLanguageFeatureName_SubgroupUniformity = 0x00000008, + WGPUWGSLLanguageFeatureName_TextureFormatsTier1 = 0x00000009, + WGPUWGSLLanguageFeatureName_Force32 = 0x7FFFFFFF +} WGPUWGSLLanguageFeatureName WGPU_ENUM_ATTRIBUTE; /** @} */ /** - * \defgroup Bitflags + * \defgroup Bitflags Bitflags * \brief Type and constant definitions for bitflag types. * * @{ */ + +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ typedef WGPUFlags WGPUBufferUsage; +/** + * `0`. + */ static const WGPUBufferUsage WGPUBufferUsage_None = 0x0000000000000000; +/** + * The buffer can be *mapped* on the CPU side in *read* mode (using @ref WGPUMapMode_Read). + */ static const WGPUBufferUsage WGPUBufferUsage_MapRead = 0x0000000000000001; +/** + * The buffer can be *mapped* on the CPU side in *write* mode (using @ref WGPUMapMode_Write). + * + * @note This usage is **not** required to set `mappedAtCreation` to `true` in @ref WGPUBufferDescriptor. + */ static const WGPUBufferUsage WGPUBufferUsage_MapWrite = 0x0000000000000002; +/** + * The buffer can be used as the *source* of a GPU-side copy operation. + */ static const WGPUBufferUsage WGPUBufferUsage_CopySrc = 0x0000000000000004; +/** + * The buffer can be used as the *destination* of a GPU-side copy operation. + */ static const WGPUBufferUsage WGPUBufferUsage_CopyDst = 0x0000000000000008; +/** + * The buffer can be used as an Index buffer when doing indexed drawing in a render pipeline. + */ static const WGPUBufferUsage WGPUBufferUsage_Index = 0x0000000000000010; +/** + * The buffer can be used as a Vertex buffer when using a render pipeline. + */ static const WGPUBufferUsage WGPUBufferUsage_Vertex = 0x0000000000000020; +/** + * The buffer can be bound to a shader as a uniform buffer. + */ static const WGPUBufferUsage WGPUBufferUsage_Uniform = 0x0000000000000040; +/** + * The buffer can be bound to a shader as a storage buffer. + */ static const WGPUBufferUsage WGPUBufferUsage_Storage = 0x0000000000000080; +/** + * The buffer can store arguments for an indirect draw call. + */ static const WGPUBufferUsage WGPUBufferUsage_Indirect = 0x0000000000000100; +/** + * The buffer can store the result of a timestamp or occlusion query. + */ static const WGPUBufferUsage WGPUBufferUsage_QueryResolve = 0x0000000000000200; +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ typedef WGPUFlags WGPUColorWriteMask; +/** + * `0`. + */ static const WGPUColorWriteMask WGPUColorWriteMask_None = 0x0000000000000000; static const WGPUColorWriteMask WGPUColorWriteMask_Red = 0x0000000000000001; static const WGPUColorWriteMask WGPUColorWriteMask_Green = 0x0000000000000002; static const WGPUColorWriteMask WGPUColorWriteMask_Blue = 0x0000000000000004; static const WGPUColorWriteMask WGPUColorWriteMask_Alpha = 0x0000000000000008; -static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F /* Red | Green | Blue | Alpha */; +/** + * `Red | Green | Blue | Alpha`. + */ +static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F; +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ typedef WGPUFlags WGPUMapMode; +/** + * `0`. + */ static const WGPUMapMode WGPUMapMode_None = 0x0000000000000000; static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001; static const WGPUMapMode WGPUMapMode_Write = 0x0000000000000002; +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ typedef WGPUFlags WGPUShaderStage; +/** + * `0`. + */ static const WGPUShaderStage WGPUShaderStage_None = 0x0000000000000000; static const WGPUShaderStage WGPUShaderStage_Vertex = 0x0000000000000001; static const WGPUShaderStage WGPUShaderStage_Fragment = 0x0000000000000002; static const WGPUShaderStage WGPUShaderStage_Compute = 0x0000000000000004; +/** + * For reserved non-standard bitflag values, see @ref BitflagRegistry. + */ typedef WGPUFlags WGPUTextureUsage; +/** + * `0`. + */ static const WGPUTextureUsage WGPUTextureUsage_None = 0x0000000000000000; static const WGPUTextureUsage WGPUTextureUsage_CopySrc = 0x0000000000000001; static const WGPUTextureUsage WGPUTextureUsage_CopyDst = 0x0000000000000002; static const WGPUTextureUsage WGPUTextureUsage_TextureBinding = 0x0000000000000004; static const WGPUTextureUsage WGPUTextureUsage_StorageBinding = 0x0000000000000008; static const WGPUTextureUsage WGPUTextureUsage_RenderAttachment = 0x0000000000000010; - +static const WGPUTextureUsage WGPUTextureUsage_TransientAttachment = 0x0000000000000020; /** @} */ + typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; - /** - * \defgroup Callbacks + * \defgroup Callbacks Callbacks * \brief Callbacks through which asynchronous functions return. * * @{ */ + /** - * @param message - * This parameter is @ref PassedWithoutOwnership. - */ -typedef void (*WGPUBufferMapCallback)(WGPUMapAsyncStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; -/** - * @param compilationInfo - * This parameter is @ref PassedWithoutOwnership. - */ -typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; -/** - * @param pipeline - * This parameter is @ref PassedWithOwnership. - */ -typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; -/** - * @param pipeline - * This parameter is @ref PassedWithOwnership. - */ -typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; -/** - * @param device - * Reference to the device which was lost. If, and only if, the `reason` is @ref WGPUDeviceLostReason_FailedCreation, this is a non-null pointer to a null @ref WGPUDevice. - * This parameter is @ref PassedWithoutOwnership. + * See also @ref CallbackError. * * @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; +typedef void (*WGPUBufferMapCallback)(WGPUMapAsyncStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + /** + * See also @ref CallbackError. + * + * @param compilationInfo + * This argument contains multiple @ref ImplementationAllocatedStructChain roots. + * Arbitrary chains must be handled gracefully by the application! + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** + * See also @ref CallbackError. + * + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** + * See also @ref CallbackError. + * + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** + * See also @ref CallbackError. + * + * @param device + * Pointer to the device which was lost. This is always a non-null pointer. + * The pointed-to @ref WGPUDevice will be null if, and only if, either: + * (1) The `reason` is @ref WGPUDeviceLostReason_FailedCreation. + * (2) The last ref of the device has been (or is being) released: see @ref DeviceRelease. + * This parameter is @ref PassedWithoutOwnership. + * + * @param reason + * An error code explaining why the device was lost. + * + * @param message + * A @ref LocalizableHumanReadableMessageString describing why the device was lost. + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUDeviceLostCallback)(WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** + * See also @ref CallbackError. + * * @param status * See @ref WGPUPopErrorScopeStatus. * @@ -1226,13 +1444,31 @@ typedef void (*WGPUDeviceLostCallback)(WGPUDevice const * device, WGPUDeviceLost * 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; + * If the `status` is not @ref WGPUPopErrorScopeStatus_Success **or** + * the `type` is not @ref WGPUErrorType_NoError, this is a non-empty + * @ref LocalizableHumanReadableMessageString; * otherwise, this is an empty string. * This parameter is @ref PassedWithoutOwnership. */ typedef void (*WGPUPopErrorScopeCallback)(WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + /** + * See also @ref CallbackError. + * + * @param status + * See @ref WGPUQueueWorkDoneStatus. + * + * @param message + * If the `status` is not @ref WGPUQueueWorkDoneStatus_Success, + * this is a non-empty @ref LocalizableHumanReadableMessageString; + * otherwise, this is an empty string. + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + +/** + * See also @ref CallbackError. + * * @param adapter * This parameter is @ref PassedWithOwnership. * @@ -1240,7 +1476,10 @@ typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_N * This parameter is @ref PassedWithoutOwnership. */ typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + /** + * See also @ref CallbackError. + * * @param device * This parameter is @ref PassedWithOwnership. * @@ -1248,7 +1487,10 @@ typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPU * This parameter is @ref PassedWithoutOwnership. */ typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; + /** + * See also @ref CallbackError. + * * @param device * This parameter is @ref PassedWithoutOwnership. * @@ -1266,953 +1508,3362 @@ typedef void (*WGPUUncapturedErrorCallback)(WGPUDevice const * device, WGPUError */ typedef struct WGPUChainedStruct { - struct WGPUChainedStruct const * next; + struct WGPUChainedStruct * next; WGPUSType sType; } WGPUChainedStruct WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUChainedStructOut { - struct WGPUChainedStructOut * next; - WGPUSType sType; -} WGPUChainedStructOut WGPU_STRUCTURE_ATTRIBUTE; - /** @} */ /** - * \defgroup Structures + * \defgroup Structures Structures * \brief Descriptors and other transparent structures. * * @{ */ - /** - * \defgroup WGPUCallbackInfo +/** + * \defgroup CallbackInfoStructs Callback Info Structs * \brief Callback info structures that are used in asynchronous functions. * * @{ */ + typedef struct WGPUBufferMapCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUBufferMapCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUBufferMapCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBufferMapCallbackInfo. + */ +#define WGPU_BUFFER_MAP_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBufferMapCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUCompilationInfoCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUCompilationInfoCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUCompilationInfoCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCompilationInfoCallbackInfo. + */ +#define WGPU_COMPILATION_INFO_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompilationInfoCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUCreateComputePipelineAsyncCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUCreateComputePipelineAsyncCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUCreateComputePipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCreateComputePipelineAsyncCallbackInfo. + */ +#define WGPU_CREATE_COMPUTE_PIPELINE_ASYNC_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCreateComputePipelineAsyncCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUCreateRenderPipelineAsyncCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUCreateRenderPipelineAsyncCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUCreateRenderPipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCreateRenderPipelineAsyncCallbackInfo. + */ +#define WGPU_CREATE_RENDER_PIPELINE_ASYNC_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCreateRenderPipelineAsyncCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUDeviceLostCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUDeviceLostCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUDeviceLostCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUDeviceLostCallbackInfo. + */ +#define WGPU_DEVICE_LOST_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUDeviceLostCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUPopErrorScopeCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUPopErrorScopeCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUPopErrorScopeCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUPopErrorScopeCallbackInfo. + */ +#define WGPU_POP_ERROR_SCOPE_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPopErrorScopeCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUQueueWorkDoneCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPUQueueWorkDoneCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUQueueWorkDoneCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUQueueWorkDoneCallbackInfo. + */ +#define WGPU_QUEUE_WORK_DONE_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUQueueWorkDoneCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPURequestAdapterCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPURequestAdapterCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPURequestAdapterCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURequestAdapterCallbackInfo. + */ +#define WGPU_REQUEST_ADAPTER_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestAdapterCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPURequestDeviceCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Controls when the callback may be called. + * + * Has no default. The `INIT` macro sets this to (@ref WGPUCallbackMode)0. + */ WGPUCallbackMode mode; WGPURequestDeviceCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPURequestDeviceCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURequestDeviceCallbackInfo. + */ +#define WGPU_REQUEST_DEVICE_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestDeviceCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.mode=*/_wgpu_ENUM_ZERO_INIT(WGPUCallbackMode) _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + typedef struct WGPUUncapturedErrorCallbackInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; WGPUUncapturedErrorCallback callback; WGPU_NULLABLE void* userdata1; WGPU_NULLABLE void* userdata2; } WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUUncapturedErrorCallbackInfo. + */ +#define WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUUncapturedErrorCallbackInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.callback=*/NULL _wgpu_COMMA \ + /*.userdata1=*/NULL _wgpu_COMMA \ + /*.userdata2=*/NULL _wgpu_COMMA \ +}) + /** @} */ +/** + * Default values can be set using @ref WGPU_ADAPTER_INFO_INIT as initializer. + */ typedef struct WGPUAdapterInfo { - WGPUChainedStructOut * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView vendor; /** * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView architecture; /** * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView device; /** * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView description; + /** + * The `INIT` macro sets this to @ref WGPUBackendType_Undefined. + */ WGPUBackendType backendType; + /** + * The `INIT` macro sets this to (@ref WGPUAdapterType)0. + */ WGPUAdapterType adapterType; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t vendorID; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t deviceID; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t subgroupMinSize; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t subgroupMaxSize; } WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUBindGroupEntry { - WGPUChainedStruct const * nextInChain; - uint32_t binding; - WGPU_NULLABLE WGPUBuffer buffer; - uint64_t offset; - uint64_t size; - WGPU_NULLABLE WGPUSampler sampler; - WGPU_NULLABLE WGPUTextureView textureView; -} WGPUBindGroupEntry WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUAdapterInfo. + */ +#define WGPU_ADAPTER_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUAdapterInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.vendor=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.architecture=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.device=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.description=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.backendType=*/WGPUBackendType_Undefined _wgpu_COMMA \ + /*.adapterType=*/_wgpu_ENUM_ZERO_INIT(WGPUAdapterType) _wgpu_COMMA \ + /*.vendorID=*/0 _wgpu_COMMA \ + /*.deviceID=*/0 _wgpu_COMMA \ + /*.subgroupMinSize=*/0 _wgpu_COMMA \ + /*.subgroupMaxSize=*/0 _wgpu_COMMA \ +}) +/** + * Default values can be set using @ref WGPU_BLEND_COMPONENT_INIT as initializer. + */ typedef struct WGPUBlendComponent { + /** + * If set to @ref WGPUBlendOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendOperation_Add. + * + * The `INIT` macro sets this to @ref WGPUBlendOperation_Undefined. + */ WGPUBlendOperation operation; + /** + * If set to @ref WGPUBlendFactor_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_One. + * + * The `INIT` macro sets this to @ref WGPUBlendFactor_Undefined. + */ WGPUBlendFactor srcFactor; + /** + * If set to @ref WGPUBlendFactor_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBlendFactor_Zero. + * + * The `INIT` macro sets this to @ref WGPUBlendFactor_Undefined. + */ WGPUBlendFactor dstFactor; } WGPUBlendComponent WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBlendComponent. + */ +#define WGPU_BLEND_COMPONENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBlendComponent, { \ + /*.operation=*/WGPUBlendOperation_Undefined _wgpu_COMMA \ + /*.srcFactor=*/WGPUBlendFactor_Undefined _wgpu_COMMA \ + /*.dstFactor=*/WGPUBlendFactor_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BUFFER_BINDING_LAYOUT_INIT as initializer. + */ typedef struct WGPUBufferBindingLayout { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUBufferBindingType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUBufferBindingType_Uniform. + * + * The `INIT` macro sets this to @ref WGPUBufferBindingType_Undefined. + */ WGPUBufferBindingType type; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool hasDynamicOffset; + /** + * The `INIT` macro sets this to `0`. + */ uint64_t minBindingSize; } WGPUBufferBindingLayout WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBufferBindingLayout. + */ +#define WGPU_BUFFER_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBufferBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.type=*/WGPUBufferBindingType_Undefined _wgpu_COMMA \ + /*.hasDynamicOffset=*/WGPU_FALSE _wgpu_COMMA \ + /*.minBindingSize=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BUFFER_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUBufferDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * The `INIT` macro sets this to @ref WGPUBufferUsage_None. + */ WGPUBufferUsage usage; + /** + * The `INIT` macro sets this to `0`. + */ uint64_t size; + /** + * When true, the buffer is mapped in write mode at creation. It should thus be unmapped once its initial data has been written. + * + * @note Mapping at creation does **not** require the usage @ref WGPUBufferUsage_MapWrite. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool mappedAtCreation; } WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBufferDescriptor. + */ +#define WGPU_BUFFER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBufferDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.usage=*/WGPUBufferUsage_None _wgpu_COMMA \ + /*.size=*/0 _wgpu_COMMA \ + /*.mappedAtCreation=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * An RGBA color. Represents a `f32`, `i32`, or `u32` color using @ref DoubleAsSupertype. + * + * If any channel is non-finite, produces a @ref NonFiniteFloatValueError. + * + * Default values can be set using @ref WGPU_COLOR_INIT as initializer. + */ typedef struct WGPUColor { + /** + * The `INIT` macro sets this to `0.`. + */ double r; + /** + * The `INIT` macro sets this to `0.`. + */ double g; + /** + * The `INIT` macro sets this to `0.`. + */ double b; + /** + * The `INIT` macro sets this to `0.`. + */ double a; } WGPUColor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUColor. + */ +#define WGPU_COLOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUColor, { \ + /*.r=*/0. _wgpu_COMMA \ + /*.g=*/0. _wgpu_COMMA \ + /*.b=*/0. _wgpu_COMMA \ + /*.a=*/0. _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMMAND_BUFFER_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUCommandBufferDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; } WGPUCommandBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCommandBufferDescriptor. + */ +#define WGPU_COMMAND_BUFFER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCommandBufferDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMMAND_ENCODER_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUCommandEncoderDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; } WGPUCommandEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCommandEncoderDescriptor. + */ +#define WGPU_COMMAND_ENCODER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCommandEncoderDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Note: While Compatibility Mode is optional to implement, this extension struct + * is required to be supported (for both queries and requests) and behave as + * defined in the WebGPU spec. + * + * Default values can be set using @ref WGPU_COMPATIBILITY_MODE_LIMITS_INIT as initializer. + */ +typedef struct WGPUCompatibilityModeLimits { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageBuffersInVertexStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageTexturesInVertexStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageBuffersInFragmentStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageTexturesInFragmentStage; +} WGPUCompatibilityModeLimits WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUCompatibilityModeLimits. + */ +#define WGPU_COMPATIBILITY_MODE_LIMITS_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompatibilityModeLimits, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_CompatibilityModeLimits _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.maxStorageBuffersInVertexStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageTexturesInVertexStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageBuffersInFragmentStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageTexturesInFragmentStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ +}) + +/** + * This is an @ref ImplementationAllocatedStructChain root. + * Arbitrary chains must be handled gracefully by the application! + * + * Default values can be set using @ref WGPU_COMPILATION_MESSAGE_INIT as initializer. + */ typedef struct WGPUCompilationMessage { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * A @ref LocalizableHumanReadableMessageString. * * This is an \ref OutputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView message; /** * Severity level of the message. + * + * The `INIT` macro sets this to (@ref WGPUCompilationMessageType)0. */ WGPUCompilationMessageType type; /** * Line number where the message is attached, starting at 1. + * + * The `INIT` macro sets this to `0`. */ uint64_t lineNum; /** * Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + * + * The `INIT` macro sets this to `0`. */ uint64_t linePos; /** * Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + * + * The `INIT` macro sets this to `0`. */ uint64_t offset; /** * Length in UTF-8 code units (bytes) of the span the message corresponds to. + * + * The `INIT` macro sets this to `0`. */ uint64_t length; } WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUComputePassTimestampWrites { - WGPUQuerySet querySet; - uint32_t beginningOfPassWriteIndex; - uint32_t endOfPassWriteIndex; -} WGPUComputePassTimestampWrites WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCompilationMessage. + */ +#define WGPU_COMPILATION_MESSAGE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompilationMessage, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.message=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.type=*/_wgpu_ENUM_ZERO_INIT(WGPUCompilationMessageType) _wgpu_COMMA \ + /*.lineNum=*/0 _wgpu_COMMA \ + /*.linePos=*/0 _wgpu_COMMA \ + /*.offset=*/0 _wgpu_COMMA \ + /*.length=*/0 _wgpu_COMMA \ +}) +/** + * Default values can be set using @ref WGPU_CONSTANT_ENTRY_INIT as initializer. + */ typedef struct WGPUConstantEntry { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView key; + /** + * Represents a WGSL numeric or boolean value using @ref DoubleAsSupertype. + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.`. + */ double value; } WGPUConstantEntry WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUConstantEntry. + */ +#define WGPU_CONSTANT_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUConstantEntry, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.key=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.value=*/0. _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_EXTENT_3D_INIT as initializer. + */ typedef struct WGPUExtent3D { + /** + * The `INIT` macro sets this to `0`. + */ uint32_t width; + /** + * The `INIT` macro sets this to `1`. + */ uint32_t height; + /** + * The `INIT` macro sets this to `1`. + */ uint32_t depthOrArrayLayers; } WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUExtent3D. + */ +#define WGPU_EXTENT_3D_INIT _wgpu_MAKE_INIT_STRUCT(WGPUExtent3D, { \ + /*.width=*/0 _wgpu_COMMA \ + /*.height=*/1 _wgpu_COMMA \ + /*.depthOrArrayLayers=*/1 _wgpu_COMMA \ +}) + +/** + * Chained in an @ref WGPUBindGroupEntry to set it to an @ref WGPUExternalTexture. This must have a corresponding @ref WGPUExternalTextureBindingLayout in the @ref WGPUBindGroupLayout. + * + * Default values can be set using @ref WGPU_EXTERNAL_TEXTURE_BINDING_ENTRY_INIT as initializer. + */ +typedef struct WGPUExternalTextureBindingEntry { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUExternalTexture externalTexture; +} WGPUExternalTextureBindingEntry WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUExternalTextureBindingEntry. + */ +#define WGPU_EXTERNAL_TEXTURE_BINDING_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUExternalTextureBindingEntry, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ExternalTextureBindingEntry _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.externalTexture=*/NULL _wgpu_COMMA \ +}) + +/** + * Chained in @ref WGPUBindGroupLayoutEntry to specify that the corresponding entries in an @ref WGPUBindGroup will contain an @ref WGPUExternalTexture. + * + * Default values can be set using @ref WGPU_EXTERNAL_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ +typedef struct WGPUExternalTextureBindingLayout { + WGPUChainedStruct chain; +} WGPUExternalTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUExternalTextureBindingLayout. + */ +#define WGPU_EXTERNAL_TEXTURE_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUExternalTextureBindingLayout, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ExternalTextureBindingLayout _wgpu_COMMA \ + }) _wgpu_COMMA \ +}) + /** * Opaque handle to an asynchronous operation. See @ref Asynchronous-Operations for more information. + * + * Default values can be set using @ref WGPU_FUTURE_INIT as initializer. */ typedef struct WGPUFuture { /** * Opaque id of the @ref WGPUFuture + * + * The `INIT` macro sets this to `0`. */ uint64_t id; } WGPUFuture WGPU_STRUCTURE_ATTRIBUTE; /** - * Features enabled on the WGPUInstance + * Initializer for @ref WGPUFuture. */ -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; +#define WGPU_FUTURE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUFuture, { \ + /*.id=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_INSTANCE_LIMITS_INIT as initializer. + */ +typedef struct WGPUInstanceLimits { + WGPUChainedStruct * nextInChain; /** * The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + * + * The `INIT` macro sets this to `0`. */ size_t timedWaitAnyMaxCount; -} WGPUInstanceCapabilities WGPU_STRUCTURE_ATTRIBUTE; +} WGPUInstanceLimits 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; - uint32_t maxTextureArrayLayers; - uint32_t maxBindGroups; - uint32_t maxBindGroupsPlusVertexBuffers; - uint32_t maxBindingsPerBindGroup; - uint32_t maxDynamicUniformBuffersPerPipelineLayout; - uint32_t maxDynamicStorageBuffersPerPipelineLayout; - uint32_t maxSampledTexturesPerShaderStage; - uint32_t maxSamplersPerShaderStage; - uint32_t maxStorageBuffersPerShaderStage; - uint32_t maxStorageTexturesPerShaderStage; - uint32_t maxUniformBuffersPerShaderStage; - uint64_t maxUniformBufferBindingSize; - uint64_t maxStorageBufferBindingSize; - uint32_t minUniformBufferOffsetAlignment; - uint32_t minStorageBufferOffsetAlignment; - uint32_t maxVertexBuffers; - uint64_t maxBufferSize; - uint32_t maxVertexAttributes; - uint32_t maxVertexBufferArrayStride; - uint32_t maxInterStageShaderVariables; - uint32_t maxColorAttachments; - uint32_t maxColorAttachmentBytesPerSample; - uint32_t maxComputeWorkgroupStorageSize; - uint32_t maxComputeInvocationsPerWorkgroup; - uint32_t maxComputeWorkgroupSizeX; - uint32_t maxComputeWorkgroupSizeY; - uint32_t maxComputeWorkgroupSizeZ; - uint32_t maxComputeWorkgroupsPerDimension; -} WGPULimits WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUInstanceLimits. + */ +#define WGPU_INSTANCE_LIMITS_INIT _wgpu_MAKE_INIT_STRUCT(WGPUInstanceLimits, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.timedWaitAnyMaxCount=*/0 _wgpu_COMMA \ +}) +/** + * Default values can be set using @ref WGPU_MULTISAMPLE_STATE_INIT as initializer. + */ typedef struct WGPUMultisampleState { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `1`. + */ uint32_t count; + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ uint32_t mask; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool alphaToCoverageEnabled; - } WGPUMultisampleState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUMultisampleState. + */ +#define WGPU_MULTISAMPLE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUMultisampleState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.count=*/1 _wgpu_COMMA \ + /*.mask=*/0xFFFFFFFF _wgpu_COMMA \ + /*.alphaToCoverageEnabled=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_ORIGIN_3D_INIT as initializer. + */ typedef struct WGPUOrigin3D { + /** + * The `INIT` macro sets this to `0`. + */ uint32_t x; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t y; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t z; } WGPUOrigin3D WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUOrigin3D. + */ +#define WGPU_ORIGIN_3D_INIT _wgpu_MAKE_INIT_STRUCT(WGPUOrigin3D, { \ + /*.x=*/0 _wgpu_COMMA \ + /*.y=*/0 _wgpu_COMMA \ + /*.z=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_PASS_TIMESTAMP_WRITES_INIT as initializer. + */ +typedef struct WGPUPassTimestampWrites { + WGPUChainedStruct * nextInChain; + /** + * Query set to write timestamps to. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPUQuerySet querySet; + /** + * The `INIT` macro sets this to @ref WGPU_QUERY_SET_INDEX_UNDEFINED. + */ + uint32_t beginningOfPassWriteIndex; + /** + * The `INIT` macro sets this to @ref WGPU_QUERY_SET_INDEX_UNDEFINED. + */ + uint32_t endOfPassWriteIndex; +} WGPUPassTimestampWrites WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUPassTimestampWrites. + */ +#define WGPU_PASS_TIMESTAMP_WRITES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPassTimestampWrites, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.querySet=*/NULL _wgpu_COMMA \ + /*.beginningOfPassWriteIndex=*/WGPU_QUERY_SET_INDEX_UNDEFINED _wgpu_COMMA \ + /*.endOfPassWriteIndex=*/WGPU_QUERY_SET_INDEX_UNDEFINED _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_PIPELINE_LAYOUT_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUPipelineLayoutDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * Array count for `bindGroupLayouts`. The `INIT` macro sets this to 0. + */ size_t bindGroupLayoutCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUBindGroupLayout const * bindGroupLayouts; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t immediateSize; } WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUPipelineLayoutDescriptor. + */ +#define WGPU_PIPELINE_LAYOUT_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPipelineLayoutDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.bindGroupLayoutCount=*/0 _wgpu_COMMA \ + /*.bindGroupLayouts=*/NULL _wgpu_COMMA \ + /*.immediateSize=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_PRIMITIVE_STATE_INIT as initializer. + */ typedef struct WGPUPrimitiveState { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUPrimitiveTopology_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUPrimitiveTopology_TriangleList. + * + * The `INIT` macro sets this to @ref WGPUPrimitiveTopology_Undefined. + */ WGPUPrimitiveTopology topology; + /** + * The `INIT` macro sets this to @ref WGPUIndexFormat_Undefined. + */ WGPUIndexFormat stripIndexFormat; + /** + * If set to @ref WGPUFrontFace_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFrontFace_CCW. + * + * The `INIT` macro sets this to @ref WGPUFrontFace_Undefined. + */ WGPUFrontFace frontFace; + /** + * If set to @ref WGPUCullMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUCullMode_None. + * + * The `INIT` macro sets this to @ref WGPUCullMode_Undefined. + */ WGPUCullMode cullMode; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool unclippedDepth; } WGPUPrimitiveState WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUPrimitiveState. + */ +#define WGPU_PRIMITIVE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUPrimitiveState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.topology=*/WGPUPrimitiveTopology_Undefined _wgpu_COMMA \ + /*.stripIndexFormat=*/WGPUIndexFormat_Undefined _wgpu_COMMA \ + /*.frontFace=*/WGPUFrontFace_Undefined _wgpu_COMMA \ + /*.cullMode=*/WGPUCullMode_Undefined _wgpu_COMMA \ + /*.unclippedDepth=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_QUERY_SET_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUQuerySetDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * The `INIT` macro sets this to (@ref WGPUQueryType)0. + */ WGPUQueryType type; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t count; } WGPUQuerySetDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUQuerySetDescriptor. + */ +#define WGPU_QUERY_SET_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUQuerySetDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.type=*/_wgpu_ENUM_ZERO_INIT(WGPUQueryType) _wgpu_COMMA \ + /*.count=*/0 _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_QUEUE_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUQueueDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; } WGPUQueueDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUQueueDescriptor. + */ +#define WGPU_QUEUE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUQueueDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_BUNDLE_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPURenderBundleDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; } WGPURenderBundleDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderBundleDescriptor. + */ +#define WGPU_RENDER_BUNDLE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderBundleDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_BUNDLE_ENCODER_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPURenderBundleEncoderDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * Array count for `colorFormats`. The `INIT` macro sets this to 0. + */ size_t colorFormatCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUTextureFormat const * colorFormats; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ WGPUTextureFormat depthStencilFormat; + /** + * The `INIT` macro sets this to `1`. + */ uint32_t sampleCount; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool depthReadOnly; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool stencilReadOnly; } WGPURenderBundleEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderBundleEncoderDescriptor. + */ +#define WGPU_RENDER_BUNDLE_ENCODER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderBundleEncoderDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.colorFormatCount=*/0 _wgpu_COMMA \ + /*.colorFormats=*/NULL _wgpu_COMMA \ + /*.depthStencilFormat=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.sampleCount=*/1 _wgpu_COMMA \ + /*.depthReadOnly=*/WGPU_FALSE _wgpu_COMMA \ + /*.stencilReadOnly=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_DEPTH_STENCIL_ATTACHMENT_INIT as initializer. + */ typedef struct WGPURenderPassDepthStencilAttachment { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUTextureView view; + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ WGPULoadOp depthLoadOp; + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ WGPUStoreOp depthStoreOp; + /** + * This is a @ref NullableFloatingPointType. + * + * If `NaN`, indicates an `undefined` value (as defined by the JS spec). + * Use @ref WGPU_DEPTH_CLEAR_VALUE_UNDEFINED to indicate this semantically. + * + * If infinite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to @ref WGPU_DEPTH_CLEAR_VALUE_UNDEFINED. + */ float depthClearValue; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool depthReadOnly; + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ WGPULoadOp stencilLoadOp; + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ WGPUStoreOp stencilStoreOp; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t stencilClearValue; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool stencilReadOnly; } WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderPassDepthStencilAttachment. + */ +#define WGPU_RENDER_PASS_DEPTH_STENCIL_ATTACHMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassDepthStencilAttachment, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.view=*/NULL _wgpu_COMMA \ + /*.depthLoadOp=*/WGPULoadOp_Undefined _wgpu_COMMA \ + /*.depthStoreOp=*/WGPUStoreOp_Undefined _wgpu_COMMA \ + /*.depthClearValue=*/WGPU_DEPTH_CLEAR_VALUE_UNDEFINED _wgpu_COMMA \ + /*.depthReadOnly=*/WGPU_FALSE _wgpu_COMMA \ + /*.stencilLoadOp=*/WGPULoadOp_Undefined _wgpu_COMMA \ + /*.stencilStoreOp=*/WGPUStoreOp_Undefined _wgpu_COMMA \ + /*.stencilClearValue=*/0 _wgpu_COMMA \ + /*.stencilReadOnly=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_MAX_DRAW_COUNT_INIT as initializer. + */ typedef struct WGPURenderPassMaxDrawCount { WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to `50000000`. + */ uint64_t maxDrawCount; } WGPURenderPassMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURenderPassTimestampWrites { - WGPUQuerySet querySet; - uint32_t beginningOfPassWriteIndex; - uint32_t endOfPassWriteIndex; -} WGPURenderPassTimestampWrites WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderPassMaxDrawCount. + */ +#define WGPU_RENDER_PASS_MAX_DRAW_COUNT_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassMaxDrawCount, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_RenderPassMaxDrawCount _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.maxDrawCount=*/50000000 _wgpu_COMMA \ +}) -typedef struct WGPURequestAdapterOptions { - WGPUChainedStruct const * nextInChain; +/** + * Extension providing requestAdapter options for implementations with WebXR interop (i.e. Wasm). + * + * Default values can be set using @ref WGPU_REQUEST_ADAPTER_WEBXR_OPTIONS_INIT as initializer. + */ +typedef struct WGPURequestAdapterWebXROptions { + WGPUChainedStruct chain; /** - * "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + * Sets the `xrCompatible` option in the JS API. * - * 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). + * The `INIT` macro sets this to `WGPU_FALSE`. */ - WGPUFeatureLevel featureLevel; - WGPUPowerPreference powerPreference; - /** - * If true, requires the adapter to be a "fallback" adapter as defined by the JS spec. - * If this is not possible, the request returns null. - */ - 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; + WGPUBool xrCompatible; +} WGPURequestAdapterWebXROptions WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURequestAdapterWebXROptions. + */ +#define WGPU_REQUEST_ADAPTER_WEBXR_OPTIONS_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestAdapterWebXROptions, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_RequestAdapterWebXROptions _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.xrCompatible=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SAMPLER_BINDING_LAYOUT_INIT as initializer. + */ typedef struct WGPUSamplerBindingLayout { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUSamplerBindingType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUSamplerBindingType_Filtering. + * + * The `INIT` macro sets this to @ref WGPUSamplerBindingType_Undefined. + */ WGPUSamplerBindingType type; } WGPUSamplerBindingLayout WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSamplerBindingLayout. + */ +#define WGPU_SAMPLER_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSamplerBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.type=*/WGPUSamplerBindingType_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SAMPLER_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUSamplerDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ WGPUAddressMode addressModeU; + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ WGPUAddressMode addressModeV; + /** + * If set to @ref WGPUAddressMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUAddressMode_ClampToEdge. + * + * The `INIT` macro sets this to @ref WGPUAddressMode_Undefined. + */ WGPUAddressMode addressModeW; + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUFilterMode_Undefined. + */ WGPUFilterMode magFilter; + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUFilterMode_Undefined. + */ WGPUFilterMode minFilter; + /** + * If set to @ref WGPUFilterMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUMipmapFilterMode_Nearest. + * + * The `INIT` macro sets this to @ref WGPUMipmapFilterMode_Undefined. + */ WGPUMipmapFilterMode mipmapFilter; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ float lodMinClamp; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `32.f`. + */ float lodMaxClamp; + /** + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ WGPUCompareFunction compare; + /** + * The `INIT` macro sets this to `1`. + */ uint16_t maxAnisotropy; } WGPUSamplerDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleDescriptor { - WGPUChainedStruct const * nextInChain; - /** - * This is a \ref NonNullInputString. - */ - WGPUStringView label; -} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSamplerDescriptor. + */ +#define WGPU_SAMPLER_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSamplerDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.addressModeU=*/WGPUAddressMode_Undefined _wgpu_COMMA \ + /*.addressModeV=*/WGPUAddressMode_Undefined _wgpu_COMMA \ + /*.addressModeW=*/WGPUAddressMode_Undefined _wgpu_COMMA \ + /*.magFilter=*/WGPUFilterMode_Undefined _wgpu_COMMA \ + /*.minFilter=*/WGPUFilterMode_Undefined _wgpu_COMMA \ + /*.mipmapFilter=*/WGPUMipmapFilterMode_Undefined _wgpu_COMMA \ + /*.lodMinClamp=*/0.f _wgpu_COMMA \ + /*.lodMaxClamp=*/32.f _wgpu_COMMA \ + /*.compare=*/WGPUCompareFunction_Undefined _wgpu_COMMA \ + /*.maxAnisotropy=*/1 _wgpu_COMMA \ +}) +/** + * Default values can be set using @ref WGPU_SHADER_SOURCE_SPIRV_INIT as initializer. + */ typedef struct WGPUShaderSourceSPIRV { WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t codeSize; + /** + * The `INIT` macro sets this to `NULL`. + */ uint32_t const * code; } WGPUShaderSourceSPIRV WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUShaderSourceSPIRV. + */ +#define WGPU_SHADER_SOURCE_SPIRV_INIT _wgpu_MAKE_INIT_STRUCT(WGPUShaderSourceSPIRV, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ShaderSourceSPIRV _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.codeSize=*/0 _wgpu_COMMA \ + /*.code=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SHADER_SOURCE_WGSL_INIT as initializer. + */ typedef struct WGPUShaderSourceWGSL { WGPUChainedStruct chain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView code; } WGPUShaderSourceWGSL WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUShaderSourceWGSL. + */ +#define WGPU_SHADER_SOURCE_WGSL_INIT _wgpu_MAKE_INIT_STRUCT(WGPUShaderSourceWGSL, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_ShaderSourceWGSL _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.code=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_STENCIL_FACE_STATE_INIT as initializer. + */ typedef struct WGPUStencilFaceState { + /** + * If set to @ref WGPUCompareFunction_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUCompareFunction_Always. + * + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ WGPUCompareFunction compare; + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ WGPUStencilOperation failOp; + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ WGPUStencilOperation depthFailOp; + /** + * If set to @ref WGPUStencilOperation_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStencilOperation_Keep. + * + * The `INIT` macro sets this to @ref WGPUStencilOperation_Undefined. + */ WGPUStencilOperation passOp; } WGPUStencilFaceState WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUStencilFaceState. + */ +#define WGPU_STENCIL_FACE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStencilFaceState, { \ + /*.compare=*/WGPUCompareFunction_Undefined _wgpu_COMMA \ + /*.failOp=*/WGPUStencilOperation_Undefined _wgpu_COMMA \ + /*.depthFailOp=*/WGPUStencilOperation_Undefined _wgpu_COMMA \ + /*.passOp=*/WGPUStencilOperation_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ typedef struct WGPUStorageTextureBindingLayout { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUStorageTextureAccess_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUStorageTextureAccess_WriteOnly. + * + * The `INIT` macro sets this to @ref WGPUStorageTextureAccess_Undefined. + */ WGPUStorageTextureAccess access; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ WGPUTextureFormat format; + /** + * If set to @ref WGPUTextureViewDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ WGPUTextureViewDimension viewDimension; } WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUStorageTextureBindingLayout. + */ +#define WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStorageTextureBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.access=*/WGPUStorageTextureAccess_Undefined _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.viewDimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SUPPORTED_FEATURES_INIT as initializer. + */ typedef struct WGPUSupportedFeatures { + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ size_t featureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUFeatureName const * features; } WGPUSupportedFeatures WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSupportedWGSLLanguageFeatures { +/** + * Initializer for @ref WGPUSupportedFeatures. + */ +#define WGPU_SUPPORTED_FEATURES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSupportedFeatures, { \ + /*.featureCount=*/0 _wgpu_COMMA \ + /*.features=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SUPPORTED_INSTANCE_FEATURES_INIT as initializer. + */ +typedef struct WGPUSupportedInstanceFeatures { + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ size_t featureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUInstanceFeatureName const * features; +} WGPUSupportedInstanceFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSupportedInstanceFeatures. + */ +#define WGPU_SUPPORTED_INSTANCE_FEATURES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSupportedInstanceFeatures, { \ + /*.featureCount=*/0 _wgpu_COMMA \ + /*.features=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SUPPORTED_WGSL_LANGUAGE_FEATURES_INIT as initializer. + */ +typedef struct WGPUSupportedWGSLLanguageFeatures { + /** + * Array count for `features`. The `INIT` macro sets this to 0. + */ + size_t featureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUWGSLLanguageFeatureName const * features; } WGPUSupportedWGSLLanguageFeatures WGPU_STRUCTURE_ATTRIBUTE; /** - * Filled by `::wgpuSurfaceGetCapabilities` with what's supported for `::wgpuSurfaceConfigure` for a pair of @ref WGPUSurface and @ref WGPUAdapter. + * Initializer for @ref WGPUSupportedWGSLLanguageFeatures. + */ +#define WGPU_SUPPORTED_WGSL_LANGUAGE_FEATURES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSupportedWGSLLanguageFeatures, { \ + /*.featureCount=*/0 _wgpu_COMMA \ + /*.features=*/NULL _wgpu_COMMA \ +}) + +/** + * Filled by @ref wgpuSurfaceGetCapabilities with what's supported for @ref wgpuSurfaceConfigure for a pair of @ref WGPUSurface and @ref WGPUAdapter. + * + * Default values can be set using @ref WGPU_SURFACE_CAPABILITIES_INIT as initializer. */ typedef struct WGPUSurfaceCapabilities { - WGPUChainedStructOut * nextInChain; + WGPUChainedStruct * nextInChain; /** * The bit set of supported @ref WGPUTextureUsage bits. * Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + * + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. */ WGPUTextureUsage usages; /** - * A list of supported @ref WGPUTextureFormat values, in order of preference. + * Array count for `formats`. The `INIT` macro sets this to 0. */ size_t formatCount; + /** + * A list of supported @ref WGPUTextureFormat values, in order of preference. + * + * The `INIT` macro sets this to `NULL`. + */ WGPUTextureFormat const * formats; + /** + * Array count for `presentModes`. The `INIT` macro sets this to 0. + */ + size_t presentModeCount; /** * A list of supported @ref WGPUPresentMode values. * Guaranteed to contain @ref WGPUPresentMode_Fifo. + * + * The `INIT` macro sets this to `NULL`. */ - size_t presentModeCount; WGPUPresentMode const * presentModes; + /** + * Array count for `alphaModes`. The `INIT` macro sets this to 0. + */ + size_t alphaModeCount; /** * A list of supported @ref WGPUCompositeAlphaMode values. * @ref WGPUCompositeAlphaMode_Auto will be an alias for the first element and will never be present in this array. + * + * The `INIT` macro sets this to `NULL`. */ - 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. + * Initializer for @ref WGPUSurfaceCapabilities. + */ +#define WGPU_SURFACE_CAPABILITIES_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceCapabilities, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.usages=*/WGPUTextureUsage_None _wgpu_COMMA \ + /*.formatCount=*/0 _wgpu_COMMA \ + /*.formats=*/NULL _wgpu_COMMA \ + /*.presentModeCount=*/0 _wgpu_COMMA \ + /*.presentModes=*/NULL _wgpu_COMMA \ + /*.alphaModeCount=*/0 _wgpu_COMMA \ + /*.alphaModes=*/NULL _wgpu_COMMA \ +}) + +/** + * Extension of @ref WGPUSurfaceConfiguration for color spaces and HDR. + * + * Default values can be set using @ref WGPU_SURFACE_COLOR_MANAGEMENT_INIT as initializer. + */ +typedef struct WGPUSurfaceColorManagement { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to (@ref WGPUPredefinedColorSpace)0. + */ + WGPUPredefinedColorSpace colorSpace; + /** + * The `INIT` macro sets this to (@ref WGPUToneMappingMode)0. + */ + WGPUToneMappingMode toneMappingMode; +} WGPUSurfaceColorManagement WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceColorManagement. + */ +#define WGPU_SURFACE_COLOR_MANAGEMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceColorManagement, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceColorManagement _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.colorSpace=*/_wgpu_ENUM_ZERO_INIT(WGPUPredefinedColorSpace) _wgpu_COMMA \ + /*.toneMappingMode=*/_wgpu_ENUM_ZERO_INIT(WGPUToneMappingMode) _wgpu_COMMA \ +}) + +/** + * Options to @ref wgpuSurfaceConfigure for defining how a @ref WGPUSurface will be rendered to and presented to the user. * See @ref Surface-Configuration for more details. + * + * Default values can be set using @ref WGPU_SURFACE_CONFIGURATION_INIT as initializer. */ typedef struct WGPUSurfaceConfiguration { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * The @ref WGPUDevice to use to render to surface's textures. + * + * The `INIT` macro sets this to `NULL`. */ WGPUDevice device; /** * The @ref WGPUTextureFormat of the surface's textures. + * + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. */ WGPUTextureFormat format; /** * The @ref WGPUTextureUsage of the surface's textures. + * + * The `INIT` macro sets this to @ref WGPUTextureUsage_RenderAttachment. */ WGPUTextureUsage usage; /** * The width of the surface's textures. + * + * The `INIT` macro sets this to `0`. */ uint32_t width; /** * The height of the surface's textures. + * + * The `INIT` macro sets this to `0`. */ uint32_t height; /** - * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + * Array count for `viewFormats`. The `INIT` macro sets this to 0. */ size_t viewFormatCount; + /** + * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + * + * The `INIT` macro sets this to `NULL`. + */ WGPUTextureFormat const * viewFormats; /** * How the surface's frames will be composited on the screen. + * + * If set to @ref WGPUCompositeAlphaMode_Auto, + * [defaults] to @ref WGPUCompositeAlphaMode_Inherit in native (allowing the mode + * to be configured externally), and to @ref WGPUCompositeAlphaMode_Opaque in Wasm. + * + * The `INIT` macro sets this to @ref WGPUCompositeAlphaMode_Auto. */ WGPUCompositeAlphaMode alphaMode; /** - * When and in which order the surface's frames will be shown on the screen. Defaults to @ref WGPUPresentMode_Fifo. + * When and in which order the surface's frames will be shown on the screen. + * + * If set to @ref WGPUPresentMode_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUPresentMode_Fifo. + * + * The `INIT` macro sets this to @ref WGPUPresentMode_Undefined. */ WGPUPresentMode presentMode; } WGPUSurfaceConfiguration WGPU_STRUCTURE_ATTRIBUTE; /** - * 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. + * Initializer for @ref WGPUSurfaceConfiguration. */ -typedef struct WGPUSurfaceDescriptor { - WGPUChainedStruct const * nextInChain; - /** - * Label used to refer to the object. - * - * This is a \ref NonNullInputString. - */ - WGPUStringView label; -} WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; +#define WGPU_SURFACE_CONFIGURATION_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceConfiguration, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.device=*/NULL _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.usage=*/WGPUTextureUsage_RenderAttachment _wgpu_COMMA \ + /*.width=*/0 _wgpu_COMMA \ + /*.height=*/0 _wgpu_COMMA \ + /*.viewFormatCount=*/0 _wgpu_COMMA \ + /*.viewFormats=*/NULL _wgpu_COMMA \ + /*.alphaMode=*/WGPUCompositeAlphaMode_Auto _wgpu_COMMA \ + /*.presentMode=*/WGPUPresentMode_Undefined _wgpu_COMMA \ +}) /** * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_ANDROID_NATIVE_WINDOW_INIT as initializer. */ typedef struct WGPUSurfaceSourceAndroidNativeWindow { WGPUChainedStruct chain; /** * The pointer to the [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window) that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `NULL`. */ void * window; } WGPUSurfaceSourceAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceSourceAndroidNativeWindow. + */ +#define WGPU_SURFACE_SOURCE_ANDROID_NATIVE_WINDOW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceAndroidNativeWindow, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceAndroidNativeWindow _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.window=*/NULL _wgpu_COMMA \ +}) + /** * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_METAL_LAYER_INIT as initializer. */ typedef struct WGPUSurfaceSourceMetalLayer { WGPUChainedStruct chain; /** * The pointer to the [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc) that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `NULL`. */ void * layer; } WGPUSurfaceSourceMetalLayer WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceSourceMetalLayer. + */ +#define WGPU_SURFACE_SOURCE_METAL_LAYER_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceMetalLayer, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceMetalLayer _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.layer=*/NULL _wgpu_COMMA \ +}) + /** * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [Wayland](https://wayland.freedesktop.org/) [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_WAYLAND_SURFACE_INIT as initializer. */ typedef struct WGPUSurfaceSourceWaylandSurface { WGPUChainedStruct chain; /** * A [`wl_display`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_display) for this Wayland instance. + * + * The `INIT` macro sets this to `NULL`. */ void * display; /** * A [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface) that will be wrapped by the @ref WGPUSurface + * + * The `INIT` macro sets this to `NULL`. */ void * surface; } WGPUSurfaceSourceWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceSourceWaylandSurface. + */ +#define WGPU_SURFACE_SOURCE_WAYLAND_SURFACE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceWaylandSurface, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceWaylandSurface _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.display=*/NULL _wgpu_COMMA \ + /*.surface=*/NULL _wgpu_COMMA \ +}) + /** * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a Windows [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd). + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_WINDOWS_HWND_INIT as initializer. */ typedef struct WGPUSurfaceSourceWindowsHWND { WGPUChainedStruct chain; /** * The [`HINSTANCE`](https://learn.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point) for this application. * Most commonly `GetModuleHandle(nullptr)`. + * + * The `INIT` macro sets this to `NULL`. */ void * hinstance; /** * The [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd) that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `NULL`. */ void * hwnd; } WGPUSurfaceSourceWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceSourceWindowsHWND. + */ +#define WGPU_SURFACE_SOURCE_WINDOWS_HWND_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceWindowsHWND, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceWindowsHWND _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.hinstance=*/NULL _wgpu_COMMA \ + /*.hwnd=*/NULL _wgpu_COMMA \ +}) + /** * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_XCB_WINDOW_INIT as initializer. */ typedef struct WGPUSurfaceSourceXCBWindow { WGPUChainedStruct chain; /** * The `xcb_connection_t` for the connection to the X server. + * + * The `INIT` macro sets this to `NULL`. */ void * connection; /** * The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `0`. */ uint32_t window; } WGPUSurfaceSourceXCBWindow WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceSourceXCBWindow. + */ +#define WGPU_SURFACE_SOURCE_XCB_WINDOW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceXCBWindow, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceXCBWindow _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.connection=*/NULL _wgpu_COMMA \ + /*.window=*/0 _wgpu_COMMA \ +}) + /** * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. + * + * Default values can be set using @ref WGPU_SURFACE_SOURCE_XLIB_WINDOW_INIT as initializer. */ typedef struct WGPUSurfaceSourceXlibWindow { WGPUChainedStruct chain; /** * A pointer to the [`Display`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Opening_the_Display) connected to the X server. + * + * The `INIT` macro sets this to `NULL`. */ void * display; /** * The [`Window`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Creating_Windows) that will be wrapped by the @ref WGPUSurface. + * + * The `INIT` macro sets this to `0`. */ uint64_t window; } WGPUSurfaceSourceXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceSourceXlibWindow. + */ +#define WGPU_SURFACE_SOURCE_XLIB_WINDOW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceSourceXlibWindow, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_SurfaceSourceXlibWindow _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.display=*/NULL _wgpu_COMMA \ + /*.window=*/0 _wgpu_COMMA \ +}) + /** * Queried each frame from a @ref WGPUSurface to get a @ref WGPUTexture to render to along with some metadata. * See @ref Surface-Presenting for more details. + * + * Default values can be set using @ref WGPU_SURFACE_TEXTURE_INIT as initializer. */ typedef struct WGPUSurfaceTexture { - WGPUChainedStructOut * nextInChain; + WGPUChainedStruct * nextInChain; /** * The @ref WGPUTexture representing the frame that will be shown on the surface. * It is @ref ReturnedWithOwnership from @ref wgpuSurfaceGetCurrentTexture. + * + * The `INIT` macro sets this to `NULL`. */ WGPUTexture texture; /** - * Whether the call to `::wgpuSurfaceGetCurrentTexture` succeeded and a hint as to why it might not have. + * Whether the call to @ref wgpuSurfaceGetCurrentTexture succeeded and a hint as to why it might not have. + * + * The `INIT` macro sets this to (@ref WGPUSurfaceGetCurrentTextureStatus)0. */ WGPUSurfaceGetCurrentTextureStatus status; } WGPUSurfaceTexture WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUSurfaceTexture. + */ +#define WGPU_SURFACE_TEXTURE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceTexture, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.texture=*/NULL _wgpu_COMMA \ + /*.status=*/_wgpu_ENUM_ZERO_INIT(WGPUSurfaceGetCurrentTextureStatus) _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT as initializer. + */ typedef struct WGPUTexelCopyBufferLayout { + /** + * The `INIT` macro sets this to `0`. + */ uint64_t offset; + /** + * The `INIT` macro sets this to @ref WGPU_COPY_STRIDE_UNDEFINED. + */ uint32_t bytesPerRow; + /** + * The `INIT` macro sets this to @ref WGPU_COPY_STRIDE_UNDEFINED. + */ uint32_t rowsPerImage; } WGPUTexelCopyBufferLayout WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUTexelCopyBufferLayout. + */ +#define WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTexelCopyBufferLayout, { \ + /*.offset=*/0 _wgpu_COMMA \ + /*.bytesPerRow=*/WGPU_COPY_STRIDE_UNDEFINED _wgpu_COMMA \ + /*.rowsPerImage=*/WGPU_COPY_STRIDE_UNDEFINED _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_BINDING_LAYOUT_INIT as initializer. + */ typedef struct WGPUTextureBindingLayout { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * If set to @ref WGPUTextureSampleType_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureSampleType_Float. + * + * The `INIT` macro sets this to @ref WGPUTextureSampleType_Undefined. + */ WGPUTextureSampleType sampleType; + /** + * If set to @ref WGPUTextureViewDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureViewDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ WGPUTextureViewDimension viewDimension; + /** + * The `INIT` macro sets this to `WGPU_FALSE`. + */ WGPUBool multisampled; } WGPUTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUTextureViewDescriptor { - WGPUChainedStruct const * nextInChain; - /** - * This is a \ref NonNullInputString. - */ - WGPUStringView label; - WGPUTextureFormat format; - WGPUTextureViewDimension dimension; - uint32_t baseMipLevel; - uint32_t mipLevelCount; - uint32_t baseArrayLayer; - uint32_t arrayLayerCount; - WGPUTextureAspect aspect; - WGPUTextureUsage usage; -} WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUTextureBindingLayout. + */ +#define WGPU_TEXTURE_BINDING_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureBindingLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.sampleType=*/WGPUTextureSampleType_Undefined _wgpu_COMMA \ + /*.viewDimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ + /*.multisampled=*/WGPU_FALSE _wgpu_COMMA \ +}) +/** + * Note: While Compatibility Mode is optional to implement, this extension struct + * is required to be accepted (but per the WebGPU spec, its contents are ignored + * on devices that have the @ref WGPUFeatureName_CoreFeaturesAndLimits feature). + * + * Default values can be set using @ref WGPU_TEXTURE_BINDING_VIEW_DIMENSION_INIT as initializer. + */ +typedef struct WGPUTextureBindingViewDimension { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + WGPUTextureViewDimension textureBindingViewDimension; +} WGPUTextureBindingViewDimension WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureBindingViewDimension. + */ +#define WGPU_TEXTURE_BINDING_VIEW_DIMENSION_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureBindingViewDimension, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_TextureBindingViewDimension _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.textureBindingViewDimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ +}) + +/** + * When accessed by a shader, the red/green/blue/alpha channels are replaced + * by the value corresponding to the component specified in r, g, b, and a, + * respectively unlike the JS API which uses a string of length four, with + * each character mapping to the texture view's red/green/blue/alpha channels. + * + * Default values can be set using @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT as initializer. + */ +typedef struct WGPUTextureComponentSwizzle { + /** + * The value that replaces the red channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_R. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle r; + /** + * The value that replaces the green channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_G. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle g; + /** + * The value that replaces the blue channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_B. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle b; + /** + * The value that replaces the alpha channel in the shader. + * + * If set to @ref WGPUComponentSwizzle_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUComponentSwizzle_A. + * + * The `INIT` macro sets this to @ref WGPUComponentSwizzle_Undefined. + */ + WGPUComponentSwizzle a; +} WGPUTextureComponentSwizzle WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureComponentSwizzle. + */ +#define WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureComponentSwizzle, { \ + /*.r=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ + /*.g=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ + /*.b=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ + /*.a=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_VERTEX_ATTRIBUTE_INIT as initializer. + */ typedef struct WGPUVertexAttribute { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to (@ref WGPUVertexFormat)0. + */ WGPUVertexFormat format; + /** + * The `INIT` macro sets this to `0`. + */ uint64_t offset; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t shaderLocation; } WGPUVertexAttribute WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUBindGroupDescriptor { - WGPUChainedStruct const * nextInChain; - /** - * This is a \ref NonNullInputString. - */ - WGPUStringView label; - WGPUBindGroupLayout layout; - size_t entryCount; - WGPUBindGroupEntry const * entries; -} WGPUBindGroupDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUVertexAttribute. + */ +#define WGPU_VERTEX_ATTRIBUTE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUVertexAttribute, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.format=*/_wgpu_ENUM_ZERO_INIT(WGPUVertexFormat) _wgpu_COMMA \ + /*.offset=*/0 _wgpu_COMMA \ + /*.shaderLocation=*/0 _wgpu_COMMA \ +}) -typedef struct WGPUBindGroupLayoutEntry { - WGPUChainedStruct const * nextInChain; +/** + * Default values can be set using @ref WGPU_BIND_GROUP_ENTRY_INIT as initializer. + */ +typedef struct WGPUBindGroupEntry { + WGPUChainedStruct * nextInChain; + /** + * Binding index in the bind group. + * + * The `INIT` macro sets this to `0`. + */ uint32_t binding; + /** + * Set this if the binding is a buffer object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUBuffer buffer; + /** + * If the binding is a buffer, this is the byte offset of the binding range. + * Otherwise ignored. + * + * The `INIT` macro sets this to `0`. + */ + uint64_t offset; + /** + * If the binding is a buffer, this is the byte size of the binding range + * (@ref WGPU_WHOLE_SIZE means the binding ends at the end of the buffer). + * Otherwise ignored. + * + * The `INIT` macro sets this to @ref WGPU_WHOLE_SIZE. + */ + uint64_t size; + /** + * Set this if the binding is a sampler object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUSampler sampler; + /** + * Set this if the binding is a texture view object. + * Otherwise must be null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUTextureView textureView; +} WGPUBindGroupEntry WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBindGroupEntry. + */ +#define WGPU_BIND_GROUP_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupEntry, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.binding=*/0 _wgpu_COMMA \ + /*.buffer=*/NULL _wgpu_COMMA \ + /*.offset=*/0 _wgpu_COMMA \ + /*.size=*/WGPU_WHOLE_SIZE _wgpu_COMMA \ + /*.sampler=*/NULL _wgpu_COMMA \ + /*.textureView=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_LAYOUT_ENTRY_INIT as initializer. + */ +typedef struct WGPUBindGroupLayoutEntry { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t binding; + /** + * The `INIT` macro sets this to @ref WGPUShaderStage_None. + */ WGPUShaderStage visibility; + /** + * If non-zero, this entry defines a binding array with this size. + * + * The `INIT` macro sets this to `0`. + */ + uint32_t bindingArraySize; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ WGPUBufferBindingLayout buffer; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ WGPUSamplerBindingLayout sampler; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ WGPUTextureBindingLayout texture; + /** + * The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`). + */ WGPUStorageTextureBindingLayout storageTexture; } WGPUBindGroupLayoutEntry WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBindGroupLayoutEntry. + */ +#define WGPU_BIND_GROUP_LAYOUT_ENTRY_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupLayoutEntry, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.binding=*/0 _wgpu_COMMA \ + /*.visibility=*/WGPUShaderStage_None _wgpu_COMMA \ + /*.bindingArraySize=*/0 _wgpu_COMMA \ + /*.buffer=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ + /*.sampler=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ + /*.texture=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ + /*.storageTexture=*/_wgpu_STRUCT_ZERO_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BLEND_STATE_INIT as initializer. + */ typedef struct WGPUBlendState { + /** + * The `INIT` macro sets this to @ref WGPU_BLEND_COMPONENT_INIT. + */ WGPUBlendComponent color; + /** + * The `INIT` macro sets this to @ref WGPU_BLEND_COMPONENT_INIT. + */ WGPUBlendComponent alpha; } WGPUBlendState WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBlendState. + */ +#define WGPU_BLEND_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBlendState, { \ + /*.color=*/WGPU_BLEND_COMPONENT_INIT _wgpu_COMMA \ + /*.alpha=*/WGPU_BLEND_COMPONENT_INIT _wgpu_COMMA \ +}) + +/** + * This is an @ref ImplementationAllocatedStructChain root. + * Arbitrary chains must be handled gracefully by the application! + * + * Default values can be set using @ref WGPU_COMPILATION_INFO_INIT as initializer. + */ typedef struct WGPUCompilationInfo { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * Array count for `messages`. The `INIT` macro sets this to 0. + */ size_t messageCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUCompilationMessage const * messages; } WGPUCompilationInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUCompilationInfo. + */ +#define WGPU_COMPILATION_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUCompilationInfo, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.messageCount=*/0 _wgpu_COMMA \ + /*.messages=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMPUTE_PASS_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUComputePassDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; - WGPU_NULLABLE WGPUComputePassTimestampWrites const * timestampWrites; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUPassTimestampWrites const * timestampWrites; } WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUComputePassDescriptor. + */ +#define WGPU_COMPUTE_PASS_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUComputePassDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.timestampWrites=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMPUTE_STATE_INIT as initializer. + */ +typedef struct WGPUComputeState { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUShaderModule module; + /** + * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView entryPoint; + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ + size_t constantCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUConstantEntry const * constants; +} WGPUComputeState WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUComputeState. + */ +#define WGPU_COMPUTE_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUComputeState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.module=*/NULL _wgpu_COMMA \ + /*.entryPoint=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.constantCount=*/0 _wgpu_COMMA \ + /*.constants=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_DEPTH_STENCIL_STATE_INIT as initializer. + */ typedef struct WGPUDepthStencilState { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ WGPUTextureFormat format; + /** + * The `INIT` macro sets this to @ref WGPUOptionalBool_Undefined. + */ WGPUOptionalBool depthWriteEnabled; + /** + * The `INIT` macro sets this to @ref WGPUCompareFunction_Undefined. + */ WGPUCompareFunction depthCompare; + /** + * The `INIT` macro sets this to @ref WGPU_STENCIL_FACE_STATE_INIT. + */ WGPUStencilFaceState stencilFront; + /** + * The `INIT` macro sets this to @ref WGPU_STENCIL_FACE_STATE_INIT. + */ WGPUStencilFaceState stencilBack; + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ uint32_t stencilReadMask; + /** + * The `INIT` macro sets this to `0xFFFFFFFF`. + */ uint32_t stencilWriteMask; + /** + * The `INIT` macro sets this to `0`. + */ int32_t depthBias; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ float depthBiasSlopeScale; + /** + * TODO + * + * If non-finite, produces a @ref NonFiniteFloatValueError. + * + * The `INIT` macro sets this to `0.f`. + */ float depthBiasClamp; } WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUDeviceDescriptor { - WGPUChainedStruct const * nextInChain; - /** - * 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; +/** + * Initializer for @ref WGPUDepthStencilState. + */ +#define WGPU_DEPTH_STENCIL_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUDepthStencilState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.depthWriteEnabled=*/WGPUOptionalBool_Undefined _wgpu_COMMA \ + /*.depthCompare=*/WGPUCompareFunction_Undefined _wgpu_COMMA \ + /*.stencilFront=*/WGPU_STENCIL_FACE_STATE_INIT _wgpu_COMMA \ + /*.stencilBack=*/WGPU_STENCIL_FACE_STATE_INIT _wgpu_COMMA \ + /*.stencilReadMask=*/0xFFFFFFFF _wgpu_COMMA \ + /*.stencilWriteMask=*/0xFFFFFFFF _wgpu_COMMA \ + /*.depthBias=*/0 _wgpu_COMMA \ + /*.depthBiasSlopeScale=*/0.f _wgpu_COMMA \ + /*.depthBiasClamp=*/0.f _wgpu_COMMA \ +}) /** * Struct holding a future to wait on, and a `completed` boolean flag. + * + * Default values can be set using @ref WGPU_FUTURE_WAIT_INFO_INIT as initializer. */ typedef struct WGPUFutureWaitInfo { /** * The future to wait on. + * + * The `INIT` macro sets this to @ref WGPU_FUTURE_INIT. */ WGPUFuture future; /** * Whether or not the future completed. + * + * The `INIT` macro sets this to `WGPU_FALSE`. */ WGPUBool completed; } WGPUFutureWaitInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUFutureWaitInfo. + */ +#define WGPU_FUTURE_WAIT_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUFutureWaitInfo, { \ + /*.future=*/WGPU_FUTURE_INIT _wgpu_COMMA \ + /*.completed=*/WGPU_FALSE _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_INSTANCE_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUInstanceDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** - * Instance features to enable + * Array count for `requiredFeatures`. The `INIT` macro sets this to 0. */ - WGPUInstanceCapabilities features; + size_t requiredFeatureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUInstanceFeatureName const * requiredFeatures; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUInstanceLimits const * requiredLimits; } WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUProgrammableStageDescriptor { - WGPUChainedStruct const * nextInChain; - WGPUShaderModule module; - /** - * This is a \ref NullableInputString. - */ - WGPUStringView entryPoint; - size_t constantCount; - WGPUConstantEntry const * constants; -} WGPUProgrammableStageDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUInstanceDescriptor. + */ +#define WGPU_INSTANCE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUInstanceDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.requiredFeatureCount=*/0 _wgpu_COMMA \ + /*.requiredFeatures=*/NULL _wgpu_COMMA \ + /*.requiredLimits=*/NULL _wgpu_COMMA \ +}) +/** + * Default values can be set using @ref WGPU_LIMITS_INIT as initializer. + */ +typedef struct WGPULimits { + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureDimension1D; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureDimension2D; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureDimension3D; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxTextureArrayLayers; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxBindGroups; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxBindGroupsPlusVertexBuffers; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxBindingsPerBindGroup; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxDynamicUniformBuffersPerPipelineLayout; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxDynamicStorageBuffersPerPipelineLayout; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxSampledTexturesPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxSamplersPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageBuffersPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxStorageTexturesPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxUniformBuffersPerShaderStage; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + uint64_t maxUniformBufferBindingSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + uint64_t maxStorageBufferBindingSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t minUniformBufferOffsetAlignment; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t minStorageBufferOffsetAlignment; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxVertexBuffers; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U64_UNDEFINED. + */ + uint64_t maxBufferSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxVertexAttributes; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxVertexBufferArrayStride; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxInterStageShaderVariables; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxColorAttachments; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxColorAttachmentBytesPerSample; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupStorageSize; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeInvocationsPerWorkgroup; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupSizeX; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupSizeY; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupSizeZ; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxComputeWorkgroupsPerDimension; + /** + * The `INIT` macro sets this to @ref WGPU_LIMIT_U32_UNDEFINED. + */ + uint32_t maxImmediateSize; +} WGPULimits WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPULimits. + */ +#define WGPU_LIMITS_INIT _wgpu_MAKE_INIT_STRUCT(WGPULimits, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.maxTextureDimension1D=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxTextureDimension2D=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxTextureDimension3D=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxTextureArrayLayers=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBindGroups=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBindGroupsPlusVertexBuffers=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBindingsPerBindGroup=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxDynamicUniformBuffersPerPipelineLayout=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxDynamicStorageBuffersPerPipelineLayout=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxSampledTexturesPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxSamplersPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageBuffersPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxStorageTexturesPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxUniformBuffersPerShaderStage=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxUniformBufferBindingSize=*/WGPU_LIMIT_U64_UNDEFINED _wgpu_COMMA \ + /*.maxStorageBufferBindingSize=*/WGPU_LIMIT_U64_UNDEFINED _wgpu_COMMA \ + /*.minUniformBufferOffsetAlignment=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.minStorageBufferOffsetAlignment=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxVertexBuffers=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxBufferSize=*/WGPU_LIMIT_U64_UNDEFINED _wgpu_COMMA \ + /*.maxVertexAttributes=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxVertexBufferArrayStride=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxInterStageShaderVariables=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxColorAttachments=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxColorAttachmentBytesPerSample=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupStorageSize=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeInvocationsPerWorkgroup=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupSizeX=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupSizeY=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupSizeZ=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxComputeWorkgroupsPerDimension=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ + /*.maxImmediateSize=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT as initializer. + */ typedef struct WGPURenderPassColorAttachment { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * If `NULL`, indicates a hole in the parent + * @ref WGPURenderPassDescriptor::colorAttachments array. + * + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUTextureView view; + /** + * The `INIT` macro sets this to @ref WGPU_DEPTH_SLICE_UNDEFINED. + */ uint32_t depthSlice; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUTextureView resolveTarget; + /** + * The `INIT` macro sets this to @ref WGPULoadOp_Undefined. + */ WGPULoadOp loadOp; + /** + * The `INIT` macro sets this to @ref WGPUStoreOp_Undefined. + */ WGPUStoreOp storeOp; + /** + * The `INIT` macro sets this to @ref WGPU_COLOR_INIT. + */ WGPUColor clearValue; } WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderPassColorAttachment. + */ +#define WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassColorAttachment, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.view=*/NULL _wgpu_COMMA \ + /*.depthSlice=*/WGPU_DEPTH_SLICE_UNDEFINED _wgpu_COMMA \ + /*.resolveTarget=*/NULL _wgpu_COMMA \ + /*.loadOp=*/WGPULoadOp_Undefined _wgpu_COMMA \ + /*.storeOp=*/WGPUStoreOp_Undefined _wgpu_COMMA \ + /*.clearValue=*/WGPU_COLOR_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_REQUEST_ADAPTER_OPTIONS_INIT as initializer. + */ +typedef struct WGPURequestAdapterOptions { + WGPUChainedStruct * nextInChain; + /** + * "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + * + * If set to @ref WGPUFeatureLevel_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUFeatureLevel_Core. + * Additionally, implementations may ignore @ref WGPUFeatureLevel_Compatibility + * and provide @ref WGPUFeatureLevel_Core instead. + * + * The `INIT` macro sets this to @ref WGPUFeatureLevel_Undefined. + */ + WGPUFeatureLevel featureLevel; + /** + * The `INIT` macro sets this to @ref WGPUPowerPreference_Undefined. + */ + WGPUPowerPreference powerPreference; + /** + * If true, requires the adapter to be a "fallback" adapter as defined by the JS spec. + * If this is not possible, the request returns null. + * + * The `INIT` macro sets this to `WGPU_FALSE`. + */ + WGPUBool forceFallbackAdapter; + /** + * If set, requires the adapter to have a particular backend type. + * If this is not possible, the request returns null. + * + * The `INIT` macro sets this to @ref WGPUBackendType_Undefined. + */ + WGPUBackendType backendType; + /** + * If set, requires the adapter to be able to output to a particular surface. + * If this is not possible, the request returns null. + * + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUSurface compatibleSurface; +} WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPURequestAdapterOptions. + */ +#define WGPU_REQUEST_ADAPTER_OPTIONS_INIT _wgpu_MAKE_INIT_STRUCT(WGPURequestAdapterOptions, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.featureLevel=*/WGPUFeatureLevel_Undefined _wgpu_COMMA \ + /*.powerPreference=*/WGPUPowerPreference_Undefined _wgpu_COMMA \ + /*.forceFallbackAdapter=*/WGPU_FALSE _wgpu_COMMA \ + /*.backendType=*/WGPUBackendType_Undefined _wgpu_COMMA \ + /*.compatibleSurface=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_SHADER_MODULE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUShaderModuleDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUShaderModuleDescriptor. + */ +#define WGPU_SHADER_MODULE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUShaderModuleDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * The root descriptor for the creation of an @ref WGPUSurface with @ref wgpuInstanceCreateSurface. + * It isn't sufficient by itself and must have one of the `WGPUSurfaceSource*` in its chain. + * See @ref Surface-Creation for more details. + * + * Default values can be set using @ref WGPU_SURFACE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUSurfaceDescriptor { + WGPUChainedStruct * nextInChain; + /** + * Label used to refer to the object. + * + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; +} WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUSurfaceDescriptor. + */ +#define WGPU_SURFACE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_BUFFER_INFO_INIT as initializer. + */ typedef struct WGPUTexelCopyBufferInfo { + /** + * The `INIT` macro sets this to @ref WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT. + */ WGPUTexelCopyBufferLayout layout; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUBuffer buffer; } WGPUTexelCopyBufferInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUTexelCopyBufferInfo. + */ +#define WGPU_TEXEL_COPY_BUFFER_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTexelCopyBufferInfo, { \ + /*.layout=*/WGPU_TEXEL_COPY_BUFFER_LAYOUT_INIT _wgpu_COMMA \ + /*.buffer=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXEL_COPY_TEXTURE_INFO_INIT as initializer. + */ typedef struct WGPUTexelCopyTextureInfo { + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUTexture texture; + /** + * The `INIT` macro sets this to `0`. + */ uint32_t mipLevel; + /** + * The `INIT` macro sets this to @ref WGPU_ORIGIN_3D_INIT. + */ WGPUOrigin3D origin; + /** + * If set to @ref WGPUTextureAspect_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + * + * The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined. + */ WGPUTextureAspect aspect; } WGPUTexelCopyTextureInfo WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUTexelCopyTextureInfo. + */ +#define WGPU_TEXEL_COPY_TEXTURE_INFO_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTexelCopyTextureInfo, { \ + /*.texture=*/NULL _wgpu_COMMA \ + /*.mipLevel=*/0 _wgpu_COMMA \ + /*.origin=*/WGPU_ORIGIN_3D_INIT _wgpu_COMMA \ + /*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUTextureComponentSwizzleDescriptor { + WGPUChainedStruct chain; + /** + * The `INIT` macro sets this to @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT. + */ + WGPUTextureComponentSwizzle swizzle; +} WGPUTextureComponentSwizzleDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureComponentSwizzleDescriptor. + */ +#define WGPU_TEXTURE_COMPONENT_SWIZZLE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureComponentSwizzleDescriptor, { \ + /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \ + /*.next=*/NULL _wgpu_COMMA \ + /*.sType=*/WGPUSType_TextureComponentSwizzleDescriptor _wgpu_COMMA \ + }) _wgpu_COMMA \ + /*.swizzle=*/WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUTextureDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ WGPUTextureUsage usage; + /** + * If set to @ref WGPUTextureDimension_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureDimension_2D. + * + * The `INIT` macro sets this to @ref WGPUTextureDimension_Undefined. + */ WGPUTextureDimension dimension; + /** + * The `INIT` macro sets this to @ref WGPU_EXTENT_3D_INIT. + */ WGPUExtent3D size; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ WGPUTextureFormat format; + /** + * The `INIT` macro sets this to `1`. + */ uint32_t mipLevelCount; + /** + * The `INIT` macro sets this to `1`. + */ uint32_t sampleCount; + /** + * Array count for `viewFormats`. The `INIT` macro sets this to 0. + */ size_t viewFormatCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUTextureFormat const * viewFormats; } WGPUTextureDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUTextureDescriptor. + */ +#define WGPU_TEXTURE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.usage=*/WGPUTextureUsage_None _wgpu_COMMA \ + /*.dimension=*/WGPUTextureDimension_Undefined _wgpu_COMMA \ + /*.size=*/WGPU_EXTENT_3D_INIT _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.mipLevelCount=*/1 _wgpu_COMMA \ + /*.sampleCount=*/1 _wgpu_COMMA \ + /*.viewFormatCount=*/0 _wgpu_COMMA \ + /*.viewFormats=*/NULL _wgpu_COMMA \ +}) + +/** + * If `attributes` is empty *and* `stepMode` is @ref WGPUVertexStepMode_Undefined, + * indicates a "hole" in the parent @ref WGPUVertexState `buffers` array, + * with behavior equivalent to `null` in the JS API. + * + * If `attributes` is empty but `stepMode` is *not* @ref WGPUVertexStepMode_Undefined, + * indicates a vertex buffer with no attributes, with behavior equivalent to + * `{ attributes: [] }` in the JS API. (TODO: If the JS API changes not to + * distinguish these cases, then this distinction doesn't matter and we can + * remove this documentation.) + * + * If `stepMode` is @ref WGPUVertexStepMode_Undefined but `attributes` is *not* empty, + * `stepMode` [defaults](@ref SentinelValues) to @ref WGPUVertexStepMode_Vertex. + * + * Default values can be set using @ref WGPU_VERTEX_BUFFER_LAYOUT_INIT as initializer. + */ typedef struct WGPUVertexBufferLayout { + WGPUChainedStruct * nextInChain; /** - * The 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`. + * The `INIT` macro sets this to @ref WGPUVertexStepMode_Undefined. */ WGPUVertexStepMode stepMode; + /** + * The `INIT` macro sets this to `0`. + */ uint64_t arrayStride; + /** + * Array count for `attributes`. The `INIT` macro sets this to 0. + */ size_t attributeCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUVertexAttribute const * attributes; } WGPUVertexBufferLayout WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUBindGroupLayoutDescriptor { - WGPUChainedStruct const * nextInChain; +/** + * Initializer for @ref WGPUVertexBufferLayout. + */ +#define WGPU_VERTEX_BUFFER_LAYOUT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUVertexBufferLayout, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.stepMode=*/WGPUVertexStepMode_Undefined _wgpu_COMMA \ + /*.arrayStride=*/0 _wgpu_COMMA \ + /*.attributeCount=*/0 _wgpu_COMMA \ + /*.attributes=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUBindGroupDescriptor { + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBindGroupLayout layout; + /** + * Array count for `entries`. The `INIT` macro sets this to 0. + */ size_t entryCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUBindGroupEntry const * entries; +} WGPUBindGroupDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUBindGroupDescriptor. + */ +#define WGPU_BIND_GROUP_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.layout=*/NULL _wgpu_COMMA \ + /*.entryCount=*/0 _wgpu_COMMA \ + /*.entries=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUBindGroupLayoutDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `entries`. The `INIT` macro sets this to 0. + */ + size_t entryCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUBindGroupLayoutDescriptor. + */ +#define WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUBindGroupLayoutDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.entryCount=*/0 _wgpu_COMMA \ + /*.entries=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COLOR_TARGET_STATE_INIT as initializer. + */ typedef struct WGPUColorTargetState { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * The texture format of the target. If @ref WGPUTextureFormat_Undefined, * indicates a "hole" in the parent @ref WGPUFragmentState `targets` array: * the pipeline does not output a value at this `location`. + * + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. */ WGPUTextureFormat format; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUBlendState const * blend; + /** + * The `INIT` macro sets this to @ref WGPUColorWriteMask_All. + */ WGPUColorWriteMask writeMask; } WGPUColorTargetState WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUColorTargetState. + */ +#define WGPU_COLOR_TARGET_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUColorTargetState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.blend=*/NULL _wgpu_COMMA \ + /*.writeMask=*/WGPUColorWriteMask_All _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPUComputePipelineDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUPipelineLayout layout; - WGPUProgrammableStageDescriptor compute; + /** + * The `INIT` macro sets this to @ref WGPU_COMPUTE_STATE_INIT. + */ + WGPUComputeState compute; } WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURenderPassDescriptor { - WGPUChainedStruct const * nextInChain; +/** + * Initializer for @ref WGPUComputePipelineDescriptor. + */ +#define WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUComputePipelineDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.layout=*/NULL _wgpu_COMMA \ + /*.compute=*/WGPU_COMPUTE_STATE_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_DEVICE_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUDeviceDescriptor { + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * Array count for `requiredFeatures`. The `INIT` macro sets this to 0. + */ + size_t requiredFeatureCount; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPUFeatureName const * requiredFeatures; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPULimits const * requiredLimits; + /** + * The `INIT` macro sets this to @ref WGPU_QUEUE_DESCRIPTOR_INIT. + */ + WGPUQueueDescriptor defaultQueue; + /** + * The `INIT` macro sets this to @ref WGPU_DEVICE_LOST_CALLBACK_INFO_INIT. + */ + WGPUDeviceLostCallbackInfo deviceLostCallbackInfo; + /** + * Called when there is an uncaptured error on this device, from any thread. + * See @ref ErrorScopes. + * + * **Important:** This callback does not have a configurable @ref WGPUCallbackMode; it may be called at any time (like @ref WGPUCallbackMode_AllowSpontaneous). As such, calls into the `webgpu.h` API from this callback are unsafe. See @ref CallbackReentrancy. + * + * The `INIT` macro sets this to @ref WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT. + */ + WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; +} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUDeviceDescriptor. + */ +#define WGPU_DEVICE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUDeviceDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.requiredFeatureCount=*/0 _wgpu_COMMA \ + /*.requiredFeatures=*/NULL _wgpu_COMMA \ + /*.requiredLimits=*/NULL _wgpu_COMMA \ + /*.defaultQueue=*/WGPU_QUEUE_DESCRIPTOR_INIT _wgpu_COMMA \ + /*.deviceLostCallbackInfo=*/WGPU_DEVICE_LOST_CALLBACK_INFO_INIT _wgpu_COMMA \ + /*.uncapturedErrorCallbackInfo=*/WGPU_UNCAPTURED_ERROR_CALLBACK_INFO_INIT _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PASS_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPURenderPassDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * Array count for `colorAttachments`. The `INIT` macro sets this to 0. + */ size_t colorAttachmentCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPURenderPassColorAttachment const * colorAttachments; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUQuerySet occlusionQuerySet; - WGPU_NULLABLE WGPURenderPassTimestampWrites const * timestampWrites; + /** + * The `INIT` macro sets this to `NULL`. + */ + WGPU_NULLABLE WGPUPassTimestampWrites const * timestampWrites; } WGPURenderPassDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderPassDescriptor. + */ +#define WGPU_RENDER_PASS_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPassDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.colorAttachmentCount=*/0 _wgpu_COMMA \ + /*.colorAttachments=*/NULL _wgpu_COMMA \ + /*.depthStencilAttachment=*/NULL _wgpu_COMMA \ + /*.occlusionQuerySet=*/NULL _wgpu_COMMA \ + /*.timestampWrites=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT as initializer. + */ +typedef struct WGPUTextureViewDescriptor { + WGPUChainedStruct * nextInChain; + /** + * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. + */ + WGPUStringView label; + /** + * The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined. + */ + WGPUTextureFormat format; + /** + * The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined. + */ + WGPUTextureViewDimension dimension; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t baseMipLevel; + /** + * The `INIT` macro sets this to @ref WGPU_MIP_LEVEL_COUNT_UNDEFINED. + */ + uint32_t mipLevelCount; + /** + * The `INIT` macro sets this to `0`. + */ + uint32_t baseArrayLayer; + /** + * The `INIT` macro sets this to @ref WGPU_ARRAY_LAYER_COUNT_UNDEFINED. + */ + uint32_t arrayLayerCount; + /** + * If set to @ref WGPUTextureAspect_Undefined, + * [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All. + * + * The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined. + */ + WGPUTextureAspect aspect; + /** + * The `INIT` macro sets this to @ref WGPUTextureUsage_None. + */ + WGPUTextureUsage usage; +} WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Initializer for @ref WGPUTextureViewDescriptor. + */ +#define WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureViewDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \ + /*.dimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \ + /*.baseMipLevel=*/0 _wgpu_COMMA \ + /*.mipLevelCount=*/WGPU_MIP_LEVEL_COUNT_UNDEFINED _wgpu_COMMA \ + /*.baseArrayLayer=*/0 _wgpu_COMMA \ + /*.arrayLayerCount=*/WGPU_ARRAY_LAYER_COUNT_UNDEFINED _wgpu_COMMA \ + /*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \ + /*.usage=*/WGPUTextureUsage_None _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_VERTEX_STATE_INIT as initializer. + */ typedef struct WGPUVertexState { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUShaderModule module; /** * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView entryPoint; + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ size_t constantCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUConstantEntry const * constants; + /** + * Array count for `buffers`. The `INIT` macro sets this to 0. + */ size_t bufferCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUVertexBufferLayout const * buffers; } WGPUVertexState WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUVertexState. + */ +#define WGPU_VERTEX_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUVertexState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.module=*/NULL _wgpu_COMMA \ + /*.entryPoint=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.constantCount=*/0 _wgpu_COMMA \ + /*.constants=*/NULL _wgpu_COMMA \ + /*.bufferCount=*/0 _wgpu_COMMA \ + /*.buffers=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_FRAGMENT_STATE_INIT as initializer. + */ typedef struct WGPUFragmentState { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUShaderModule module; /** * This is a \ref NullableInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView entryPoint; + /** + * Array count for `constants`. The `INIT` macro sets this to 0. + */ size_t constantCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUConstantEntry const * constants; + /** + * Array count for `targets`. The `INIT` macro sets this to 0. + */ size_t targetCount; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPUColorTargetState const * targets; } WGPUFragmentState WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPUFragmentState. + */ +#define WGPU_FRAGMENT_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUFragmentState, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.module=*/NULL _wgpu_COMMA \ + /*.entryPoint=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.constantCount=*/0 _wgpu_COMMA \ + /*.constants=*/NULL _wgpu_COMMA \ + /*.targetCount=*/0 _wgpu_COMMA \ + /*.targets=*/NULL _wgpu_COMMA \ +}) + +/** + * Default values can be set using @ref WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT as initializer. + */ typedef struct WGPURenderPipelineDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct * nextInChain; /** * This is a \ref NonNullInputString. + * + * The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT. */ WGPUStringView label; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUPipelineLayout layout; + /** + * The `INIT` macro sets this to @ref WGPU_VERTEX_STATE_INIT. + */ WGPUVertexState vertex; + /** + * The `INIT` macro sets this to @ref WGPU_PRIMITIVE_STATE_INIT. + */ WGPUPrimitiveState primitive; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUDepthStencilState const * depthStencil; + /** + * The `INIT` macro sets this to @ref WGPU_MULTISAMPLE_STATE_INIT. + */ WGPUMultisampleState multisample; + /** + * The `INIT` macro sets this to `NULL`. + */ WGPU_NULLABLE WGPUFragmentState const * fragment; } WGPURenderPipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Initializer for @ref WGPURenderPipelineDescriptor. + */ +#define WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPURenderPipelineDescriptor, { \ + /*.nextInChain=*/NULL _wgpu_COMMA \ + /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \ + /*.layout=*/NULL _wgpu_COMMA \ + /*.vertex=*/WGPU_VERTEX_STATE_INIT _wgpu_COMMA \ + /*.primitive=*/WGPU_PRIMITIVE_STATE_INIT _wgpu_COMMA \ + /*.depthStencil=*/NULL _wgpu_COMMA \ + /*.multisample=*/WGPU_MULTISAMPLE_STATE_INIT _wgpu_COMMA \ + /*.fragment=*/NULL _wgpu_COMMA \ +}) + /** @} */ #ifdef __cplusplus @@ -2220,23 +4871,34 @@ extern "C" { #endif #if !defined(WGPU_SKIP_PROCS) - +// Global procs /** * Proc pointer type for @ref wgpuCreateInstance: * > @copydoc wgpuCreateInstance */ typedef WGPUInstance (*WGPUProcCreateInstance)(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuGetInstanceCapabilities: - * > @copydoc wgpuGetInstanceCapabilities + * Proc pointer type for @ref wgpuGetInstanceFeatures: + * > @copydoc wgpuGetInstanceFeatures */ -typedef WGPUStatus (*WGPUProcGetInstanceCapabilities)(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcGetInstanceFeatures)(WGPUSupportedInstanceFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetInstanceLimits: + * > @copydoc wgpuGetInstanceLimits + */ +typedef WGPUStatus (*WGPUProcGetInstanceLimits)(WGPUInstanceLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuHasInstanceFeature: + * > @copydoc wgpuHasInstanceFeature + */ +typedef WGPUBool (*WGPUProcHasInstanceFeature)(WGPUInstanceFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuGetProcAddress: * > @copydoc wgpuGetProcAddress */ typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; + // Procs of Adapter /** * Proc pointer type for @ref wgpuAdapterGetFeatures: @@ -2264,12 +4926,12 @@ typedef WGPUBool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureNa */ typedef WGPUFuture (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuAdapterAddRef. + * Proc pointer type for @ref wgpuAdapterAddRef: * > @copydoc wgpuAdapterAddRef */ typedef void (*WGPUProcAdapterAddRef)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuAdapterRelease. + * Proc pointer type for @ref wgpuAdapterRelease: * > @copydoc wgpuAdapterRelease */ typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; @@ -2288,12 +4950,12 @@ typedef void (*WGPUProcAdapterInfoFreeMembers)(WGPUAdapterInfo adapterInfo) WGPU */ typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuBindGroupAddRef. + * Proc pointer type for @ref wgpuBindGroupAddRef: * > @copydoc wgpuBindGroupAddRef */ typedef void (*WGPUProcBindGroupAddRef)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuBindGroupRelease. + * Proc pointer type for @ref wgpuBindGroupRelease: * > @copydoc wgpuBindGroupRelease */ typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; @@ -2305,12 +4967,12 @@ typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ */ typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuBindGroupLayoutAddRef. + * Proc pointer type for @ref wgpuBindGroupLayoutAddRef: * > @copydoc wgpuBindGroupLayoutAddRef */ typedef void (*WGPUProcBindGroupLayoutAddRef)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuBindGroupLayoutRelease. + * Proc pointer type for @ref wgpuBindGroupLayoutRelease: * > @copydoc wgpuBindGroupLayoutRelease */ typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; @@ -2326,16 +4988,16 @@ typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE * > @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 wgpuBufferGetMapState: + * > @copydoc wgpuBufferGetMapState + */ +typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuBufferGetSize: * > @copydoc wgpuBufferGetSize @@ -2351,6 +5013,11 @@ typedef WGPUBufferUsage (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTI * > @copydoc wgpuBufferMapAsync */ typedef WGPUFuture (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferReadMappedRange: + * > @copydoc wgpuBufferReadMappedRange + */ +typedef WGPUStatus (*WGPUProcBufferReadMappedRange)(WGPUBuffer buffer, size_t offset, void * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuBufferSetLabel: * > @copydoc wgpuBufferSetLabel @@ -2362,12 +5029,17 @@ typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, WGPUStringView label) */ typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuBufferAddRef. + * Proc pointer type for @ref wgpuBufferWriteMappedRange: + * > @copydoc wgpuBufferWriteMappedRange + */ +typedef WGPUStatus (*WGPUProcBufferWriteMappedRange)(WGPUBuffer buffer, size_t offset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferAddRef: * > @copydoc wgpuBufferAddRef */ typedef void (*WGPUProcBufferAddRef)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuBufferRelease. + * Proc pointer type for @ref wgpuBufferRelease: * > @copydoc wgpuBufferRelease */ typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; @@ -2379,12 +5051,12 @@ typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE */ typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuCommandBufferAddRef. + * Proc pointer type for @ref wgpuCommandBufferAddRef: * > @copydoc wgpuCommandBufferAddRef */ typedef void (*WGPUProcCommandBufferAddRef)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuCommandBufferRelease. + * Proc pointer type for @ref wgpuCommandBufferRelease: * > @copydoc wgpuCommandBufferRelease */ typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; @@ -2461,12 +5133,12 @@ typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder */ typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuCommandEncoderAddRef. + * Proc pointer type for @ref wgpuCommandEncoderAddRef: * > @copydoc wgpuCommandEncoderAddRef */ typedef void (*WGPUProcCommandEncoderAddRef)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuCommandEncoderRelease. + * Proc pointer type for @ref wgpuCommandEncoderRelease: * > @copydoc wgpuCommandEncoderRelease */ typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -2518,12 +5190,12 @@ typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder comput */ typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuComputePassEncoderAddRef. + * Proc pointer type for @ref wgpuComputePassEncoderAddRef: * > @copydoc wgpuComputePassEncoderAddRef */ typedef void (*WGPUProcComputePassEncoderAddRef)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuComputePassEncoderRelease. + * Proc pointer type for @ref wgpuComputePassEncoderRelease: * > @copydoc wgpuComputePassEncoderRelease */ typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -2540,12 +5212,12 @@ typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUCom */ typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuComputePipelineAddRef. + * Proc pointer type for @ref wgpuComputePipelineAddRef: * > @copydoc wgpuComputePipelineAddRef */ typedef void (*WGPUProcComputePipelineAddRef)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuComputePipelineRelease. + * Proc pointer type for @ref wgpuComputePipelineRelease: * > @copydoc wgpuComputePipelineRelease */ typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; @@ -2565,7 +5237,7 @@ typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice de * Proc pointer type for @ref wgpuDeviceCreateBuffer: * > @copydoc wgpuDeviceCreateBuffer */ -typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPU_NULLABLE WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuDeviceCreateCommandEncoder: * > @copydoc wgpuDeviceCreateCommandEncoder @@ -2630,7 +5302,7 @@ typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE * Proc pointer type for @ref wgpuDeviceGetAdapterInfo: * > @copydoc wgpuDeviceGetAdapterInfo */ -typedef WGPUAdapterInfo (*WGPUProcDeviceGetAdapterInfo)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUStatus (*WGPUProcDeviceGetAdapterInfo)(WGPUDevice device, WGPUAdapterInfo * adapterInfo) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuDeviceGetFeatures: * > @copydoc wgpuDeviceGetFeatures @@ -2672,16 +5344,33 @@ typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter */ typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuDeviceAddRef. + * Proc pointer type for @ref wgpuDeviceAddRef: * > @copydoc wgpuDeviceAddRef */ typedef void (*WGPUProcDeviceAddRef)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuDeviceRelease. + * Proc pointer type for @ref wgpuDeviceRelease: * > @copydoc wgpuDeviceRelease */ typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +// Procs of ExternalTexture +/** + * Proc pointer type for @ref wgpuExternalTextureSetLabel: + * > @copydoc wgpuExternalTextureSetLabel + */ +typedef void (*WGPUProcExternalTextureSetLabel)(WGPUExternalTexture externalTexture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuExternalTextureAddRef: + * > @copydoc wgpuExternalTextureAddRef + */ +typedef void (*WGPUProcExternalTextureAddRef)(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuExternalTextureRelease: + * > @copydoc wgpuExternalTextureRelease + */ +typedef void (*WGPUProcExternalTextureRelease)(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; + // Procs of Instance /** * Proc pointer type for @ref wgpuInstanceCreateSurface: @@ -2692,7 +5381,7 @@ typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPU * Proc pointer type for @ref wgpuInstanceGetWGSLLanguageFeatures: * > @copydoc wgpuInstanceGetWGSLLanguageFeatures */ -typedef WGPUStatus (*WGPUProcInstanceGetWGSLLanguageFeatures)(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcInstanceGetWGSLLanguageFeatures)(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuInstanceHasWGSLLanguageFeature: * > @copydoc wgpuInstanceHasWGSLLanguageFeature @@ -2714,12 +5403,12 @@ typedef WGPUFuture (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU */ typedef WGPUWaitStatus (*WGPUProcInstanceWaitAny)(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuInstanceAddRef. + * Proc pointer type for @ref wgpuInstanceAddRef: * > @copydoc wgpuInstanceAddRef */ typedef void (*WGPUProcInstanceAddRef)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuInstanceRelease. + * Proc pointer type for @ref wgpuInstanceRelease: * > @copydoc wgpuInstanceRelease */ typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; @@ -2731,12 +5420,12 @@ typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATT */ typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuPipelineLayoutAddRef. + * Proc pointer type for @ref wgpuPipelineLayoutAddRef: * > @copydoc wgpuPipelineLayoutAddRef */ typedef void (*WGPUProcPipelineLayoutAddRef)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuPipelineLayoutRelease. + * Proc pointer type for @ref wgpuPipelineLayoutRelease: * > @copydoc wgpuPipelineLayoutRelease */ typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; @@ -2763,12 +5452,12 @@ typedef WGPUQueryType (*WGPUProcQuerySetGetType)(WGPUQuerySet querySet) WGPU_FUN */ typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuQuerySetAddRef. + * Proc pointer type for @ref wgpuQuerySetAddRef: * > @copydoc wgpuQuerySetAddRef */ typedef void (*WGPUProcQuerySetAddRef)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuQuerySetRelease. + * Proc pointer type for @ref wgpuQuerySetRelease: * > @copydoc wgpuQuerySetRelease */ typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; @@ -2800,12 +5489,12 @@ typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uin */ 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. + * Proc pointer type for @ref wgpuQueueAddRef: * > @copydoc wgpuQueueAddRef */ typedef void (*WGPUProcQueueAddRef)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuQueueRelease. + * Proc pointer type for @ref wgpuQueueRelease: * > @copydoc wgpuQueueRelease */ typedef void (*WGPUProcQueueRelease)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; @@ -2817,12 +5506,12 @@ typedef void (*WGPUProcQueueRelease)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; */ typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderBundleAddRef. + * Proc pointer type for @ref wgpuRenderBundleAddRef: * > @copydoc wgpuRenderBundleAddRef */ typedef void (*WGPUProcRenderBundleAddRef)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderBundleRelease. + * Proc pointer type for @ref wgpuRenderBundleRelease: * > @copydoc wgpuRenderBundleRelease */ typedef void (*WGPUProcRenderBundleRelease)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; @@ -2894,12 +5583,12 @@ typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder r */ typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderBundleEncoderAddRef. + * Proc pointer type for @ref wgpuRenderBundleEncoderAddRef: * > @copydoc wgpuRenderBundleEncoderAddRef */ typedef void (*WGPUProcRenderBundleEncoderAddRef)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderBundleEncoderRelease. + * Proc pointer type for @ref wgpuRenderBundleEncoderRelease: * > @copydoc wgpuRenderBundleEncoderRelease */ typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -3006,12 +5695,12 @@ typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder r */ typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderPassEncoderAddRef. + * Proc pointer type for @ref wgpuRenderPassEncoderAddRef: * > @copydoc wgpuRenderPassEncoderAddRef */ typedef void (*WGPUProcRenderPassEncoderAddRef)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderPassEncoderRelease. + * Proc pointer type for @ref wgpuRenderPassEncoderRelease: * > @copydoc wgpuRenderPassEncoderRelease */ typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -3028,12 +5717,12 @@ typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURend */ typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderPipelineAddRef. + * Proc pointer type for @ref wgpuRenderPipelineAddRef: * > @copydoc wgpuRenderPipelineAddRef */ typedef void (*WGPUProcRenderPipelineAddRef)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuRenderPipelineRelease. + * Proc pointer type for @ref wgpuRenderPipelineRelease: * > @copydoc wgpuRenderPipelineRelease */ typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; @@ -3045,12 +5734,12 @@ typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline) */ typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuSamplerAddRef. + * Proc pointer type for @ref wgpuSamplerAddRef: * > @copydoc wgpuSamplerAddRef */ typedef void (*WGPUProcSamplerAddRef)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuSamplerRelease. + * Proc pointer type for @ref wgpuSamplerRelease: * > @copydoc wgpuSamplerRelease */ typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; @@ -3067,12 +5756,12 @@ typedef WGPUFuture (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule sh */ typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuShaderModuleAddRef. + * Proc pointer type for @ref wgpuShaderModuleAddRef: * > @copydoc wgpuShaderModuleAddRef */ typedef void (*WGPUProcShaderModuleAddRef)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuShaderModuleRelease. + * Proc pointer type for @ref wgpuShaderModuleRelease: * > @copydoc wgpuShaderModuleRelease */ typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; @@ -3084,6 +5773,13 @@ typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_ */ typedef void (*WGPUProcSupportedFeaturesFreeMembers)(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; +// Procs of SupportedInstanceFeatures +/** + * Proc pointer type for @ref wgpuSupportedInstanceFeaturesFreeMembers: + * > @copydoc wgpuSupportedInstanceFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedInstanceFeaturesFreeMembers)(WGPUSupportedInstanceFeatures supportedInstanceFeatures) WGPU_FUNCTION_ATTRIBUTE; + // Procs of SupportedWGSLLanguageFeatures /** * Proc pointer type for @ref wgpuSupportedWGSLLanguageFeaturesFreeMembers: @@ -3123,12 +5819,12 @@ typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, WGPUStringView labe */ typedef void (*WGPUProcSurfaceUnconfigure)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuSurfaceAddRef. + * Proc pointer type for @ref wgpuSurfaceAddRef: * > @copydoc wgpuSurfaceAddRef */ typedef void (*WGPUProcSurfaceAddRef)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuSurfaceRelease. + * Proc pointer type for @ref wgpuSurfaceRelease: * > @copydoc wgpuSurfaceRelease */ typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; @@ -3181,6 +5877,11 @@ typedef uint32_t (*WGPUProcTextureGetMipLevelCount)(WGPUTexture texture) WGPU_FU * > @copydoc wgpuTextureGetSampleCount */ typedef uint32_t (*WGPUProcTextureGetSampleCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetTextureBindingViewDimension: + * > @copydoc wgpuTextureGetTextureBindingViewDimension + */ +typedef WGPUTextureViewDimension (*WGPUProcTextureGetTextureBindingViewDimension)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; /** * Proc pointer type for @ref wgpuTextureGetUsage: * > @copydoc wgpuTextureGetUsage @@ -3197,12 +5898,12 @@ typedef uint32_t (*WGPUProcTextureGetWidth)(WGPUTexture texture) WGPU_FUNCTION_A */ typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuTextureAddRef. + * Proc pointer type for @ref wgpuTextureAddRef: * > @copydoc wgpuTextureAddRef */ typedef void (*WGPUProcTextureAddRef)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuTextureRelease. + * Proc pointer type for @ref wgpuTextureRelease: * > @copydoc wgpuTextureRelease */ typedef void (*WGPUProcTextureRelease)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; @@ -3214,12 +5915,12 @@ typedef void (*WGPUProcTextureRelease)(WGPUTexture texture) WGPU_FUNCTION_ATTRIB */ typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuTextureViewAddRef. + * Proc pointer type for @ref wgpuTextureViewAddRef: * > @copydoc wgpuTextureViewAddRef */ typedef void (*WGPUProcTextureViewAddRef)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; /** - * Proc pointer type for @ref wgpuTextureViewRelease. + * Proc pointer type for @ref wgpuTextureViewRelease: * > @copydoc wgpuTextureViewRelease */ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; @@ -3235,29 +5936,39 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUN */ /** * Create a WGPUInstance + * + * @returns + * This value is @ref ReturnedWithOwnership. */ WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; /** - * Query the supported instance capabilities. + * Get the list of @ref WGPUInstanceFeatureName values supported by the instance. * - * @param capabilities - * The supported instance capabilities + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuGetInstanceFeatures(WGPUSupportedInstanceFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the limits supported by the instance. * * @returns * Indicates if there was an @ref OutStructChainError. */ -WGPU_EXPORT WGPUStatus wgpuGetInstanceCapabilities(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUStatus wgpuGetInstanceLimits(WGPUInstanceLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Check whether a particular @ref WGPUInstanceFeatureName is supported by the instance. + */ +WGPU_EXPORT WGPUBool wgpuHasInstanceFeature(WGPUInstanceFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; /** * Returns the "procedure address" (function pointer) of the named function. * The result must be cast to the appropriate proc pointer type. */ WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; - /** @} */ /** - * \defgroup Methods + * \defgroup Methods Methods * \brief Functions that are relative to a specific object. * * @{ @@ -3293,10 +6004,9 @@ WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName WGPU_EXPORT WGPUFuture wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterAddRef(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods * \brief Functions whose first argument has type WGPUAdapterInfo. @@ -3304,13 +6014,12 @@ WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE * @{ */ /** - * Frees array members of WGPUAdapterInfo which were allocated by the API. + * Frees members which were allocated by the API. */ WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUBindGroupMethods WGPUBindGroup methods * \brief Functions whose first argument has type WGPUBindGroup. @@ -3320,10 +6029,9 @@ WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FU WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupAddRef(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUBindGroupLayoutMethods WGPUBindGroupLayout methods * \brief Functions whose first argument has type WGPUBindGroupLayout. @@ -3333,10 +6041,9 @@ WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATT WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutAddRef(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUBufferMethods WGPUBuffer methods * \brief Functions whose first argument has type WGPUBuffer. @@ -3345,49 +6052,104 @@ WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) */ 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: + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, if `memcpy`ing from this range, prefer using @ref wgpuBufferReadMappedRange + * instead for better performance. * - * - 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 + * Byte size of the range to get. + * If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + * The returned pointer is valid for exactly this many bytes. + */ +WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** * Returns a mutable pointer to beginning of the mapped range. - * Returns `NULL` with @ref ImplementationDefinedLogging if: + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). * - * - 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. + * In Wasm, if `memcpy`ing into this range, prefer using @ref wgpuBufferWriteMappedRange + * instead for better performance. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. + * If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + * The returned pointer is valid for exactly this many bytes. */ WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param mode + * The mapping mode (read or write). + * + * @param offset + * Byte offset relative to beginning of the buffer. + * + * @param size + * Byte size of the region to map. + * If this is @ref WGPU_WHOLE_MAP_SIZE, it defaults to `buffer.size - offset`. + */ WGPU_EXPORT WGPUFuture wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Copies a range of data from the buffer mapping into the provided destination pointer. + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, this is more efficient than copying from a mapped range into a `malloc`'d range. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param data + * Destination, to read buffer data into. + * + * @param size + * Number of bytes of data to read from the buffer. + * (Note @ref WGPU_WHOLE_MAP_SIZE is *not* accepted here.) + * + * @returns + * @ref WGPUStatus_Error if the copy did not occur. + */ +WGPU_EXPORT WGPUStatus wgpuBufferReadMappedRange(WGPUBuffer buffer, size_t offset, void * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Copies a range of data from the provided source pointer into the buffer mapping. + * See @ref MappedRangeBehavior for error conditions and guarantees. + * This function is safe to call inside spontaneous callbacks (see @ref CallbackReentrancy). + * + * In Wasm, this is more efficient than copying from a `malloc`'d range into a mapped range. + * + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param data + * Source, to write buffer data from. + * + * @param size + * Number of bytes of data to write to the buffer. + * (Note @ref WGPU_WHOLE_MAP_SIZE is *not* accepted here.) + * + * @returns + * @ref WGPUStatus_Error if the copy did not occur. + */ +WGPU_EXPORT WGPUStatus wgpuBufferWriteMappedRange(WGPUBuffer buffer, size_t offset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferAddRef(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUCommandBufferMethods WGPUCommandBuffer methods * \brief Functions whose first argument has type WGPUCommandBuffer. @@ -3397,23 +6159,34 @@ WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) 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; + /** @} */ - - /** * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods * \brief Functions whose first argument has type WGPUCommandEncoder. * * @{ */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -3423,10 +6196,9 @@ WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, W WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderAddRef(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUComputePassEncoderMethods WGPUComputePassEncoder methods * \brief Functions whose first argument has type WGPUComputePassEncoder. @@ -3444,46 +6216,108 @@ WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePa WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderAddRef(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods * \brief Functions whose first argument has type WGPUComputePipeline. * * @{ */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineAddRef(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUDeviceMethods WGPUDevice methods * \brief Functions whose first argument has type WGPUDevice. * * @{ */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * TODO + * + * If @ref WGPUBufferDescriptor::mappedAtCreation is `true` and the mapping allocation fails, + * returns `NULL`. + * + * @returns + * This value is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT WGPU_NULLABLE WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUFuture wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUFuture wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUAdapterInfo wgpuDeviceGetAdapterInfo(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param adapterInfo + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuDeviceGetAdapterInfo(WGPUDevice device, WGPUAdapterInfo * adapterInfo) WGPU_FUNCTION_ATTRIBUTE; /** * Get the list of @ref WGPUFeatureName values supported by the device. * @@ -3501,16 +6335,39 @@ WGPU_EXPORT WGPUStatus wgpuDeviceGetLimits(WGPUDevice device, WGPULimits * limit * The @ref WGPUFuture for the device-lost event of the device. */ WGPU_EXPORT WGPUFuture wgpuDeviceGetLostFuture(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Pops an error scope to the current thread's error scope stack, + * asynchronously returning the result. See @ref ErrorScopes. + */ WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Pushes an error scope to the current thread's error scope stack. + * See @ref ErrorScopes. + */ WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceAddRef(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ +/** + * \defgroup WGPUExternalTextureMethods WGPUExternalTexture methods + * \brief Functions whose first argument has type WGPUExternalTexture. + * + * @{ + */ +WGPU_EXPORT void wgpuExternalTextureSetLabel(WGPUExternalTexture externalTexture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuExternalTextureAddRef(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuExternalTextureRelease(WGPUExternalTexture externalTexture) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ /** * \defgroup WGPUInstanceMethods WGPUInstance methods @@ -3526,15 +6383,16 @@ WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; * * @returns * A new @ref WGPUSurface for this descriptor (or an error @ref WGPUSurface). + * This value is @ref ReturnedWithOwnership. */ WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; /** * Get the list of @ref WGPUWGSLLanguageFeatureName values supported by the instance. */ -WGPU_EXPORT WGPUStatus wgpuInstanceGetWGSLLanguageFeatures(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceGetWGSLLanguageFeatures(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; /** - * Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with `::WGPUCallbackMode_AllowProcessEvents`. + * Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with @ref WGPUCallbackMode_AllowProcessEvents. * * See @ref Process-Events for more information. */ @@ -3548,10 +6406,9 @@ WGPU_EXPORT WGPUFuture wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NU WGPU_EXPORT WGPUWaitStatus wgpuInstanceWaitAny(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceAddRef(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUPipelineLayoutMethods WGPUPipelineLayout methods * \brief Functions whose first argument has type WGPUPipelineLayout. @@ -3561,10 +6418,9 @@ WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIB WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutAddRef(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUQuerySetMethods WGPUQuerySet methods * \brief Functions whose first argument has type WGPUQuerySet. @@ -3577,10 +6433,9 @@ WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTI WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetAddRef(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUQueueMethods WGPUQueue methods * \brief Functions whose first argument has type WGPUQueue. @@ -3598,10 +6453,9 @@ WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64 WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueAddRef(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPURenderBundleMethods WGPURenderBundle methods * \brief Functions whose first argument has type WGPURenderBundle. @@ -3611,10 +6465,9 @@ WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) 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; + /** @} */ - - /** * \defgroup WGPURenderBundleEncoderMethods WGPURenderBundleEncoder methods * \brief Functions whose first argument has type WGPURenderBundleEncoder. @@ -3625,6 +6478,10 @@ WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundl WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -3636,10 +6493,9 @@ WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder rend WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderAddRef(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPURenderPassEncoderMethods WGPURenderPassEncoder methods * \brief Functions whose first argument has type WGPURenderPassEncoder. @@ -3658,6 +6514,10 @@ WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder re WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param color + * The RGBA blend constant. Represents an `f32` color using @ref DoubleAsSupertype. + */ WGPU_EXPORT void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; @@ -3665,27 +6525,34 @@ WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPa WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * TODO + * + * If any argument is non-finite, produces a @ref NonFiniteFloatValueError. + */ WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderAddRef(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods * \brief Functions whose first argument has type WGPURenderPipeline. * * @{ */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineAddRef(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUSamplerMethods WGPUSampler methods * \brief Functions whose first argument has type WGPUSampler. @@ -3695,10 +6562,9 @@ WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WG WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerAddRef(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUShaderModuleMethods WGPUShaderModule methods * \brief Functions whose first argument has type WGPUShaderModule. @@ -3709,10 +6575,9 @@ WGPU_EXPORT WGPUFuture wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shade 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. @@ -3720,12 +6585,24 @@ WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUN * @{ */ /** - * Frees array members of WGPUSupportedFeatures which were allocated by the API. + * Frees members which were allocated by the API. */ WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ +/** + * \defgroup WGPUSupportedInstanceFeaturesMethods WGPUSupportedInstanceFeatures methods + * \brief Functions whose first argument has type WGPUSupportedInstanceFeatures. + * + * @{ + */ +/** + * Frees members which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedInstanceFeaturesFreeMembers(WGPUSupportedInstanceFeatures supportedInstanceFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ /** * \defgroup WGPUSupportedWGSLLanguageFeaturesMethods WGPUSupportedWGSLLanguageFeatures methods @@ -3734,13 +6611,12 @@ WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supporte * @{ */ /** - * Frees array members of WGPUSupportedWGSLLanguageFeatures which were allocated by the API. + * Frees members which were allocated by the API. */ WGPU_EXPORT void wgpuSupportedWGSLLanguageFeaturesFreeMembers(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUSurfaceMethods WGPUSurface methods * \brief Functions whose first argument has type WGPUSurface. @@ -3766,7 +6642,7 @@ WGPU_EXPORT void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfigurat * * @param capabilities * The structure to fill capabilities in. - * It may contain memory allocations so `::wgpuSurfaceCapabilitiesFreeMembers` must be called to avoid memory leaks. + * It may contain memory allocations so @ref wgpuSurfaceCapabilitiesFreeMembers must be called to avoid memory leaks. * This parameter is @ref ReturnedWithOwnership. * * @returns @@ -3805,10 +6681,9 @@ WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, WGPUStringView label) WGPU_EXPORT void wgpuSurfaceUnconfigure(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceAddRef(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods * \brief Functions whose first argument has type WGPUSurfaceCapabilities. @@ -3816,19 +6691,22 @@ WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE * @{ */ /** - * Frees array members of WGPUSurfaceCapabilities which were allocated by the API. + * Frees members which were allocated by the API. */ WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUTextureMethods WGPUTexture methods * \brief Functions whose first argument has type WGPUTexture. * * @{ */ +/** + * @returns + * This value is @ref ReturnedWithOwnership. + */ WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureDestroy(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; @@ -3837,15 +6715,15 @@ 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 WGPUTextureViewDimension wgpuTextureGetTextureBindingViewDimension(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureAddRef(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; + /** @} */ - - /** * \defgroup WGPUTextureViewMethods WGPUTextureView methods * \brief Functions whose first argument has type WGPUTextureView. @@ -3855,8 +6733,8 @@ WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) 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; -/** @} */ +/** @} */ /** @} */ diff --git a/libs/wgpu/include/webgpu/wgpu.h b/libs/wgpu/include/webgpu/wgpu.h index 2adc5c0..4bf1979 100644 --- a/libs/wgpu/include/webgpu/wgpu.h +++ b/libs/wgpu/include/webgpu/wgpu.h @@ -1,208 +1,1090 @@ +/** + * @file wgpu.h + * @brief wgpu-native specific extensions to the standard WebGPU C API. + * + * This header defines native-only types, enumerations, structures, and functions + * that extend the WebGPU specification defined in @c webgpu.h. All extension + * enum values and struct type identifiers (@ref WGPUNativeSType) are allocated + * within the @c 0x0003XXXX range reserved for wgpu-native. + * + * Include this header after @c webgpu.h (it is included automatically). + */ #ifndef WGPU_H_ #define WGPU_H_ #include "webgpu.h" -typedef enum WGPUNativeSType { +typedef enum WGPUNativeSType +{ // Start at 0003 since that's allocated range for wgpu-native + /** Identifies @ref WGPUDeviceExtras. */ WGPUSType_DeviceExtras = 0x00030001, + /** Identifies @ref WGPUNativeLimits. */ WGPUSType_NativeLimits = 0x00030002, + /** Identifies @ref WGPUPipelineLayoutExtras. */ WGPUSType_PipelineLayoutExtras = 0x00030003, + /** Identifies @ref WGPUShaderSourceGLSL. */ WGPUSType_ShaderSourceGLSL = 0x00030004, + /** Identifies @ref WGPUInstanceExtras. */ WGPUSType_InstanceExtras = 0x00030006, + /** Identifies @ref WGPUBindGroupEntryExtras. */ WGPUSType_BindGroupEntryExtras = 0x00030007, + /** Identifies @ref WGPUBindGroupLayoutEntryExtras. */ WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, + /** Identifies @ref WGPUQuerySetDescriptorExtras. */ WGPUSType_QuerySetDescriptorExtras = 0x00030009, + /** Identifies @ref WGPUSurfaceConfigurationExtras. */ WGPUSType_SurfaceConfigurationExtras = 0x0003000A, + /** Identifies @ref WGPUSurfaceSourceSwapChainPanel. */ WGPUSType_SurfaceSourceSwapChainPanel = 0x0003000B, + /** Identifies @ref WGPUPrimitiveStateExtras. */ + WGPUSType_PrimitiveStateExtras = 0x0003000C, WGPUNativeSType_Force32 = 0x7FFFFFFF } WGPUNativeSType; -typedef enum WGPUNativeFeature { - WGPUNativeFeature_PushConstants = 0x00030001, +/** + * Additional surface-get-current-texture status codes defined by wgpu-native. + * + * These extend the standard @c WGPUSurfaceGetCurrentTextureStatus values. + */ +typedef enum WGPUNativeSurfaceGetCurrentTextureStatus +{ + /** + * The surface texture was not acquired because the window is occluded + * (e.g. minimized or fully covered by another window). + * + * No texture is returned and the @c texture field of + * @c WGPUSurfaceTexture will be NULL. The surface and swapchain remain + * valid -- there is no need to reconfigure or recreate the surface. + * + * Applications should skip rendering for the current frame and try + * again once the window is no longer occluded. If you are using a + * windowing library such as winit, listen for the window's "occluded" + * event and request a new redraw when the window becomes visible again. + * + * When does this occur? + * + * Currently this status is only produced by the Metal backend on macOS. + * When a window is not visible (checked via the @c NSWindow + * @c occlusionState property), acquiring the next drawable would block + * for up to one second waiting for vsync. wgpu-native returns + * @c Occluded instead to avoid that hang. + * + * Other backends (Vulkan, DX12, GL) do not currently report this + * status; an occluded window on those backends may produce + * @c WGPUSurfaceGetCurrentTextureStatus_Timeout or simply succeed + * normally. + */ + WGPUSurfaceGetCurrentTextureStatus_Occluded = 0x00030001, + WGPUNativeSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF +} WGPUNativeSurfaceGetCurrentTextureStatus; + +/** + * Native-only device features. + * + * These extend the standard @c WGPUFeatureName values and can be passed to + * @c WGPUDeviceDescriptor::requiredFeatures to request additional + * capabilities when creating a device. + */ +typedef enum WGPUNativeFeature +{ + /** + * Allows the use of immediate data: small, fast blocks of memory + * that can be updated inside a render pass, compute pass, or render + * bundle encoder. + * + * Enables @ref wgpuRenderPassEncoderSetImmediates, + * @ref wgpuComputePassEncoderSetImmediates, + * @ref wgpuRenderBundleEncoderSetImmediates, + * non-zero @c immediateDataSize in @ref WGPUPipelineLayoutExtras, + * and non-zero @c maxImmediateSize in @ref WGPUNativeLimits. + * + * A block of immediate data can be declared in WGSL with + * @c var: + * @code + * struct Immediates { example: f32, } + * var c: Immediates; + * @endcode + * + * In GLSL, this corresponds to @c layout(immediates) @c uniform @c Name @c {..}. + * + * Supported platforms: + * - DX12 + * - Vulkan + * - Metal + * - OpenGL (emulated with uniforms) + * - WebGPU + * + * This is a web and native feature. + */ + WGPUNativeFeature_Immediates = 0x00030001, + /** + * Enables device-specific texture format features. + * + * By default only texture format properties as defined by the WebGPU + * specification are allowed. Enabling this feature flag extends the + * features of each format to the ones supported by the current device. + * Note that without this flag, read/write storage access is not allowed + * at all. + * + * This extension does not enable additional formats. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ WGPUNativeFeature_TextureAdapterSpecificFormatFeatures = 0x00030002, - WGPUNativeFeature_MultiDrawIndirect = 0x00030003, + /** + * Allows the use of a buffer containing the actual number of draw calls. + * + * Enables @ref wgpuRenderPassEncoderMultiDrawIndirectCount and + * @ref wgpuRenderPassEncoderMultiDrawIndexedIndirectCount. + * + * This feature being present also implies that all calls to + * @ref wgpuRenderPassEncoderMultiDrawIndirect and + * @ref wgpuRenderPassEncoderMultiDrawIndexedIndirect are not being + * emulated with a series of @c draw_indirect calls. + * + * Supported platforms: + * - DX12 + * - Vulkan 1.2+ (or VK_KHR_draw_indirect_count) + * + * This is a native only feature. + */ WGPUNativeFeature_MultiDrawIndirectCount = 0x00030004, + /** + * Enables bindings of writable storage buffers and textures visible + * to vertex shaders. + * + * Note: some (tiled-based) platforms do not support vertex shaders + * with any side-effects. + * + * Supported platforms: + * - All + * + * This is a native only feature. + */ WGPUNativeFeature_VertexWritableStorage = 0x00030005, + /** + * Allows the user to create uniform arrays of textures in shaders: + * + * - WGSL: @c var @c textures: @c binding_array, @c 10> + * - GLSL: @c uniform @c texture2D @c textures[10] + * + * If @ref WGPUNativeFeature_StorageResourceBindingArray is supported + * as well as this, the user may also create uniform arrays of storage + * textures. + * + * This capability allows them to exist and to be indexed by dynamically + * uniform values. + * + * Supported platforms: + * - DX12 + * - Metal (with MSL 2.0+ on macOS 10.13+) + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_TextureBindingArray = 0x00030006, + /** + * Allows shaders to index sampled texture and storage buffer resource + * arrays with dynamically non-uniform values: + * + * e.g. @c texture_array[vertex_data] + * + * In order to use this capability, the corresponding GLSL extension must + * be enabled: + * + * @c \#extension @c GL_EXT_nonuniform_qualifier @c : @c require + * + * and then used either as @c nonuniformEXT qualifier in variable + * declaration or as @c nonuniformEXT constructor. + * + * WGSL and HLSL do not need any extension. + * + * Supported platforms: + * - DX12 + * - Metal (with MSL 2.0+ on macOS 10.13+) + * - Vulkan 1.2+ (or VK_EXT_descriptor_indexing) + * + * This is a native only feature. + */ WGPUNativeFeature_SampledTextureAndStorageBufferArrayNonUniformIndexing = 0x00030007, + /** + * Enables use of Pipeline Statistics Queries. These queries report the + * count of various operations performed between the start and stop call. + * + * Use @ref wgpuRenderPassEncoderBeginPipelineStatisticsQuery / + * @ref wgpuRenderPassEncoderEndPipelineStatisticsQuery (or the compute + * pass equivalents) to start and stop a query. + * + * They must be resolved using @c wgpuCommandEncoderResolveQuerySet into + * a buffer. See @ref WGPUPipelineStatisticName for the list of available + * statistics. + * + * Supported platforms: + * - Vulkan + * - DX12 + * + * This is a native only feature. + */ WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008, + /** + * Allows the user to create uniform arrays of storage buffers or + * textures in shaders, if @ref WGPUNativeFeature_BufferBindingArray + * or @ref WGPUNativeFeature_TextureBindingArray (respectively) + * is also supported. + * + * This capability allows them to exist and to be indexed by dynamically + * uniform values. + * + * Supported platforms: + * - Metal (with MSL 2.2+ on macOS 10.13+) + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_StorageResourceBindingArray = 0x00030009, + /** + * Allows the user to create bind groups containing arrays with fewer + * bindings than the @c WGPUBindGroupLayout requires. + * + * Supported platforms: + * - Vulkan + * - DX12 + * + * This is a native only feature. + */ WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, + /** + * Enables normalized 16-bit texture formats: + * @ref WGPUNativeTextureFormat_R16Unorm, @ref WGPUNativeTextureFormat_R16Snorm, + * @ref WGPUNativeTextureFormat_Rg16Unorm, @ref WGPUNativeTextureFormat_Rg16Snorm, + * @ref WGPUNativeTextureFormat_Rgba16Unorm, @ref WGPUNativeTextureFormat_Rgba16Snorm. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B, + /** + * Enables ASTC HDR family of compressed textures. + * + * Compressed textures sacrifice some quality in exchange for + * significantly reduced bandwidth usage. + * + * Support for this feature guarantees availability of + * @c COPY_SRC | @c COPY_DST | @c TEXTURE_BINDING for ASTC formats + * with the HDR channel type. + * @ref WGPUNativeFeature_TextureAdapterSpecificFormatFeatures may + * enable additional usages. + * + * Supported platforms: + * - Metal + * - Vulkan + * - OpenGL + * + * This is a native only feature. + */ WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C, + /** + * Removes the WebGPU restriction that @c MAP_READ and @c MAP_WRITE + * buffer usages must be paired exclusively with @c COPY_DST and + * @c COPY_SRC respectively. + * + * This is only beneficial on systems that share memory between CPU and + * GPU. If enabled on a system that doesn't, this can severely hinder + * performance. Only use if you understand the consequences. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E, + /** + * Allows the user to create arrays of buffers in shaders: + * + * - WGSL: @c var @c buffer_array: @c array + * - GLSL: @c uniform @c myBuffer @c { @c ... @c } @c buffer_array[10] + * + * This capability allows them to exist and to be indexed by dynamically + * uniform values. + * + * If @ref WGPUNativeFeature_StorageResourceBindingArray is supported as + * well as this, the user may also create arrays of storage buffers. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_BufferBindingArray = 0x0003000F, + /** + * Allows shaders to index uniform buffer and storage texture resource + * arrays with dynamically non-uniform values. + * + * This is a native only feature. + */ WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010, // TODO: requires wgpu.h api change // WGPUNativeFeature_AddressModeClampToZero = 0x00030011, // WGPUNativeFeature_AddressModeClampToBorder = 0x00030012, - // WGPUNativeFeature_PolygonModeLine = 0x00030013, - // WGPUNativeFeature_PolygonModePoint = 0x00030014, - // WGPUNativeFeature_ConservativeRasterization = 0x00030015, + /** + * Allows the user to set @ref WGPUPolygonMode_Line in + * @ref WGPUPrimitiveStateExtras::polygonMode. + * + * This allows drawing polygons/triangles as lines (wireframe) instead + * of filled. + * + * Supported platforms: + * - DX12 + * - Vulkan + * - Metal + * + * This is a native only feature. + */ + WGPUNativeFeature_PolygonModeLine = 0x00030013, + /** + * Allows the user to set @ref WGPUPolygonMode_Point in + * @ref WGPUPrimitiveStateExtras::polygonMode. + * + * This allows only drawing the vertices of polygons/triangles instead + * of filled. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_PolygonModePoint = 0x00030014, + /** + * Allows the user to enable overestimation conservative rasterization + * via @ref WGPUPrimitiveStateExtras::conservative. + * + * Processing of degenerate triangles/lines is hardware specific. + * Only triangles are supported. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ + WGPUNativeFeature_ConservativeRasterization = 0x00030015, // WGPUNativeFeature_ClearTexture = 0x00030016, + /** + * Enables creating shader modules from pre-compiled SPIR-V binary via + * @ref wgpuDeviceCreateShaderModuleSpirV. + * + * Shader code isn't parsed or interpreted in any way. It is the caller's + * responsibility to ensure the code is correct. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * - WebGPU + * + * This is a native only feature. + */ WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, // WGPUNativeFeature_Multiview = 0x00030018, + /** + * Enables using 64-bit types for vertex attributes. + * + * Requires @ref WGPUNativeFeature_ShaderF64. + * + * This is a native only feature. + */ WGPUNativeFeature_VertexAttribute64bit = 0x00030019, + /** + * Allows for creation of textures of format + * @ref WGPUNativeTextureFormat_NV12. + * + * Supported platforms: + * - DX12 + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, - WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001B, + /** + * Allows for the creation of ray-tracing queries within shaders. + * + * @b EXPERIMENTAL: Features enabled by this may have major bugs and are + * expected to be subject to breaking changes. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_RayQuery = 0x0003001C, + /** + * Enables 64-bit floating point types in SPIR-V shaders. + * + * Note: even when supported by GPU hardware, 64-bit floating point + * operations are frequently between 16 and 64 @e times slower than + * equivalent operations on 32-bit floats. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_ShaderF64 = 0x0003001D, + /** + * Allows shaders to use i16. Not currently supported in naga, only + * available through SPIR-V passthrough. + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_ShaderI16 = 0x0003001E, - WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F, + /** + * Allows shaders to use the @c early_depth_test attribute. + * + * The attribute is applied to the fragment shader entry point and can be + * used in two ways: + * + * 1. Force early depth/stencil tests: + * - WGSL: @c \@early_depth_test(force) + * - GLSL: @c layout(early_fragment_tests) @c in; + * + * 2. Provide a conservative depth specifier that allows an additional + * early depth test under certain conditions: + * - WGSL: @c \@early_depth_test(greater_equal/less_equal/unchanged) + * - GLSL: @c layout(depth_) @c out @c float @c gl_FragDepth; + * + * Supported platforms: + * - Vulkan + * - GLES 3.1+ + * + * This is a native only feature. + */ WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, + /** + * Allows compute and fragment shaders to use the subgroup operation + * built-ins and perform subgroup operations (except barriers). + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * + * This is a native only feature. + */ WGPUNativeFeature_Subgroup = 0x00030021, + /** + * Allows vertex shaders to use the subgroup operation built-ins and + * perform subgroup operations (except barriers). + * + * Supported platforms: + * - Vulkan + * + * This is a native only feature. + */ WGPUNativeFeature_SubgroupVertex = 0x00030022, + /** + * Allows compute shaders to use the subgroup barrier. + * + * Requires @ref WGPUNativeFeature_Subgroup. Without it, enables nothing. + * + * Supported platforms: + * - Vulkan + * - Metal + * + * This is a native only feature. + */ WGPUNativeFeature_SubgroupBarrier = 0x00030023, + /** + * Allows for timestamp queries directly on command encoders. + * + * Implies @c WGPUFeatureName_TimestampQuery is supported. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal + * - OpenGL (with GL_ARB_timer_query) + * + * This is a native only feature. + */ WGPUNativeFeature_TimestampQueryInsideEncoders = 0x00030024, + /** + * Allows for timestamp queries inside render and compute passes. + * + * Implies @c WGPUFeatureName_TimestampQuery and + * @ref WGPUNativeFeature_TimestampQueryInsideEncoders are supported. + * + * Enables @ref wgpuRenderPassEncoderWriteTimestamp and + * @ref wgpuComputePassEncoderWriteTimestamp. + * + * This is generally not available on tile-based rasterization GPUs. + * + * Supported platforms: + * - Vulkan + * - DX12 + * - Metal (AMD & Intel, not Apple GPUs) + * - OpenGL (with GL_ARB_timer_query) + * + * This is a native only feature. + */ WGPUNativeFeature_TimestampQueryInsidePasses = 0x00030025, + /** + * Allows shaders to use i64 and u64. + * + * Supported platforms: + * - Vulkan + * - DX12 (DXC only) + * - Metal (with MSL 2.3+) + * + * This is a native only feature. + */ WGPUNativeFeature_ShaderInt64 = 0x00030026, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; -typedef enum WGPULogLevel { +typedef enum WGPULogLevel +{ WGPULogLevel_Off = 0x00000000, + /** Only error messages. */ WGPULogLevel_Error = 0x00000001, + /** Errors and warnings. */ WGPULogLevel_Warn = 0x00000002, + /** Errors, warnings, and informational messages. */ WGPULogLevel_Info = 0x00000003, + /** Errors, warnings, informational, and debug messages. */ WGPULogLevel_Debug = 0x00000004, + /** All messages, including very verbose trace-level output. */ WGPULogLevel_Trace = 0x00000005, WGPULogLevel_Force32 = 0x7FFFFFFF } WGPULogLevel; +/** + * Bitflags selecting which graphics backends the @ref WGPUInstance should + * enable. + * + * Pass in the @c backends field of @ref WGPUInstanceExtras. + */ typedef WGPUFlags WGPUInstanceBackend; +/** All backends (the default when zero-initialized). */ static const WGPUInstanceBackend WGPUInstanceBackend_All = 0x00000000; +/** + * Vulkan backend. + * Supported on Windows, Linux/Android, and macOS/iOS via Vulkan Portability. + */ static const WGPUInstanceBackend WGPUInstanceBackend_Vulkan = 1 << 0; +/** + * OpenGL / OpenGL ES backend. + * Supported on Linux/Android, the web via WebGL, and Windows/macOS via ANGLE. + */ static const WGPUInstanceBackend WGPUInstanceBackend_GL = 1 << 1; +/** + * Metal backend. + * Supported on macOS and iOS. + */ static const WGPUInstanceBackend WGPUInstanceBackend_Metal = 1 << 2; +/** + * Direct3D 12 backend. + * Supported on Windows 10 and later. + */ static const WGPUInstanceBackend WGPUInstanceBackend_DX12 = 1 << 3; -static const WGPUInstanceBackend WGPUInstanceBackend_DX11 = 1 << 4; +/** + * Browser WebGPU backend. + * Supported when targeting the web through WebAssembly. + */ static const WGPUInstanceBackend WGPUInstanceBackend_BrowserWebGPU = 1 << 5; -// Vulkan, Metal, DX12 and BrowserWebGPU +/** Primary (first-tier) backends: 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); +/** Secondary (second-tier) backends: GL. */ +static const WGPUInstanceBackend WGPUInstanceBackend_Secondary = (1 << 1); static const WGPUInstanceBackend WGPUInstanceBackend_Force32 = 0x7FFFFFFF; +/** + * Bitflags controlling instance debugging and validation behavior. + * + * These are not part of the WebGPU standard. + * + * Pass in the @c flags field of @ref WGPUInstanceExtras. + */ typedef WGPUFlags WGPUInstanceFlag; -static const WGPUInstanceFlag WGPUInstanceFlag_Default = 0x00000000; +/** No flags set. */ +static const WGPUInstanceFlag WGPUInstanceFlag_Empty = 0x00000000; +/** + * Generate debug information in shaders and objects. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_DEBUG environment variable. + */ static const WGPUInstanceFlag WGPUInstanceFlag_Debug = 1 << 0; +/** + * Enable validation in the backend API, if possible: + * + * - On the DX12 backend, this calls @c ID3D12Debug::EnableDebugLayer. + * - On the Vulkan backend, this enables the Vulkan Validation Layers. + * - On the GLES backend (Windows), this enables debug output. + * - On the GLES backend (non-Windows), this calls @c eglDebugMessageControlKHR. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_VALIDATION environment variable. + */ static const WGPUInstanceFlag WGPUInstanceFlag_Validation = 1 << 1; +/** + * Don't pass labels to the backend API (wgpu-hal). + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_DISCARD_HAL_LABELS environment variable. + */ static const WGPUInstanceFlag WGPUInstanceFlag_DiscardHalLabels = 1 << 2; +/** + * Whether wgpu should expose adapters that run on top of non-compliant + * adapters. + * + * Turning this on might mean that some of the functionality provided by the + * wgpu adapter/device is not working or broken. This mainly applies to a + * Vulkan driver's compliance version. If the major compliance version is 0, + * then the driver is ignored unless this flag is set. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_AllowUnderlyingNoncompliantAdapter = 1 << 3; +/** + * Enable GPU-based validation. Implies @ref WGPUInstanceFlag_Validation. + * Currently only changes behavior on the DX12 and Vulkan backends. + * + * - D3D12: Called "GPU-based validation" (GBV). + * - Vulkan: Called "GPU-Assisted Validation" via VK_LAYER_KHRONOS_validation. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_GPU_BASED_VALIDATION environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_GPUBasedValidation = 1 << 4; +/** + * Validate indirect buffer content prior to issuing indirect draws/dispatches. + * + * This validation will transform indirect calls into no-ops if they are not + * valid. For example, @c dispatch_workgroups_indirect arguments must be less + * than the @c max_compute_workgroups_per_dimension device limit. + * + * When using @ref WGPUInstanceFlag_WithEnv, takes value from the + * @c WGPU_VALIDATION_INDIRECT_CALL environment variable. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_ValidationIndirectCall = 1 << 5; +/** + * Enable automatic timestamp normalization. When enabled, + * @c wgpuCommandEncoderResolveQuerySet will automatically normalize timestamps + * to nanoseconds instead of returning raw timestamp values. + * + * This introduces a compute shader into the resolution of query sets. When + * enabled, the timestamp period returned by @ref wgpuQueueGetTimestampPeriod + * will always be @c 1.0. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_AutomaticTimestampNormalization = 1 << 6; +/** + * Use the default flags for the current build configuration. + * In debug builds, this typically enables @ref WGPUInstanceFlag_Debug and + * @ref WGPUInstanceFlag_Validation. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_Default = 1 << 24; +/** + * Convenience alias that enables @ref WGPUInstanceFlag_Debug and + * @ref WGPUInstanceFlag_Validation. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_Debugging = 1 << 25; +/** + * Convenience alias that enables @ref WGPUInstanceFlag_Debug, + * @ref WGPUInstanceFlag_Validation, and + * @ref WGPUInstanceFlag_GPUBasedValidation. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_AdvancedDebugging = 1 << 26; +/** + * Modify the flags based on environment variables. Flags with environment + * variable support (e.g. @c WGPU_DEBUG, @c WGPU_VALIDATION) will be read + * from the process environment and applied on top of the explicitly set flags. + */ +static const WGPUInstanceFlag WGPUInstanceFlag_WithEnv = 1 << 27; static const WGPUInstanceFlag WGPUInstanceFlag_Force32 = 0x7FFFFFFF; -typedef enum WGPUDx12Compiler { +typedef enum WGPUDx12Compiler +{ WGPUDx12Compiler_Undefined = 0x00000000, + /** + * Use the FXC (D3DCompile) shader compiler. + * + * The FXC compiler is old, slow, and unmaintained. However, it doesn't + * require any additional DLLs to be shipped with the application. + */ WGPUDx12Compiler_Fxc = 0x00000001, + /** + * Use the DXC (DirectX Shader Compiler). + * + * The DXC compiler is new, fast, and maintained. However, it requires + * @c dxcompiler.dll to be available. The path to this DLL can be + * specified via @ref WGPUInstanceExtras::dxcPath. + * + * Minimum supported version: v1.8.2502. + * Requires WDDM 2.1 (Windows 10 version 1607). + */ WGPUDx12Compiler_Dxc = 0x00000002, WGPUDx12Compiler_Force32 = 0x7FFFFFFF } WGPUDx12Compiler; -typedef enum WGPUGles3MinorVersion { +typedef enum WGPUGles3MinorVersion +{ WGPUGles3MinorVersion_Automatic = 0x00000000, + /** Request an ES 3.0 context. */ WGPUGles3MinorVersion_Version0 = 0x00000001, + /** Request an ES 3.1 context. */ WGPUGles3MinorVersion_Version1 = 0x00000002, + /** Request an ES 3.2 context. */ WGPUGles3MinorVersion_Version2 = 0x00000003, WGPUGles3MinorVersion_Force32 = 0x7FFFFFFF } WGPUGles3MinorVersion; -typedef enum WGPUPipelineStatisticName { +typedef enum WGPUPipelineStatisticName +{ WGPUPipelineStatisticName_VertexShaderInvocations = 0x00000000, + /** + * Number of times the clipper is invoked. This is also the number of + * triangles output by the vertex shader. + */ WGPUPipelineStatisticName_ClipperInvocations = 0x00000001, + /** + * Number of primitives that are not culled by the clipper. This is the + * number of triangles that are actually on screen and will be rasterized + * and rendered. + */ WGPUPipelineStatisticName_ClipperPrimitivesOut = 0x00000002, + /** + * Number of times the fragment shader is invoked. Accounts for fragment + * shaders running in 2x2 blocks in order to get derivatives. + */ WGPUPipelineStatisticName_FragmentShaderInvocations = 0x00000003, + /** + * Number of times a compute shader is invoked. This will be equivalent + * to the dispatch count times the workgroup size. + */ WGPUPipelineStatisticName_ComputeShaderInvocations = 0x00000004, WGPUPipelineStatisticName_Force32 = 0x7FFFFFFF } WGPUPipelineStatisticName WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUNativeQueryType { +typedef enum WGPUNativeQueryType +{ WGPUNativeQueryType_PipelineStatistics = 0x00030000, WGPUNativeQueryType_Force32 = 0x7FFFFFFF } WGPUNativeQueryType WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUDxcMaxShaderModel { +typedef enum WGPUDxcMaxShaderModel +{ WGPUDxcMaxShaderModel_V6_0 = 0x00000000, + /** Shader Model 6.1 */ WGPUDxcMaxShaderModel_V6_1 = 0x00000001, + /** Shader Model 6.2 */ WGPUDxcMaxShaderModel_V6_2 = 0x00000002, + /** Shader Model 6.3 */ WGPUDxcMaxShaderModel_V6_3 = 0x00000003, + /** Shader Model 6.4 */ WGPUDxcMaxShaderModel_V6_4 = 0x00000004, + /** Shader Model 6.5 */ WGPUDxcMaxShaderModel_V6_5 = 0x00000005, + /** Shader Model 6.6 */ WGPUDxcMaxShaderModel_V6_6 = 0x00000006, + /** Shader Model 6.7 */ WGPUDxcMaxShaderModel_V6_7 = 0x00000007, WGPUDxcMaxShaderModel_Force32 = 0x7FFFFFFF } WGPUDxcMaxShaderModel; -typedef enum WGPUGLFenceBehaviour { +typedef enum WGPUGLFenceBehaviour +{ WGPUGLFenceBehaviour_Normal = 0x00000000, + /** + * Fences are short-circuited to always report completion immediately. + * + * This solves a specific issue that arose due to a bug in wgpu-core that + * made many WebGL programs work when they shouldn't have. If you have + * code that calls @ref wgpuDevicePoll with @c wait=true on WebGL, you + * may need to enable this option for "wait" to behave how you expect. + * + * When this is set, @c wgpuQueueOnCompletedWorkDone callbacks will fire + * the next time the device is polled, not when work is actually done on + * the GPU. + */ WGPUGLFenceBehaviour_AutoFinish = 0x00000001, WGPUGLFenceBehaviour_Force32 = 0x7FFFFFFF } WGPUGLFenceBehaviour; -typedef struct WGPUInstanceExtras { +typedef enum WGPUDx12SwapchainKind +{ + WGPUDx12SwapchainKind_Undefined = 0x00000000, + /** + * Use a DXGI swapchain created directly from the window's HWND. + * + * This does not support transparency but has better support from + * developer tooling such as RenderDoc. + */ + WGPUDx12SwapchainKind_DxgiFromHwnd = 0x00000001, + /** + * Use a DXGI swapchain created from a DirectComposition visual made + * automatically from the window's HWND. + * + * This creates a single @c IDCompositionVisual over the entire window. + * Supports transparency. If you want to manage the composition tree + * yourself, create your own device and composition and pass the relevant + * visual via the surface target. + */ + WGPUDx12SwapchainKind_DxgiFromVisual = 0x00000002, + WGPUDx12SwapchainKind_Force32 = 0x7FFFFFFF +} WGPUDx12SwapchainKind; + +/** + * Discriminant for @ref WGPUNativeDisplayHandle. + * + * Identifies which platform's display connection is stored in the tagged union. + * Use @ref WGPUNativeDisplayHandleType_None (the default when zero-initialized) when + * no display handle is needed. Platforms with no display connection data (Windows, + * macOS, iOS, Android) should use @ref WGPUNativeDisplayHandleType_None. + */ +typedef enum WGPUNativeDisplayHandleType +{ + /** No display handle provided. */ + WGPUNativeDisplayHandleType_None = 0x00000000, + /** X11 display connection via Xlib. See @ref WGPUXlibDisplayHandle. */ + WGPUNativeDisplayHandleType_Xlib = 0x00000001, + /** X11 display connection via XCB. See @ref WGPUXcbDisplayHandle. */ + WGPUNativeDisplayHandleType_Xcb = 0x00000002, + /** Wayland display connection. See @ref WGPUWaylandDisplayHandle. */ + WGPUNativeDisplayHandleType_Wayland = 0x00000003, + WGPUNativeDisplayHandleType_Force32 = 0x7FFFFFFF +} WGPUNativeDisplayHandleType; + +/** + * Xlib display connection data for @ref WGPUNativeDisplayHandle. + */ +typedef struct WGPUXlibDisplayHandle +{ + /** Pointer to the X11 @c Display (i.e. @c Display*). Must not be NULL. */ + void *display; + /** X11 screen number. */ + int screen; +} WGPUXlibDisplayHandle; + +/** + * XCB display connection data for @ref WGPUNativeDisplayHandle. + */ +typedef struct WGPUXcbDisplayHandle +{ + /** Pointer to the XCB connection (i.e. @c xcb_connection_t*). Must not be NULL. */ + void *connection; + /** X11 screen number. */ + int screen; +} WGPUXcbDisplayHandle; + +/** + * Wayland display connection data for @ref WGPUNativeDisplayHandle. + */ +typedef struct WGPUWaylandDisplayHandle +{ + /** Pointer to the Wayland display (i.e. @c wl_display*). Must not be NULL. */ + void *display; +} WGPUWaylandDisplayHandle; + +/** + * Platform display connection, passed as a field of @ref WGPUInstanceExtras. + * + * This is a tagged union. Set @c type to indicate which variant is active, then + * populate the corresponding field in @c data. Zero-initialization yields + * @ref WGPUNativeDisplayHandleType_None, meaning no display handle is provided. + * + * Currently required by the GLES backend when presenting on Wayland. Other + * backends ignore this field. If the instance is created with a display handle, + * all surfaces created from it must use the same display connection. + */ +typedef struct WGPUNativeDisplayHandle +{ + WGPUNativeDisplayHandleType type; + union + { + WGPUXlibDisplayHandle xlib; + WGPUXcbDisplayHandle xcb; + WGPUWaylandDisplayHandle wayland; + } data; +} WGPUNativeDisplayHandle; + +typedef struct WGPUInstanceExtras +{ WGPUChainedStruct chain; + /** + * Which backends to enable. + * Zero (@ref WGPUInstanceBackend_All) enables all backends. + */ WGPUInstanceBackend backends; + /** + * Flags controlling debug/validation behavior. + * See @ref WGPUInstanceFlag for available flags. + */ WGPUInstanceFlag flags; + /** + * Which DX12 shader compiler to use. + * See @ref WGPUDx12Compiler. Ignored on non-DX12 backends. + */ WGPUDx12Compiler dx12ShaderCompiler; + /** + * Which OpenGL ES 3 minor version to request. + * See @ref WGPUGles3MinorVersion. Ignored on non-GL backends. + */ WGPUGles3MinorVersion gles3MinorVersion; + /** + * Controls OpenGL fence synchronization behavior. + * See @ref WGPUGLFenceBehaviour. Ignored on non-GL backends. + */ WGPUGLFenceBehaviour glFenceBehaviour; - WGPUStringView dxilPath; + /** + * File system path to @c dxcompiler.dll for dynamic DXC loading. + * Only used when @c dx12ShaderCompiler is @ref WGPUDx12Compiler_Dxc. + * An empty/undefined string view means the DLL will be searched for + * on the system PATH. + */ WGPUStringView dxcPath; + /** + * Maximum HLSL shader model version that DXC should target. + * See @ref WGPUDxcMaxShaderModel. Only used with the DXC compiler. + */ WGPUDxcMaxShaderModel dxcMaxShaderModel; + /** + * Which DX12 presentation system (swapchain kind) to use. + * See @ref WGPUDx12SwapchainKind. Ignored on non-DX12 backends. + */ + WGPUDx12SwapchainKind dx12PresentationSystem; + + WGPU_NULLABLE const uint8_t *budgetForDeviceCreation; + WGPU_NULLABLE const uint8_t *budgetForDeviceLoss; + + /** + * Platform display connection to associate with this instance. + * Zero-initialized yields @ref WGPUNativeDisplayHandleType_None (no handle). + */ + WGPUNativeDisplayHandle displayHandle; } WGPUInstanceExtras; -typedef struct WGPUDeviceExtras { +typedef struct WGPUDeviceExtras +{ WGPUChainedStruct chain; + /** + * File system path for API trace output. + * + * When set to a non-empty path, wgpu will record all API calls to + * the given directory, which can later be replayed for debugging. + * An empty/undefined string view disables tracing. + */ WGPUStringView tracePath; } WGPUDeviceExtras; -typedef struct WGPUNativeLimits { +typedef struct WGPUNativeLimits +{ /** This struct chain is used as mutable in some places and immutable in others. */ - WGPUChainedStructOut chain; - uint32_t maxPushConstantSize; + WGPUChainedStruct chain; + /** + * Amount of storage available for immediate data, in bytes. + * + * Defaults to 0. A non-zero value requires + * @ref WGPUNativeFeature_Immediates. Expected maximum sizes vary by + * backend: + * - Vulkan: 128-256 bytes + * - DX12: 128 bytes + * - Metal: 4096 bytes + * - OpenGL: ~256 bytes (emulated with uniforms) + */ + uint32_t maxImmediateSize; + /** + * Maximum number of live non-sampler bindings. + * + * Default is 1,000,000. Only meaningful on D3D12. + * + * @b Warning: On integrated GPUs, large values can cause significant + * system RAM consumption. + */ uint32_t maxNonSamplerBindings; + /** + * Maximum number of individual resources within binding arrays per + * shader stage. + */ + uint32_t maxBindingArrayElementsPerShaderStage; } WGPUNativeLimits; -typedef struct WGPUPushConstantRange { - WGPUShaderStage stages; - uint32_t start; - uint32_t end; -} WGPUPushConstantRange; - -typedef struct WGPUPipelineLayoutExtras { +typedef struct WGPUPipelineLayoutExtras +{ WGPUChainedStruct chain; - size_t pushConstantRangeCount; - WGPUPushConstantRange const * pushConstantRanges; + /** + * The number of bytes of immediate data allocated for use in shaders + * attached to this pipeline. + * + * The @c var declarations in the shader must be equal or + * smaller than this size. If this value is non-zero, + * @ref WGPUNativeFeature_Immediates must be enabled. + */ + uint32_t immediateDataSize; } WGPUPipelineLayoutExtras; +/** + * Identifier for a particular call to @ref wgpuQueueSubmitForIndex. + * + * Can be passed to @ref wgpuDevicePoll to block until a particular + * submission has finished execution. + * + * This type is unique to wgpu-native; there is no analogue in the + * WebGPU specification. + */ typedef uint64_t WGPUSubmissionIndex; -typedef struct WGPUShaderDefine { +typedef struct WGPUShaderDefine +{ WGPUStringView name; + /** The value of the preprocessor macro (e.g. @c "1"). */ WGPUStringView value; } WGPUShaderDefine; -typedef struct WGPUShaderSourceGLSL { +typedef struct WGPUShaderSourceGLSL +{ WGPUChainedStruct chain; + /** The shader stage this GLSL source targets. */ WGPUShaderStage stage; + /** GLSL source code. */ WGPUStringView code; + /** Number of entries in @c defines. */ uint32_t defineCount; - WGPUShaderDefine * defines; + WGPUShaderDefine const *defines; } WGPUShaderSourceGLSL; -typedef struct WGPUShaderModuleDescriptorSpirV { +typedef struct WGPUShaderModuleDescriptorSpirV +{ WGPUStringView label; + /** Number of 32-bit words in @c source. */ uint32_t sourceSize; - uint32_t const * source; + uint32_t const *source; } WGPUShaderModuleDescriptorSpirV; -typedef struct WGPURegistryReport { - size_t numAllocated; - size_t numKeptFromUser; - size_t numReleasedFromUser; - size_t elementSize; +typedef struct WGPURegistryReport +{ + size_t numAllocated; + size_t numKeptFromUser; + size_t numReleasedFromUser; + size_t elementSize; } WGPURegistryReport; -typedef struct WGPUHubReport { +typedef struct WGPUHubReport +{ WGPURegistryReport adapters; WGPURegistryReport devices; WGPURegistryReport queues; @@ -222,104 +1104,226 @@ typedef struct WGPUHubReport { WGPURegistryReport samplers; } WGPUHubReport; -typedef struct WGPUGlobalReport { +typedef struct WGPUGlobalReport +{ WGPURegistryReport surfaces; + /** Statistics for all other resource types, grouped by backend hub. */ WGPUHubReport hub; } WGPUGlobalReport; -typedef struct WGPUInstanceEnumerateAdapterOptions { - WGPUChainedStruct const * nextInChain; +typedef struct WGPUInstanceEnumerateAdapterOptions +{ + WGPUChainedStruct const *nextInChain; WGPUInstanceBackend backends; } WGPUInstanceEnumerateAdapterOptions; -typedef struct WGPUBindGroupEntryExtras { +typedef struct WGPUBindGroupEntryExtras +{ WGPUChainedStruct chain; - WGPUBuffer const * buffers; + WGPUBuffer const *buffers; size_t bufferCount; - WGPUSampler const * samplers; + WGPUSampler const *samplers; size_t samplerCount; - WGPUTextureView const * textureViews; + WGPUTextureView const *textureViews; size_t textureViewCount; } WGPUBindGroupEntryExtras; -typedef struct WGPUBindGroupLayoutEntryExtras { +typedef struct WGPUBindGroupLayoutEntryExtras +{ WGPUChainedStruct chain; + /** + * Number of resources in this binding array slot. Corresponds to the + * array size in the shader (e.g. @c binding_array). + */ uint32_t count; } WGPUBindGroupLayoutEntryExtras; -typedef struct WGPUQuerySetDescriptorExtras { +typedef struct WGPUQuerySetDescriptorExtras +{ WGPUChainedStruct chain; - WGPUPipelineStatisticName const * pipelineStatistics; + WGPUPipelineStatisticName const *pipelineStatistics; size_t pipelineStatisticCount; } WGPUQuerySetDescriptorExtras WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceConfigurationExtras { +typedef struct WGPUSurfaceConfigurationExtras +{ WGPUChainedStruct chain; + /** + * Desired maximum number of frames in flight (i.e. the number of monitor + * refreshes between @c wgpuSurfaceGetCurrentTexture and presentation). + * + * - 1: Minimize latency (CPU and GPU cannot run in parallel). + * - 2: Balance between latency and throughput (the default). + * - 3+: Maximize throughput. + */ uint32_t desiredMaximumFrameLatency; } WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; /** * Chained in @ref WGPUSurfaceDescriptor to make a @ref WGPUSurface wrapping a WinUI [`SwapChainPanel`](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.swapchainpanel). */ -typedef struct WGPUSurfaceSourceSwapChainPanel { +typedef struct WGPUSurfaceSourceSwapChainPanel +{ WGPUChainedStruct chain; /** * A pointer to the [`ISwapChainPanelNative`](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/win32/microsoft.ui.xaml.media.dxinterop/nn-microsoft-ui-xaml-media-dxinterop-iswapchainpanelnative) * interface of the SwapChainPanel that will be wrapped by the @ref WGPUSurface. */ - void * panelNative; + void *panelNative; } WGPUSurfaceSourceSwapChainPanel WGPU_STRUCTURE_ATTRIBUTE; -typedef void (*WGPULogCallback)(WGPULogLevel level, WGPUStringView message, void * userdata); +typedef enum WGPUPolygonMode +{ + WGPUPolygonMode_Fill = 0, + /** + * Polygons are drawn as line segments (wireframe). + * Requires @ref WGPUNativeFeature_PolygonModeLine. + */ + WGPUPolygonMode_Line = 1, + /** + * Polygons are drawn as points (vertices only). + * Requires @ref WGPUNativeFeature_PolygonModePoint. + */ + WGPUPolygonMode_Point = 2, +} WGPUPolygonMode; -typedef enum WGPUNativeTextureFormat { +typedef struct WGPUPrimitiveStateExtras +{ + WGPUChainedStruct chain; + /** + * Controls the way each polygon is rasterized. + * See @ref WGPUPolygonMode. Defaults to @ref WGPUPolygonMode_Fill. + */ + WGPUPolygonMode polygonMode; + /** + * If set to true, the primitives are rendered with conservative + * overestimation. Only valid when @c polygonMode is + * @ref WGPUPolygonMode_Fill. + * Requires @ref WGPUNativeFeature_ConservativeRasterization. + */ + WGPUBool conservative; +} WGPUPrimitiveStateExtras WGPU_STRUCTURE_ATTRIBUTE; + +typedef void (*WGPULogCallback)(WGPULogLevel level, WGPUStringView message, void *userdata); + +typedef enum WGPUNativeTextureFormat +{ // From Features::TEXTURE_FORMAT_16BIT_NORM WGPUNativeTextureFormat_R16Unorm = 0x00030001, + /** + * Red channel only. 16-bit signed integer per channel. + * [-32767, 32767] converted to/from float [-1, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ WGPUNativeTextureFormat_R16Snorm = 0x00030002, + /** + * Red and green channels. 16-bit unsigned integer per channel. + * [0, 65535] converted to/from float [0, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ WGPUNativeTextureFormat_Rg16Unorm = 0x00030003, + /** + * Red and green channels. 16-bit signed integer per channel. + * [-32767, 32767] converted to/from float [-1, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ WGPUNativeTextureFormat_Rg16Snorm = 0x00030004, + /** + * Red, green, blue, and alpha channels. 16-bit unsigned integer per channel. + * [0, 65535] converted to/from float [0, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ WGPUNativeTextureFormat_Rgba16Unorm = 0x00030005, + /** + * Red, green, blue, and alpha channels. 16-bit signed integer per channel. + * [-32767, 32767] converted to/from float [-1, 1] in shader. + * Requires @ref WGPUNativeFeature_TextureFormat16bitNorm. + */ WGPUNativeTextureFormat_Rgba16Snorm = 0x00030006, - // From Features::TEXTURE_FORMAT_NV12 + /** + * YUV 4:2:0 chroma subsampled format (NV12). + * Plane 0 contains R8Unorm luminance (Y), Plane 1 contains Rg8Unorm + * chrominance (UV) at half width and half height. + * Requires @ref WGPUNativeFeature_TextureFormatNv12. + */ WGPUNativeTextureFormat_NV12 = 0x00030007, + /** + * YUV 4:2:0 with 10 bits used from 16-bit channels (P010). + * Plane 0 contains R16Unorm luminance (Y), Plane 1 contains Rg16Unorm + * chrominance (UV) at half width and half height. + */ + WGPUNativeTextureFormat_P010 = 0x00030008, } WGPUNativeTextureFormat; #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport * report); -size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters); + void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport *report); + size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const *options, WGPUAdapter *adapters); -WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); + WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const *commands); + float wgpuQueueGetTimestampPeriod(WGPUQueue queue); -// Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * submissionIndex); -WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); + // Returns true if the queue is empty, or false if there are more queue submissions still in flight. + WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const *submissionIndex); + WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const *descriptor); -void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); + void wgpuSetLogCallback(WGPULogCallback callback, void *userdata); -void wgpuSetLogLevel(WGPULogLevel level); + void wgpuSetLogLevel(WGPULogLevel level); -uint32_t wgpuGetVersion(void); + uint32_t wgpuGetVersion(void); -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); + /** + * Returns the backend-native `id` as an opaque pointer. + * + * The returned pointer is borrowed and remains valid only while `device` is alive. + * Ownership is retained by wgpu-native; callers must not release or destroy it. + * Returns NULL when the active backend is not Metal or when the handle is unavailable. + */ + void *wgpuDeviceGetNativeMetalDevice(WGPUDevice device); -void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); -void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); + /** + * Returns the backend-native `id` as an opaque pointer. + * + * The returned pointer is borrowed and remains valid only while `queue` is alive. + * Ownership is retained by wgpu-native; callers must not release or destroy it. + * Returns NULL when the active backend is not Metal or when the handle is unavailable. + */ + void *wgpuQueueGetNativeMetalCommandQueue(WGPUQueue queue); -void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); -void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); + /** + * Returns the backend-native `id` as an opaque pointer. + * + * The returned pointer is borrowed and remains valid only while `texture` is alive. + * Ownership is retained by wgpu-native; callers must not release or destroy it. + * Returns NULL when the active backend is not Metal or when the handle is unavailable. + */ + void *wgpuTextureGetNativeMetalTexture(WGPUTexture texture); -void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder); -void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); + void wgpuRenderPassEncoderSetImmediates(WGPURenderPassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); + void wgpuComputePassEncoderSetImmediates(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); + void wgpuRenderBundleEncoderSetImmediates(WGPURenderBundleEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); -void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); + void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); + + void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); + void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); + + void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder); + void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); + + void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + + // Returns true if the capture was successfully started, or false if it failed to start or is not supported on the current platform. + WGPUBool wgpuDeviceStartGraphicsDebuggerCapture(WGPUDevice device); + void wgpuDeviceStopGraphicsDebuggerCapture(WGPUDevice device); #ifdef __cplusplus } // extern "C" diff --git a/libs/wgpu/lib/Linux/libwgpu_native.a b/libs/wgpu/lib/Linux/libwgpu_native.a index 923d594..5cd5982 100644 Binary files a/libs/wgpu/lib/Linux/libwgpu_native.a and b/libs/wgpu/lib/Linux/libwgpu_native.a differ diff --git a/libs/wgpu/lib/Windows/wgpu_native.lib b/libs/wgpu/lib/Windows/wgpu_native.lib index 7db05c7..9c74bbe 100644 Binary files a/libs/wgpu/lib/Windows/wgpu_native.lib and b/libs/wgpu/lib/Windows/wgpu_native.lib differ diff --git a/libs/wgpu/wgpu-native-git-tag b/libs/wgpu/wgpu-native-git-tag index 1446204..2f691f9 100644 --- a/libs/wgpu/wgpu-native-git-tag +++ b/libs/wgpu/wgpu-native-git-tag @@ -1 +1 @@ -v25.0.2.2 +v29.0.0.0 diff --git a/src/main.cpp b/src/main.cpp index cdc00af..26fdb25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2273,7 +2273,7 @@ int main(int argc, char **argv) { WGPURenderPassColorAttachment render_pass_color_attachment = { .view = framebuffer_view, - .depthSlice = 0, + .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, .resolveTarget = surface_texture_view, .loadOp = WGPULoadOp_Clear, .storeOp = WGPUStoreOp_Discard,