diff --git a/3rdparty/include/webgpu/include/dawn/EnumClassBitmasks.h b/3rdparty/include/webgpu/include/dawn/EnumClassBitmasks.h new file mode 100644 index 000000000000..93d2be4574d4 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn/EnumClassBitmasks.h @@ -0,0 +1,144 @@ +// Copyright 2017 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWN_ENUM_CLASS_BITMASKS_H_ +#define DAWN_ENUM_CLASS_BITMASKS_H_ + +#include + +namespace wgpu { + + template + struct IsDawnBitmask { + static constexpr bool enable = false; + }; + + template + struct LowerBitmask { + static constexpr bool enable = false; + }; + + template + struct LowerBitmask::enable>::type> { + static constexpr bool enable = true; + using type = T; + constexpr static T Lower(T t) { + return t; + } + }; + + template + struct BoolConvertible { + using Integral = typename std::underlying_type::type; + + constexpr BoolConvertible(Integral value) : value(value) { + } + constexpr operator bool() const { + return value != 0; + } + constexpr operator T() const { + return static_cast(value); + } + + Integral value; + }; + + template + struct LowerBitmask> { + static constexpr bool enable = true; + using type = T; + static constexpr type Lower(BoolConvertible t) { + return t; + } + }; + + template ::enable && + LowerBitmask::enable>::type> + constexpr BoolConvertible::type> operator|(T1 left, T2 right) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return static_cast(LowerBitmask::Lower(left)) | + static_cast(LowerBitmask::Lower(right)); + } + + template ::enable && + LowerBitmask::enable>::type> + constexpr BoolConvertible::type> operator&(T1 left, T2 right) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return static_cast(LowerBitmask::Lower(left)) & + static_cast(LowerBitmask::Lower(right)); + } + + template ::enable && + LowerBitmask::enable>::type> + constexpr BoolConvertible::type> operator^(T1 left, T2 right) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return static_cast(LowerBitmask::Lower(left)) ^ + static_cast(LowerBitmask::Lower(right)); + } + + template + constexpr BoolConvertible::type> operator~(T1 t) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return ~static_cast(LowerBitmask::Lower(t)); + } + + template ::enable && + LowerBitmask::enable>::type> + constexpr T& operator&=(T& l, T2 right) { + T r = LowerBitmask::Lower(right); + l = l & r; + return l; + } + + template ::enable && + LowerBitmask::enable>::type> + constexpr T& operator|=(T& l, T2 right) { + T r = LowerBitmask::Lower(right); + l = l | r; + return l; + } + + template ::enable && + LowerBitmask::enable>::type> + constexpr T& operator^=(T& l, T2 right) { + T r = LowerBitmask::Lower(right); + l = l ^ r; + return l; + } + + template + constexpr bool HasZeroOrOneBits(T value) { + using Integral = typename std::underlying_type::type; + return (static_cast(value) & (static_cast(value) - 1)) == 0; + } + +} // namespace wgpu + +#endif // DAWN_ENUM_CLASS_BITMASKS_H_ diff --git a/3rdparty/include/webgpu/include/dawn/dawn_proc.h b/3rdparty/include/webgpu/include/dawn/dawn_proc.h new file mode 100644 index 000000000000..adeec4633521 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn/dawn_proc.h @@ -0,0 +1,36 @@ +// Copyright 2019 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWN_DAWN_PROC_H_ +#define DAWN_DAWN_PROC_H_ + +#include "dawn/dawn_proc_table.h" +#include "dawn/webgpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL +// for `procs` sets up the null proctable that contains only null function pointers. It is the +// default value of the proctable. Setting the proctable back to null is good practice when you +// are done using libdawn_proc since further usage will cause a segfault instead of calling an +// unexpected function. +WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // DAWN_DAWN_PROC_H_ diff --git a/3rdparty/include/webgpu/include/dawn/dawn_proc_table.h b/3rdparty/include/webgpu/include/dawn/dawn_proc_table.h new file mode 100644 index 000000000000..55acca0270ce --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn/dawn_proc_table.h @@ -0,0 +1,165 @@ + +#ifndef DAWN_DAWN_PROC_TABLE_H_ +#define DAWN_DAWN_PROC_TABLE_H_ + +#include "dawn/webgpu.h" + +typedef struct DawnProcTable { + WGPUProcGetProcAddress getProcAddress; + WGPUProcCreateInstance createInstance; + + WGPUProcBindGroupReference bindGroupReference; + WGPUProcBindGroupRelease bindGroupRelease; + + WGPUProcBindGroupLayoutReference bindGroupLayoutReference; + WGPUProcBindGroupLayoutRelease bindGroupLayoutRelease; + + WGPUProcBufferDestroy bufferDestroy; + WGPUProcBufferMapReadAsync bufferMapReadAsync; + WGPUProcBufferMapWriteAsync bufferMapWriteAsync; + WGPUProcBufferSetSubData bufferSetSubData; + WGPUProcBufferUnmap bufferUnmap; + WGPUProcBufferReference bufferReference; + WGPUProcBufferRelease bufferRelease; + + WGPUProcCommandBufferReference commandBufferReference; + WGPUProcCommandBufferRelease commandBufferRelease; + + WGPUProcCommandEncoderBeginComputePass commandEncoderBeginComputePass; + WGPUProcCommandEncoderBeginRenderPass commandEncoderBeginRenderPass; + WGPUProcCommandEncoderCopyBufferToBuffer commandEncoderCopyBufferToBuffer; + WGPUProcCommandEncoderCopyBufferToTexture commandEncoderCopyBufferToTexture; + WGPUProcCommandEncoderCopyTextureToBuffer commandEncoderCopyTextureToBuffer; + WGPUProcCommandEncoderCopyTextureToTexture commandEncoderCopyTextureToTexture; + WGPUProcCommandEncoderFinish commandEncoderFinish; + WGPUProcCommandEncoderInsertDebugMarker commandEncoderInsertDebugMarker; + WGPUProcCommandEncoderPopDebugGroup commandEncoderPopDebugGroup; + WGPUProcCommandEncoderPushDebugGroup commandEncoderPushDebugGroup; + WGPUProcCommandEncoderReference commandEncoderReference; + WGPUProcCommandEncoderRelease commandEncoderRelease; + + WGPUProcComputePassEncoderDispatch computePassEncoderDispatch; + WGPUProcComputePassEncoderDispatchIndirect computePassEncoderDispatchIndirect; + WGPUProcComputePassEncoderEndPass computePassEncoderEndPass; + WGPUProcComputePassEncoderInsertDebugMarker computePassEncoderInsertDebugMarker; + WGPUProcComputePassEncoderPopDebugGroup computePassEncoderPopDebugGroup; + WGPUProcComputePassEncoderPushDebugGroup computePassEncoderPushDebugGroup; + WGPUProcComputePassEncoderSetBindGroup computePassEncoderSetBindGroup; + WGPUProcComputePassEncoderSetPipeline computePassEncoderSetPipeline; + WGPUProcComputePassEncoderReference computePassEncoderReference; + WGPUProcComputePassEncoderRelease computePassEncoderRelease; + + WGPUProcComputePipelineGetBindGroupLayout computePipelineGetBindGroupLayout; + WGPUProcComputePipelineReference computePipelineReference; + WGPUProcComputePipelineRelease computePipelineRelease; + + WGPUProcDeviceCreateBindGroup deviceCreateBindGroup; + WGPUProcDeviceCreateBindGroupLayout deviceCreateBindGroupLayout; + WGPUProcDeviceCreateBuffer deviceCreateBuffer; + WGPUProcDeviceCreateBufferMapped deviceCreateBufferMapped; + WGPUProcDeviceCreateCommandEncoder deviceCreateCommandEncoder; + WGPUProcDeviceCreateComputePipeline deviceCreateComputePipeline; + WGPUProcDeviceCreatePipelineLayout deviceCreatePipelineLayout; + WGPUProcDeviceCreateRenderBundleEncoder deviceCreateRenderBundleEncoder; + WGPUProcDeviceCreateRenderPipeline deviceCreateRenderPipeline; + WGPUProcDeviceCreateSampler deviceCreateSampler; + WGPUProcDeviceCreateShaderModule deviceCreateShaderModule; + WGPUProcDeviceCreateSwapChain deviceCreateSwapChain; + WGPUProcDeviceCreateTexture deviceCreateTexture; + WGPUProcDeviceGetDefaultQueue deviceGetDefaultQueue; + WGPUProcDeviceInjectError deviceInjectError; + WGPUProcDeviceLoseForTesting deviceLoseForTesting; + WGPUProcDevicePopErrorScope devicePopErrorScope; + WGPUProcDevicePushErrorScope devicePushErrorScope; + WGPUProcDeviceSetDeviceLostCallback deviceSetDeviceLostCallback; + WGPUProcDeviceSetUncapturedErrorCallback deviceSetUncapturedErrorCallback; + WGPUProcDeviceTick deviceTick; + WGPUProcDeviceReference deviceReference; + WGPUProcDeviceRelease deviceRelease; + + WGPUProcFenceGetCompletedValue fenceGetCompletedValue; + WGPUProcFenceOnCompletion fenceOnCompletion; + WGPUProcFenceReference fenceReference; + WGPUProcFenceRelease fenceRelease; + + WGPUProcInstanceCreateSurface instanceCreateSurface; + WGPUProcInstanceReference instanceReference; + WGPUProcInstanceRelease instanceRelease; + + WGPUProcPipelineLayoutReference pipelineLayoutReference; + WGPUProcPipelineLayoutRelease pipelineLayoutRelease; + + WGPUProcQueueCreateFence queueCreateFence; + WGPUProcQueueSignal queueSignal; + WGPUProcQueueSubmit queueSubmit; + WGPUProcQueueReference queueReference; + WGPUProcQueueRelease queueRelease; + + WGPUProcRenderBundleReference renderBundleReference; + WGPUProcRenderBundleRelease renderBundleRelease; + + WGPUProcRenderBundleEncoderDraw renderBundleEncoderDraw; + WGPUProcRenderBundleEncoderDrawIndexed renderBundleEncoderDrawIndexed; + WGPUProcRenderBundleEncoderDrawIndexedIndirect renderBundleEncoderDrawIndexedIndirect; + WGPUProcRenderBundleEncoderDrawIndirect renderBundleEncoderDrawIndirect; + WGPUProcRenderBundleEncoderFinish renderBundleEncoderFinish; + WGPUProcRenderBundleEncoderInsertDebugMarker renderBundleEncoderInsertDebugMarker; + WGPUProcRenderBundleEncoderPopDebugGroup renderBundleEncoderPopDebugGroup; + WGPUProcRenderBundleEncoderPushDebugGroup renderBundleEncoderPushDebugGroup; + WGPUProcRenderBundleEncoderSetBindGroup renderBundleEncoderSetBindGroup; + WGPUProcRenderBundleEncoderSetIndexBuffer renderBundleEncoderSetIndexBuffer; + WGPUProcRenderBundleEncoderSetPipeline renderBundleEncoderSetPipeline; + WGPUProcRenderBundleEncoderSetVertexBuffer renderBundleEncoderSetVertexBuffer; + WGPUProcRenderBundleEncoderReference renderBundleEncoderReference; + WGPUProcRenderBundleEncoderRelease renderBundleEncoderRelease; + + WGPUProcRenderPassEncoderDraw renderPassEncoderDraw; + WGPUProcRenderPassEncoderDrawIndexed renderPassEncoderDrawIndexed; + WGPUProcRenderPassEncoderDrawIndexedIndirect renderPassEncoderDrawIndexedIndirect; + WGPUProcRenderPassEncoderDrawIndirect renderPassEncoderDrawIndirect; + WGPUProcRenderPassEncoderEndPass renderPassEncoderEndPass; + WGPUProcRenderPassEncoderExecuteBundles renderPassEncoderExecuteBundles; + WGPUProcRenderPassEncoderInsertDebugMarker renderPassEncoderInsertDebugMarker; + WGPUProcRenderPassEncoderPopDebugGroup renderPassEncoderPopDebugGroup; + WGPUProcRenderPassEncoderPushDebugGroup renderPassEncoderPushDebugGroup; + WGPUProcRenderPassEncoderSetBindGroup renderPassEncoderSetBindGroup; + WGPUProcRenderPassEncoderSetBlendColor renderPassEncoderSetBlendColor; + WGPUProcRenderPassEncoderSetIndexBuffer renderPassEncoderSetIndexBuffer; + WGPUProcRenderPassEncoderSetPipeline renderPassEncoderSetPipeline; + WGPUProcRenderPassEncoderSetScissorRect renderPassEncoderSetScissorRect; + WGPUProcRenderPassEncoderSetStencilReference renderPassEncoderSetStencilReference; + WGPUProcRenderPassEncoderSetVertexBuffer renderPassEncoderSetVertexBuffer; + WGPUProcRenderPassEncoderSetViewport renderPassEncoderSetViewport; + WGPUProcRenderPassEncoderReference renderPassEncoderReference; + WGPUProcRenderPassEncoderRelease renderPassEncoderRelease; + + WGPUProcRenderPipelineGetBindGroupLayout renderPipelineGetBindGroupLayout; + WGPUProcRenderPipelineReference renderPipelineReference; + WGPUProcRenderPipelineRelease renderPipelineRelease; + + WGPUProcSamplerReference samplerReference; + WGPUProcSamplerRelease samplerRelease; + + WGPUProcShaderModuleReference shaderModuleReference; + WGPUProcShaderModuleRelease shaderModuleRelease; + + WGPUProcSurfaceReference surfaceReference; + WGPUProcSurfaceRelease surfaceRelease; + + WGPUProcSwapChainConfigure swapChainConfigure; + WGPUProcSwapChainGetCurrentTextureView swapChainGetCurrentTextureView; + WGPUProcSwapChainPresent swapChainPresent; + WGPUProcSwapChainReference swapChainReference; + WGPUProcSwapChainRelease swapChainRelease; + + WGPUProcTextureCreateView textureCreateView; + WGPUProcTextureDestroy textureDestroy; + WGPUProcTextureReference textureReference; + WGPUProcTextureRelease textureRelease; + + WGPUProcTextureViewReference textureViewReference; + WGPUProcTextureViewRelease textureViewRelease; + +} DawnProcTable; + +#endif // DAWN_DAWN_PROC_TABLE_H_ diff --git a/3rdparty/include/webgpu/include/dawn/dawn_wsi.h b/3rdparty/include/webgpu/include/dawn/dawn_wsi.h new file mode 100644 index 000000000000..e07e74185cd5 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn/dawn_wsi.h @@ -0,0 +1,86 @@ +// Copyright 2017 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWN_DAWN_WSI_H_ +#define DAWN_DAWN_WSI_H_ + +#include + +// Error message (or nullptr if there was no error) +typedef const char* DawnSwapChainError; +constexpr DawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr; + +typedef struct { + /// Backend-specific texture id/name/pointer + union { + void* ptr; + uint64_t u64; + uint32_t u32; + } texture; +} DawnSwapChainNextTexture; + +typedef struct { + /// Initialize the swap chain implementation. + /// (*wsiContext) is one of DawnWSIContext{D3D12,Metal,GL} + void (*Init)(void* userData, void* wsiContext); + + /// Destroy the swap chain implementation. + void (*Destroy)(void* userData); + + /// Configure/reconfigure the swap chain. + DawnSwapChainError (*Configure)(void* userData, + WGPUTextureFormat format, + WGPUTextureUsage allowedUsage, + uint32_t width, + uint32_t height); + + /// Acquire the next texture from the swap chain. + DawnSwapChainError (*GetNextTexture)(void* userData, DawnSwapChainNextTexture* nextTexture); + + /// Present the last acquired texture to the screen. + DawnSwapChainError (*Present)(void* userData); + + /// Each function is called with userData as its first argument. + void* userData; + + /// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture. + WGPUTextureUsage textureUsage; +} DawnSwapChainImplementation; + +#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus) +typedef struct { + WGPUDevice device = nullptr; +} DawnWSIContextD3D12; +#endif + +#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__) +# import + +typedef struct { + id device = nil; + id queue = nil; +} DawnWSIContextMetal; +#endif + +#ifdef DAWN_ENABLE_BACKEND_OPENGL +typedef struct { +} DawnWSIContextGL; +#endif + +#ifdef DAWN_ENABLE_BACKEND_VULKAN +typedef struct { +} DawnWSIContextVulkan; +#endif + +#endif // DAWN_DAWN_WSI_H diff --git a/3rdparty/include/webgpu/include/dawn/webgpu.h b/3rdparty/include/webgpu/include/dawn/webgpu.h new file mode 100644 index 000000000000..36941b3a1d1c --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn/webgpu.h @@ -0,0 +1,1195 @@ +// BSD 3-Clause License +// +// Copyright (c) 2019, "WebGPU native" developers +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifndef WEBGPU_H_ +#define WEBGPU_H_ + +#if defined(WGPU_SHARED_LIBRARY) +# if defined(_WIN32) +# if defined(WGPU_IMPLEMENTATION) +# define WGPU_EXPORT __declspec(dllexport) +# else +# define WGPU_EXPORT __declspec(dllimport) +# endif +# else // defined(_WIN32) +# if defined(WGPU_IMPLEMENTATION) +# define WGPU_EXPORT __attribute__((visibility("default"))) +# else +# define WGPU_EXPORT +# endif +# endif // defined(_WIN32) +#else // defined(WGPU_SHARED_LIBRARY) +# define WGPU_EXPORT +#endif // defined(WGPU_SHARED_LIBRARY) + +#include +#include +#include + +#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) + +typedef uint32_t WGPUFlags; + +typedef struct WGPUBindGroupImpl* WGPUBindGroup; +typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout; +typedef struct WGPUBufferImpl* WGPUBuffer; +typedef struct WGPUCommandBufferImpl* WGPUCommandBuffer; +typedef struct WGPUCommandEncoderImpl* WGPUCommandEncoder; +typedef struct WGPUComputePassEncoderImpl* WGPUComputePassEncoder; +typedef struct WGPUComputePipelineImpl* WGPUComputePipeline; +typedef struct WGPUDeviceImpl* WGPUDevice; +typedef struct WGPUFenceImpl* WGPUFence; +typedef struct WGPUInstanceImpl* WGPUInstance; +typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout; +typedef struct WGPUQueueImpl* WGPUQueue; +typedef struct WGPURenderBundleImpl* WGPURenderBundle; +typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder; +typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder; +typedef struct WGPURenderPipelineImpl* WGPURenderPipeline; +typedef struct WGPUSamplerImpl* WGPUSampler; +typedef struct WGPUShaderModuleImpl* WGPUShaderModule; +typedef struct WGPUSurfaceImpl* WGPUSurface; +typedef struct WGPUSwapChainImpl* WGPUSwapChain; +typedef struct WGPUTextureImpl* WGPUTexture; +typedef struct WGPUTextureViewImpl* WGPUTextureView; + +typedef enum WGPUAdapterType { + WGPUAdapterType_DiscreteGPU = 0x00000000, + WGPUAdapterType_IntegratedGPU = 0x00000001, + WGPUAdapterType_CPU = 0x00000002, + WGPUAdapterType_Unknown = 0x00000003, + WGPUAdapterType_Force32 = 0x7FFFFFFF +} WGPUAdapterType; + +typedef enum WGPUAddressMode { + WGPUAddressMode_Repeat = 0x00000000, + WGPUAddressMode_MirrorRepeat = 0x00000001, + WGPUAddressMode_ClampToEdge = 0x00000002, + WGPUAddressMode_Force32 = 0x7FFFFFFF +} WGPUAddressMode; + +typedef enum WGPUBackendType { + WGPUBackendType_Null = 0x00000000, + WGPUBackendType_D3D11 = 0x00000001, + WGPUBackendType_D3D12 = 0x00000002, + WGPUBackendType_Metal = 0x00000003, + WGPUBackendType_Vulkan = 0x00000004, + WGPUBackendType_OpenGL = 0x00000005, + WGPUBackendType_OpenGLES = 0x00000006, + WGPUBackendType_Force32 = 0x7FFFFFFF +} WGPUBackendType; + +typedef enum WGPUBindingType { + WGPUBindingType_UniformBuffer = 0x00000000, + WGPUBindingType_StorageBuffer = 0x00000001, + WGPUBindingType_ReadonlyStorageBuffer = 0x00000002, + WGPUBindingType_Sampler = 0x00000003, + WGPUBindingType_ComparisonSampler = 0x00000004, + WGPUBindingType_SampledTexture = 0x00000005, + WGPUBindingType_StorageTexture = 0x00000006, + WGPUBindingType_ReadonlyStorageTexture = 0x00000007, + WGPUBindingType_WriteonlyStorageTexture = 0x00000008, + WGPUBindingType_Force32 = 0x7FFFFFFF +} WGPUBindingType; + +typedef enum WGPUBlendFactor { + WGPUBlendFactor_Zero = 0x00000000, + WGPUBlendFactor_One = 0x00000001, + WGPUBlendFactor_SrcColor = 0x00000002, + WGPUBlendFactor_OneMinusSrcColor = 0x00000003, + WGPUBlendFactor_SrcAlpha = 0x00000004, + WGPUBlendFactor_OneMinusSrcAlpha = 0x00000005, + WGPUBlendFactor_DstColor = 0x00000006, + WGPUBlendFactor_OneMinusDstColor = 0x00000007, + WGPUBlendFactor_DstAlpha = 0x00000008, + WGPUBlendFactor_OneMinusDstAlpha = 0x00000009, + WGPUBlendFactor_SrcAlphaSaturated = 0x0000000A, + WGPUBlendFactor_BlendColor = 0x0000000B, + WGPUBlendFactor_OneMinusBlendColor = 0x0000000C, + WGPUBlendFactor_Force32 = 0x7FFFFFFF +} WGPUBlendFactor; + +typedef enum WGPUBlendOperation { + WGPUBlendOperation_Add = 0x00000000, + WGPUBlendOperation_Subtract = 0x00000001, + WGPUBlendOperation_ReverseSubtract = 0x00000002, + WGPUBlendOperation_Min = 0x00000003, + WGPUBlendOperation_Max = 0x00000004, + WGPUBlendOperation_Force32 = 0x7FFFFFFF +} WGPUBlendOperation; + +typedef enum WGPUBufferMapAsyncStatus { + WGPUBufferMapAsyncStatus_Success = 0x00000000, + WGPUBufferMapAsyncStatus_Error = 0x00000001, + WGPUBufferMapAsyncStatus_Unknown = 0x00000002, + WGPUBufferMapAsyncStatus_DeviceLost = 0x00000003, + WGPUBufferMapAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUBufferMapAsyncStatus; + +typedef enum WGPUCompareFunction { + WGPUCompareFunction_Undefined = 0x00000000, + WGPUCompareFunction_Never = 0x00000001, + WGPUCompareFunction_Less = 0x00000002, + WGPUCompareFunction_LessEqual = 0x00000003, + WGPUCompareFunction_Greater = 0x00000004, + WGPUCompareFunction_GreaterEqual = 0x00000005, + WGPUCompareFunction_Equal = 0x00000006, + WGPUCompareFunction_NotEqual = 0x00000007, + WGPUCompareFunction_Always = 0x00000008, + WGPUCompareFunction_Force32 = 0x7FFFFFFF +} WGPUCompareFunction; + +typedef enum WGPUCullMode { + WGPUCullMode_None = 0x00000000, + WGPUCullMode_Front = 0x00000001, + WGPUCullMode_Back = 0x00000002, + WGPUCullMode_Force32 = 0x7FFFFFFF +} WGPUCullMode; + +typedef enum WGPUErrorFilter { + WGPUErrorFilter_None = 0x00000000, + WGPUErrorFilter_Validation = 0x00000001, + WGPUErrorFilter_OutOfMemory = 0x00000002, + WGPUErrorFilter_Force32 = 0x7FFFFFFF +} WGPUErrorFilter; + +typedef enum WGPUErrorType { + WGPUErrorType_NoError = 0x00000000, + WGPUErrorType_Validation = 0x00000001, + WGPUErrorType_OutOfMemory = 0x00000002, + WGPUErrorType_Unknown = 0x00000003, + WGPUErrorType_DeviceLost = 0x00000004, + WGPUErrorType_Force32 = 0x7FFFFFFF +} WGPUErrorType; + +typedef enum WGPUFenceCompletionStatus { + WGPUFenceCompletionStatus_Success = 0x00000000, + WGPUFenceCompletionStatus_Error = 0x00000001, + WGPUFenceCompletionStatus_Unknown = 0x00000002, + WGPUFenceCompletionStatus_DeviceLost = 0x00000003, + WGPUFenceCompletionStatus_Force32 = 0x7FFFFFFF +} WGPUFenceCompletionStatus; + +typedef enum WGPUFilterMode { + WGPUFilterMode_Nearest = 0x00000000, + WGPUFilterMode_Linear = 0x00000001, + WGPUFilterMode_Force32 = 0x7FFFFFFF +} WGPUFilterMode; + +typedef enum WGPUFrontFace { + WGPUFrontFace_CCW = 0x00000000, + WGPUFrontFace_CW = 0x00000001, + WGPUFrontFace_Force32 = 0x7FFFFFFF +} WGPUFrontFace; + +typedef enum WGPUIndexFormat { + WGPUIndexFormat_Uint16 = 0x00000000, + WGPUIndexFormat_Uint32 = 0x00000001, + WGPUIndexFormat_Force32 = 0x7FFFFFFF +} WGPUIndexFormat; + +typedef enum WGPUInputStepMode { + WGPUInputStepMode_Vertex = 0x00000000, + WGPUInputStepMode_Instance = 0x00000001, + WGPUInputStepMode_Force32 = 0x7FFFFFFF +} WGPUInputStepMode; + +typedef enum WGPULoadOp { + WGPULoadOp_Clear = 0x00000000, + WGPULoadOp_Load = 0x00000001, + WGPULoadOp_Force32 = 0x7FFFFFFF +} WGPULoadOp; + +typedef enum WGPUPresentMode { + WGPUPresentMode_Immediate = 0x00000000, + WGPUPresentMode_Mailbox = 0x00000001, + WGPUPresentMode_Fifo = 0x00000002, + WGPUPresentMode_Force32 = 0x7FFFFFFF +} WGPUPresentMode; + +typedef enum WGPUPrimitiveTopology { + WGPUPrimitiveTopology_PointList = 0x00000000, + WGPUPrimitiveTopology_LineList = 0x00000001, + WGPUPrimitiveTopology_LineStrip = 0x00000002, + WGPUPrimitiveTopology_TriangleList = 0x00000003, + WGPUPrimitiveTopology_TriangleStrip = 0x00000004, + WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF +} WGPUPrimitiveTopology; + +typedef enum WGPUSType { + WGPUSType_Invalid = 0x00000000, + WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, + WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, + WGPUSType_SurfaceDescriptorFromXlib = 0x00000003, + WGPUSType_SurfaceDescriptorFromHTMLCanvasId = 0x00000004, + WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, + WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, + WGPUSType_SamplerDescriptorDummyAnisotropicFiltering = 0x00000007, + WGPUSType_RenderPipelineDescriptorDummyExtension = 0x00000008, + WGPUSType_Force32 = 0x7FFFFFFF +} WGPUSType; + +typedef enum WGPUStencilOperation { + WGPUStencilOperation_Keep = 0x00000000, + WGPUStencilOperation_Zero = 0x00000001, + WGPUStencilOperation_Replace = 0x00000002, + WGPUStencilOperation_Invert = 0x00000003, + WGPUStencilOperation_IncrementClamp = 0x00000004, + WGPUStencilOperation_DecrementClamp = 0x00000005, + WGPUStencilOperation_IncrementWrap = 0x00000006, + WGPUStencilOperation_DecrementWrap = 0x00000007, + WGPUStencilOperation_Force32 = 0x7FFFFFFF +} WGPUStencilOperation; + +typedef enum WGPUStoreOp { + WGPUStoreOp_Store = 0x00000000, + WGPUStoreOp_Clear = 0x00000001, + WGPUStoreOp_Force32 = 0x7FFFFFFF +} WGPUStoreOp; + +typedef enum WGPUTextureAspect { + WGPUTextureAspect_All = 0x00000000, + WGPUTextureAspect_StencilOnly = 0x00000001, + WGPUTextureAspect_DepthOnly = 0x00000002, + WGPUTextureAspect_Force32 = 0x7FFFFFFF +} WGPUTextureAspect; + +typedef enum WGPUTextureComponentType { + WGPUTextureComponentType_Float = 0x00000000, + WGPUTextureComponentType_Sint = 0x00000001, + WGPUTextureComponentType_Uint = 0x00000002, + WGPUTextureComponentType_Force32 = 0x7FFFFFFF +} WGPUTextureComponentType; + +typedef enum WGPUTextureDimension { + WGPUTextureDimension_1D = 0x00000000, + WGPUTextureDimension_2D = 0x00000001, + WGPUTextureDimension_3D = 0x00000002, + WGPUTextureDimension_Force32 = 0x7FFFFFFF +} WGPUTextureDimension; + +typedef enum WGPUTextureFormat { + 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_RGB10A2Unorm = 0x00000019, + WGPUTextureFormat_RG11B10Float = 0x0000001A, + WGPUTextureFormat_RG32Float = 0x0000001B, + WGPUTextureFormat_RG32Uint = 0x0000001C, + WGPUTextureFormat_RG32Sint = 0x0000001D, + WGPUTextureFormat_RGBA16Uint = 0x0000001E, + WGPUTextureFormat_RGBA16Sint = 0x0000001F, + WGPUTextureFormat_RGBA16Float = 0x00000020, + WGPUTextureFormat_RGBA32Float = 0x00000021, + WGPUTextureFormat_RGBA32Uint = 0x00000022, + WGPUTextureFormat_RGBA32Sint = 0x00000023, + WGPUTextureFormat_Depth32Float = 0x00000024, + WGPUTextureFormat_Depth24Plus = 0x00000025, + WGPUTextureFormat_Depth24PlusStencil8 = 0x00000026, + WGPUTextureFormat_BC1RGBAUnorm = 0x00000027, + WGPUTextureFormat_BC1RGBAUnormSrgb = 0x00000028, + WGPUTextureFormat_BC2RGBAUnorm = 0x00000029, + WGPUTextureFormat_BC2RGBAUnormSrgb = 0x0000002A, + WGPUTextureFormat_BC3RGBAUnorm = 0x0000002B, + WGPUTextureFormat_BC3RGBAUnormSrgb = 0x0000002C, + WGPUTextureFormat_BC4RUnorm = 0x0000002D, + WGPUTextureFormat_BC4RSnorm = 0x0000002E, + WGPUTextureFormat_BC5RGUnorm = 0x0000002F, + WGPUTextureFormat_BC5RGSnorm = 0x00000030, + WGPUTextureFormat_BC6HRGBUfloat = 0x00000031, + WGPUTextureFormat_BC6HRGBSfloat = 0x00000032, + WGPUTextureFormat_BC7RGBAUnorm = 0x00000033, + WGPUTextureFormat_BC7RGBAUnormSrgb = 0x00000034, + WGPUTextureFormat_Force32 = 0x7FFFFFFF +} WGPUTextureFormat; + +typedef enum WGPUTextureViewDimension { + WGPUTextureViewDimension_Undefined = 0x00000000, + WGPUTextureViewDimension_1D = 0x00000001, + WGPUTextureViewDimension_2D = 0x00000002, + WGPUTextureViewDimension_2DArray = 0x00000003, + WGPUTextureViewDimension_Cube = 0x00000004, + WGPUTextureViewDimension_CubeArray = 0x00000005, + WGPUTextureViewDimension_3D = 0x00000006, + WGPUTextureViewDimension_Force32 = 0x7FFFFFFF +} WGPUTextureViewDimension; + +typedef enum WGPUVertexFormat { + WGPUVertexFormat_UChar2 = 0x00000000, + WGPUVertexFormat_UChar4 = 0x00000001, + WGPUVertexFormat_Char2 = 0x00000002, + WGPUVertexFormat_Char4 = 0x00000003, + WGPUVertexFormat_UChar2Norm = 0x00000004, + WGPUVertexFormat_UChar4Norm = 0x00000005, + WGPUVertexFormat_Char2Norm = 0x00000006, + WGPUVertexFormat_Char4Norm = 0x00000007, + WGPUVertexFormat_UShort2 = 0x00000008, + WGPUVertexFormat_UShort4 = 0x00000009, + WGPUVertexFormat_Short2 = 0x0000000A, + WGPUVertexFormat_Short4 = 0x0000000B, + WGPUVertexFormat_UShort2Norm = 0x0000000C, + WGPUVertexFormat_UShort4Norm = 0x0000000D, + WGPUVertexFormat_Short2Norm = 0x0000000E, + WGPUVertexFormat_Short4Norm = 0x0000000F, + WGPUVertexFormat_Half2 = 0x00000010, + WGPUVertexFormat_Half4 = 0x00000011, + WGPUVertexFormat_Float = 0x00000012, + WGPUVertexFormat_Float2 = 0x00000013, + WGPUVertexFormat_Float3 = 0x00000014, + WGPUVertexFormat_Float4 = 0x00000015, + WGPUVertexFormat_UInt = 0x00000016, + WGPUVertexFormat_UInt2 = 0x00000017, + WGPUVertexFormat_UInt3 = 0x00000018, + WGPUVertexFormat_UInt4 = 0x00000019, + WGPUVertexFormat_Int = 0x0000001A, + WGPUVertexFormat_Int2 = 0x0000001B, + WGPUVertexFormat_Int3 = 0x0000001C, + WGPUVertexFormat_Int4 = 0x0000001D, + WGPUVertexFormat_Force32 = 0x7FFFFFFF +} WGPUVertexFormat; + +typedef enum WGPUBufferUsage { + WGPUBufferUsage_None = 0x00000000, + WGPUBufferUsage_MapRead = 0x00000001, + WGPUBufferUsage_MapWrite = 0x00000002, + WGPUBufferUsage_CopySrc = 0x00000004, + WGPUBufferUsage_CopyDst = 0x00000008, + WGPUBufferUsage_Index = 0x00000010, + WGPUBufferUsage_Vertex = 0x00000020, + WGPUBufferUsage_Uniform = 0x00000040, + WGPUBufferUsage_Storage = 0x00000080, + WGPUBufferUsage_Indirect = 0x00000100, + WGPUBufferUsage_Force32 = 0x7FFFFFFF +} WGPUBufferUsage; +typedef WGPUFlags WGPUBufferUsageFlags; + +typedef enum WGPUColorWriteMask { + WGPUColorWriteMask_None = 0x00000000, + WGPUColorWriteMask_Red = 0x00000001, + WGPUColorWriteMask_Green = 0x00000002, + WGPUColorWriteMask_Blue = 0x00000004, + WGPUColorWriteMask_Alpha = 0x00000008, + WGPUColorWriteMask_All = 0x0000000F, + WGPUColorWriteMask_Force32 = 0x7FFFFFFF +} WGPUColorWriteMask; +typedef WGPUFlags WGPUColorWriteMaskFlags; + +typedef enum WGPUShaderStage { + WGPUShaderStage_None = 0x00000000, + WGPUShaderStage_Vertex = 0x00000001, + WGPUShaderStage_Fragment = 0x00000002, + WGPUShaderStage_Compute = 0x00000004, + WGPUShaderStage_Force32 = 0x7FFFFFFF +} WGPUShaderStage; +typedef WGPUFlags WGPUShaderStageFlags; + +typedef enum WGPUTextureUsage { + WGPUTextureUsage_None = 0x00000000, + WGPUTextureUsage_CopySrc = 0x00000001, + WGPUTextureUsage_CopyDst = 0x00000002, + WGPUTextureUsage_Sampled = 0x00000004, + WGPUTextureUsage_Storage = 0x00000008, + WGPUTextureUsage_OutputAttachment = 0x00000010, + WGPUTextureUsage_Present = 0x00000020, + WGPUTextureUsage_Force32 = 0x7FFFFFFF +} WGPUTextureUsage; +typedef WGPUFlags WGPUTextureUsageFlags; + + +typedef struct WGPUChainedStruct { + struct WGPUChainedStruct const * next; + WGPUSType sType; +} WGPUChainedStruct; + +typedef struct WGPUAdapterProperties { + WGPUChainedStruct const * nextInChain; + uint32_t deviceID; + uint32_t vendorID; + char const * name; + WGPUAdapterType adapterType; + WGPUBackendType backendType; +} WGPUAdapterProperties; + +typedef struct WGPUBindGroupEntry { + uint32_t binding; + WGPUBuffer buffer; + uint64_t offset; + uint64_t size; + WGPUSampler sampler; + WGPUTextureView textureView; +} WGPUBindGroupEntry; + +typedef struct WGPUBindGroupLayoutEntry { + uint32_t binding; + WGPUShaderStageFlags visibility; + WGPUBindingType type; + bool hasDynamicOffset; + bool multisampled; + WGPUTextureViewDimension viewDimension; + WGPUTextureComponentType textureComponentType; + WGPUTextureFormat storageTextureFormat; +} WGPUBindGroupLayoutEntry; + +typedef struct WGPUBlendDescriptor { + WGPUBlendOperation operation; + WGPUBlendFactor srcFactor; + WGPUBlendFactor dstFactor; +} WGPUBlendDescriptor; + +typedef struct WGPUBufferCopyView { + WGPUChainedStruct const * nextInChain; + WGPUBuffer buffer; + uint64_t offset; + uint32_t bytesPerRow; + uint32_t rowsPerImage; +} WGPUBufferCopyView; + +typedef struct WGPUBufferDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUBufferUsageFlags usage; + uint64_t size; +} WGPUBufferDescriptor; + +typedef struct WGPUColor { + float r; + float g; + float b; + float a; +} WGPUColor; + +typedef struct WGPUCommandBufferDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; +} WGPUCommandBufferDescriptor; + +typedef struct WGPUCommandEncoderDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; +} WGPUCommandEncoderDescriptor; + +typedef struct WGPUComputePassDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; +} WGPUComputePassDescriptor; + +typedef struct WGPUCreateBufferMappedResult { + WGPUBuffer buffer; + uint64_t dataLength; + void * data; +} WGPUCreateBufferMappedResult; + +typedef struct WGPUDeviceProperties { + bool textureCompressionBC; + bool shaderFloat16; + bool pipelineStatisticsQuery; + bool timestampQuery; +} WGPUDeviceProperties; + +typedef struct WGPUExtent3D { + uint32_t width; + uint32_t height; + uint32_t depth; +} WGPUExtent3D; + +typedef struct WGPUFenceDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + uint64_t initialValue; +} WGPUFenceDescriptor; + +typedef struct WGPUInstanceDescriptor { + WGPUChainedStruct const * nextInChain; +} WGPUInstanceDescriptor; + +typedef struct WGPUOrigin3D { + uint32_t x; + uint32_t y; + uint32_t z; +} WGPUOrigin3D; + +typedef struct WGPUPipelineLayoutDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + uint32_t bindGroupLayoutCount; + WGPUBindGroupLayout const * bindGroupLayouts; +} WGPUPipelineLayoutDescriptor; + +typedef struct WGPUProgrammableStageDescriptor { + WGPUChainedStruct const * nextInChain; + WGPUShaderModule module; + char const * entryPoint; +} WGPUProgrammableStageDescriptor; + +typedef struct WGPURasterizationStateDescriptor { + WGPUChainedStruct const * nextInChain; + WGPUFrontFace frontFace; + WGPUCullMode cullMode; + int32_t depthBias; + float depthBiasSlopeScale; + float depthBiasClamp; +} WGPURasterizationStateDescriptor; + +typedef struct WGPURenderBundleDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; +} WGPURenderBundleDescriptor; + +typedef struct WGPURenderBundleEncoderDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + uint32_t colorFormatsCount; + WGPUTextureFormat const * colorFormats; + WGPUTextureFormat depthStencilFormat; + uint32_t sampleCount; +} WGPURenderBundleEncoderDescriptor; + +typedef struct WGPURenderPassDepthStencilAttachmentDescriptor { + WGPUTextureView attachment; + WGPULoadOp depthLoadOp; + WGPUStoreOp depthStoreOp; + float clearDepth; + WGPULoadOp stencilLoadOp; + WGPUStoreOp stencilStoreOp; + uint32_t clearStencil; +} WGPURenderPassDepthStencilAttachmentDescriptor; + +typedef struct WGPUSamplerDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUAddressMode addressModeU; + WGPUAddressMode addressModeV; + WGPUAddressMode addressModeW; + WGPUFilterMode magFilter; + WGPUFilterMode minFilter; + WGPUFilterMode mipmapFilter; + float lodMinClamp; + float lodMaxClamp; + WGPUCompareFunction compare; +} WGPUSamplerDescriptor; + +typedef struct WGPUSamplerDescriptorDummyAnisotropicFiltering { + WGPUChainedStruct chain; + float maxAnisotropy; +} WGPUSamplerDescriptorDummyAnisotropicFiltering; + +typedef struct WGPUShaderModuleDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; +} WGPUShaderModuleDescriptor; + +typedef struct WGPUShaderModuleSPIRVDescriptor { + WGPUChainedStruct chain; + uint32_t codeSize; + uint32_t const * code; +} WGPUShaderModuleSPIRVDescriptor; + +typedef struct WGPUShaderModuleWGSLDescriptor { + WGPUChainedStruct chain; + char const * source; +} WGPUShaderModuleWGSLDescriptor; + +typedef struct WGPUStencilStateFaceDescriptor { + WGPUCompareFunction compare; + WGPUStencilOperation failOp; + WGPUStencilOperation depthFailOp; + WGPUStencilOperation passOp; +} WGPUStencilStateFaceDescriptor; + +typedef struct WGPUSurfaceDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; +} WGPUSurfaceDescriptor; + +typedef struct WGPUSurfaceDescriptorFromHTMLCanvasId { + WGPUChainedStruct chain; + char const * id; +} WGPUSurfaceDescriptorFromHTMLCanvasId; + +typedef struct WGPUSurfaceDescriptorFromMetalLayer { + WGPUChainedStruct chain; + void * layer; +} WGPUSurfaceDescriptorFromMetalLayer; + +typedef struct WGPUSurfaceDescriptorFromWindowsHWND { + WGPUChainedStruct chain; + void * hinstance; + void * hwnd; +} WGPUSurfaceDescriptorFromWindowsHWND; + +typedef struct WGPUSurfaceDescriptorFromXlib { + WGPUChainedStruct chain; + void * display; + uint32_t window; +} WGPUSurfaceDescriptorFromXlib; + +typedef struct WGPUSwapChainDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUTextureUsageFlags usage; + WGPUTextureFormat format; + uint32_t width; + uint32_t height; + WGPUPresentMode presentMode; + uint64_t implementation; +} WGPUSwapChainDescriptor; + +typedef struct WGPUTextureViewDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUTextureFormat format; + WGPUTextureViewDimension dimension; + uint32_t baseMipLevel; + uint32_t mipLevelCount; + uint32_t baseArrayLayer; + uint32_t arrayLayerCount; + WGPUTextureAspect aspect; +} WGPUTextureViewDescriptor; + +typedef struct WGPUVertexAttributeDescriptor { + WGPUVertexFormat format; + uint64_t offset; + uint32_t shaderLocation; +} WGPUVertexAttributeDescriptor; + +typedef struct WGPUBindGroupDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUBindGroupLayout layout; + uint32_t entryCount; + WGPUBindGroupEntry const * entries; +} WGPUBindGroupDescriptor; + +typedef struct WGPUBindGroupLayoutDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + uint32_t entryCount; + WGPUBindGroupLayoutEntry const * entries; +} WGPUBindGroupLayoutDescriptor; + +typedef struct WGPUColorStateDescriptor { + WGPUChainedStruct const * nextInChain; + WGPUTextureFormat format; + WGPUBlendDescriptor alphaBlend; + WGPUBlendDescriptor colorBlend; + WGPUColorWriteMaskFlags writeMask; +} WGPUColorStateDescriptor; + +typedef struct WGPUComputePipelineDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUPipelineLayout layout; + WGPUProgrammableStageDescriptor computeStage; +} WGPUComputePipelineDescriptor; + +typedef struct WGPUDepthStencilStateDescriptor { + WGPUChainedStruct const * nextInChain; + WGPUTextureFormat format; + bool depthWriteEnabled; + WGPUCompareFunction depthCompare; + WGPUStencilStateFaceDescriptor stencilFront; + WGPUStencilStateFaceDescriptor stencilBack; + uint32_t stencilReadMask; + uint32_t stencilWriteMask; +} WGPUDepthStencilStateDescriptor; + +typedef struct WGPURenderPassColorAttachmentDescriptor { + WGPUTextureView attachment; + WGPUTextureView resolveTarget; + WGPULoadOp loadOp; + WGPUStoreOp storeOp; + WGPUColor clearColor; +} WGPURenderPassColorAttachmentDescriptor; + +typedef struct WGPURenderPipelineDescriptorDummyExtension { + WGPUChainedStruct chain; + WGPUProgrammableStageDescriptor dummyStage; +} WGPURenderPipelineDescriptorDummyExtension; + +typedef struct WGPUTextureCopyView { + WGPUChainedStruct const * nextInChain; + WGPUTexture texture; + uint32_t mipLevel; + uint32_t arrayLayer; + WGPUOrigin3D origin; +} WGPUTextureCopyView; + +typedef struct WGPUTextureDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUTextureUsageFlags usage; + WGPUTextureDimension dimension; + WGPUExtent3D size; + uint32_t arrayLayerCount; + WGPUTextureFormat format; + uint32_t mipLevelCount; + uint32_t sampleCount; +} WGPUTextureDescriptor; + +typedef struct WGPUVertexBufferLayoutDescriptor { + uint64_t arrayStride; + WGPUInputStepMode stepMode; + uint32_t attributeCount; + WGPUVertexAttributeDescriptor const * attributes; +} WGPUVertexBufferLayoutDescriptor; + +typedef struct WGPURenderPassDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + uint32_t colorAttachmentCount; + WGPURenderPassColorAttachmentDescriptor const * colorAttachments; + WGPURenderPassDepthStencilAttachmentDescriptor const * depthStencilAttachment; +} WGPURenderPassDescriptor; + +typedef struct WGPUVertexStateDescriptor { + WGPUChainedStruct const * nextInChain; + WGPUIndexFormat indexFormat; + uint32_t vertexBufferCount; + WGPUVertexBufferLayoutDescriptor const * vertexBuffers; +} WGPUVertexStateDescriptor; + +typedef struct WGPURenderPipelineDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUPipelineLayout layout; + WGPUProgrammableStageDescriptor vertexStage; + WGPUProgrammableStageDescriptor const * fragmentStage; + WGPUVertexStateDescriptor const * vertexState; + WGPUPrimitiveTopology primitiveTopology; + WGPURasterizationStateDescriptor const * rasterizationState; + uint32_t sampleCount; + WGPUDepthStencilStateDescriptor const * depthStencilState; + uint32_t colorStateCount; + WGPUColorStateDescriptor const * colorStates; + uint32_t sampleMask; + bool alphaToCoverageEnabled; +} WGPURenderPipelineDescriptor; + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, void const * data, uint64_t dataLength, void * userdata); +typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, void * data, uint64_t dataLength, void * userdata); +typedef void (*WGPUDeviceLostCallback)(char const * message, void * userdata); +typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata); +typedef void (*WGPUFenceOnCompletionCallback)(WGPUFenceCompletionStatus status, void * userdata); + +typedef void (*WGPUProc)(void); + +#if !defined(WGPU_SKIP_PROCS) + +typedef WGPUInstance (*WGPUProcCreateInstance)(WGPUInstanceDescriptor const * descriptor); +typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName); + +// Procs of BindGroup +typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup); +typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup); + +// Procs of BindGroupLayout +typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout); +typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout); + +// Procs of Buffer +typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer); +typedef void (*WGPUProcBufferMapReadAsync)(WGPUBuffer buffer, WGPUBufferMapReadCallback callback, void * userdata); +typedef void (*WGPUProcBufferMapWriteAsync)(WGPUBuffer buffer, WGPUBufferMapWriteCallback callback, void * userdata); +typedef void (*WGPUProcBufferSetSubData)(WGPUBuffer buffer, uint64_t start, uint64_t count, void const * data); +typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer); +typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer); +typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer); + +// Procs of CommandBuffer +typedef void (*WGPUProcCommandBufferReference)(WGPUCommandBuffer commandBuffer); +typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer); + +// Procs of CommandEncoder +typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor); +typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor); +typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size); +typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUBufferCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize); +typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUBufferCopyView const * destination, WGPUExtent3D const * copySize); +typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize); +typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor); +typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * groupLabel); +typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder); +typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel); +typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder); +typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder); + +// Procs of ComputePassEncoder +typedef void (*WGPUProcComputePassEncoderDispatch)(WGPUComputePassEncoder computePassEncoder, uint32_t x, uint32_t y, uint32_t z); +typedef void (*WGPUProcComputePassEncoderDispatchIndirect)(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef void (*WGPUProcComputePassEncoderEndPass)(WGPUComputePassEncoder computePassEncoder); +typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel); +typedef void (*WGPUProcComputePassEncoderPopDebugGroup)(WGPUComputePassEncoder computePassEncoder); +typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel); +typedef void (*WGPUProcComputePassEncoderSetBindGroup)(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); +typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline); +typedef void (*WGPUProcComputePassEncoderReference)(WGPUComputePassEncoder computePassEncoder); +typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder); + +// Procs of ComputePipeline +typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex); +typedef void (*WGPUProcComputePipelineReference)(WGPUComputePipeline computePipeline); +typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline); + +// Procs of Device +typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor); +typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor); +typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor); +typedef WGPUCreateBufferMappedResult (*WGPUProcDeviceCreateBufferMapped)(WGPUDevice device, WGPUBufferDescriptor const * descriptor); +typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor); +typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor); +typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); +typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); +typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); +typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPUSamplerDescriptor const * descriptor); +typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor); +typedef WGPUSwapChain (*WGPUProcDeviceCreateSwapChain)(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor); +typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor); +typedef WGPUQueue (*WGPUProcDeviceGetDefaultQueue)(WGPUDevice device); +typedef void (*WGPUProcDeviceInjectError)(WGPUDevice device, WGPUErrorType type, char const * message); +typedef void (*WGPUProcDeviceLoseForTesting)(WGPUDevice device); +typedef bool (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata); +typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter); +typedef void (*WGPUProcDeviceSetDeviceLostCallback)(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata); +typedef void (*WGPUProcDeviceSetUncapturedErrorCallback)(WGPUDevice device, WGPUErrorCallback callback, void * userdata); +typedef void (*WGPUProcDeviceTick)(WGPUDevice device); +typedef void (*WGPUProcDeviceReference)(WGPUDevice device); +typedef void (*WGPUProcDeviceRelease)(WGPUDevice device); + +// Procs of Fence +typedef uint64_t (*WGPUProcFenceGetCompletedValue)(WGPUFence fence); +typedef void (*WGPUProcFenceOnCompletion)(WGPUFence fence, uint64_t value, WGPUFenceOnCompletionCallback callback, void * userdata); +typedef void (*WGPUProcFenceReference)(WGPUFence fence); +typedef void (*WGPUProcFenceRelease)(WGPUFence fence); + +// Procs of Instance +typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); +typedef void (*WGPUProcInstanceReference)(WGPUInstance instance); +typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance); + +// Procs of PipelineLayout +typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout); +typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout); + +// Procs of Queue +typedef WGPUFence (*WGPUProcQueueCreateFence)(WGPUQueue queue, WGPUFenceDescriptor const * descriptor); +typedef void (*WGPUProcQueueSignal)(WGPUQueue queue, WGPUFence fence, uint64_t signalValue); +typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands); +typedef void (*WGPUProcQueueReference)(WGPUQueue queue); +typedef void (*WGPUProcQueueRelease)(WGPUQueue queue); + +// Procs of RenderBundle +typedef void (*WGPUProcRenderBundleReference)(WGPURenderBundle renderBundle); +typedef void (*WGPUProcRenderBundleRelease)(WGPURenderBundle renderBundle); + +// Procs of RenderBundleEncoder +typedef void (*WGPUProcRenderBundleEncoderDraw)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +typedef void (*WGPUProcRenderBundleEncoderDrawIndexed)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); +typedef void (*WGPUProcRenderBundleEncoderDrawIndexedIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef void (*WGPUProcRenderBundleEncoderDrawIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef WGPURenderBundle (*WGPUProcRenderBundleEncoderFinish)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor); +typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); +typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder); +typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); +typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); +typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); +typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline); +typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); +typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder renderBundleEncoder); +typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder); + +// Procs of RenderPassEncoder +typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); +typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef void (*WGPUProcRenderPassEncoderEndPass)(WGPURenderPassEncoder renderPassEncoder); +typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); +typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); +typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder renderPassEncoder); +typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); +typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); +typedef void (*WGPUProcRenderPassEncoderSetBlendColor)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color); +typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); +typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline); +typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height); +typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference); +typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); +typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth); +typedef void (*WGPUProcRenderPassEncoderReference)(WGPURenderPassEncoder renderPassEncoder); +typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder); + +// Procs of RenderPipeline +typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex); +typedef void (*WGPUProcRenderPipelineReference)(WGPURenderPipeline renderPipeline); +typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline); + +// Procs of Sampler +typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler); +typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler); + +// Procs of ShaderModule +typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule); +typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule); + +// Procs of Surface +typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface); +typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface); + +// Procs of SwapChain +typedef void (*WGPUProcSwapChainConfigure)(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height); +typedef WGPUTextureView (*WGPUProcSwapChainGetCurrentTextureView)(WGPUSwapChain swapChain); +typedef void (*WGPUProcSwapChainPresent)(WGPUSwapChain swapChain); +typedef void (*WGPUProcSwapChainReference)(WGPUSwapChain swapChain); +typedef void (*WGPUProcSwapChainRelease)(WGPUSwapChain swapChain); + +// Procs of Texture +typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor); +typedef void (*WGPUProcTextureDestroy)(WGPUTexture texture); +typedef void (*WGPUProcTextureReference)(WGPUTexture texture); +typedef void (*WGPUProcTextureRelease)(WGPUTexture texture); + +// Procs of TextureView +typedef void (*WGPUProcTextureViewReference)(WGPUTextureView textureView); +typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView); + +#endif // !defined(WGPU_SKIP_PROCS) + +#if !defined(WGPU_SKIP_DECLARATIONS) + +WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor); +WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName); + +// Methods of BindGroup +WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup); +WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup); + +// Methods of BindGroupLayout +WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout); +WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout); + +// Methods of Buffer +WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer); +WGPU_EXPORT void wgpuBufferMapReadAsync(WGPUBuffer buffer, WGPUBufferMapReadCallback callback, void * userdata); +WGPU_EXPORT void wgpuBufferMapWriteAsync(WGPUBuffer buffer, WGPUBufferMapWriteCallback callback, void * userdata); +WGPU_EXPORT void wgpuBufferSetSubData(WGPUBuffer buffer, uint64_t start, uint64_t count, void const * data); +WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer); +WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer); +WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer); + +// Methods of CommandBuffer +WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer); +WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer); + +// Methods of CommandEncoder +WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor); +WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor); +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size); +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUBufferCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize); +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUBufferCopyView const * destination, WGPUExtent3D const * copySize); +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize); +WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor); +WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder); +WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder); +WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder); + +// Methods of ComputePassEncoder +WGPU_EXPORT void wgpuComputePassEncoderDispatch(WGPUComputePassEncoder computePassEncoder, uint32_t x, uint32_t y, uint32_t z); +WGPU_EXPORT void wgpuComputePassEncoderDispatchIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT void wgpuComputePassEncoderEndPass(WGPUComputePassEncoder computePassEncoder); +WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder); +WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); +WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline); +WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder); +WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder); + +// Methods of ComputePipeline +WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex); +WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline); +WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline); + +// Methods of Device +WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor); +WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor); +WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor); +WGPU_EXPORT WGPUCreateBufferMappedResult wgpuDeviceCreateBufferMapped(WGPUDevice device, WGPUBufferDescriptor const * descriptor); +WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor); +WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor); +WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); +WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); +WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); +WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor); +WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor); +WGPU_EXPORT WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor); +WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor); +WGPU_EXPORT WGPUQueue wgpuDeviceGetDefaultQueue(WGPUDevice device); +WGPU_EXPORT void wgpuDeviceInjectError(WGPUDevice device, WGPUErrorType type, char const * message); +WGPU_EXPORT void wgpuDeviceLoseForTesting(WGPUDevice device); +WGPU_EXPORT bool wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata); +WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter); +WGPU_EXPORT void wgpuDeviceSetDeviceLostCallback(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata); +WGPU_EXPORT void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata); +WGPU_EXPORT void wgpuDeviceTick(WGPUDevice device); +WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device); +WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device); + +// Methods of Fence +WGPU_EXPORT uint64_t wgpuFenceGetCompletedValue(WGPUFence fence); +WGPU_EXPORT void wgpuFenceOnCompletion(WGPUFence fence, uint64_t value, WGPUFenceOnCompletionCallback callback, void * userdata); +WGPU_EXPORT void wgpuFenceReference(WGPUFence fence); +WGPU_EXPORT void wgpuFenceRelease(WGPUFence fence); + +// Methods of Instance +WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); +WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance); +WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance); + +// Methods of PipelineLayout +WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout); +WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout); + +// Methods of Queue +WGPU_EXPORT WGPUFence wgpuQueueCreateFence(WGPUQueue queue, WGPUFenceDescriptor const * descriptor); +WGPU_EXPORT void wgpuQueueSignal(WGPUQueue queue, WGPUFence fence, uint64_t signalValue); +WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands); +WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue); +WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue); + +// Methods of RenderBundle +WGPU_EXPORT void wgpuRenderBundleReference(WGPURenderBundle renderBundle); +WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle); + +// Methods of RenderBundleEncoder +WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); +WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor); +WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder); +WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); +WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); +WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline); +WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); +WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder); +WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder); + +// Methods of RenderPassEncoder +WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT void wgpuRenderPassEncoderEndPass(WGPURenderPassEncoder renderPassEncoder); +WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); +WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder); +WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); +WGPU_EXPORT void wgpuRenderPassEncoderSetBlendColor(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color); +WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); +WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline); +WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height); +WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference); +WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); +WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth); +WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder); +WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder); + +// Methods of RenderPipeline +WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex); +WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline); +WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline); + +// Methods of Sampler +WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler); +WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler); + +// Methods of ShaderModule +WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule); +WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule); + +// Methods of Surface +WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface); +WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface); + +// Methods of SwapChain +WGPU_EXPORT void wgpuSwapChainConfigure(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height); +WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain); +WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain); +WGPU_EXPORT void wgpuSwapChainReference(WGPUSwapChain swapChain); +WGPU_EXPORT void wgpuSwapChainRelease(WGPUSwapChain swapChain); + +// Methods of Texture +WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor); +WGPU_EXPORT void wgpuTextureDestroy(WGPUTexture texture); +WGPU_EXPORT void wgpuTextureReference(WGPUTexture texture); +WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture); + +// Methods of TextureView +WGPU_EXPORT void wgpuTextureViewReference(WGPUTextureView textureView); +WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView); + +#endif // !defined(WGPU_SKIP_DECLARATIONS) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBGPU_H_ diff --git a/3rdparty/include/webgpu/include/dawn/webgpu_cpp.h b/3rdparty/include/webgpu/include/dawn/webgpu_cpp.h new file mode 100644 index 000000000000..5b64fa6416f2 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn/webgpu_cpp.h @@ -0,0 +1,1262 @@ + +#ifndef WEBGPU_CPP_H_ +#define WEBGPU_CPP_H_ + +#include "webgpu.h" +#include "EnumClassBitmasks.h" + +namespace wgpu { + + static constexpr uint64_t kWholeSize = WGPU_WHOLE_SIZE; + + enum class AdapterType : uint32_t { + DiscreteGPU = 0x00000000, + IntegratedGPU = 0x00000001, + CPU = 0x00000002, + Unknown = 0x00000003, + }; + + enum class AddressMode : uint32_t { + Repeat = 0x00000000, + MirrorRepeat = 0x00000001, + ClampToEdge = 0x00000002, + }; + + enum class BackendType : uint32_t { + Null = 0x00000000, + D3D11 = 0x00000001, + D3D12 = 0x00000002, + Metal = 0x00000003, + Vulkan = 0x00000004, + OpenGL = 0x00000005, + OpenGLES = 0x00000006, + }; + + enum class BindingType : uint32_t { + UniformBuffer = 0x00000000, + StorageBuffer = 0x00000001, + ReadonlyStorageBuffer = 0x00000002, + Sampler = 0x00000003, + ComparisonSampler = 0x00000004, + SampledTexture = 0x00000005, + StorageTexture = 0x00000006, + ReadonlyStorageTexture = 0x00000007, + WriteonlyStorageTexture = 0x00000008, + }; + + enum class BlendFactor : uint32_t { + Zero = 0x00000000, + One = 0x00000001, + SrcColor = 0x00000002, + OneMinusSrcColor = 0x00000003, + SrcAlpha = 0x00000004, + OneMinusSrcAlpha = 0x00000005, + DstColor = 0x00000006, + OneMinusDstColor = 0x00000007, + DstAlpha = 0x00000008, + OneMinusDstAlpha = 0x00000009, + SrcAlphaSaturated = 0x0000000A, + BlendColor = 0x0000000B, + OneMinusBlendColor = 0x0000000C, + }; + + enum class BlendOperation : uint32_t { + Add = 0x00000000, + Subtract = 0x00000001, + ReverseSubtract = 0x00000002, + Min = 0x00000003, + Max = 0x00000004, + }; + + enum class BufferMapAsyncStatus : uint32_t { + Success = 0x00000000, + Error = 0x00000001, + Unknown = 0x00000002, + DeviceLost = 0x00000003, + }; + + enum class CompareFunction : uint32_t { + Undefined = 0x00000000, + Never = 0x00000001, + Less = 0x00000002, + LessEqual = 0x00000003, + Greater = 0x00000004, + GreaterEqual = 0x00000005, + Equal = 0x00000006, + NotEqual = 0x00000007, + Always = 0x00000008, + }; + + enum class CullMode : uint32_t { + None = 0x00000000, + Front = 0x00000001, + Back = 0x00000002, + }; + + enum class ErrorFilter : uint32_t { + None = 0x00000000, + Validation = 0x00000001, + OutOfMemory = 0x00000002, + }; + + enum class ErrorType : uint32_t { + NoError = 0x00000000, + Validation = 0x00000001, + OutOfMemory = 0x00000002, + Unknown = 0x00000003, + DeviceLost = 0x00000004, + }; + + enum class FenceCompletionStatus : uint32_t { + Success = 0x00000000, + Error = 0x00000001, + Unknown = 0x00000002, + DeviceLost = 0x00000003, + }; + + enum class FilterMode : uint32_t { + Nearest = 0x00000000, + Linear = 0x00000001, + }; + + enum class FrontFace : uint32_t { + CCW = 0x00000000, + CW = 0x00000001, + }; + + enum class IndexFormat : uint32_t { + Uint16 = 0x00000000, + Uint32 = 0x00000001, + }; + + enum class InputStepMode : uint32_t { + Vertex = 0x00000000, + Instance = 0x00000001, + }; + + enum class LoadOp : uint32_t { + Clear = 0x00000000, + Load = 0x00000001, + }; + + enum class PresentMode : uint32_t { + Immediate = 0x00000000, + Mailbox = 0x00000001, + Fifo = 0x00000002, + }; + + enum class PrimitiveTopology : uint32_t { + PointList = 0x00000000, + LineList = 0x00000001, + LineStrip = 0x00000002, + TriangleList = 0x00000003, + TriangleStrip = 0x00000004, + }; + + enum class SType : uint32_t { + Invalid = 0x00000000, + SurfaceDescriptorFromMetalLayer = 0x00000001, + SurfaceDescriptorFromWindowsHWND = 0x00000002, + SurfaceDescriptorFromXlib = 0x00000003, + SurfaceDescriptorFromHTMLCanvasId = 0x00000004, + ShaderModuleSPIRVDescriptor = 0x00000005, + ShaderModuleWGSLDescriptor = 0x00000006, + SamplerDescriptorDummyAnisotropicFiltering = 0x00000007, + RenderPipelineDescriptorDummyExtension = 0x00000008, + }; + + enum class StencilOperation : uint32_t { + Keep = 0x00000000, + Zero = 0x00000001, + Replace = 0x00000002, + Invert = 0x00000003, + IncrementClamp = 0x00000004, + DecrementClamp = 0x00000005, + IncrementWrap = 0x00000006, + DecrementWrap = 0x00000007, + }; + + enum class StoreOp : uint32_t { + Store = 0x00000000, + Clear = 0x00000001, + }; + + enum class TextureAspect : uint32_t { + All = 0x00000000, + StencilOnly = 0x00000001, + DepthOnly = 0x00000002, + }; + + enum class TextureComponentType : uint32_t { + Float = 0x00000000, + Sint = 0x00000001, + Uint = 0x00000002, + }; + + enum class TextureDimension : uint32_t { + e1D = 0x00000000, + e2D = 0x00000001, + e3D = 0x00000002, + }; + + enum class TextureFormat : uint32_t { + Undefined = 0x00000000, + R8Unorm = 0x00000001, + R8Snorm = 0x00000002, + R8Uint = 0x00000003, + R8Sint = 0x00000004, + R16Uint = 0x00000005, + R16Sint = 0x00000006, + R16Float = 0x00000007, + RG8Unorm = 0x00000008, + RG8Snorm = 0x00000009, + RG8Uint = 0x0000000A, + RG8Sint = 0x0000000B, + R32Float = 0x0000000C, + R32Uint = 0x0000000D, + R32Sint = 0x0000000E, + RG16Uint = 0x0000000F, + RG16Sint = 0x00000010, + RG16Float = 0x00000011, + RGBA8Unorm = 0x00000012, + RGBA8UnormSrgb = 0x00000013, + RGBA8Snorm = 0x00000014, + RGBA8Uint = 0x00000015, + RGBA8Sint = 0x00000016, + BGRA8Unorm = 0x00000017, + BGRA8UnormSrgb = 0x00000018, + RGB10A2Unorm = 0x00000019, + RG11B10Float = 0x0000001A, + RG32Float = 0x0000001B, + RG32Uint = 0x0000001C, + RG32Sint = 0x0000001D, + RGBA16Uint = 0x0000001E, + RGBA16Sint = 0x0000001F, + RGBA16Float = 0x00000020, + RGBA32Float = 0x00000021, + RGBA32Uint = 0x00000022, + RGBA32Sint = 0x00000023, + Depth32Float = 0x00000024, + Depth24Plus = 0x00000025, + Depth24PlusStencil8 = 0x00000026, + BC1RGBAUnorm = 0x00000027, + BC1RGBAUnormSrgb = 0x00000028, + BC2RGBAUnorm = 0x00000029, + BC2RGBAUnormSrgb = 0x0000002A, + BC3RGBAUnorm = 0x0000002B, + BC3RGBAUnormSrgb = 0x0000002C, + BC4RUnorm = 0x0000002D, + BC4RSnorm = 0x0000002E, + BC5RGUnorm = 0x0000002F, + BC5RGSnorm = 0x00000030, + BC6HRGBUfloat = 0x00000031, + BC6HRGBSfloat = 0x00000032, + BC7RGBAUnorm = 0x00000033, + BC7RGBAUnormSrgb = 0x00000034, + }; + + enum class TextureViewDimension : uint32_t { + Undefined = 0x00000000, + e1D = 0x00000001, + e2D = 0x00000002, + e2DArray = 0x00000003, + Cube = 0x00000004, + CubeArray = 0x00000005, + e3D = 0x00000006, + }; + + enum class VertexFormat : uint32_t { + UChar2 = 0x00000000, + UChar4 = 0x00000001, + Char2 = 0x00000002, + Char4 = 0x00000003, + UChar2Norm = 0x00000004, + UChar4Norm = 0x00000005, + Char2Norm = 0x00000006, + Char4Norm = 0x00000007, + UShort2 = 0x00000008, + UShort4 = 0x00000009, + Short2 = 0x0000000A, + Short4 = 0x0000000B, + UShort2Norm = 0x0000000C, + UShort4Norm = 0x0000000D, + Short2Norm = 0x0000000E, + Short4Norm = 0x0000000F, + Half2 = 0x00000010, + Half4 = 0x00000011, + Float = 0x00000012, + Float2 = 0x00000013, + Float3 = 0x00000014, + Float4 = 0x00000015, + UInt = 0x00000016, + UInt2 = 0x00000017, + UInt3 = 0x00000018, + UInt4 = 0x00000019, + Int = 0x0000001A, + Int2 = 0x0000001B, + Int3 = 0x0000001C, + Int4 = 0x0000001D, + }; + + + enum class BufferUsage : uint32_t { + None = 0x00000000, + MapRead = 0x00000001, + MapWrite = 0x00000002, + CopySrc = 0x00000004, + CopyDst = 0x00000008, + Index = 0x00000010, + Vertex = 0x00000020, + Uniform = 0x00000040, + Storage = 0x00000080, + Indirect = 0x00000100, + }; + + enum class ColorWriteMask : uint32_t { + None = 0x00000000, + Red = 0x00000001, + Green = 0x00000002, + Blue = 0x00000004, + Alpha = 0x00000008, + All = 0x0000000F, + }; + + enum class ShaderStage : uint32_t { + None = 0x00000000, + Vertex = 0x00000001, + Fragment = 0x00000002, + Compute = 0x00000004, + }; + + enum class TextureUsage : uint32_t { + None = 0x00000000, + CopySrc = 0x00000001, + CopyDst = 0x00000002, + Sampled = 0x00000004, + Storage = 0x00000008, + OutputAttachment = 0x00000010, + Present = 0x00000020, + }; + + + template<> + struct IsDawnBitmask { + static constexpr bool enable = true; + }; + + template<> + struct IsDawnBitmask { + static constexpr bool enable = true; + }; + + template<> + struct IsDawnBitmask { + static constexpr bool enable = true; + }; + + template<> + struct IsDawnBitmask { + static constexpr bool enable = true; + }; + + + using Proc = WGPUProc; + using BufferMapReadCallback = WGPUBufferMapReadCallback; + using BufferMapWriteCallback = WGPUBufferMapWriteCallback; + using DeviceLostCallback = WGPUDeviceLostCallback; + using ErrorCallback = WGPUErrorCallback; + using FenceOnCompletionCallback = WGPUFenceOnCompletionCallback; + + class BindGroup; + class BindGroupLayout; + class Buffer; + class CommandBuffer; + class CommandEncoder; + class ComputePassEncoder; + class ComputePipeline; + class Device; + class Fence; + class Instance; + class PipelineLayout; + class Queue; + class RenderBundle; + class RenderBundleEncoder; + class RenderPassEncoder; + class RenderPipeline; + class Sampler; + class ShaderModule; + class Surface; + class SwapChain; + class Texture; + class TextureView; + + struct AdapterProperties; + struct BindGroupEntry; + struct BindGroupLayoutEntry; + struct BlendDescriptor; + struct BufferCopyView; + struct BufferDescriptor; + struct Color; + struct CommandBufferDescriptor; + struct CommandEncoderDescriptor; + struct ComputePassDescriptor; + struct CreateBufferMappedResult; + struct DeviceProperties; + struct Extent3D; + struct FenceDescriptor; + struct InstanceDescriptor; + struct Origin3D; + struct PipelineLayoutDescriptor; + struct ProgrammableStageDescriptor; + struct RasterizationStateDescriptor; + struct RenderBundleDescriptor; + struct RenderBundleEncoderDescriptor; + struct RenderPassDepthStencilAttachmentDescriptor; + struct SamplerDescriptor; + struct SamplerDescriptorDummyAnisotropicFiltering; + struct ShaderModuleDescriptor; + struct ShaderModuleSPIRVDescriptor; + struct ShaderModuleWGSLDescriptor; + struct StencilStateFaceDescriptor; + struct SurfaceDescriptor; + struct SurfaceDescriptorFromHTMLCanvasId; + struct SurfaceDescriptorFromMetalLayer; + struct SurfaceDescriptorFromWindowsHWND; + struct SurfaceDescriptorFromXlib; + struct SwapChainDescriptor; + struct TextureViewDescriptor; + struct VertexAttributeDescriptor; + struct BindGroupDescriptor; + struct BindGroupLayoutDescriptor; + struct ColorStateDescriptor; + struct ComputePipelineDescriptor; + struct DepthStencilStateDescriptor; + struct RenderPassColorAttachmentDescriptor; + struct RenderPipelineDescriptorDummyExtension; + struct TextureCopyView; + struct TextureDescriptor; + struct VertexBufferLayoutDescriptor; + struct RenderPassDescriptor; + struct VertexStateDescriptor; + struct RenderPipelineDescriptor; + + template + class ObjectBase { + public: + ObjectBase() = default; + ObjectBase(CType handle): mHandle(handle) { + if (mHandle) Derived::WGPUReference(mHandle); + } + ~ObjectBase() { + if (mHandle) Derived::WGPURelease(mHandle); + } + + ObjectBase(ObjectBase const& other) + : ObjectBase(other.Get()) { + } + Derived& operator=(ObjectBase const& other) { + if (&other != this) { + if (mHandle) Derived::WGPURelease(mHandle); + mHandle = other.mHandle; + if (mHandle) Derived::WGPUReference(mHandle); + } + + return static_cast(*this); + } + + ObjectBase(ObjectBase&& other) { + mHandle = other.mHandle; + other.mHandle = 0; + } + Derived& operator=(ObjectBase&& other) { + if (&other != this) { + if (mHandle) Derived::WGPURelease(mHandle); + mHandle = other.mHandle; + other.mHandle = 0; + } + + return static_cast(*this); + } + + ObjectBase(std::nullptr_t) {} + Derived& operator=(std::nullptr_t) { + if (mHandle != nullptr) { + Derived::WGPURelease(mHandle); + mHandle = nullptr; + } + return static_cast(*this); + } + + bool operator==(std::nullptr_t) const { + return mHandle == nullptr; + } + bool operator!=(std::nullptr_t) const { + return mHandle != nullptr; + } + + explicit operator bool() const { + return mHandle != nullptr; + } + CType Get() const { + return mHandle; + } + CType Release() { + CType result = mHandle; + mHandle = 0; + return result; + } + static Derived Acquire(CType handle) { + Derived result; + result.mHandle = handle; + return result; + } + + protected: + CType mHandle = nullptr; + }; + + + + class BindGroup : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUBindGroup handle); + static void WGPURelease(WGPUBindGroup handle); + }; + + class BindGroupLayout : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUBindGroupLayout handle); + static void WGPURelease(WGPUBindGroupLayout handle); + }; + + class Buffer : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Destroy() const; + void MapReadAsync(BufferMapReadCallback callback, void * userdata) const; + void MapWriteAsync(BufferMapWriteCallback callback, void * userdata) const; + void SetSubData(uint64_t start, uint64_t count, void const * data) const; + void Unmap() const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUBuffer handle); + static void WGPURelease(WGPUBuffer handle); + }; + + class CommandBuffer : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUCommandBuffer handle); + static void WGPURelease(WGPUCommandBuffer handle); + }; + + class CommandEncoder : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + ComputePassEncoder BeginComputePass(ComputePassDescriptor const * descriptor = nullptr) const; + RenderPassEncoder BeginRenderPass(RenderPassDescriptor const * descriptor) const; + void CopyBufferToBuffer(Buffer const& source, uint64_t sourceOffset, Buffer const& destination, uint64_t destinationOffset, uint64_t size) const; + void CopyBufferToTexture(BufferCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const; + void CopyTextureToBuffer(TextureCopyView const * source, BufferCopyView const * destination, Extent3D const * copySize) const; + void CopyTextureToTexture(TextureCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const; + CommandBuffer Finish(CommandBufferDescriptor const * descriptor = nullptr) const; + void InsertDebugMarker(char const * groupLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const * groupLabel) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUCommandEncoder handle); + static void WGPURelease(WGPUCommandEncoder handle); + }; + + class ComputePassEncoder : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Dispatch(uint32_t x, uint32_t y = 1, uint32_t z = 1) const; + void DispatchIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const; + void EndPass() const; + void InsertDebugMarker(char const * groupLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const * groupLabel) const; + void SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount = 0, uint32_t const * dynamicOffsets = nullptr) const; + void SetPipeline(ComputePipeline const& pipeline) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUComputePassEncoder handle); + static void WGPURelease(WGPUComputePassEncoder handle); + }; + + class ComputePipeline : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + BindGroupLayout GetBindGroupLayout(uint32_t groupIndex) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUComputePipeline handle); + static void WGPURelease(WGPUComputePipeline handle); + }; + + class Device : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + BindGroup CreateBindGroup(BindGroupDescriptor const * descriptor) const; + BindGroupLayout CreateBindGroupLayout(BindGroupLayoutDescriptor const * descriptor) const; + Buffer CreateBuffer(BufferDescriptor const * descriptor) const; + CreateBufferMappedResult CreateBufferMapped(BufferDescriptor const * descriptor) const; + CommandEncoder CreateCommandEncoder(CommandEncoderDescriptor const * descriptor = nullptr) const; + ComputePipeline CreateComputePipeline(ComputePipelineDescriptor const * descriptor) const; + PipelineLayout CreatePipelineLayout(PipelineLayoutDescriptor const * descriptor) const; + RenderBundleEncoder CreateRenderBundleEncoder(RenderBundleEncoderDescriptor const * descriptor) const; + RenderPipeline CreateRenderPipeline(RenderPipelineDescriptor const * descriptor) const; + Sampler CreateSampler(SamplerDescriptor const * descriptor) const; + ShaderModule CreateShaderModule(ShaderModuleDescriptor const * descriptor) const; + SwapChain CreateSwapChain(Surface const& surface, SwapChainDescriptor const * descriptor) const; + Texture CreateTexture(TextureDescriptor const * descriptor) const; + Queue GetDefaultQueue() const; + void InjectError(ErrorType type, char const * message) const; + void LoseForTesting() const; + bool PopErrorScope(ErrorCallback callback, void * userdata) const; + void PushErrorScope(ErrorFilter filter) const; + void SetDeviceLostCallback(DeviceLostCallback callback, void * userdata) const; + void SetUncapturedErrorCallback(ErrorCallback callback, void * userdata) const; + void Tick() const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUDevice handle); + static void WGPURelease(WGPUDevice handle); + }; + + class Fence : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + uint64_t GetCompletedValue() const; + void OnCompletion(uint64_t value, FenceOnCompletionCallback callback, void * userdata) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUFence handle); + static void WGPURelease(WGPUFence handle); + }; + + class Instance : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Surface CreateSurface(SurfaceDescriptor const * descriptor) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUInstance handle); + static void WGPURelease(WGPUInstance handle); + }; + + class PipelineLayout : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUPipelineLayout handle); + static void WGPURelease(WGPUPipelineLayout handle); + }; + + class Queue : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Fence CreateFence(FenceDescriptor const * descriptor = nullptr) const; + void Signal(Fence const& fence, uint64_t signalValue) const; + void Submit(uint32_t commandCount, CommandBuffer const * commands) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUQueue handle); + static void WGPURelease(WGPUQueue handle); + }; + + class RenderBundle : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPURenderBundle handle); + static void WGPURelease(WGPURenderBundle handle); + }; + + class RenderBundleEncoder : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t firstVertex = 0, uint32_t firstInstance = 0) const; + void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t firstIndex = 0, int32_t baseVertex = 0, uint32_t firstInstance = 0) const; + void DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const; + void DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const; + RenderBundle Finish(RenderBundleDescriptor const * descriptor = nullptr) const; + void InsertDebugMarker(char const * groupLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const * groupLabel) const; + void SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount = 0, uint32_t const * dynamicOffsets = nullptr) const; + void SetIndexBuffer(Buffer const& buffer, uint64_t offset = 0, uint64_t size = 0) const; + void SetPipeline(RenderPipeline const& pipeline) const; + void SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset = 0, uint64_t size = 0) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPURenderBundleEncoder handle); + static void WGPURelease(WGPURenderBundleEncoder handle); + }; + + class RenderPassEncoder : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t firstVertex = 0, uint32_t firstInstance = 0) const; + void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t firstIndex = 0, int32_t baseVertex = 0, uint32_t firstInstance = 0) const; + void DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const; + void DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const; + void EndPass() const; + void ExecuteBundles(uint32_t bundlesCount, RenderBundle const * bundles) const; + void InsertDebugMarker(char const * groupLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const * groupLabel) const; + void SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount = 0, uint32_t const * dynamicOffsets = nullptr) const; + void SetBlendColor(Color const * color) const; + void SetIndexBuffer(Buffer const& buffer, uint64_t offset = 0, uint64_t size = 0) const; + void SetPipeline(RenderPipeline const& pipeline) const; + void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const; + void SetStencilReference(uint32_t reference) const; + void SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset = 0, uint64_t size = 0) const; + void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPURenderPassEncoder handle); + static void WGPURelease(WGPURenderPassEncoder handle); + }; + + class RenderPipeline : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + BindGroupLayout GetBindGroupLayout(uint32_t groupIndex) const; + + private: + friend ObjectBase; + static void WGPUReference(WGPURenderPipeline handle); + static void WGPURelease(WGPURenderPipeline handle); + }; + + class Sampler : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUSampler handle); + static void WGPURelease(WGPUSampler handle); + }; + + class ShaderModule : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUShaderModule handle); + static void WGPURelease(WGPUShaderModule handle); + }; + + class Surface : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUSurface handle); + static void WGPURelease(WGPUSurface handle); + }; + + class SwapChain : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Configure(TextureFormat format, TextureUsage allowedUsage, uint32_t width, uint32_t height) const; + TextureView GetCurrentTextureView() const; + void Present() const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUSwapChain handle); + static void WGPURelease(WGPUSwapChain handle); + }; + + class Texture : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + TextureView CreateView(TextureViewDescriptor const * descriptor = nullptr) const; + void Destroy() const; + + private: + friend ObjectBase; + static void WGPUReference(WGPUTexture handle); + static void WGPURelease(WGPUTexture handle); + }; + + class TextureView : public ObjectBase { + public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + + private: + friend ObjectBase; + static void WGPUReference(WGPUTextureView handle); + static void WGPURelease(WGPUTextureView handle); + }; + + + Instance CreateInstance(InstanceDescriptor const * descriptor = nullptr); + Proc GetProcAddress(Device const& device, const char* procName); + + struct ChainedStruct { + ChainedStruct const * nextInChain = nullptr; + SType sType = SType::Invalid; + }; + + struct AdapterProperties { + ChainedStruct const * nextInChain = nullptr; + uint32_t deviceID; + uint32_t vendorID; + char const * name; + AdapterType adapterType; + BackendType backendType; + }; + + struct BindGroupEntry { + uint32_t binding; + Buffer buffer; + uint64_t offset = 0; + uint64_t size; + Sampler sampler; + TextureView textureView; + }; + + struct BindGroupLayoutEntry { + uint32_t binding; + ShaderStage visibility; + BindingType type; + bool hasDynamicOffset = false; + bool multisampled = false; + TextureViewDimension viewDimension = TextureViewDimension::Undefined; + TextureComponentType textureComponentType = TextureComponentType::Float; + TextureFormat storageTextureFormat = TextureFormat::Undefined; + }; + + struct BlendDescriptor { + BlendOperation operation = BlendOperation::Add; + BlendFactor srcFactor = BlendFactor::One; + BlendFactor dstFactor = BlendFactor::Zero; + }; + + struct BufferCopyView { + ChainedStruct const * nextInChain = nullptr; + Buffer buffer; + uint64_t offset = 0; + uint32_t bytesPerRow; + uint32_t rowsPerImage = 0; + }; + + struct BufferDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + BufferUsage usage; + uint64_t size; + }; + + struct Color { + float r; + float g; + float b; + float a; + }; + + struct CommandBufferDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + }; + + struct CommandEncoderDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + }; + + struct ComputePassDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + }; + + struct CreateBufferMappedResult { + Buffer buffer; + uint64_t dataLength; + void * data; + }; + + struct DeviceProperties { + bool textureCompressionBC = false; + bool shaderFloat16 = false; + bool pipelineStatisticsQuery = false; + bool timestampQuery = false; + }; + + struct Extent3D { + uint32_t width; + uint32_t height; + uint32_t depth; + }; + + struct FenceDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + uint64_t initialValue = 0; + }; + + struct InstanceDescriptor { + ChainedStruct const * nextInChain = nullptr; + }; + + struct Origin3D { + uint32_t x = 0; + uint32_t y = 0; + uint32_t z = 0; + }; + + struct PipelineLayoutDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + uint32_t bindGroupLayoutCount; + BindGroupLayout const * bindGroupLayouts; + }; + + struct ProgrammableStageDescriptor { + ChainedStruct const * nextInChain = nullptr; + ShaderModule module; + char const * entryPoint; + }; + + struct RasterizationStateDescriptor { + ChainedStruct const * nextInChain = nullptr; + FrontFace frontFace = FrontFace::CCW; + CullMode cullMode = CullMode::None; + int32_t depthBias = 0; + float depthBiasSlopeScale = 0.0f; + float depthBiasClamp = 0.0f; + }; + + struct RenderBundleDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + }; + + struct RenderBundleEncoderDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + uint32_t colorFormatsCount; + TextureFormat const * colorFormats; + TextureFormat depthStencilFormat = TextureFormat::Undefined; + uint32_t sampleCount = 1; + }; + + struct RenderPassDepthStencilAttachmentDescriptor { + TextureView attachment; + LoadOp depthLoadOp; + StoreOp depthStoreOp; + float clearDepth; + LoadOp stencilLoadOp; + StoreOp stencilStoreOp; + uint32_t clearStencil = 0; + }; + + struct SamplerDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + AddressMode addressModeU = AddressMode::ClampToEdge; + AddressMode addressModeV = AddressMode::ClampToEdge; + AddressMode addressModeW = AddressMode::ClampToEdge; + FilterMode magFilter = FilterMode::Nearest; + FilterMode minFilter = FilterMode::Nearest; + FilterMode mipmapFilter = FilterMode::Nearest; + float lodMinClamp = 0.0f; + float lodMaxClamp = 1000.0f; + CompareFunction compare = CompareFunction::Undefined; + }; + + struct SamplerDescriptorDummyAnisotropicFiltering : ChainedStruct { + SamplerDescriptorDummyAnisotropicFiltering() { + sType = SType::SamplerDescriptorDummyAnisotropicFiltering; + } + alignas(ChainedStruct) float maxAnisotropy; + }; + + struct ShaderModuleDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + }; + + struct ShaderModuleSPIRVDescriptor : ChainedStruct { + ShaderModuleSPIRVDescriptor() { + sType = SType::ShaderModuleSPIRVDescriptor; + } + alignas(ChainedStruct) uint32_t codeSize; + uint32_t const * code; + }; + + struct ShaderModuleWGSLDescriptor : ChainedStruct { + ShaderModuleWGSLDescriptor() { + sType = SType::ShaderModuleWGSLDescriptor; + } + alignas(ChainedStruct) char const * source; + }; + + struct StencilStateFaceDescriptor { + CompareFunction compare = CompareFunction::Always; + StencilOperation failOp = StencilOperation::Keep; + StencilOperation depthFailOp = StencilOperation::Keep; + StencilOperation passOp = StencilOperation::Keep; + }; + + struct SurfaceDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + }; + + struct SurfaceDescriptorFromHTMLCanvasId : ChainedStruct { + SurfaceDescriptorFromHTMLCanvasId() { + sType = SType::SurfaceDescriptorFromHTMLCanvasId; + } + alignas(ChainedStruct) char const * id; + }; + + struct SurfaceDescriptorFromMetalLayer : ChainedStruct { + SurfaceDescriptorFromMetalLayer() { + sType = SType::SurfaceDescriptorFromMetalLayer; + } + alignas(ChainedStruct) void * layer; + }; + + struct SurfaceDescriptorFromWindowsHWND : ChainedStruct { + SurfaceDescriptorFromWindowsHWND() { + sType = SType::SurfaceDescriptorFromWindowsHWND; + } + alignas(ChainedStruct) void * hinstance; + void * hwnd; + }; + + struct SurfaceDescriptorFromXlib : ChainedStruct { + SurfaceDescriptorFromXlib() { + sType = SType::SurfaceDescriptorFromXlib; + } + alignas(ChainedStruct) void * display; + uint32_t window; + }; + + struct SwapChainDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + TextureUsage usage; + TextureFormat format; + uint32_t width; + uint32_t height; + PresentMode presentMode; + uint64_t implementation = 0; + }; + + struct TextureViewDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + TextureFormat format = TextureFormat::Undefined; + TextureViewDimension dimension = TextureViewDimension::Undefined; + uint32_t baseMipLevel = 0; + uint32_t mipLevelCount = 0; + uint32_t baseArrayLayer = 0; + uint32_t arrayLayerCount = 0; + TextureAspect aspect = TextureAspect::All; + }; + + struct VertexAttributeDescriptor { + VertexFormat format; + uint64_t offset; + uint32_t shaderLocation; + }; + + struct BindGroupDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + BindGroupLayout layout; + uint32_t entryCount; + BindGroupEntry const * entries; + }; + + struct BindGroupLayoutDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + uint32_t entryCount; + BindGroupLayoutEntry const * entries; + }; + + struct ColorStateDescriptor { + ChainedStruct const * nextInChain = nullptr; + TextureFormat format; + BlendDescriptor alphaBlend; + BlendDescriptor colorBlend; + ColorWriteMask writeMask = ColorWriteMask::All; + }; + + struct ComputePipelineDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + PipelineLayout layout; + ProgrammableStageDescriptor computeStage; + }; + + struct DepthStencilStateDescriptor { + ChainedStruct const * nextInChain = nullptr; + TextureFormat format; + bool depthWriteEnabled = false; + CompareFunction depthCompare = CompareFunction::Always; + StencilStateFaceDescriptor stencilFront; + StencilStateFaceDescriptor stencilBack; + uint32_t stencilReadMask = 0xFFFFFFFF; + uint32_t stencilWriteMask = 0xFFFFFFFF; + }; + + struct RenderPassColorAttachmentDescriptor { + TextureView attachment; + TextureView resolveTarget; + LoadOp loadOp; + StoreOp storeOp; + Color clearColor; + }; + + struct RenderPipelineDescriptorDummyExtension : ChainedStruct { + RenderPipelineDescriptorDummyExtension() { + sType = SType::RenderPipelineDescriptorDummyExtension; + } + alignas(ChainedStruct) ProgrammableStageDescriptor dummyStage; + }; + + struct TextureCopyView { + ChainedStruct const * nextInChain = nullptr; + Texture texture; + uint32_t mipLevel = 0; + uint32_t arrayLayer = 0; + Origin3D origin; + }; + + struct TextureDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + TextureUsage usage; + TextureDimension dimension = TextureDimension::e2D; + Extent3D size; + uint32_t arrayLayerCount = 1; + TextureFormat format; + uint32_t mipLevelCount = 1; + uint32_t sampleCount = 1; + }; + + struct VertexBufferLayoutDescriptor { + uint64_t arrayStride; + InputStepMode stepMode = InputStepMode::Vertex; + uint32_t attributeCount; + VertexAttributeDescriptor const * attributes; + }; + + struct RenderPassDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + uint32_t colorAttachmentCount; + RenderPassColorAttachmentDescriptor const * colorAttachments; + RenderPassDepthStencilAttachmentDescriptor const * depthStencilAttachment = nullptr; + }; + + struct VertexStateDescriptor { + ChainedStruct const * nextInChain = nullptr; + IndexFormat indexFormat = IndexFormat::Uint32; + uint32_t vertexBufferCount = 0; + VertexBufferLayoutDescriptor const * vertexBuffers; + }; + + struct RenderPipelineDescriptor { + ChainedStruct const * nextInChain = nullptr; + char const * label = nullptr; + PipelineLayout layout; + ProgrammableStageDescriptor vertexStage; + ProgrammableStageDescriptor const * fragmentStage = nullptr; + VertexStateDescriptor const * vertexState = nullptr; + PrimitiveTopology primitiveTopology; + RasterizationStateDescriptor const * rasterizationState = nullptr; + uint32_t sampleCount = 1; + DepthStencilStateDescriptor const * depthStencilState = nullptr; + uint32_t colorStateCount; + ColorStateDescriptor const * colorStates; + uint32_t sampleMask = 0xFFFFFFFF; + bool alphaToCoverageEnabled = false; + }; + + +} // namespace wgpu + +#endif // WEBGPU_CPP_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/D3D12Backend.h b/3rdparty/include/webgpu/include/dawn_native/D3D12Backend.h new file mode 100644 index 000000000000..bdefdf37be81 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/D3D12Backend.h @@ -0,0 +1,57 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_D3D12BACKEND_H_ +#define DAWNNATIVE_D3D12BACKEND_H_ + +#include +#include + +#include +#include + +struct ID3D12Device; + +namespace dawn_native { namespace d3d12 { + DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr GetD3D12Device(WGPUDevice device); + DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device, + HWND window); + DAWN_NATIVE_EXPORT WGPUTextureFormat + GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain); + + enum MemorySegment { + Local, + NonLocal, + }; + + DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device, + uint64_t requestedReservationSize, + MemorySegment memorySegment); + + struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor { + public: + ExternalImageDescriptorDXGISharedHandle(); + + HANDLE sharedHandle; + uint64_t acquireMutexKey; + bool isSwapChainTexture = false; + }; + + // Note: SharedHandle must be a handle to a texture object. + DAWN_NATIVE_EXPORT WGPUTexture + WrapSharedHandle(WGPUDevice device, const ExternalImageDescriptorDXGISharedHandle* descriptor); + +}} // namespace dawn_native::d3d12 + +#endif // DAWNNATIVE_D3D12BACKEND_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/DawnNative.h b/3rdparty/include/webgpu/include/dawn_native/DawnNative.h new file mode 100644 index 000000000000..219e53fa94b2 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/DawnNative.h @@ -0,0 +1,218 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_DAWNNATIVE_H_ +#define DAWNNATIVE_DAWNNATIVE_H_ + +#include +#include +#include + +#include +#include + +namespace dawn_platform { + class Platform; +} // namespace dawn_platform + +namespace wgpu { + struct AdapterProperties; +} + +namespace dawn_native { + + // DEPRECATED: use WGPUAdapterProperties instead. + struct PCIInfo { + uint32_t deviceId = 0; + uint32_t vendorId = 0; + std::string name; + }; + + // DEPRECATED: use WGPUBackendType instead. + enum class BackendType { + D3D12, + Metal, + Null, + OpenGL, + Vulkan, + }; + + // DEPRECATED: use WGPUAdapterType instead. + enum class DeviceType { + DiscreteGPU, + IntegratedGPU, + CPU, + Unknown, + }; + + class InstanceBase; + class AdapterBase; + + // An optional parameter of Adapter::CreateDevice() to send additional information when creating + // a Device. For example, we can use it to enable a workaround, optimization or feature. + struct DAWN_NATIVE_EXPORT DeviceDescriptor { + std::vector requiredExtensions; + std::vector forceEnabledToggles; + std::vector forceDisabledToggles; + }; + + // A struct to record the information of a toggle. A toggle is a code path in Dawn device that + // can be manually configured to run or not outside Dawn, including workarounds, special + // features and optimizations. + struct ToggleInfo { + const char* name; + const char* description; + const char* url; + }; + + // A struct to record the information of an extension. An extension is a GPU feature that is not + // required to be supported by all Dawn backends and can only be used when it is enabled on the + // creation of device. + using ExtensionInfo = ToggleInfo; + + // An adapter is an object that represent on possibility of creating devices in the system. + // Most of the time it will represent a combination of a physical GPU and an API. Not that the + // same GPU can be represented by multiple adapters but on different APIs. + // + // The underlying Dawn adapter is owned by the Dawn instance so this class is not RAII but just + // a reference to an underlying adapter. + class DAWN_NATIVE_EXPORT Adapter { + public: + Adapter(); + Adapter(AdapterBase* impl); + ~Adapter(); + + // DEPRECATED: use GetProperties instead. + BackendType GetBackendType() const; + DeviceType GetDeviceType() const; + const PCIInfo& GetPCIInfo() const; + + // Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in + // dawn.json + void GetProperties(wgpu::AdapterProperties* properties) const; + + std::vector GetSupportedExtensions() const; + WGPUDeviceProperties GetAdapterProperties() const; + + explicit operator bool() const; + + // Create a device on this adapter, note that the interface will change to include at least + // a device descriptor and a pointer to backend specific options. + // On an error, nullptr is returned. + WGPUDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr); + + private: + AdapterBase* mImpl = nullptr; + }; + + // Base class for options passed to Instance::DiscoverAdapters. + struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase { + public: + const WGPUBackendType backendType; + + protected: + AdapterDiscoveryOptionsBase(WGPUBackendType type); + }; + + // Represents a connection to dawn_native and is used for dependency injection, discovering + // system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter). + // + // This is an RAII class for Dawn instances and also controls the lifetime of all adapters + // for this instance. + class DAWN_NATIVE_EXPORT Instance { + public: + Instance(); + ~Instance(); + + Instance(const Instance& other) = delete; + Instance& operator=(const Instance& other) = delete; + + // Gather all adapters in the system that can be accessed with no special options. These + // adapters will later be returned by GetAdapters. + void DiscoverDefaultAdapters(); + + // Adds adapters that can be discovered with the options provided (like a getProcAddress). + // The backend is chosen based on the type of the options used. Returns true on success. + bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options); + + // Returns all the adapters that the instance knows about. + std::vector GetAdapters() const; + + const ToggleInfo* GetToggleInfo(const char* toggleName); + + // Enable backend's validation layers if it has. + void EnableBackendValidation(bool enableBackendValidation); + + // Enable debug capture on Dawn startup + void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup); + + void SetPlatform(dawn_platform::Platform* platform); + + // Returns the underlying WGPUInstance object. + WGPUInstance Get() const; + + private: + InstanceBase* mImpl = nullptr; + }; + + // Backend-agnostic API for dawn_native + DAWN_NATIVE_EXPORT DawnProcTable GetProcs(); + + // Query the names of all the toggles that are enabled in device + DAWN_NATIVE_EXPORT std::vector GetTogglesUsed(WGPUDevice device); + + // Backdoor to get the number of lazy clears for testing + DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device); + + // Backdoor to get the number of deprecation warnings for testing + DAWN_NATIVE_EXPORT size_t GetDeprecationWarningCountForTesting(WGPUDevice device); + + // Query if texture has been initialized + DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(WGPUTexture texture, + uint32_t baseMipLevel, + uint32_t levelCount, + uint32_t baseArrayLayer, + uint32_t layerCount); + + // Backdoor to get the order of the ProcMap for testing + DAWN_NATIVE_EXPORT std::vector GetProcMapNamesForTesting(); + + // ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp + DAWN_NATIVE_EXPORT void EnableErrorInjector(); + DAWN_NATIVE_EXPORT void DisableErrorInjector(); + DAWN_NATIVE_EXPORT void ClearErrorInjector(); + DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount(); + DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index); + + // The different types of ExternalImageDescriptors + enum ExternalImageDescriptorType { + OpaqueFD, + DmaBuf, + IOSurface, + DXGISharedHandle, + }; + + // Common properties of external images + struct DAWN_NATIVE_EXPORT ExternalImageDescriptor { + public: + const ExternalImageDescriptorType type; + const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params + bool isCleared; // Sets whether the texture will be cleared before use + + protected: + ExternalImageDescriptor(ExternalImageDescriptorType type); + }; +} // namespace dawn_native + +#endif // DAWNNATIVE_DAWNNATIVE_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/MetalBackend.h b/3rdparty/include/webgpu/include/dawn_native/MetalBackend.h new file mode 100644 index 000000000000..90884ee7f24a --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/MetalBackend.h @@ -0,0 +1,63 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_METALBACKEND_H_ +#define DAWNNATIVE_METALBACKEND_H_ + +#include +#include + +// The specifics of the Metal backend expose types in function signatures that might not be +// available in dependent's minimum supported SDK version. Suppress all availability errors using +// clang's pragmas. Dependents using the types without guarded availability will still get errors +// when using the types. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" + +struct __IOSurface; +typedef __IOSurface* IOSurfaceRef; + +#ifdef __OBJC__ +# import +#endif //__OBJC__ + +namespace dawn_native { namespace metal { + struct DAWN_NATIVE_EXPORT ExternalImageDescriptorIOSurface : ExternalImageDescriptor { + public: + ExternalImageDescriptorIOSurface(); + + IOSurfaceRef ioSurface; + uint32_t plane; + }; + + DAWN_NATIVE_EXPORT WGPUTexture + WrapIOSurface(WGPUDevice device, const ExternalImageDescriptorIOSurface* descriptor); + + // When making Metal interop with other APIs, we need to be careful that QueueSubmit doesn't + // mean that the operations will be visible to other APIs/Metal devices right away. macOS + // does have a global queue of graphics operations, but the command buffers are inserted there + // when they are "scheduled". Submitting other operations before the command buffer is + // scheduled could lead to races in who gets scheduled first and incorrect rendering. + DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device); +}} // namespace dawn_native::metal + +#ifdef __OBJC__ +namespace dawn_native { namespace metal { + DAWN_NATIVE_EXPORT id GetMetalDevice(WGPUDevice device); +}} // namespace dawn_native::metal +#endif // __OBJC__ + +#pragma clang diagnostic pop + +#endif // DAWNNATIVE_METALBACKEND_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/NullBackend.h b/3rdparty/include/webgpu/include/dawn_native/NullBackend.h new file mode 100644 index 000000000000..5762a776205e --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/NullBackend.h @@ -0,0 +1,25 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_NULLBACKEND_H_ +#define DAWNNATIVE_NULLBACKEND_H_ + +#include +#include + +namespace dawn_native { namespace null { + DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(); +}} // namespace dawn_native::null + +#endif // DAWNNATIVE_NULLBACKEND_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/OpenGLBackend.h b/3rdparty/include/webgpu/include/dawn_native/OpenGLBackend.h new file mode 100644 index 000000000000..05896716a3fe --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/OpenGLBackend.h @@ -0,0 +1,37 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_OPENGLBACKEND_H_ +#define DAWNNATIVE_OPENGLBACKEND_H_ + +#include +#include + +namespace dawn_native { namespace opengl { + + struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase { + AdapterDiscoveryOptions(); + + void* (*getProc)(const char*); + }; + + using PresentCallback = void (*)(void*); + DAWN_NATIVE_EXPORT DawnSwapChainImplementation + CreateNativeSwapChainImpl(WGPUDevice device, PresentCallback present, void* presentUserdata); + DAWN_NATIVE_EXPORT WGPUTextureFormat + GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain); + +}} // namespace dawn_native::opengl + +#endif // DAWNNATIVE_OPENGLBACKEND_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/VulkanBackend.h b/3rdparty/include/webgpu/include/dawn_native/VulkanBackend.h new file mode 100644 index 000000000000..0965871941cf --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/VulkanBackend.h @@ -0,0 +1,80 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_VULKANBACKEND_H_ +#define DAWNNATIVE_VULKANBACKEND_H_ + +#include +#include + +#include + +#include + +namespace dawn_native { namespace vulkan { + DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device); + + DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName); + + DAWN_NATIVE_EXPORT DawnSwapChainImplementation + CreateNativeSwapChainImpl(WGPUDevice device, ::VkSurfaceKHR surface); + DAWN_NATIVE_EXPORT WGPUTextureFormat + GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain); + +// Can't use DAWN_PLATFORM_LINUX since header included in both dawn and chrome +#ifdef __linux__ + // Common properties of external images represented by FDs. On successful import the file + // descriptor's ownership is transferred to the Dawn implementation and they shouldn't be + // used outside of Dawn again. TODO(enga): Also transfer ownership in the error case so the + // caller can assume the FD is always consumed. + struct DAWN_NATIVE_EXPORT ExternalImageDescriptorFD : ExternalImageDescriptor { + public: + int memoryFD; // A file descriptor from an export of the memory of the image + std::vector waitFDs; // File descriptors of semaphores which will be waited on + + protected: + ExternalImageDescriptorFD(ExternalImageDescriptorType type); + }; + + // Descriptor for opaque file descriptor image import + struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescriptorFD { + ExternalImageDescriptorOpaqueFD(); + + VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation + uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation + }; + + // Descriptor for dma-buf file descriptor image import + struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD { + ExternalImageDescriptorDmaBuf(); + + uint32_t stride; // Stride of the buffer in bytes + uint64_t drmModifier; // DRM modifier of the buffer + }; + + // Exports a signal semaphore from a wrapped texture. This must be called on wrapped + // textures before they are destroyed. On failure, returns -1 + DAWN_NATIVE_EXPORT int ExportSignalSemaphoreOpaqueFD(WGPUDevice cDevice, + WGPUTexture cTexture); + + // Imports external memory into a Vulkan image. Internally, this uses external memory / + // semaphore extensions to import the image and wait on the provided synchronizaton + // primitives before the texture can be used. + // On failure, returns a nullptr. + DAWN_NATIVE_EXPORT WGPUTexture WrapVulkanImage(WGPUDevice cDevice, + const ExternalImageDescriptor* descriptor); +#endif // __linux__ +}} // namespace dawn_native::vulkan + +#endif // DAWNNATIVE_VULKANBACKEND_H_ diff --git a/3rdparty/include/webgpu/include/dawn_native/dawn_native_export.h b/3rdparty/include/webgpu/include/dawn_native/dawn_native_export.h new file mode 100644 index 000000000000..ffbd9cc369f2 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_native/dawn_native_export.h @@ -0,0 +1,36 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_EXPORT_H_ +#define DAWNNATIVE_EXPORT_H_ + +#if defined(DAWN_NATIVE_SHARED_LIBRARY) +# if defined(_WIN32) +# if defined(DAWN_NATIVE_IMPLEMENTATION) +# define DAWN_NATIVE_EXPORT __declspec(dllexport) +# else +# define DAWN_NATIVE_EXPORT __declspec(dllimport) +# endif +# else // defined(_WIN32) +# if defined(DAWN_NATIVE_IMPLEMENTATION) +# define DAWN_NATIVE_EXPORT __attribute__((visibility("default"))) +# else +# define DAWN_NATIVE_EXPORT +# endif +# endif // defined(_WIN32) +#else // defined(DAWN_NATIVE_SHARED_LIBRARY) +# define DAWN_NATIVE_EXPORT +#endif // defined(DAWN_NATIVE_SHARED_LIBRARY) + +#endif // DAWNNATIVE_EXPORT_H_ diff --git a/3rdparty/include/webgpu/include/dawn_platform/DawnPlatform.h b/3rdparty/include/webgpu/include/dawn_platform/DawnPlatform.h new file mode 100644 index 000000000000..61b029e986b2 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_platform/DawnPlatform.h @@ -0,0 +1,53 @@ +// Copyright 2019 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNPLATFORM_DAWNPLATFORM_H_ +#define DAWNPLATFORM_DAWNPLATFORM_H_ + +#include + +#include + +namespace dawn_platform { + + enum class TraceCategory { + General, // General trace events + Validation, // Dawn validation + Recording, // Native command recording + GPUWork, // Actual GPU work + }; + + class DAWN_NATIVE_EXPORT Platform { + public: + virtual ~Platform() { + } + virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category) = 0; + + virtual double MonotonicallyIncreasingTime() = 0; + + virtual uint64_t AddTraceEvent(char phase, + const unsigned char* categoryGroupEnabled, + const char* name, + uint64_t id, + double timestamp, + int numArgs, + const char** argNames, + const unsigned char* argTypes, + const uint64_t* argValues, + unsigned char flags) = 0; + }; + +} // namespace dawn_platform + +#endif // DAWNPLATFORM_DAWNPLATFORM_H_ diff --git a/3rdparty/include/webgpu/include/dawn_wire/Wire.h b/3rdparty/include/webgpu/include/dawn_wire/Wire.h new file mode 100644 index 000000000000..6120f8b9ce61 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_wire/Wire.h @@ -0,0 +1,50 @@ +// Copyright 2017 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNWIRE_WIRE_H_ +#define DAWNWIRE_WIRE_H_ + +#include + +#include "dawn/webgpu.h" +#include "dawn_wire/dawn_wire_export.h" + +namespace dawn_wire { + + class DAWN_WIRE_EXPORT CommandSerializer { + public: + virtual ~CommandSerializer() = default; + virtual void* GetCmdSpace(size_t size) = 0; + virtual bool Flush() = 0; + }; + + class DAWN_WIRE_EXPORT CommandHandler { + public: + virtual ~CommandHandler() = default; + virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0; + }; + + DAWN_WIRE_EXPORT size_t + SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties); + + DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties( + const WGPUDeviceProperties* deviceProperties, + char* serializeBuffer); + + DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties, + const volatile char* deserializeBuffer); + +} // namespace dawn_wire + +#endif // DAWNWIRE_WIRE_H_ diff --git a/3rdparty/include/webgpu/include/dawn_wire/WireClient.h b/3rdparty/include/webgpu/include/dawn_wire/WireClient.h new file mode 100644 index 000000000000..5b5f33c2ace0 --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_wire/WireClient.h @@ -0,0 +1,135 @@ +// Copyright 2019 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNWIRE_WIRECLIENT_H_ +#define DAWNWIRE_WIRECLIENT_H_ + +#include "dawn/dawn_proc_table.h" +#include "dawn_wire/Wire.h" + +#include +#include + +namespace dawn_wire { + + namespace client { + class Client; + class MemoryTransferService; + } + + struct ReservedTexture { + WGPUTexture texture; + uint32_t id; + uint32_t generation; + }; + + struct DAWN_WIRE_EXPORT WireClientDescriptor { + CommandSerializer* serializer; + client::MemoryTransferService* memoryTransferService = nullptr; + }; + + class DAWN_WIRE_EXPORT WireClient : public CommandHandler { + public: + WireClient(const WireClientDescriptor& descriptor); + ~WireClient() override; + + static DawnProcTable GetProcs(); + + WGPUDevice GetDevice() const; + const volatile char* HandleCommands(const volatile char* commands, + size_t size) override final; + + ReservedTexture ReserveTexture(WGPUDevice device); + + // Disconnects the client. + // Commands allocated after this point will not be sent. + void Disconnect(); + + private: + std::unique_ptr mImpl; + }; + + namespace client { + class DAWN_WIRE_EXPORT MemoryTransferService { + public: + class ReadHandle; + class WriteHandle; + + virtual ~MemoryTransferService(); + + // Create a handle for reading server data. + // This may fail and return nullptr. + virtual ReadHandle* CreateReadHandle(size_t) = 0; + + // Create a handle for writing server data. + // This may fail and return nullptr. + virtual WriteHandle* CreateWriteHandle(size_t) = 0; + + // Imported memory implementation needs to override these to create Read/Write + // handles associated with a particular buffer. The client should receive a file + // descriptor for the buffer out-of-band. + virtual ReadHandle* CreateReadHandle(WGPUBuffer, uint64_t offset, size_t size); + virtual WriteHandle* CreateWriteHandle(WGPUBuffer, uint64_t offset, size_t size); + + class DAWN_WIRE_EXPORT ReadHandle { + public: + // Get the required serialization size for SerializeCreate + virtual size_t SerializeCreateSize() = 0; + + // Serialize the handle into |serializePointer| so it can be received by the server. + virtual void SerializeCreate(void* serializePointer) = 0; + + // Load initial data and open the handle for reading. + // This function takes in the serialized result of + // server::MemoryTransferService::ReadHandle::SerializeInitialData. + // This function should write to |data| and |dataLength| the pointer and size of the + // mapped data for reading. It must live at least until the ReadHandle is + // destructed. + virtual bool DeserializeInitialData(const void* deserializePointer, + size_t deserializeSize, + const void** data, + size_t* dataLength) = 0; + virtual ~ReadHandle(); + }; + + class DAWN_WIRE_EXPORT WriteHandle { + public: + // Get the required serialization size for SerializeCreate + virtual size_t SerializeCreateSize() = 0; + + // Serialize the handle into |serializePointer| so it can be received by the server. + virtual void SerializeCreate(void* serializePointer) = 0; + + // Open the handle for reading. The data returned should be zero-initialized. + // The data returned must live at least until the WriteHandle is destructed. + // On failure, the pointer returned should be null. + virtual std::pair Open() = 0; + + // Get the required serialization size for SerializeFlush + virtual size_t SerializeFlushSize() = 0; + + // Flush writes to the handle. This should serialize info to send updates to the + // server. + virtual void SerializeFlush(void* serializePointer) = 0; + + virtual ~WriteHandle(); + }; + }; + + // Backdoor to get the order of the ProcMap for testing + DAWN_WIRE_EXPORT std::vector GetProcMapNamesForTesting(); + } // namespace client +} // namespace dawn_wire + +#endif // DAWNWIRE_WIRECLIENT_H_ diff --git a/3rdparty/include/webgpu/include/dawn_wire/WireServer.h b/3rdparty/include/webgpu/include/dawn_wire/WireServer.h new file mode 100644 index 000000000000..b59572180a8e --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_wire/WireServer.h @@ -0,0 +1,103 @@ +// Copyright 2019 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNWIRE_WIRESERVER_H_ +#define DAWNWIRE_WIRESERVER_H_ + +#include + +#include "dawn_wire/Wire.h" + +struct DawnProcTable; + +namespace dawn_wire { + + namespace server { + class Server; + class MemoryTransferService; + } + + struct DAWN_WIRE_EXPORT WireServerDescriptor { + WGPUDevice device; + const DawnProcTable* procs; + CommandSerializer* serializer; + server::MemoryTransferService* memoryTransferService = nullptr; + }; + + class DAWN_WIRE_EXPORT WireServer : public CommandHandler { + public: + WireServer(const WireServerDescriptor& descriptor); + ~WireServer() override; + + const volatile char* HandleCommands(const volatile char* commands, + size_t size) override final; + + bool InjectTexture(WGPUTexture texture, uint32_t id, uint32_t generation); + + private: + std::unique_ptr mImpl; + }; + + namespace server { + class DAWN_WIRE_EXPORT MemoryTransferService { + public: + class ReadHandle; + class WriteHandle; + + virtual ~MemoryTransferService(); + + // Deserialize data to create Read/Write handles. These handles are for the client + // to Read/Write data. + virtual bool DeserializeReadHandle(const void* deserializePointer, + size_t deserializeSize, + ReadHandle** readHandle) = 0; + virtual bool DeserializeWriteHandle(const void* deserializePointer, + size_t deserializeSize, + WriteHandle** writeHandle) = 0; + + class DAWN_WIRE_EXPORT ReadHandle { + public: + // Get the required serialization size for SerializeInitialData + virtual size_t SerializeInitialDataSize(const void* data, size_t dataLength) = 0; + + // Initialize the handle data. + // Serialize into |serializePointer| so the client can update handle data. + virtual void SerializeInitialData(const void* data, + size_t dataLength, + void* serializePointer) = 0; + virtual ~ReadHandle(); + }; + + class DAWN_WIRE_EXPORT WriteHandle { + public: + // Set the target for writes from the client. DeserializeFlush should copy data + // into the target. + void SetTarget(void* data, size_t dataLength); + + // This function takes in the serialized result of + // client::MemoryTransferService::WriteHandle::SerializeFlush. + virtual bool DeserializeFlush(const void* deserializePointer, + size_t deserializeSize) = 0; + virtual ~WriteHandle(); + + protected: + void* mTargetData = nullptr; + size_t mDataLength = 0; + }; + }; + } // namespace server + +} // namespace dawn_wire + +#endif // DAWNWIRE_WIRESERVER_H_ diff --git a/3rdparty/include/webgpu/include/dawn_wire/dawn_wire_export.h b/3rdparty/include/webgpu/include/dawn_wire/dawn_wire_export.h new file mode 100644 index 000000000000..8043f618c19e --- /dev/null +++ b/3rdparty/include/webgpu/include/dawn_wire/dawn_wire_export.h @@ -0,0 +1,36 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNWIRE_EXPORT_H_ +#define DAWNWIRE_EXPORT_H_ + +#if defined(DAWN_WIRE_SHARED_LIBRARY) +# if defined(_WIN32) +# if defined(DAWN_WIRE_IMPLEMENTATION) +# define DAWN_WIRE_EXPORT __declspec(dllexport) +# else +# define DAWN_WIRE_EXPORT __declspec(dllimport) +# endif +# else // defined(_WIN32) +# if defined(DAWN_WIRE_IMPLEMENTATION) +# define DAWN_WIRE_EXPORT __attribute__((visibility("default"))) +# else +# define DAWN_WIRE_EXPORT +# endif +# endif // defined(_WIN32) +#else // defined(DAWN_WIRE_SHARED_LIBRARY) +# define DAWN_WIRE_EXPORT +#endif // defined(DAWN_WIRE_SHARED_LIBRARY) + +#endif // DAWNWIRE_EXPORT_H_ diff --git a/3rdparty/include/webgpu/include/webgpu_cpp.cpp b/3rdparty/include/webgpu/include/webgpu_cpp.cpp new file mode 100644 index 000000000000..fd324184007c --- /dev/null +++ b/3rdparty/include/webgpu/include/webgpu_cpp.cpp @@ -0,0 +1,1746 @@ + +#include "dawn/webgpu_cpp.h" + +namespace wgpu { + + + static_assert(sizeof(AdapterType) == sizeof(WGPUAdapterType), "sizeof mismatch for AdapterType"); + static_assert(alignof(AdapterType) == alignof(WGPUAdapterType), "alignof mismatch for AdapterType"); + + static_assert(static_cast(AdapterType::DiscreteGPU) == WGPUAdapterType_DiscreteGPU, "value mismatch for AdapterType::DiscreteGPU"); + static_assert(static_cast(AdapterType::IntegratedGPU) == WGPUAdapterType_IntegratedGPU, "value mismatch for AdapterType::IntegratedGPU"); + static_assert(static_cast(AdapterType::CPU) == WGPUAdapterType_CPU, "value mismatch for AdapterType::CPU"); + static_assert(static_cast(AdapterType::Unknown) == WGPUAdapterType_Unknown, "value mismatch for AdapterType::Unknown"); + + + static_assert(sizeof(AddressMode) == sizeof(WGPUAddressMode), "sizeof mismatch for AddressMode"); + static_assert(alignof(AddressMode) == alignof(WGPUAddressMode), "alignof mismatch for AddressMode"); + + static_assert(static_cast(AddressMode::Repeat) == WGPUAddressMode_Repeat, "value mismatch for AddressMode::Repeat"); + static_assert(static_cast(AddressMode::MirrorRepeat) == WGPUAddressMode_MirrorRepeat, "value mismatch for AddressMode::MirrorRepeat"); + static_assert(static_cast(AddressMode::ClampToEdge) == WGPUAddressMode_ClampToEdge, "value mismatch for AddressMode::ClampToEdge"); + + + static_assert(sizeof(BackendType) == sizeof(WGPUBackendType), "sizeof mismatch for BackendType"); + static_assert(alignof(BackendType) == alignof(WGPUBackendType), "alignof mismatch for BackendType"); + + static_assert(static_cast(BackendType::Null) == WGPUBackendType_Null, "value mismatch for BackendType::Null"); + static_assert(static_cast(BackendType::D3D11) == WGPUBackendType_D3D11, "value mismatch for BackendType::D3D11"); + static_assert(static_cast(BackendType::D3D12) == WGPUBackendType_D3D12, "value mismatch for BackendType::D3D12"); + static_assert(static_cast(BackendType::Metal) == WGPUBackendType_Metal, "value mismatch for BackendType::Metal"); + static_assert(static_cast(BackendType::Vulkan) == WGPUBackendType_Vulkan, "value mismatch for BackendType::Vulkan"); + static_assert(static_cast(BackendType::OpenGL) == WGPUBackendType_OpenGL, "value mismatch for BackendType::OpenGL"); + static_assert(static_cast(BackendType::OpenGLES) == WGPUBackendType_OpenGLES, "value mismatch for BackendType::OpenGLES"); + + + static_assert(sizeof(BindingType) == sizeof(WGPUBindingType), "sizeof mismatch for BindingType"); + static_assert(alignof(BindingType) == alignof(WGPUBindingType), "alignof mismatch for BindingType"); + + static_assert(static_cast(BindingType::UniformBuffer) == WGPUBindingType_UniformBuffer, "value mismatch for BindingType::UniformBuffer"); + static_assert(static_cast(BindingType::StorageBuffer) == WGPUBindingType_StorageBuffer, "value mismatch for BindingType::StorageBuffer"); + static_assert(static_cast(BindingType::ReadonlyStorageBuffer) == WGPUBindingType_ReadonlyStorageBuffer, "value mismatch for BindingType::ReadonlyStorageBuffer"); + static_assert(static_cast(BindingType::Sampler) == WGPUBindingType_Sampler, "value mismatch for BindingType::Sampler"); + static_assert(static_cast(BindingType::ComparisonSampler) == WGPUBindingType_ComparisonSampler, "value mismatch for BindingType::ComparisonSampler"); + static_assert(static_cast(BindingType::SampledTexture) == WGPUBindingType_SampledTexture, "value mismatch for BindingType::SampledTexture"); + static_assert(static_cast(BindingType::StorageTexture) == WGPUBindingType_StorageTexture, "value mismatch for BindingType::StorageTexture"); + static_assert(static_cast(BindingType::ReadonlyStorageTexture) == WGPUBindingType_ReadonlyStorageTexture, "value mismatch for BindingType::ReadonlyStorageTexture"); + static_assert(static_cast(BindingType::WriteonlyStorageTexture) == WGPUBindingType_WriteonlyStorageTexture, "value mismatch for BindingType::WriteonlyStorageTexture"); + + + static_assert(sizeof(BlendFactor) == sizeof(WGPUBlendFactor), "sizeof mismatch for BlendFactor"); + static_assert(alignof(BlendFactor) == alignof(WGPUBlendFactor), "alignof mismatch for BlendFactor"); + + static_assert(static_cast(BlendFactor::Zero) == WGPUBlendFactor_Zero, "value mismatch for BlendFactor::Zero"); + static_assert(static_cast(BlendFactor::One) == WGPUBlendFactor_One, "value mismatch for BlendFactor::One"); + static_assert(static_cast(BlendFactor::SrcColor) == WGPUBlendFactor_SrcColor, "value mismatch for BlendFactor::SrcColor"); + static_assert(static_cast(BlendFactor::OneMinusSrcColor) == WGPUBlendFactor_OneMinusSrcColor, "value mismatch for BlendFactor::OneMinusSrcColor"); + static_assert(static_cast(BlendFactor::SrcAlpha) == WGPUBlendFactor_SrcAlpha, "value mismatch for BlendFactor::SrcAlpha"); + static_assert(static_cast(BlendFactor::OneMinusSrcAlpha) == WGPUBlendFactor_OneMinusSrcAlpha, "value mismatch for BlendFactor::OneMinusSrcAlpha"); + static_assert(static_cast(BlendFactor::DstColor) == WGPUBlendFactor_DstColor, "value mismatch for BlendFactor::DstColor"); + static_assert(static_cast(BlendFactor::OneMinusDstColor) == WGPUBlendFactor_OneMinusDstColor, "value mismatch for BlendFactor::OneMinusDstColor"); + static_assert(static_cast(BlendFactor::DstAlpha) == WGPUBlendFactor_DstAlpha, "value mismatch for BlendFactor::DstAlpha"); + static_assert(static_cast(BlendFactor::OneMinusDstAlpha) == WGPUBlendFactor_OneMinusDstAlpha, "value mismatch for BlendFactor::OneMinusDstAlpha"); + static_assert(static_cast(BlendFactor::SrcAlphaSaturated) == WGPUBlendFactor_SrcAlphaSaturated, "value mismatch for BlendFactor::SrcAlphaSaturated"); + static_assert(static_cast(BlendFactor::BlendColor) == WGPUBlendFactor_BlendColor, "value mismatch for BlendFactor::BlendColor"); + static_assert(static_cast(BlendFactor::OneMinusBlendColor) == WGPUBlendFactor_OneMinusBlendColor, "value mismatch for BlendFactor::OneMinusBlendColor"); + + + static_assert(sizeof(BlendOperation) == sizeof(WGPUBlendOperation), "sizeof mismatch for BlendOperation"); + static_assert(alignof(BlendOperation) == alignof(WGPUBlendOperation), "alignof mismatch for BlendOperation"); + + static_assert(static_cast(BlendOperation::Add) == WGPUBlendOperation_Add, "value mismatch for BlendOperation::Add"); + static_assert(static_cast(BlendOperation::Subtract) == WGPUBlendOperation_Subtract, "value mismatch for BlendOperation::Subtract"); + static_assert(static_cast(BlendOperation::ReverseSubtract) == WGPUBlendOperation_ReverseSubtract, "value mismatch for BlendOperation::ReverseSubtract"); + static_assert(static_cast(BlendOperation::Min) == WGPUBlendOperation_Min, "value mismatch for BlendOperation::Min"); + static_assert(static_cast(BlendOperation::Max) == WGPUBlendOperation_Max, "value mismatch for BlendOperation::Max"); + + + static_assert(sizeof(BufferMapAsyncStatus) == sizeof(WGPUBufferMapAsyncStatus), "sizeof mismatch for BufferMapAsyncStatus"); + static_assert(alignof(BufferMapAsyncStatus) == alignof(WGPUBufferMapAsyncStatus), "alignof mismatch for BufferMapAsyncStatus"); + + static_assert(static_cast(BufferMapAsyncStatus::Success) == WGPUBufferMapAsyncStatus_Success, "value mismatch for BufferMapAsyncStatus::Success"); + static_assert(static_cast(BufferMapAsyncStatus::Error) == WGPUBufferMapAsyncStatus_Error, "value mismatch for BufferMapAsyncStatus::Error"); + static_assert(static_cast(BufferMapAsyncStatus::Unknown) == WGPUBufferMapAsyncStatus_Unknown, "value mismatch for BufferMapAsyncStatus::Unknown"); + static_assert(static_cast(BufferMapAsyncStatus::DeviceLost) == WGPUBufferMapAsyncStatus_DeviceLost, "value mismatch for BufferMapAsyncStatus::DeviceLost"); + + + static_assert(sizeof(CompareFunction) == sizeof(WGPUCompareFunction), "sizeof mismatch for CompareFunction"); + static_assert(alignof(CompareFunction) == alignof(WGPUCompareFunction), "alignof mismatch for CompareFunction"); + + static_assert(static_cast(CompareFunction::Undefined) == WGPUCompareFunction_Undefined, "value mismatch for CompareFunction::Undefined"); + static_assert(static_cast(CompareFunction::Never) == WGPUCompareFunction_Never, "value mismatch for CompareFunction::Never"); + static_assert(static_cast(CompareFunction::Less) == WGPUCompareFunction_Less, "value mismatch for CompareFunction::Less"); + static_assert(static_cast(CompareFunction::LessEqual) == WGPUCompareFunction_LessEqual, "value mismatch for CompareFunction::LessEqual"); + static_assert(static_cast(CompareFunction::Greater) == WGPUCompareFunction_Greater, "value mismatch for CompareFunction::Greater"); + static_assert(static_cast(CompareFunction::GreaterEqual) == WGPUCompareFunction_GreaterEqual, "value mismatch for CompareFunction::GreaterEqual"); + static_assert(static_cast(CompareFunction::Equal) == WGPUCompareFunction_Equal, "value mismatch for CompareFunction::Equal"); + static_assert(static_cast(CompareFunction::NotEqual) == WGPUCompareFunction_NotEqual, "value mismatch for CompareFunction::NotEqual"); + static_assert(static_cast(CompareFunction::Always) == WGPUCompareFunction_Always, "value mismatch for CompareFunction::Always"); + + + static_assert(sizeof(CullMode) == sizeof(WGPUCullMode), "sizeof mismatch for CullMode"); + static_assert(alignof(CullMode) == alignof(WGPUCullMode), "alignof mismatch for CullMode"); + + static_assert(static_cast(CullMode::None) == WGPUCullMode_None, "value mismatch for CullMode::None"); + static_assert(static_cast(CullMode::Front) == WGPUCullMode_Front, "value mismatch for CullMode::Front"); + static_assert(static_cast(CullMode::Back) == WGPUCullMode_Back, "value mismatch for CullMode::Back"); + + + static_assert(sizeof(ErrorFilter) == sizeof(WGPUErrorFilter), "sizeof mismatch for ErrorFilter"); + static_assert(alignof(ErrorFilter) == alignof(WGPUErrorFilter), "alignof mismatch for ErrorFilter"); + + static_assert(static_cast(ErrorFilter::None) == WGPUErrorFilter_None, "value mismatch for ErrorFilter::None"); + static_assert(static_cast(ErrorFilter::Validation) == WGPUErrorFilter_Validation, "value mismatch for ErrorFilter::Validation"); + static_assert(static_cast(ErrorFilter::OutOfMemory) == WGPUErrorFilter_OutOfMemory, "value mismatch for ErrorFilter::OutOfMemory"); + + + static_assert(sizeof(ErrorType) == sizeof(WGPUErrorType), "sizeof mismatch for ErrorType"); + static_assert(alignof(ErrorType) == alignof(WGPUErrorType), "alignof mismatch for ErrorType"); + + static_assert(static_cast(ErrorType::NoError) == WGPUErrorType_NoError, "value mismatch for ErrorType::NoError"); + static_assert(static_cast(ErrorType::Validation) == WGPUErrorType_Validation, "value mismatch for ErrorType::Validation"); + static_assert(static_cast(ErrorType::OutOfMemory) == WGPUErrorType_OutOfMemory, "value mismatch for ErrorType::OutOfMemory"); + static_assert(static_cast(ErrorType::Unknown) == WGPUErrorType_Unknown, "value mismatch for ErrorType::Unknown"); + static_assert(static_cast(ErrorType::DeviceLost) == WGPUErrorType_DeviceLost, "value mismatch for ErrorType::DeviceLost"); + + + static_assert(sizeof(FenceCompletionStatus) == sizeof(WGPUFenceCompletionStatus), "sizeof mismatch for FenceCompletionStatus"); + static_assert(alignof(FenceCompletionStatus) == alignof(WGPUFenceCompletionStatus), "alignof mismatch for FenceCompletionStatus"); + + static_assert(static_cast(FenceCompletionStatus::Success) == WGPUFenceCompletionStatus_Success, "value mismatch for FenceCompletionStatus::Success"); + static_assert(static_cast(FenceCompletionStatus::Error) == WGPUFenceCompletionStatus_Error, "value mismatch for FenceCompletionStatus::Error"); + static_assert(static_cast(FenceCompletionStatus::Unknown) == WGPUFenceCompletionStatus_Unknown, "value mismatch for FenceCompletionStatus::Unknown"); + static_assert(static_cast(FenceCompletionStatus::DeviceLost) == WGPUFenceCompletionStatus_DeviceLost, "value mismatch for FenceCompletionStatus::DeviceLost"); + + + static_assert(sizeof(FilterMode) == sizeof(WGPUFilterMode), "sizeof mismatch for FilterMode"); + static_assert(alignof(FilterMode) == alignof(WGPUFilterMode), "alignof mismatch for FilterMode"); + + static_assert(static_cast(FilterMode::Nearest) == WGPUFilterMode_Nearest, "value mismatch for FilterMode::Nearest"); + static_assert(static_cast(FilterMode::Linear) == WGPUFilterMode_Linear, "value mismatch for FilterMode::Linear"); + + + static_assert(sizeof(FrontFace) == sizeof(WGPUFrontFace), "sizeof mismatch for FrontFace"); + static_assert(alignof(FrontFace) == alignof(WGPUFrontFace), "alignof mismatch for FrontFace"); + + static_assert(static_cast(FrontFace::CCW) == WGPUFrontFace_CCW, "value mismatch for FrontFace::CCW"); + static_assert(static_cast(FrontFace::CW) == WGPUFrontFace_CW, "value mismatch for FrontFace::CW"); + + + static_assert(sizeof(IndexFormat) == sizeof(WGPUIndexFormat), "sizeof mismatch for IndexFormat"); + static_assert(alignof(IndexFormat) == alignof(WGPUIndexFormat), "alignof mismatch for IndexFormat"); + + static_assert(static_cast(IndexFormat::Uint16) == WGPUIndexFormat_Uint16, "value mismatch for IndexFormat::Uint16"); + static_assert(static_cast(IndexFormat::Uint32) == WGPUIndexFormat_Uint32, "value mismatch for IndexFormat::Uint32"); + + + static_assert(sizeof(InputStepMode) == sizeof(WGPUInputStepMode), "sizeof mismatch for InputStepMode"); + static_assert(alignof(InputStepMode) == alignof(WGPUInputStepMode), "alignof mismatch for InputStepMode"); + + static_assert(static_cast(InputStepMode::Vertex) == WGPUInputStepMode_Vertex, "value mismatch for InputStepMode::Vertex"); + static_assert(static_cast(InputStepMode::Instance) == WGPUInputStepMode_Instance, "value mismatch for InputStepMode::Instance"); + + + static_assert(sizeof(LoadOp) == sizeof(WGPULoadOp), "sizeof mismatch for LoadOp"); + static_assert(alignof(LoadOp) == alignof(WGPULoadOp), "alignof mismatch for LoadOp"); + + static_assert(static_cast(LoadOp::Clear) == WGPULoadOp_Clear, "value mismatch for LoadOp::Clear"); + static_assert(static_cast(LoadOp::Load) == WGPULoadOp_Load, "value mismatch for LoadOp::Load"); + + + static_assert(sizeof(PresentMode) == sizeof(WGPUPresentMode), "sizeof mismatch for PresentMode"); + static_assert(alignof(PresentMode) == alignof(WGPUPresentMode), "alignof mismatch for PresentMode"); + + static_assert(static_cast(PresentMode::Immediate) == WGPUPresentMode_Immediate, "value mismatch for PresentMode::Immediate"); + static_assert(static_cast(PresentMode::Mailbox) == WGPUPresentMode_Mailbox, "value mismatch for PresentMode::Mailbox"); + static_assert(static_cast(PresentMode::Fifo) == WGPUPresentMode_Fifo, "value mismatch for PresentMode::Fifo"); + + + static_assert(sizeof(PrimitiveTopology) == sizeof(WGPUPrimitiveTopology), "sizeof mismatch for PrimitiveTopology"); + static_assert(alignof(PrimitiveTopology) == alignof(WGPUPrimitiveTopology), "alignof mismatch for PrimitiveTopology"); + + static_assert(static_cast(PrimitiveTopology::PointList) == WGPUPrimitiveTopology_PointList, "value mismatch for PrimitiveTopology::PointList"); + static_assert(static_cast(PrimitiveTopology::LineList) == WGPUPrimitiveTopology_LineList, "value mismatch for PrimitiveTopology::LineList"); + static_assert(static_cast(PrimitiveTopology::LineStrip) == WGPUPrimitiveTopology_LineStrip, "value mismatch for PrimitiveTopology::LineStrip"); + static_assert(static_cast(PrimitiveTopology::TriangleList) == WGPUPrimitiveTopology_TriangleList, "value mismatch for PrimitiveTopology::TriangleList"); + static_assert(static_cast(PrimitiveTopology::TriangleStrip) == WGPUPrimitiveTopology_TriangleStrip, "value mismatch for PrimitiveTopology::TriangleStrip"); + + + static_assert(sizeof(SType) == sizeof(WGPUSType), "sizeof mismatch for SType"); + static_assert(alignof(SType) == alignof(WGPUSType), "alignof mismatch for SType"); + + static_assert(static_cast(SType::Invalid) == WGPUSType_Invalid, "value mismatch for SType::Invalid"); + static_assert(static_cast(SType::SurfaceDescriptorFromMetalLayer) == WGPUSType_SurfaceDescriptorFromMetalLayer, "value mismatch for SType::SurfaceDescriptorFromMetalLayer"); + static_assert(static_cast(SType::SurfaceDescriptorFromWindowsHWND) == WGPUSType_SurfaceDescriptorFromWindowsHWND, "value mismatch for SType::SurfaceDescriptorFromWindowsHWND"); + static_assert(static_cast(SType::SurfaceDescriptorFromXlib) == WGPUSType_SurfaceDescriptorFromXlib, "value mismatch for SType::SurfaceDescriptorFromXlib"); + static_assert(static_cast(SType::SurfaceDescriptorFromHTMLCanvasId) == WGPUSType_SurfaceDescriptorFromHTMLCanvasId, "value mismatch for SType::SurfaceDescriptorFromHTMLCanvasId"); + static_assert(static_cast(SType::ShaderModuleSPIRVDescriptor) == WGPUSType_ShaderModuleSPIRVDescriptor, "value mismatch for SType::ShaderModuleSPIRVDescriptor"); + static_assert(static_cast(SType::ShaderModuleWGSLDescriptor) == WGPUSType_ShaderModuleWGSLDescriptor, "value mismatch for SType::ShaderModuleWGSLDescriptor"); + static_assert(static_cast(SType::SamplerDescriptorDummyAnisotropicFiltering) == WGPUSType_SamplerDescriptorDummyAnisotropicFiltering, "value mismatch for SType::SamplerDescriptorDummyAnisotropicFiltering"); + static_assert(static_cast(SType::RenderPipelineDescriptorDummyExtension) == WGPUSType_RenderPipelineDescriptorDummyExtension, "value mismatch for SType::RenderPipelineDescriptorDummyExtension"); + + + static_assert(sizeof(StencilOperation) == sizeof(WGPUStencilOperation), "sizeof mismatch for StencilOperation"); + static_assert(alignof(StencilOperation) == alignof(WGPUStencilOperation), "alignof mismatch for StencilOperation"); + + static_assert(static_cast(StencilOperation::Keep) == WGPUStencilOperation_Keep, "value mismatch for StencilOperation::Keep"); + static_assert(static_cast(StencilOperation::Zero) == WGPUStencilOperation_Zero, "value mismatch for StencilOperation::Zero"); + static_assert(static_cast(StencilOperation::Replace) == WGPUStencilOperation_Replace, "value mismatch for StencilOperation::Replace"); + static_assert(static_cast(StencilOperation::Invert) == WGPUStencilOperation_Invert, "value mismatch for StencilOperation::Invert"); + static_assert(static_cast(StencilOperation::IncrementClamp) == WGPUStencilOperation_IncrementClamp, "value mismatch for StencilOperation::IncrementClamp"); + static_assert(static_cast(StencilOperation::DecrementClamp) == WGPUStencilOperation_DecrementClamp, "value mismatch for StencilOperation::DecrementClamp"); + static_assert(static_cast(StencilOperation::IncrementWrap) == WGPUStencilOperation_IncrementWrap, "value mismatch for StencilOperation::IncrementWrap"); + static_assert(static_cast(StencilOperation::DecrementWrap) == WGPUStencilOperation_DecrementWrap, "value mismatch for StencilOperation::DecrementWrap"); + + + static_assert(sizeof(StoreOp) == sizeof(WGPUStoreOp), "sizeof mismatch for StoreOp"); + static_assert(alignof(StoreOp) == alignof(WGPUStoreOp), "alignof mismatch for StoreOp"); + + static_assert(static_cast(StoreOp::Store) == WGPUStoreOp_Store, "value mismatch for StoreOp::Store"); + static_assert(static_cast(StoreOp::Clear) == WGPUStoreOp_Clear, "value mismatch for StoreOp::Clear"); + + + static_assert(sizeof(TextureAspect) == sizeof(WGPUTextureAspect), "sizeof mismatch for TextureAspect"); + static_assert(alignof(TextureAspect) == alignof(WGPUTextureAspect), "alignof mismatch for TextureAspect"); + + static_assert(static_cast(TextureAspect::All) == WGPUTextureAspect_All, "value mismatch for TextureAspect::All"); + static_assert(static_cast(TextureAspect::StencilOnly) == WGPUTextureAspect_StencilOnly, "value mismatch for TextureAspect::StencilOnly"); + static_assert(static_cast(TextureAspect::DepthOnly) == WGPUTextureAspect_DepthOnly, "value mismatch for TextureAspect::DepthOnly"); + + + static_assert(sizeof(TextureComponentType) == sizeof(WGPUTextureComponentType), "sizeof mismatch for TextureComponentType"); + static_assert(alignof(TextureComponentType) == alignof(WGPUTextureComponentType), "alignof mismatch for TextureComponentType"); + + static_assert(static_cast(TextureComponentType::Float) == WGPUTextureComponentType_Float, "value mismatch for TextureComponentType::Float"); + static_assert(static_cast(TextureComponentType::Sint) == WGPUTextureComponentType_Sint, "value mismatch for TextureComponentType::Sint"); + static_assert(static_cast(TextureComponentType::Uint) == WGPUTextureComponentType_Uint, "value mismatch for TextureComponentType::Uint"); + + + static_assert(sizeof(TextureDimension) == sizeof(WGPUTextureDimension), "sizeof mismatch for TextureDimension"); + static_assert(alignof(TextureDimension) == alignof(WGPUTextureDimension), "alignof mismatch for TextureDimension"); + + static_assert(static_cast(TextureDimension::e1D) == WGPUTextureDimension_1D, "value mismatch for TextureDimension::e1D"); + static_assert(static_cast(TextureDimension::e2D) == WGPUTextureDimension_2D, "value mismatch for TextureDimension::e2D"); + static_assert(static_cast(TextureDimension::e3D) == WGPUTextureDimension_3D, "value mismatch for TextureDimension::e3D"); + + + static_assert(sizeof(TextureFormat) == sizeof(WGPUTextureFormat), "sizeof mismatch for TextureFormat"); + static_assert(alignof(TextureFormat) == alignof(WGPUTextureFormat), "alignof mismatch for TextureFormat"); + + static_assert(static_cast(TextureFormat::Undefined) == WGPUTextureFormat_Undefined, "value mismatch for TextureFormat::Undefined"); + static_assert(static_cast(TextureFormat::R8Unorm) == WGPUTextureFormat_R8Unorm, "value mismatch for TextureFormat::R8Unorm"); + static_assert(static_cast(TextureFormat::R8Snorm) == WGPUTextureFormat_R8Snorm, "value mismatch for TextureFormat::R8Snorm"); + static_assert(static_cast(TextureFormat::R8Uint) == WGPUTextureFormat_R8Uint, "value mismatch for TextureFormat::R8Uint"); + static_assert(static_cast(TextureFormat::R8Sint) == WGPUTextureFormat_R8Sint, "value mismatch for TextureFormat::R8Sint"); + static_assert(static_cast(TextureFormat::R16Uint) == WGPUTextureFormat_R16Uint, "value mismatch for TextureFormat::R16Uint"); + static_assert(static_cast(TextureFormat::R16Sint) == WGPUTextureFormat_R16Sint, "value mismatch for TextureFormat::R16Sint"); + static_assert(static_cast(TextureFormat::R16Float) == WGPUTextureFormat_R16Float, "value mismatch for TextureFormat::R16Float"); + static_assert(static_cast(TextureFormat::RG8Unorm) == WGPUTextureFormat_RG8Unorm, "value mismatch for TextureFormat::RG8Unorm"); + static_assert(static_cast(TextureFormat::RG8Snorm) == WGPUTextureFormat_RG8Snorm, "value mismatch for TextureFormat::RG8Snorm"); + static_assert(static_cast(TextureFormat::RG8Uint) == WGPUTextureFormat_RG8Uint, "value mismatch for TextureFormat::RG8Uint"); + static_assert(static_cast(TextureFormat::RG8Sint) == WGPUTextureFormat_RG8Sint, "value mismatch for TextureFormat::RG8Sint"); + static_assert(static_cast(TextureFormat::R32Float) == WGPUTextureFormat_R32Float, "value mismatch for TextureFormat::R32Float"); + static_assert(static_cast(TextureFormat::R32Uint) == WGPUTextureFormat_R32Uint, "value mismatch for TextureFormat::R32Uint"); + static_assert(static_cast(TextureFormat::R32Sint) == WGPUTextureFormat_R32Sint, "value mismatch for TextureFormat::R32Sint"); + static_assert(static_cast(TextureFormat::RG16Uint) == WGPUTextureFormat_RG16Uint, "value mismatch for TextureFormat::RG16Uint"); + static_assert(static_cast(TextureFormat::RG16Sint) == WGPUTextureFormat_RG16Sint, "value mismatch for TextureFormat::RG16Sint"); + static_assert(static_cast(TextureFormat::RG16Float) == WGPUTextureFormat_RG16Float, "value mismatch for TextureFormat::RG16Float"); + static_assert(static_cast(TextureFormat::RGBA8Unorm) == WGPUTextureFormat_RGBA8Unorm, "value mismatch for TextureFormat::RGBA8Unorm"); + static_assert(static_cast(TextureFormat::RGBA8UnormSrgb) == WGPUTextureFormat_RGBA8UnormSrgb, "value mismatch for TextureFormat::RGBA8UnormSrgb"); + static_assert(static_cast(TextureFormat::RGBA8Snorm) == WGPUTextureFormat_RGBA8Snorm, "value mismatch for TextureFormat::RGBA8Snorm"); + static_assert(static_cast(TextureFormat::RGBA8Uint) == WGPUTextureFormat_RGBA8Uint, "value mismatch for TextureFormat::RGBA8Uint"); + static_assert(static_cast(TextureFormat::RGBA8Sint) == WGPUTextureFormat_RGBA8Sint, "value mismatch for TextureFormat::RGBA8Sint"); + static_assert(static_cast(TextureFormat::BGRA8Unorm) == WGPUTextureFormat_BGRA8Unorm, "value mismatch for TextureFormat::BGRA8Unorm"); + static_assert(static_cast(TextureFormat::BGRA8UnormSrgb) == WGPUTextureFormat_BGRA8UnormSrgb, "value mismatch for TextureFormat::BGRA8UnormSrgb"); + static_assert(static_cast(TextureFormat::RGB10A2Unorm) == WGPUTextureFormat_RGB10A2Unorm, "value mismatch for TextureFormat::RGB10A2Unorm"); + static_assert(static_cast(TextureFormat::RG11B10Float) == WGPUTextureFormat_RG11B10Float, "value mismatch for TextureFormat::RG11B10Float"); + static_assert(static_cast(TextureFormat::RG32Float) == WGPUTextureFormat_RG32Float, "value mismatch for TextureFormat::RG32Float"); + static_assert(static_cast(TextureFormat::RG32Uint) == WGPUTextureFormat_RG32Uint, "value mismatch for TextureFormat::RG32Uint"); + static_assert(static_cast(TextureFormat::RG32Sint) == WGPUTextureFormat_RG32Sint, "value mismatch for TextureFormat::RG32Sint"); + static_assert(static_cast(TextureFormat::RGBA16Uint) == WGPUTextureFormat_RGBA16Uint, "value mismatch for TextureFormat::RGBA16Uint"); + static_assert(static_cast(TextureFormat::RGBA16Sint) == WGPUTextureFormat_RGBA16Sint, "value mismatch for TextureFormat::RGBA16Sint"); + static_assert(static_cast(TextureFormat::RGBA16Float) == WGPUTextureFormat_RGBA16Float, "value mismatch for TextureFormat::RGBA16Float"); + static_assert(static_cast(TextureFormat::RGBA32Float) == WGPUTextureFormat_RGBA32Float, "value mismatch for TextureFormat::RGBA32Float"); + static_assert(static_cast(TextureFormat::RGBA32Uint) == WGPUTextureFormat_RGBA32Uint, "value mismatch for TextureFormat::RGBA32Uint"); + static_assert(static_cast(TextureFormat::RGBA32Sint) == WGPUTextureFormat_RGBA32Sint, "value mismatch for TextureFormat::RGBA32Sint"); + static_assert(static_cast(TextureFormat::Depth32Float) == WGPUTextureFormat_Depth32Float, "value mismatch for TextureFormat::Depth32Float"); + static_assert(static_cast(TextureFormat::Depth24Plus) == WGPUTextureFormat_Depth24Plus, "value mismatch for TextureFormat::Depth24Plus"); + static_assert(static_cast(TextureFormat::Depth24PlusStencil8) == WGPUTextureFormat_Depth24PlusStencil8, "value mismatch for TextureFormat::Depth24PlusStencil8"); + static_assert(static_cast(TextureFormat::BC1RGBAUnorm) == WGPUTextureFormat_BC1RGBAUnorm, "value mismatch for TextureFormat::BC1RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC1RGBAUnormSrgb) == WGPUTextureFormat_BC1RGBAUnormSrgb, "value mismatch for TextureFormat::BC1RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC2RGBAUnorm) == WGPUTextureFormat_BC2RGBAUnorm, "value mismatch for TextureFormat::BC2RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC2RGBAUnormSrgb) == WGPUTextureFormat_BC2RGBAUnormSrgb, "value mismatch for TextureFormat::BC2RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC3RGBAUnorm) == WGPUTextureFormat_BC3RGBAUnorm, "value mismatch for TextureFormat::BC3RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC3RGBAUnormSrgb) == WGPUTextureFormat_BC3RGBAUnormSrgb, "value mismatch for TextureFormat::BC3RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC4RUnorm) == WGPUTextureFormat_BC4RUnorm, "value mismatch for TextureFormat::BC4RUnorm"); + static_assert(static_cast(TextureFormat::BC4RSnorm) == WGPUTextureFormat_BC4RSnorm, "value mismatch for TextureFormat::BC4RSnorm"); + static_assert(static_cast(TextureFormat::BC5RGUnorm) == WGPUTextureFormat_BC5RGUnorm, "value mismatch for TextureFormat::BC5RGUnorm"); + static_assert(static_cast(TextureFormat::BC5RGSnorm) == WGPUTextureFormat_BC5RGSnorm, "value mismatch for TextureFormat::BC5RGSnorm"); + static_assert(static_cast(TextureFormat::BC6HRGBUfloat) == WGPUTextureFormat_BC6HRGBUfloat, "value mismatch for TextureFormat::BC6HRGBUfloat"); + static_assert(static_cast(TextureFormat::BC6HRGBSfloat) == WGPUTextureFormat_BC6HRGBSfloat, "value mismatch for TextureFormat::BC6HRGBSfloat"); + static_assert(static_cast(TextureFormat::BC7RGBAUnorm) == WGPUTextureFormat_BC7RGBAUnorm, "value mismatch for TextureFormat::BC7RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC7RGBAUnormSrgb) == WGPUTextureFormat_BC7RGBAUnormSrgb, "value mismatch for TextureFormat::BC7RGBAUnormSrgb"); + + + static_assert(sizeof(TextureViewDimension) == sizeof(WGPUTextureViewDimension), "sizeof mismatch for TextureViewDimension"); + static_assert(alignof(TextureViewDimension) == alignof(WGPUTextureViewDimension), "alignof mismatch for TextureViewDimension"); + + static_assert(static_cast(TextureViewDimension::Undefined) == WGPUTextureViewDimension_Undefined, "value mismatch for TextureViewDimension::Undefined"); + static_assert(static_cast(TextureViewDimension::e1D) == WGPUTextureViewDimension_1D, "value mismatch for TextureViewDimension::e1D"); + static_assert(static_cast(TextureViewDimension::e2D) == WGPUTextureViewDimension_2D, "value mismatch for TextureViewDimension::e2D"); + static_assert(static_cast(TextureViewDimension::e2DArray) == WGPUTextureViewDimension_2DArray, "value mismatch for TextureViewDimension::e2DArray"); + static_assert(static_cast(TextureViewDimension::Cube) == WGPUTextureViewDimension_Cube, "value mismatch for TextureViewDimension::Cube"); + static_assert(static_cast(TextureViewDimension::CubeArray) == WGPUTextureViewDimension_CubeArray, "value mismatch for TextureViewDimension::CubeArray"); + static_assert(static_cast(TextureViewDimension::e3D) == WGPUTextureViewDimension_3D, "value mismatch for TextureViewDimension::e3D"); + + + static_assert(sizeof(VertexFormat) == sizeof(WGPUVertexFormat), "sizeof mismatch for VertexFormat"); + static_assert(alignof(VertexFormat) == alignof(WGPUVertexFormat), "alignof mismatch for VertexFormat"); + + static_assert(static_cast(VertexFormat::UChar2) == WGPUVertexFormat_UChar2, "value mismatch for VertexFormat::UChar2"); + static_assert(static_cast(VertexFormat::UChar4) == WGPUVertexFormat_UChar4, "value mismatch for VertexFormat::UChar4"); + static_assert(static_cast(VertexFormat::Char2) == WGPUVertexFormat_Char2, "value mismatch for VertexFormat::Char2"); + static_assert(static_cast(VertexFormat::Char4) == WGPUVertexFormat_Char4, "value mismatch for VertexFormat::Char4"); + static_assert(static_cast(VertexFormat::UChar2Norm) == WGPUVertexFormat_UChar2Norm, "value mismatch for VertexFormat::UChar2Norm"); + static_assert(static_cast(VertexFormat::UChar4Norm) == WGPUVertexFormat_UChar4Norm, "value mismatch for VertexFormat::UChar4Norm"); + static_assert(static_cast(VertexFormat::Char2Norm) == WGPUVertexFormat_Char2Norm, "value mismatch for VertexFormat::Char2Norm"); + static_assert(static_cast(VertexFormat::Char4Norm) == WGPUVertexFormat_Char4Norm, "value mismatch for VertexFormat::Char4Norm"); + static_assert(static_cast(VertexFormat::UShort2) == WGPUVertexFormat_UShort2, "value mismatch for VertexFormat::UShort2"); + static_assert(static_cast(VertexFormat::UShort4) == WGPUVertexFormat_UShort4, "value mismatch for VertexFormat::UShort4"); + static_assert(static_cast(VertexFormat::Short2) == WGPUVertexFormat_Short2, "value mismatch for VertexFormat::Short2"); + static_assert(static_cast(VertexFormat::Short4) == WGPUVertexFormat_Short4, "value mismatch for VertexFormat::Short4"); + static_assert(static_cast(VertexFormat::UShort2Norm) == WGPUVertexFormat_UShort2Norm, "value mismatch for VertexFormat::UShort2Norm"); + static_assert(static_cast(VertexFormat::UShort4Norm) == WGPUVertexFormat_UShort4Norm, "value mismatch for VertexFormat::UShort4Norm"); + static_assert(static_cast(VertexFormat::Short2Norm) == WGPUVertexFormat_Short2Norm, "value mismatch for VertexFormat::Short2Norm"); + static_assert(static_cast(VertexFormat::Short4Norm) == WGPUVertexFormat_Short4Norm, "value mismatch for VertexFormat::Short4Norm"); + static_assert(static_cast(VertexFormat::Half2) == WGPUVertexFormat_Half2, "value mismatch for VertexFormat::Half2"); + static_assert(static_cast(VertexFormat::Half4) == WGPUVertexFormat_Half4, "value mismatch for VertexFormat::Half4"); + static_assert(static_cast(VertexFormat::Float) == WGPUVertexFormat_Float, "value mismatch for VertexFormat::Float"); + static_assert(static_cast(VertexFormat::Float2) == WGPUVertexFormat_Float2, "value mismatch for VertexFormat::Float2"); + static_assert(static_cast(VertexFormat::Float3) == WGPUVertexFormat_Float3, "value mismatch for VertexFormat::Float3"); + static_assert(static_cast(VertexFormat::Float4) == WGPUVertexFormat_Float4, "value mismatch for VertexFormat::Float4"); + static_assert(static_cast(VertexFormat::UInt) == WGPUVertexFormat_UInt, "value mismatch for VertexFormat::UInt"); + static_assert(static_cast(VertexFormat::UInt2) == WGPUVertexFormat_UInt2, "value mismatch for VertexFormat::UInt2"); + static_assert(static_cast(VertexFormat::UInt3) == WGPUVertexFormat_UInt3, "value mismatch for VertexFormat::UInt3"); + static_assert(static_cast(VertexFormat::UInt4) == WGPUVertexFormat_UInt4, "value mismatch for VertexFormat::UInt4"); + static_assert(static_cast(VertexFormat::Int) == WGPUVertexFormat_Int, "value mismatch for VertexFormat::Int"); + static_assert(static_cast(VertexFormat::Int2) == WGPUVertexFormat_Int2, "value mismatch for VertexFormat::Int2"); + static_assert(static_cast(VertexFormat::Int3) == WGPUVertexFormat_Int3, "value mismatch for VertexFormat::Int3"); + static_assert(static_cast(VertexFormat::Int4) == WGPUVertexFormat_Int4, "value mismatch for VertexFormat::Int4"); + + + + static_assert(sizeof(BufferUsage) == sizeof(WGPUBufferUsageFlags), "sizeof mismatch for BufferUsage"); + static_assert(alignof(BufferUsage) == alignof(WGPUBufferUsageFlags), "alignof mismatch for BufferUsage"); + + static_assert(static_cast(BufferUsage::None) == WGPUBufferUsage_None, "value mismatch for BufferUsage::None"); + static_assert(static_cast(BufferUsage::MapRead) == WGPUBufferUsage_MapRead, "value mismatch for BufferUsage::MapRead"); + static_assert(static_cast(BufferUsage::MapWrite) == WGPUBufferUsage_MapWrite, "value mismatch for BufferUsage::MapWrite"); + static_assert(static_cast(BufferUsage::CopySrc) == WGPUBufferUsage_CopySrc, "value mismatch for BufferUsage::CopySrc"); + static_assert(static_cast(BufferUsage::CopyDst) == WGPUBufferUsage_CopyDst, "value mismatch for BufferUsage::CopyDst"); + static_assert(static_cast(BufferUsage::Index) == WGPUBufferUsage_Index, "value mismatch for BufferUsage::Index"); + static_assert(static_cast(BufferUsage::Vertex) == WGPUBufferUsage_Vertex, "value mismatch for BufferUsage::Vertex"); + static_assert(static_cast(BufferUsage::Uniform) == WGPUBufferUsage_Uniform, "value mismatch for BufferUsage::Uniform"); + static_assert(static_cast(BufferUsage::Storage) == WGPUBufferUsage_Storage, "value mismatch for BufferUsage::Storage"); + static_assert(static_cast(BufferUsage::Indirect) == WGPUBufferUsage_Indirect, "value mismatch for BufferUsage::Indirect"); + + + static_assert(sizeof(ColorWriteMask) == sizeof(WGPUColorWriteMaskFlags), "sizeof mismatch for ColorWriteMask"); + static_assert(alignof(ColorWriteMask) == alignof(WGPUColorWriteMaskFlags), "alignof mismatch for ColorWriteMask"); + + static_assert(static_cast(ColorWriteMask::None) == WGPUColorWriteMask_None, "value mismatch for ColorWriteMask::None"); + static_assert(static_cast(ColorWriteMask::Red) == WGPUColorWriteMask_Red, "value mismatch for ColorWriteMask::Red"); + static_assert(static_cast(ColorWriteMask::Green) == WGPUColorWriteMask_Green, "value mismatch for ColorWriteMask::Green"); + static_assert(static_cast(ColorWriteMask::Blue) == WGPUColorWriteMask_Blue, "value mismatch for ColorWriteMask::Blue"); + static_assert(static_cast(ColorWriteMask::Alpha) == WGPUColorWriteMask_Alpha, "value mismatch for ColorWriteMask::Alpha"); + static_assert(static_cast(ColorWriteMask::All) == WGPUColorWriteMask_All, "value mismatch for ColorWriteMask::All"); + + + static_assert(sizeof(ShaderStage) == sizeof(WGPUShaderStageFlags), "sizeof mismatch for ShaderStage"); + static_assert(alignof(ShaderStage) == alignof(WGPUShaderStageFlags), "alignof mismatch for ShaderStage"); + + static_assert(static_cast(ShaderStage::None) == WGPUShaderStage_None, "value mismatch for ShaderStage::None"); + static_assert(static_cast(ShaderStage::Vertex) == WGPUShaderStage_Vertex, "value mismatch for ShaderStage::Vertex"); + static_assert(static_cast(ShaderStage::Fragment) == WGPUShaderStage_Fragment, "value mismatch for ShaderStage::Fragment"); + static_assert(static_cast(ShaderStage::Compute) == WGPUShaderStage_Compute, "value mismatch for ShaderStage::Compute"); + + + static_assert(sizeof(TextureUsage) == sizeof(WGPUTextureUsageFlags), "sizeof mismatch for TextureUsage"); + static_assert(alignof(TextureUsage) == alignof(WGPUTextureUsageFlags), "alignof mismatch for TextureUsage"); + + static_assert(static_cast(TextureUsage::None) == WGPUTextureUsage_None, "value mismatch for TextureUsage::None"); + static_assert(static_cast(TextureUsage::CopySrc) == WGPUTextureUsage_CopySrc, "value mismatch for TextureUsage::CopySrc"); + static_assert(static_cast(TextureUsage::CopyDst) == WGPUTextureUsage_CopyDst, "value mismatch for TextureUsage::CopyDst"); + static_assert(static_cast(TextureUsage::Sampled) == WGPUTextureUsage_Sampled, "value mismatch for TextureUsage::Sampled"); + static_assert(static_cast(TextureUsage::Storage) == WGPUTextureUsage_Storage, "value mismatch for TextureUsage::Storage"); + static_assert(static_cast(TextureUsage::OutputAttachment) == WGPUTextureUsage_OutputAttachment, "value mismatch for TextureUsage::OutputAttachment"); + static_assert(static_cast(TextureUsage::Present) == WGPUTextureUsage_Present, "value mismatch for TextureUsage::Present"); + + + static_assert(sizeof(ChainedStruct) == sizeof(WGPUChainedStruct), + "sizeof mismatch for ChainedStruct"); + static_assert(alignof(ChainedStruct) == alignof(WGPUChainedStruct), + "alignof mismatch for ChainedStruct"); + static_assert(offsetof(ChainedStruct, nextInChain) == offsetof(WGPUChainedStruct, next), + "offsetof mismatch for ChainedStruct::nextInChain"); + static_assert(offsetof(ChainedStruct, sType) == offsetof(WGPUChainedStruct, sType), + "offsetof mismatch for ChainedStruct::sType"); + + + static_assert(sizeof(AdapterProperties) == sizeof(WGPUAdapterProperties), "sizeof mismatch for AdapterProperties"); + static_assert(alignof(AdapterProperties) == alignof(WGPUAdapterProperties), "alignof mismatch for AdapterProperties"); + + static_assert(offsetof(AdapterProperties, nextInChain) == offsetof(WGPUAdapterProperties, nextInChain), + "offsetof mismatch for AdapterProperties::nextInChain"); + static_assert(offsetof(AdapterProperties, deviceID) == offsetof(WGPUAdapterProperties, deviceID), + "offsetof mismatch for AdapterProperties::deviceID"); + static_assert(offsetof(AdapterProperties, vendorID) == offsetof(WGPUAdapterProperties, vendorID), + "offsetof mismatch for AdapterProperties::vendorID"); + static_assert(offsetof(AdapterProperties, name) == offsetof(WGPUAdapterProperties, name), + "offsetof mismatch for AdapterProperties::name"); + static_assert(offsetof(AdapterProperties, adapterType) == offsetof(WGPUAdapterProperties, adapterType), + "offsetof mismatch for AdapterProperties::adapterType"); + static_assert(offsetof(AdapterProperties, backendType) == offsetof(WGPUAdapterProperties, backendType), + "offsetof mismatch for AdapterProperties::backendType"); + + + static_assert(sizeof(BindGroupEntry) == sizeof(WGPUBindGroupEntry), "sizeof mismatch for BindGroupEntry"); + static_assert(alignof(BindGroupEntry) == alignof(WGPUBindGroupEntry), "alignof mismatch for BindGroupEntry"); + + static_assert(offsetof(BindGroupEntry, binding) == offsetof(WGPUBindGroupEntry, binding), + "offsetof mismatch for BindGroupEntry::binding"); + static_assert(offsetof(BindGroupEntry, buffer) == offsetof(WGPUBindGroupEntry, buffer), + "offsetof mismatch for BindGroupEntry::buffer"); + static_assert(offsetof(BindGroupEntry, offset) == offsetof(WGPUBindGroupEntry, offset), + "offsetof mismatch for BindGroupEntry::offset"); + static_assert(offsetof(BindGroupEntry, size) == offsetof(WGPUBindGroupEntry, size), + "offsetof mismatch for BindGroupEntry::size"); + static_assert(offsetof(BindGroupEntry, sampler) == offsetof(WGPUBindGroupEntry, sampler), + "offsetof mismatch for BindGroupEntry::sampler"); + static_assert(offsetof(BindGroupEntry, textureView) == offsetof(WGPUBindGroupEntry, textureView), + "offsetof mismatch for BindGroupEntry::textureView"); + + + static_assert(sizeof(BindGroupLayoutEntry) == sizeof(WGPUBindGroupLayoutEntry), "sizeof mismatch for BindGroupLayoutEntry"); + static_assert(alignof(BindGroupLayoutEntry) == alignof(WGPUBindGroupLayoutEntry), "alignof mismatch for BindGroupLayoutEntry"); + + static_assert(offsetof(BindGroupLayoutEntry, binding) == offsetof(WGPUBindGroupLayoutEntry, binding), + "offsetof mismatch for BindGroupLayoutEntry::binding"); + static_assert(offsetof(BindGroupLayoutEntry, visibility) == offsetof(WGPUBindGroupLayoutEntry, visibility), + "offsetof mismatch for BindGroupLayoutEntry::visibility"); + static_assert(offsetof(BindGroupLayoutEntry, type) == offsetof(WGPUBindGroupLayoutEntry, type), + "offsetof mismatch for BindGroupLayoutEntry::type"); + static_assert(offsetof(BindGroupLayoutEntry, hasDynamicOffset) == offsetof(WGPUBindGroupLayoutEntry, hasDynamicOffset), + "offsetof mismatch for BindGroupLayoutEntry::hasDynamicOffset"); + static_assert(offsetof(BindGroupLayoutEntry, multisampled) == offsetof(WGPUBindGroupLayoutEntry, multisampled), + "offsetof mismatch for BindGroupLayoutEntry::multisampled"); + static_assert(offsetof(BindGroupLayoutEntry, viewDimension) == offsetof(WGPUBindGroupLayoutEntry, viewDimension), + "offsetof mismatch for BindGroupLayoutEntry::viewDimension"); + static_assert(offsetof(BindGroupLayoutEntry, textureComponentType) == offsetof(WGPUBindGroupLayoutEntry, textureComponentType), + "offsetof mismatch for BindGroupLayoutEntry::textureComponentType"); + static_assert(offsetof(BindGroupLayoutEntry, storageTextureFormat) == offsetof(WGPUBindGroupLayoutEntry, storageTextureFormat), + "offsetof mismatch for BindGroupLayoutEntry::storageTextureFormat"); + + + static_assert(sizeof(BlendDescriptor) == sizeof(WGPUBlendDescriptor), "sizeof mismatch for BlendDescriptor"); + static_assert(alignof(BlendDescriptor) == alignof(WGPUBlendDescriptor), "alignof mismatch for BlendDescriptor"); + + static_assert(offsetof(BlendDescriptor, operation) == offsetof(WGPUBlendDescriptor, operation), + "offsetof mismatch for BlendDescriptor::operation"); + static_assert(offsetof(BlendDescriptor, srcFactor) == offsetof(WGPUBlendDescriptor, srcFactor), + "offsetof mismatch for BlendDescriptor::srcFactor"); + static_assert(offsetof(BlendDescriptor, dstFactor) == offsetof(WGPUBlendDescriptor, dstFactor), + "offsetof mismatch for BlendDescriptor::dstFactor"); + + + static_assert(sizeof(BufferCopyView) == sizeof(WGPUBufferCopyView), "sizeof mismatch for BufferCopyView"); + static_assert(alignof(BufferCopyView) == alignof(WGPUBufferCopyView), "alignof mismatch for BufferCopyView"); + + static_assert(offsetof(BufferCopyView, nextInChain) == offsetof(WGPUBufferCopyView, nextInChain), + "offsetof mismatch for BufferCopyView::nextInChain"); + static_assert(offsetof(BufferCopyView, buffer) == offsetof(WGPUBufferCopyView, buffer), + "offsetof mismatch for BufferCopyView::buffer"); + static_assert(offsetof(BufferCopyView, offset) == offsetof(WGPUBufferCopyView, offset), + "offsetof mismatch for BufferCopyView::offset"); + static_assert(offsetof(BufferCopyView, bytesPerRow) == offsetof(WGPUBufferCopyView, bytesPerRow), + "offsetof mismatch for BufferCopyView::bytesPerRow"); + static_assert(offsetof(BufferCopyView, rowsPerImage) == offsetof(WGPUBufferCopyView, rowsPerImage), + "offsetof mismatch for BufferCopyView::rowsPerImage"); + + + static_assert(sizeof(BufferDescriptor) == sizeof(WGPUBufferDescriptor), "sizeof mismatch for BufferDescriptor"); + static_assert(alignof(BufferDescriptor) == alignof(WGPUBufferDescriptor), "alignof mismatch for BufferDescriptor"); + + static_assert(offsetof(BufferDescriptor, nextInChain) == offsetof(WGPUBufferDescriptor, nextInChain), + "offsetof mismatch for BufferDescriptor::nextInChain"); + static_assert(offsetof(BufferDescriptor, label) == offsetof(WGPUBufferDescriptor, label), + "offsetof mismatch for BufferDescriptor::label"); + static_assert(offsetof(BufferDescriptor, usage) == offsetof(WGPUBufferDescriptor, usage), + "offsetof mismatch for BufferDescriptor::usage"); + static_assert(offsetof(BufferDescriptor, size) == offsetof(WGPUBufferDescriptor, size), + "offsetof mismatch for BufferDescriptor::size"); + + + static_assert(sizeof(Color) == sizeof(WGPUColor), "sizeof mismatch for Color"); + static_assert(alignof(Color) == alignof(WGPUColor), "alignof mismatch for Color"); + + static_assert(offsetof(Color, r) == offsetof(WGPUColor, r), + "offsetof mismatch for Color::r"); + static_assert(offsetof(Color, g) == offsetof(WGPUColor, g), + "offsetof mismatch for Color::g"); + static_assert(offsetof(Color, b) == offsetof(WGPUColor, b), + "offsetof mismatch for Color::b"); + static_assert(offsetof(Color, a) == offsetof(WGPUColor, a), + "offsetof mismatch for Color::a"); + + + static_assert(sizeof(CommandBufferDescriptor) == sizeof(WGPUCommandBufferDescriptor), "sizeof mismatch for CommandBufferDescriptor"); + static_assert(alignof(CommandBufferDescriptor) == alignof(WGPUCommandBufferDescriptor), "alignof mismatch for CommandBufferDescriptor"); + + static_assert(offsetof(CommandBufferDescriptor, nextInChain) == offsetof(WGPUCommandBufferDescriptor, nextInChain), + "offsetof mismatch for CommandBufferDescriptor::nextInChain"); + static_assert(offsetof(CommandBufferDescriptor, label) == offsetof(WGPUCommandBufferDescriptor, label), + "offsetof mismatch for CommandBufferDescriptor::label"); + + + static_assert(sizeof(CommandEncoderDescriptor) == sizeof(WGPUCommandEncoderDescriptor), "sizeof mismatch for CommandEncoderDescriptor"); + static_assert(alignof(CommandEncoderDescriptor) == alignof(WGPUCommandEncoderDescriptor), "alignof mismatch for CommandEncoderDescriptor"); + + static_assert(offsetof(CommandEncoderDescriptor, nextInChain) == offsetof(WGPUCommandEncoderDescriptor, nextInChain), + "offsetof mismatch for CommandEncoderDescriptor::nextInChain"); + static_assert(offsetof(CommandEncoderDescriptor, label) == offsetof(WGPUCommandEncoderDescriptor, label), + "offsetof mismatch for CommandEncoderDescriptor::label"); + + + static_assert(sizeof(ComputePassDescriptor) == sizeof(WGPUComputePassDescriptor), "sizeof mismatch for ComputePassDescriptor"); + static_assert(alignof(ComputePassDescriptor) == alignof(WGPUComputePassDescriptor), "alignof mismatch for ComputePassDescriptor"); + + static_assert(offsetof(ComputePassDescriptor, nextInChain) == offsetof(WGPUComputePassDescriptor, nextInChain), + "offsetof mismatch for ComputePassDescriptor::nextInChain"); + static_assert(offsetof(ComputePassDescriptor, label) == offsetof(WGPUComputePassDescriptor, label), + "offsetof mismatch for ComputePassDescriptor::label"); + + + static_assert(sizeof(CreateBufferMappedResult) == sizeof(WGPUCreateBufferMappedResult), "sizeof mismatch for CreateBufferMappedResult"); + static_assert(alignof(CreateBufferMappedResult) == alignof(WGPUCreateBufferMappedResult), "alignof mismatch for CreateBufferMappedResult"); + + static_assert(offsetof(CreateBufferMappedResult, buffer) == offsetof(WGPUCreateBufferMappedResult, buffer), + "offsetof mismatch for CreateBufferMappedResult::buffer"); + static_assert(offsetof(CreateBufferMappedResult, dataLength) == offsetof(WGPUCreateBufferMappedResult, dataLength), + "offsetof mismatch for CreateBufferMappedResult::dataLength"); + static_assert(offsetof(CreateBufferMappedResult, data) == offsetof(WGPUCreateBufferMappedResult, data), + "offsetof mismatch for CreateBufferMappedResult::data"); + + + static_assert(sizeof(DeviceProperties) == sizeof(WGPUDeviceProperties), "sizeof mismatch for DeviceProperties"); + static_assert(alignof(DeviceProperties) == alignof(WGPUDeviceProperties), "alignof mismatch for DeviceProperties"); + + static_assert(offsetof(DeviceProperties, textureCompressionBC) == offsetof(WGPUDeviceProperties, textureCompressionBC), + "offsetof mismatch for DeviceProperties::textureCompressionBC"); + static_assert(offsetof(DeviceProperties, shaderFloat16) == offsetof(WGPUDeviceProperties, shaderFloat16), + "offsetof mismatch for DeviceProperties::shaderFloat16"); + static_assert(offsetof(DeviceProperties, pipelineStatisticsQuery) == offsetof(WGPUDeviceProperties, pipelineStatisticsQuery), + "offsetof mismatch for DeviceProperties::pipelineStatisticsQuery"); + static_assert(offsetof(DeviceProperties, timestampQuery) == offsetof(WGPUDeviceProperties, timestampQuery), + "offsetof mismatch for DeviceProperties::timestampQuery"); + + + static_assert(sizeof(Extent3D) == sizeof(WGPUExtent3D), "sizeof mismatch for Extent3D"); + static_assert(alignof(Extent3D) == alignof(WGPUExtent3D), "alignof mismatch for Extent3D"); + + static_assert(offsetof(Extent3D, width) == offsetof(WGPUExtent3D, width), + "offsetof mismatch for Extent3D::width"); + static_assert(offsetof(Extent3D, height) == offsetof(WGPUExtent3D, height), + "offsetof mismatch for Extent3D::height"); + static_assert(offsetof(Extent3D, depth) == offsetof(WGPUExtent3D, depth), + "offsetof mismatch for Extent3D::depth"); + + + static_assert(sizeof(FenceDescriptor) == sizeof(WGPUFenceDescriptor), "sizeof mismatch for FenceDescriptor"); + static_assert(alignof(FenceDescriptor) == alignof(WGPUFenceDescriptor), "alignof mismatch for FenceDescriptor"); + + static_assert(offsetof(FenceDescriptor, nextInChain) == offsetof(WGPUFenceDescriptor, nextInChain), + "offsetof mismatch for FenceDescriptor::nextInChain"); + static_assert(offsetof(FenceDescriptor, label) == offsetof(WGPUFenceDescriptor, label), + "offsetof mismatch for FenceDescriptor::label"); + static_assert(offsetof(FenceDescriptor, initialValue) == offsetof(WGPUFenceDescriptor, initialValue), + "offsetof mismatch for FenceDescriptor::initialValue"); + + + static_assert(sizeof(InstanceDescriptor) == sizeof(WGPUInstanceDescriptor), "sizeof mismatch for InstanceDescriptor"); + static_assert(alignof(InstanceDescriptor) == alignof(WGPUInstanceDescriptor), "alignof mismatch for InstanceDescriptor"); + + static_assert(offsetof(InstanceDescriptor, nextInChain) == offsetof(WGPUInstanceDescriptor, nextInChain), + "offsetof mismatch for InstanceDescriptor::nextInChain"); + + + static_assert(sizeof(Origin3D) == sizeof(WGPUOrigin3D), "sizeof mismatch for Origin3D"); + static_assert(alignof(Origin3D) == alignof(WGPUOrigin3D), "alignof mismatch for Origin3D"); + + static_assert(offsetof(Origin3D, x) == offsetof(WGPUOrigin3D, x), + "offsetof mismatch for Origin3D::x"); + static_assert(offsetof(Origin3D, y) == offsetof(WGPUOrigin3D, y), + "offsetof mismatch for Origin3D::y"); + static_assert(offsetof(Origin3D, z) == offsetof(WGPUOrigin3D, z), + "offsetof mismatch for Origin3D::z"); + + + static_assert(sizeof(PipelineLayoutDescriptor) == sizeof(WGPUPipelineLayoutDescriptor), "sizeof mismatch for PipelineLayoutDescriptor"); + static_assert(alignof(PipelineLayoutDescriptor) == alignof(WGPUPipelineLayoutDescriptor), "alignof mismatch for PipelineLayoutDescriptor"); + + static_assert(offsetof(PipelineLayoutDescriptor, nextInChain) == offsetof(WGPUPipelineLayoutDescriptor, nextInChain), + "offsetof mismatch for PipelineLayoutDescriptor::nextInChain"); + static_assert(offsetof(PipelineLayoutDescriptor, label) == offsetof(WGPUPipelineLayoutDescriptor, label), + "offsetof mismatch for PipelineLayoutDescriptor::label"); + static_assert(offsetof(PipelineLayoutDescriptor, bindGroupLayoutCount) == offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayoutCount), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayoutCount"); + static_assert(offsetof(PipelineLayoutDescriptor, bindGroupLayouts) == offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayouts), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayouts"); + + + static_assert(sizeof(ProgrammableStageDescriptor) == sizeof(WGPUProgrammableStageDescriptor), "sizeof mismatch for ProgrammableStageDescriptor"); + static_assert(alignof(ProgrammableStageDescriptor) == alignof(WGPUProgrammableStageDescriptor), "alignof mismatch for ProgrammableStageDescriptor"); + + static_assert(offsetof(ProgrammableStageDescriptor, nextInChain) == offsetof(WGPUProgrammableStageDescriptor, nextInChain), + "offsetof mismatch for ProgrammableStageDescriptor::nextInChain"); + static_assert(offsetof(ProgrammableStageDescriptor, module) == offsetof(WGPUProgrammableStageDescriptor, module), + "offsetof mismatch for ProgrammableStageDescriptor::module"); + static_assert(offsetof(ProgrammableStageDescriptor, entryPoint) == offsetof(WGPUProgrammableStageDescriptor, entryPoint), + "offsetof mismatch for ProgrammableStageDescriptor::entryPoint"); + + + static_assert(sizeof(RasterizationStateDescriptor) == sizeof(WGPURasterizationStateDescriptor), "sizeof mismatch for RasterizationStateDescriptor"); + static_assert(alignof(RasterizationStateDescriptor) == alignof(WGPURasterizationStateDescriptor), "alignof mismatch for RasterizationStateDescriptor"); + + static_assert(offsetof(RasterizationStateDescriptor, nextInChain) == offsetof(WGPURasterizationStateDescriptor, nextInChain), + "offsetof mismatch for RasterizationStateDescriptor::nextInChain"); + static_assert(offsetof(RasterizationStateDescriptor, frontFace) == offsetof(WGPURasterizationStateDescriptor, frontFace), + "offsetof mismatch for RasterizationStateDescriptor::frontFace"); + static_assert(offsetof(RasterizationStateDescriptor, cullMode) == offsetof(WGPURasterizationStateDescriptor, cullMode), + "offsetof mismatch for RasterizationStateDescriptor::cullMode"); + static_assert(offsetof(RasterizationStateDescriptor, depthBias) == offsetof(WGPURasterizationStateDescriptor, depthBias), + "offsetof mismatch for RasterizationStateDescriptor::depthBias"); + static_assert(offsetof(RasterizationStateDescriptor, depthBiasSlopeScale) == offsetof(WGPURasterizationStateDescriptor, depthBiasSlopeScale), + "offsetof mismatch for RasterizationStateDescriptor::depthBiasSlopeScale"); + static_assert(offsetof(RasterizationStateDescriptor, depthBiasClamp) == offsetof(WGPURasterizationStateDescriptor, depthBiasClamp), + "offsetof mismatch for RasterizationStateDescriptor::depthBiasClamp"); + + + static_assert(sizeof(RenderBundleDescriptor) == sizeof(WGPURenderBundleDescriptor), "sizeof mismatch for RenderBundleDescriptor"); + static_assert(alignof(RenderBundleDescriptor) == alignof(WGPURenderBundleDescriptor), "alignof mismatch for RenderBundleDescriptor"); + + static_assert(offsetof(RenderBundleDescriptor, nextInChain) == offsetof(WGPURenderBundleDescriptor, nextInChain), + "offsetof mismatch for RenderBundleDescriptor::nextInChain"); + static_assert(offsetof(RenderBundleDescriptor, label) == offsetof(WGPURenderBundleDescriptor, label), + "offsetof mismatch for RenderBundleDescriptor::label"); + + + static_assert(sizeof(RenderBundleEncoderDescriptor) == sizeof(WGPURenderBundleEncoderDescriptor), "sizeof mismatch for RenderBundleEncoderDescriptor"); + static_assert(alignof(RenderBundleEncoderDescriptor) == alignof(WGPURenderBundleEncoderDescriptor), "alignof mismatch for RenderBundleEncoderDescriptor"); + + static_assert(offsetof(RenderBundleEncoderDescriptor, nextInChain) == offsetof(WGPURenderBundleEncoderDescriptor, nextInChain), + "offsetof mismatch for RenderBundleEncoderDescriptor::nextInChain"); + static_assert(offsetof(RenderBundleEncoderDescriptor, label) == offsetof(WGPURenderBundleEncoderDescriptor, label), + "offsetof mismatch for RenderBundleEncoderDescriptor::label"); + static_assert(offsetof(RenderBundleEncoderDescriptor, colorFormatsCount) == offsetof(WGPURenderBundleEncoderDescriptor, colorFormatsCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormatsCount"); + static_assert(offsetof(RenderBundleEncoderDescriptor, colorFormats) == offsetof(WGPURenderBundleEncoderDescriptor, colorFormats), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormats"); + static_assert(offsetof(RenderBundleEncoderDescriptor, depthStencilFormat) == offsetof(WGPURenderBundleEncoderDescriptor, depthStencilFormat), + "offsetof mismatch for RenderBundleEncoderDescriptor::depthStencilFormat"); + static_assert(offsetof(RenderBundleEncoderDescriptor, sampleCount) == offsetof(WGPURenderBundleEncoderDescriptor, sampleCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::sampleCount"); + + + static_assert(sizeof(RenderPassDepthStencilAttachmentDescriptor) == sizeof(WGPURenderPassDepthStencilAttachmentDescriptor), "sizeof mismatch for RenderPassDepthStencilAttachmentDescriptor"); + static_assert(alignof(RenderPassDepthStencilAttachmentDescriptor) == alignof(WGPURenderPassDepthStencilAttachmentDescriptor), "alignof mismatch for RenderPassDepthStencilAttachmentDescriptor"); + + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, attachment) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, attachment), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::attachment"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, depthLoadOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, depthLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::depthLoadOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, depthStoreOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, depthStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::depthStoreOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, clearDepth) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, clearDepth), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::clearDepth"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, stencilLoadOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, stencilLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::stencilLoadOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, stencilStoreOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, stencilStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::stencilStoreOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, clearStencil) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, clearStencil), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::clearStencil"); + + + static_assert(sizeof(SamplerDescriptor) == sizeof(WGPUSamplerDescriptor), "sizeof mismatch for SamplerDescriptor"); + static_assert(alignof(SamplerDescriptor) == alignof(WGPUSamplerDescriptor), "alignof mismatch for SamplerDescriptor"); + + static_assert(offsetof(SamplerDescriptor, nextInChain) == offsetof(WGPUSamplerDescriptor, nextInChain), + "offsetof mismatch for SamplerDescriptor::nextInChain"); + static_assert(offsetof(SamplerDescriptor, label) == offsetof(WGPUSamplerDescriptor, label), + "offsetof mismatch for SamplerDescriptor::label"); + static_assert(offsetof(SamplerDescriptor, addressModeU) == offsetof(WGPUSamplerDescriptor, addressModeU), + "offsetof mismatch for SamplerDescriptor::addressModeU"); + static_assert(offsetof(SamplerDescriptor, addressModeV) == offsetof(WGPUSamplerDescriptor, addressModeV), + "offsetof mismatch for SamplerDescriptor::addressModeV"); + static_assert(offsetof(SamplerDescriptor, addressModeW) == offsetof(WGPUSamplerDescriptor, addressModeW), + "offsetof mismatch for SamplerDescriptor::addressModeW"); + static_assert(offsetof(SamplerDescriptor, magFilter) == offsetof(WGPUSamplerDescriptor, magFilter), + "offsetof mismatch for SamplerDescriptor::magFilter"); + static_assert(offsetof(SamplerDescriptor, minFilter) == offsetof(WGPUSamplerDescriptor, minFilter), + "offsetof mismatch for SamplerDescriptor::minFilter"); + static_assert(offsetof(SamplerDescriptor, mipmapFilter) == offsetof(WGPUSamplerDescriptor, mipmapFilter), + "offsetof mismatch for SamplerDescriptor::mipmapFilter"); + static_assert(offsetof(SamplerDescriptor, lodMinClamp) == offsetof(WGPUSamplerDescriptor, lodMinClamp), + "offsetof mismatch for SamplerDescriptor::lodMinClamp"); + static_assert(offsetof(SamplerDescriptor, lodMaxClamp) == offsetof(WGPUSamplerDescriptor, lodMaxClamp), + "offsetof mismatch for SamplerDescriptor::lodMaxClamp"); + static_assert(offsetof(SamplerDescriptor, compare) == offsetof(WGPUSamplerDescriptor, compare), + "offsetof mismatch for SamplerDescriptor::compare"); + + + static_assert(sizeof(SamplerDescriptorDummyAnisotropicFiltering) == sizeof(WGPUSamplerDescriptorDummyAnisotropicFiltering), "sizeof mismatch for SamplerDescriptorDummyAnisotropicFiltering"); + static_assert(alignof(SamplerDescriptorDummyAnisotropicFiltering) == alignof(WGPUSamplerDescriptorDummyAnisotropicFiltering), "alignof mismatch for SamplerDescriptorDummyAnisotropicFiltering"); + + static_assert(offsetof(SamplerDescriptorDummyAnisotropicFiltering, maxAnisotropy) == offsetof(WGPUSamplerDescriptorDummyAnisotropicFiltering, maxAnisotropy), + "offsetof mismatch for SamplerDescriptorDummyAnisotropicFiltering::maxAnisotropy"); + + + static_assert(sizeof(ShaderModuleDescriptor) == sizeof(WGPUShaderModuleDescriptor), "sizeof mismatch for ShaderModuleDescriptor"); + static_assert(alignof(ShaderModuleDescriptor) == alignof(WGPUShaderModuleDescriptor), "alignof mismatch for ShaderModuleDescriptor"); + + static_assert(offsetof(ShaderModuleDescriptor, nextInChain) == offsetof(WGPUShaderModuleDescriptor, nextInChain), + "offsetof mismatch for ShaderModuleDescriptor::nextInChain"); + static_assert(offsetof(ShaderModuleDescriptor, label) == offsetof(WGPUShaderModuleDescriptor, label), + "offsetof mismatch for ShaderModuleDescriptor::label"); + + + static_assert(sizeof(ShaderModuleSPIRVDescriptor) == sizeof(WGPUShaderModuleSPIRVDescriptor), "sizeof mismatch for ShaderModuleSPIRVDescriptor"); + static_assert(alignof(ShaderModuleSPIRVDescriptor) == alignof(WGPUShaderModuleSPIRVDescriptor), "alignof mismatch for ShaderModuleSPIRVDescriptor"); + + static_assert(offsetof(ShaderModuleSPIRVDescriptor, codeSize) == offsetof(WGPUShaderModuleSPIRVDescriptor, codeSize), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::codeSize"); + static_assert(offsetof(ShaderModuleSPIRVDescriptor, code) == offsetof(WGPUShaderModuleSPIRVDescriptor, code), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::code"); + + + static_assert(sizeof(ShaderModuleWGSLDescriptor) == sizeof(WGPUShaderModuleWGSLDescriptor), "sizeof mismatch for ShaderModuleWGSLDescriptor"); + static_assert(alignof(ShaderModuleWGSLDescriptor) == alignof(WGPUShaderModuleWGSLDescriptor), "alignof mismatch for ShaderModuleWGSLDescriptor"); + + static_assert(offsetof(ShaderModuleWGSLDescriptor, source) == offsetof(WGPUShaderModuleWGSLDescriptor, source), + "offsetof mismatch for ShaderModuleWGSLDescriptor::source"); + + + static_assert(sizeof(StencilStateFaceDescriptor) == sizeof(WGPUStencilStateFaceDescriptor), "sizeof mismatch for StencilStateFaceDescriptor"); + static_assert(alignof(StencilStateFaceDescriptor) == alignof(WGPUStencilStateFaceDescriptor), "alignof mismatch for StencilStateFaceDescriptor"); + + static_assert(offsetof(StencilStateFaceDescriptor, compare) == offsetof(WGPUStencilStateFaceDescriptor, compare), + "offsetof mismatch for StencilStateFaceDescriptor::compare"); + static_assert(offsetof(StencilStateFaceDescriptor, failOp) == offsetof(WGPUStencilStateFaceDescriptor, failOp), + "offsetof mismatch for StencilStateFaceDescriptor::failOp"); + static_assert(offsetof(StencilStateFaceDescriptor, depthFailOp) == offsetof(WGPUStencilStateFaceDescriptor, depthFailOp), + "offsetof mismatch for StencilStateFaceDescriptor::depthFailOp"); + static_assert(offsetof(StencilStateFaceDescriptor, passOp) == offsetof(WGPUStencilStateFaceDescriptor, passOp), + "offsetof mismatch for StencilStateFaceDescriptor::passOp"); + + + static_assert(sizeof(SurfaceDescriptor) == sizeof(WGPUSurfaceDescriptor), "sizeof mismatch for SurfaceDescriptor"); + static_assert(alignof(SurfaceDescriptor) == alignof(WGPUSurfaceDescriptor), "alignof mismatch for SurfaceDescriptor"); + + static_assert(offsetof(SurfaceDescriptor, nextInChain) == offsetof(WGPUSurfaceDescriptor, nextInChain), + "offsetof mismatch for SurfaceDescriptor::nextInChain"); + static_assert(offsetof(SurfaceDescriptor, label) == offsetof(WGPUSurfaceDescriptor, label), + "offsetof mismatch for SurfaceDescriptor::label"); + + + static_assert(sizeof(SurfaceDescriptorFromHTMLCanvasId) == sizeof(WGPUSurfaceDescriptorFromHTMLCanvasId), "sizeof mismatch for SurfaceDescriptorFromHTMLCanvasId"); + static_assert(alignof(SurfaceDescriptorFromHTMLCanvasId) == alignof(WGPUSurfaceDescriptorFromHTMLCanvasId), "alignof mismatch for SurfaceDescriptorFromHTMLCanvasId"); + + static_assert(offsetof(SurfaceDescriptorFromHTMLCanvasId, id) == offsetof(WGPUSurfaceDescriptorFromHTMLCanvasId, id), + "offsetof mismatch for SurfaceDescriptorFromHTMLCanvasId::id"); + + + static_assert(sizeof(SurfaceDescriptorFromMetalLayer) == sizeof(WGPUSurfaceDescriptorFromMetalLayer), "sizeof mismatch for SurfaceDescriptorFromMetalLayer"); + static_assert(alignof(SurfaceDescriptorFromMetalLayer) == alignof(WGPUSurfaceDescriptorFromMetalLayer), "alignof mismatch for SurfaceDescriptorFromMetalLayer"); + + static_assert(offsetof(SurfaceDescriptorFromMetalLayer, layer) == offsetof(WGPUSurfaceDescriptorFromMetalLayer, layer), + "offsetof mismatch for SurfaceDescriptorFromMetalLayer::layer"); + + + static_assert(sizeof(SurfaceDescriptorFromWindowsHWND) == sizeof(WGPUSurfaceDescriptorFromWindowsHWND), "sizeof mismatch for SurfaceDescriptorFromWindowsHWND"); + static_assert(alignof(SurfaceDescriptorFromWindowsHWND) == alignof(WGPUSurfaceDescriptorFromWindowsHWND), "alignof mismatch for SurfaceDescriptorFromWindowsHWND"); + + static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hinstance) == offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hinstance), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hinstance"); + static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hwnd) == offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hwnd), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hwnd"); + + + static_assert(sizeof(SurfaceDescriptorFromXlib) == sizeof(WGPUSurfaceDescriptorFromXlib), "sizeof mismatch for SurfaceDescriptorFromXlib"); + static_assert(alignof(SurfaceDescriptorFromXlib) == alignof(WGPUSurfaceDescriptorFromXlib), "alignof mismatch for SurfaceDescriptorFromXlib"); + + static_assert(offsetof(SurfaceDescriptorFromXlib, display) == offsetof(WGPUSurfaceDescriptorFromXlib, display), + "offsetof mismatch for SurfaceDescriptorFromXlib::display"); + static_assert(offsetof(SurfaceDescriptorFromXlib, window) == offsetof(WGPUSurfaceDescriptorFromXlib, window), + "offsetof mismatch for SurfaceDescriptorFromXlib::window"); + + + static_assert(sizeof(SwapChainDescriptor) == sizeof(WGPUSwapChainDescriptor), "sizeof mismatch for SwapChainDescriptor"); + static_assert(alignof(SwapChainDescriptor) == alignof(WGPUSwapChainDescriptor), "alignof mismatch for SwapChainDescriptor"); + + static_assert(offsetof(SwapChainDescriptor, nextInChain) == offsetof(WGPUSwapChainDescriptor, nextInChain), + "offsetof mismatch for SwapChainDescriptor::nextInChain"); + static_assert(offsetof(SwapChainDescriptor, label) == offsetof(WGPUSwapChainDescriptor, label), + "offsetof mismatch for SwapChainDescriptor::label"); + static_assert(offsetof(SwapChainDescriptor, usage) == offsetof(WGPUSwapChainDescriptor, usage), + "offsetof mismatch for SwapChainDescriptor::usage"); + static_assert(offsetof(SwapChainDescriptor, format) == offsetof(WGPUSwapChainDescriptor, format), + "offsetof mismatch for SwapChainDescriptor::format"); + static_assert(offsetof(SwapChainDescriptor, width) == offsetof(WGPUSwapChainDescriptor, width), + "offsetof mismatch for SwapChainDescriptor::width"); + static_assert(offsetof(SwapChainDescriptor, height) == offsetof(WGPUSwapChainDescriptor, height), + "offsetof mismatch for SwapChainDescriptor::height"); + static_assert(offsetof(SwapChainDescriptor, presentMode) == offsetof(WGPUSwapChainDescriptor, presentMode), + "offsetof mismatch for SwapChainDescriptor::presentMode"); + static_assert(offsetof(SwapChainDescriptor, implementation) == offsetof(WGPUSwapChainDescriptor, implementation), + "offsetof mismatch for SwapChainDescriptor::implementation"); + + + static_assert(sizeof(TextureViewDescriptor) == sizeof(WGPUTextureViewDescriptor), "sizeof mismatch for TextureViewDescriptor"); + static_assert(alignof(TextureViewDescriptor) == alignof(WGPUTextureViewDescriptor), "alignof mismatch for TextureViewDescriptor"); + + static_assert(offsetof(TextureViewDescriptor, nextInChain) == offsetof(WGPUTextureViewDescriptor, nextInChain), + "offsetof mismatch for TextureViewDescriptor::nextInChain"); + static_assert(offsetof(TextureViewDescriptor, label) == offsetof(WGPUTextureViewDescriptor, label), + "offsetof mismatch for TextureViewDescriptor::label"); + static_assert(offsetof(TextureViewDescriptor, format) == offsetof(WGPUTextureViewDescriptor, format), + "offsetof mismatch for TextureViewDescriptor::format"); + static_assert(offsetof(TextureViewDescriptor, dimension) == offsetof(WGPUTextureViewDescriptor, dimension), + "offsetof mismatch for TextureViewDescriptor::dimension"); + static_assert(offsetof(TextureViewDescriptor, baseMipLevel) == offsetof(WGPUTextureViewDescriptor, baseMipLevel), + "offsetof mismatch for TextureViewDescriptor::baseMipLevel"); + static_assert(offsetof(TextureViewDescriptor, mipLevelCount) == offsetof(WGPUTextureViewDescriptor, mipLevelCount), + "offsetof mismatch for TextureViewDescriptor::mipLevelCount"); + static_assert(offsetof(TextureViewDescriptor, baseArrayLayer) == offsetof(WGPUTextureViewDescriptor, baseArrayLayer), + "offsetof mismatch for TextureViewDescriptor::baseArrayLayer"); + static_assert(offsetof(TextureViewDescriptor, arrayLayerCount) == offsetof(WGPUTextureViewDescriptor, arrayLayerCount), + "offsetof mismatch for TextureViewDescriptor::arrayLayerCount"); + static_assert(offsetof(TextureViewDescriptor, aspect) == offsetof(WGPUTextureViewDescriptor, aspect), + "offsetof mismatch for TextureViewDescriptor::aspect"); + + + static_assert(sizeof(VertexAttributeDescriptor) == sizeof(WGPUVertexAttributeDescriptor), "sizeof mismatch for VertexAttributeDescriptor"); + static_assert(alignof(VertexAttributeDescriptor) == alignof(WGPUVertexAttributeDescriptor), "alignof mismatch for VertexAttributeDescriptor"); + + static_assert(offsetof(VertexAttributeDescriptor, format) == offsetof(WGPUVertexAttributeDescriptor, format), + "offsetof mismatch for VertexAttributeDescriptor::format"); + static_assert(offsetof(VertexAttributeDescriptor, offset) == offsetof(WGPUVertexAttributeDescriptor, offset), + "offsetof mismatch for VertexAttributeDescriptor::offset"); + static_assert(offsetof(VertexAttributeDescriptor, shaderLocation) == offsetof(WGPUVertexAttributeDescriptor, shaderLocation), + "offsetof mismatch for VertexAttributeDescriptor::shaderLocation"); + + + static_assert(sizeof(BindGroupDescriptor) == sizeof(WGPUBindGroupDescriptor), "sizeof mismatch for BindGroupDescriptor"); + static_assert(alignof(BindGroupDescriptor) == alignof(WGPUBindGroupDescriptor), "alignof mismatch for BindGroupDescriptor"); + + static_assert(offsetof(BindGroupDescriptor, nextInChain) == offsetof(WGPUBindGroupDescriptor, nextInChain), + "offsetof mismatch for BindGroupDescriptor::nextInChain"); + static_assert(offsetof(BindGroupDescriptor, label) == offsetof(WGPUBindGroupDescriptor, label), + "offsetof mismatch for BindGroupDescriptor::label"); + static_assert(offsetof(BindGroupDescriptor, layout) == offsetof(WGPUBindGroupDescriptor, layout), + "offsetof mismatch for BindGroupDescriptor::layout"); + static_assert(offsetof(BindGroupDescriptor, entryCount) == offsetof(WGPUBindGroupDescriptor, entryCount), + "offsetof mismatch for BindGroupDescriptor::entryCount"); + static_assert(offsetof(BindGroupDescriptor, entries) == offsetof(WGPUBindGroupDescriptor, entries), + "offsetof mismatch for BindGroupDescriptor::entries"); + + + static_assert(sizeof(BindGroupLayoutDescriptor) == sizeof(WGPUBindGroupLayoutDescriptor), "sizeof mismatch for BindGroupLayoutDescriptor"); + static_assert(alignof(BindGroupLayoutDescriptor) == alignof(WGPUBindGroupLayoutDescriptor), "alignof mismatch for BindGroupLayoutDescriptor"); + + static_assert(offsetof(BindGroupLayoutDescriptor, nextInChain) == offsetof(WGPUBindGroupLayoutDescriptor, nextInChain), + "offsetof mismatch for BindGroupLayoutDescriptor::nextInChain"); + static_assert(offsetof(BindGroupLayoutDescriptor, label) == offsetof(WGPUBindGroupLayoutDescriptor, label), + "offsetof mismatch for BindGroupLayoutDescriptor::label"); + static_assert(offsetof(BindGroupLayoutDescriptor, entryCount) == offsetof(WGPUBindGroupLayoutDescriptor, entryCount), + "offsetof mismatch for BindGroupLayoutDescriptor::entryCount"); + static_assert(offsetof(BindGroupLayoutDescriptor, entries) == offsetof(WGPUBindGroupLayoutDescriptor, entries), + "offsetof mismatch for BindGroupLayoutDescriptor::entries"); + + + static_assert(sizeof(ColorStateDescriptor) == sizeof(WGPUColorStateDescriptor), "sizeof mismatch for ColorStateDescriptor"); + static_assert(alignof(ColorStateDescriptor) == alignof(WGPUColorStateDescriptor), "alignof mismatch for ColorStateDescriptor"); + + static_assert(offsetof(ColorStateDescriptor, nextInChain) == offsetof(WGPUColorStateDescriptor, nextInChain), + "offsetof mismatch for ColorStateDescriptor::nextInChain"); + static_assert(offsetof(ColorStateDescriptor, format) == offsetof(WGPUColorStateDescriptor, format), + "offsetof mismatch for ColorStateDescriptor::format"); + static_assert(offsetof(ColorStateDescriptor, alphaBlend) == offsetof(WGPUColorStateDescriptor, alphaBlend), + "offsetof mismatch for ColorStateDescriptor::alphaBlend"); + static_assert(offsetof(ColorStateDescriptor, colorBlend) == offsetof(WGPUColorStateDescriptor, colorBlend), + "offsetof mismatch for ColorStateDescriptor::colorBlend"); + static_assert(offsetof(ColorStateDescriptor, writeMask) == offsetof(WGPUColorStateDescriptor, writeMask), + "offsetof mismatch for ColorStateDescriptor::writeMask"); + + + static_assert(sizeof(ComputePipelineDescriptor) == sizeof(WGPUComputePipelineDescriptor), "sizeof mismatch for ComputePipelineDescriptor"); + static_assert(alignof(ComputePipelineDescriptor) == alignof(WGPUComputePipelineDescriptor), "alignof mismatch for ComputePipelineDescriptor"); + + static_assert(offsetof(ComputePipelineDescriptor, nextInChain) == offsetof(WGPUComputePipelineDescriptor, nextInChain), + "offsetof mismatch for ComputePipelineDescriptor::nextInChain"); + static_assert(offsetof(ComputePipelineDescriptor, label) == offsetof(WGPUComputePipelineDescriptor, label), + "offsetof mismatch for ComputePipelineDescriptor::label"); + static_assert(offsetof(ComputePipelineDescriptor, layout) == offsetof(WGPUComputePipelineDescriptor, layout), + "offsetof mismatch for ComputePipelineDescriptor::layout"); + static_assert(offsetof(ComputePipelineDescriptor, computeStage) == offsetof(WGPUComputePipelineDescriptor, computeStage), + "offsetof mismatch for ComputePipelineDescriptor::computeStage"); + + + static_assert(sizeof(DepthStencilStateDescriptor) == sizeof(WGPUDepthStencilStateDescriptor), "sizeof mismatch for DepthStencilStateDescriptor"); + static_assert(alignof(DepthStencilStateDescriptor) == alignof(WGPUDepthStencilStateDescriptor), "alignof mismatch for DepthStencilStateDescriptor"); + + static_assert(offsetof(DepthStencilStateDescriptor, nextInChain) == offsetof(WGPUDepthStencilStateDescriptor, nextInChain), + "offsetof mismatch for DepthStencilStateDescriptor::nextInChain"); + static_assert(offsetof(DepthStencilStateDescriptor, format) == offsetof(WGPUDepthStencilStateDescriptor, format), + "offsetof mismatch for DepthStencilStateDescriptor::format"); + static_assert(offsetof(DepthStencilStateDescriptor, depthWriteEnabled) == offsetof(WGPUDepthStencilStateDescriptor, depthWriteEnabled), + "offsetof mismatch for DepthStencilStateDescriptor::depthWriteEnabled"); + static_assert(offsetof(DepthStencilStateDescriptor, depthCompare) == offsetof(WGPUDepthStencilStateDescriptor, depthCompare), + "offsetof mismatch for DepthStencilStateDescriptor::depthCompare"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilFront) == offsetof(WGPUDepthStencilStateDescriptor, stencilFront), + "offsetof mismatch for DepthStencilStateDescriptor::stencilFront"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilBack) == offsetof(WGPUDepthStencilStateDescriptor, stencilBack), + "offsetof mismatch for DepthStencilStateDescriptor::stencilBack"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilReadMask) == offsetof(WGPUDepthStencilStateDescriptor, stencilReadMask), + "offsetof mismatch for DepthStencilStateDescriptor::stencilReadMask"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilWriteMask) == offsetof(WGPUDepthStencilStateDescriptor, stencilWriteMask), + "offsetof mismatch for DepthStencilStateDescriptor::stencilWriteMask"); + + + static_assert(sizeof(RenderPassColorAttachmentDescriptor) == sizeof(WGPURenderPassColorAttachmentDescriptor), "sizeof mismatch for RenderPassColorAttachmentDescriptor"); + static_assert(alignof(RenderPassColorAttachmentDescriptor) == alignof(WGPURenderPassColorAttachmentDescriptor), "alignof mismatch for RenderPassColorAttachmentDescriptor"); + + static_assert(offsetof(RenderPassColorAttachmentDescriptor, attachment) == offsetof(WGPURenderPassColorAttachmentDescriptor, attachment), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::attachment"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, resolveTarget) == offsetof(WGPURenderPassColorAttachmentDescriptor, resolveTarget), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::resolveTarget"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, loadOp) == offsetof(WGPURenderPassColorAttachmentDescriptor, loadOp), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::loadOp"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, storeOp) == offsetof(WGPURenderPassColorAttachmentDescriptor, storeOp), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::storeOp"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, clearColor) == offsetof(WGPURenderPassColorAttachmentDescriptor, clearColor), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::clearColor"); + + + static_assert(sizeof(RenderPipelineDescriptorDummyExtension) == sizeof(WGPURenderPipelineDescriptorDummyExtension), "sizeof mismatch for RenderPipelineDescriptorDummyExtension"); + static_assert(alignof(RenderPipelineDescriptorDummyExtension) == alignof(WGPURenderPipelineDescriptorDummyExtension), "alignof mismatch for RenderPipelineDescriptorDummyExtension"); + + static_assert(offsetof(RenderPipelineDescriptorDummyExtension, dummyStage) == offsetof(WGPURenderPipelineDescriptorDummyExtension, dummyStage), + "offsetof mismatch for RenderPipelineDescriptorDummyExtension::dummyStage"); + + + static_assert(sizeof(TextureCopyView) == sizeof(WGPUTextureCopyView), "sizeof mismatch for TextureCopyView"); + static_assert(alignof(TextureCopyView) == alignof(WGPUTextureCopyView), "alignof mismatch for TextureCopyView"); + + static_assert(offsetof(TextureCopyView, nextInChain) == offsetof(WGPUTextureCopyView, nextInChain), + "offsetof mismatch for TextureCopyView::nextInChain"); + static_assert(offsetof(TextureCopyView, texture) == offsetof(WGPUTextureCopyView, texture), + "offsetof mismatch for TextureCopyView::texture"); + static_assert(offsetof(TextureCopyView, mipLevel) == offsetof(WGPUTextureCopyView, mipLevel), + "offsetof mismatch for TextureCopyView::mipLevel"); + static_assert(offsetof(TextureCopyView, arrayLayer) == offsetof(WGPUTextureCopyView, arrayLayer), + "offsetof mismatch for TextureCopyView::arrayLayer"); + static_assert(offsetof(TextureCopyView, origin) == offsetof(WGPUTextureCopyView, origin), + "offsetof mismatch for TextureCopyView::origin"); + + + static_assert(sizeof(TextureDescriptor) == sizeof(WGPUTextureDescriptor), "sizeof mismatch for TextureDescriptor"); + static_assert(alignof(TextureDescriptor) == alignof(WGPUTextureDescriptor), "alignof mismatch for TextureDescriptor"); + + static_assert(offsetof(TextureDescriptor, nextInChain) == offsetof(WGPUTextureDescriptor, nextInChain), + "offsetof mismatch for TextureDescriptor::nextInChain"); + static_assert(offsetof(TextureDescriptor, label) == offsetof(WGPUTextureDescriptor, label), + "offsetof mismatch for TextureDescriptor::label"); + static_assert(offsetof(TextureDescriptor, usage) == offsetof(WGPUTextureDescriptor, usage), + "offsetof mismatch for TextureDescriptor::usage"); + static_assert(offsetof(TextureDescriptor, dimension) == offsetof(WGPUTextureDescriptor, dimension), + "offsetof mismatch for TextureDescriptor::dimension"); + static_assert(offsetof(TextureDescriptor, size) == offsetof(WGPUTextureDescriptor, size), + "offsetof mismatch for TextureDescriptor::size"); + static_assert(offsetof(TextureDescriptor, arrayLayerCount) == offsetof(WGPUTextureDescriptor, arrayLayerCount), + "offsetof mismatch for TextureDescriptor::arrayLayerCount"); + static_assert(offsetof(TextureDescriptor, format) == offsetof(WGPUTextureDescriptor, format), + "offsetof mismatch for TextureDescriptor::format"); + static_assert(offsetof(TextureDescriptor, mipLevelCount) == offsetof(WGPUTextureDescriptor, mipLevelCount), + "offsetof mismatch for TextureDescriptor::mipLevelCount"); + static_assert(offsetof(TextureDescriptor, sampleCount) == offsetof(WGPUTextureDescriptor, sampleCount), + "offsetof mismatch for TextureDescriptor::sampleCount"); + + + static_assert(sizeof(VertexBufferLayoutDescriptor) == sizeof(WGPUVertexBufferLayoutDescriptor), "sizeof mismatch for VertexBufferLayoutDescriptor"); + static_assert(alignof(VertexBufferLayoutDescriptor) == alignof(WGPUVertexBufferLayoutDescriptor), "alignof mismatch for VertexBufferLayoutDescriptor"); + + static_assert(offsetof(VertexBufferLayoutDescriptor, arrayStride) == offsetof(WGPUVertexBufferLayoutDescriptor, arrayStride), + "offsetof mismatch for VertexBufferLayoutDescriptor::arrayStride"); + static_assert(offsetof(VertexBufferLayoutDescriptor, stepMode) == offsetof(WGPUVertexBufferLayoutDescriptor, stepMode), + "offsetof mismatch for VertexBufferLayoutDescriptor::stepMode"); + static_assert(offsetof(VertexBufferLayoutDescriptor, attributeCount) == offsetof(WGPUVertexBufferLayoutDescriptor, attributeCount), + "offsetof mismatch for VertexBufferLayoutDescriptor::attributeCount"); + static_assert(offsetof(VertexBufferLayoutDescriptor, attributes) == offsetof(WGPUVertexBufferLayoutDescriptor, attributes), + "offsetof mismatch for VertexBufferLayoutDescriptor::attributes"); + + + static_assert(sizeof(RenderPassDescriptor) == sizeof(WGPURenderPassDescriptor), "sizeof mismatch for RenderPassDescriptor"); + static_assert(alignof(RenderPassDescriptor) == alignof(WGPURenderPassDescriptor), "alignof mismatch for RenderPassDescriptor"); + + static_assert(offsetof(RenderPassDescriptor, nextInChain) == offsetof(WGPURenderPassDescriptor, nextInChain), + "offsetof mismatch for RenderPassDescriptor::nextInChain"); + static_assert(offsetof(RenderPassDescriptor, label) == offsetof(WGPURenderPassDescriptor, label), + "offsetof mismatch for RenderPassDescriptor::label"); + static_assert(offsetof(RenderPassDescriptor, colorAttachmentCount) == offsetof(WGPURenderPassDescriptor, colorAttachmentCount), + "offsetof mismatch for RenderPassDescriptor::colorAttachmentCount"); + static_assert(offsetof(RenderPassDescriptor, colorAttachments) == offsetof(WGPURenderPassDescriptor, colorAttachments), + "offsetof mismatch for RenderPassDescriptor::colorAttachments"); + static_assert(offsetof(RenderPassDescriptor, depthStencilAttachment) == offsetof(WGPURenderPassDescriptor, depthStencilAttachment), + "offsetof mismatch for RenderPassDescriptor::depthStencilAttachment"); + + + static_assert(sizeof(VertexStateDescriptor) == sizeof(WGPUVertexStateDescriptor), "sizeof mismatch for VertexStateDescriptor"); + static_assert(alignof(VertexStateDescriptor) == alignof(WGPUVertexStateDescriptor), "alignof mismatch for VertexStateDescriptor"); + + static_assert(offsetof(VertexStateDescriptor, nextInChain) == offsetof(WGPUVertexStateDescriptor, nextInChain), + "offsetof mismatch for VertexStateDescriptor::nextInChain"); + static_assert(offsetof(VertexStateDescriptor, indexFormat) == offsetof(WGPUVertexStateDescriptor, indexFormat), + "offsetof mismatch for VertexStateDescriptor::indexFormat"); + static_assert(offsetof(VertexStateDescriptor, vertexBufferCount) == offsetof(WGPUVertexStateDescriptor, vertexBufferCount), + "offsetof mismatch for VertexStateDescriptor::vertexBufferCount"); + static_assert(offsetof(VertexStateDescriptor, vertexBuffers) == offsetof(WGPUVertexStateDescriptor, vertexBuffers), + "offsetof mismatch for VertexStateDescriptor::vertexBuffers"); + + + static_assert(sizeof(RenderPipelineDescriptor) == sizeof(WGPURenderPipelineDescriptor), "sizeof mismatch for RenderPipelineDescriptor"); + static_assert(alignof(RenderPipelineDescriptor) == alignof(WGPURenderPipelineDescriptor), "alignof mismatch for RenderPipelineDescriptor"); + + static_assert(offsetof(RenderPipelineDescriptor, nextInChain) == offsetof(WGPURenderPipelineDescriptor, nextInChain), + "offsetof mismatch for RenderPipelineDescriptor::nextInChain"); + static_assert(offsetof(RenderPipelineDescriptor, label) == offsetof(WGPURenderPipelineDescriptor, label), + "offsetof mismatch for RenderPipelineDescriptor::label"); + static_assert(offsetof(RenderPipelineDescriptor, layout) == offsetof(WGPURenderPipelineDescriptor, layout), + "offsetof mismatch for RenderPipelineDescriptor::layout"); + static_assert(offsetof(RenderPipelineDescriptor, vertexStage) == offsetof(WGPURenderPipelineDescriptor, vertexStage), + "offsetof mismatch for RenderPipelineDescriptor::vertexStage"); + static_assert(offsetof(RenderPipelineDescriptor, fragmentStage) == offsetof(WGPURenderPipelineDescriptor, fragmentStage), + "offsetof mismatch for RenderPipelineDescriptor::fragmentStage"); + static_assert(offsetof(RenderPipelineDescriptor, vertexState) == offsetof(WGPURenderPipelineDescriptor, vertexState), + "offsetof mismatch for RenderPipelineDescriptor::vertexState"); + static_assert(offsetof(RenderPipelineDescriptor, primitiveTopology) == offsetof(WGPURenderPipelineDescriptor, primitiveTopology), + "offsetof mismatch for RenderPipelineDescriptor::primitiveTopology"); + static_assert(offsetof(RenderPipelineDescriptor, rasterizationState) == offsetof(WGPURenderPipelineDescriptor, rasterizationState), + "offsetof mismatch for RenderPipelineDescriptor::rasterizationState"); + static_assert(offsetof(RenderPipelineDescriptor, sampleCount) == offsetof(WGPURenderPipelineDescriptor, sampleCount), + "offsetof mismatch for RenderPipelineDescriptor::sampleCount"); + static_assert(offsetof(RenderPipelineDescriptor, depthStencilState) == offsetof(WGPURenderPipelineDescriptor, depthStencilState), + "offsetof mismatch for RenderPipelineDescriptor::depthStencilState"); + static_assert(offsetof(RenderPipelineDescriptor, colorStateCount) == offsetof(WGPURenderPipelineDescriptor, colorStateCount), + "offsetof mismatch for RenderPipelineDescriptor::colorStateCount"); + static_assert(offsetof(RenderPipelineDescriptor, colorStates) == offsetof(WGPURenderPipelineDescriptor, colorStates), + "offsetof mismatch for RenderPipelineDescriptor::colorStates"); + static_assert(offsetof(RenderPipelineDescriptor, sampleMask) == offsetof(WGPURenderPipelineDescriptor, sampleMask), + "offsetof mismatch for RenderPipelineDescriptor::sampleMask"); + static_assert(offsetof(RenderPipelineDescriptor, alphaToCoverageEnabled) == offsetof(WGPURenderPipelineDescriptor, alphaToCoverageEnabled), + "offsetof mismatch for RenderPipelineDescriptor::alphaToCoverageEnabled"); + + + + static_assert(sizeof(BindGroup) == sizeof(WGPUBindGroup), "sizeof mismatch for BindGroup"); + static_assert(alignof(BindGroup) == alignof(WGPUBindGroup), "alignof mismatch for BindGroup"); + + + + void BindGroup::WGPUReference(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupReference(handle); + } + } + void BindGroup::WGPURelease(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupRelease(handle); + } + } + + + static_assert(sizeof(BindGroupLayout) == sizeof(WGPUBindGroupLayout), "sizeof mismatch for BindGroupLayout"); + static_assert(alignof(BindGroupLayout) == alignof(WGPUBindGroupLayout), "alignof mismatch for BindGroupLayout"); + + + + void BindGroupLayout::WGPUReference(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutReference(handle); + } + } + void BindGroupLayout::WGPURelease(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutRelease(handle); + } + } + + + static_assert(sizeof(Buffer) == sizeof(WGPUBuffer), "sizeof mismatch for Buffer"); + static_assert(alignof(Buffer) == alignof(WGPUBuffer), "alignof mismatch for Buffer"); + + + + void Buffer::Destroy() const { + wgpuBufferDestroy(Get()); + } + void Buffer::MapReadAsync(BufferMapReadCallback callback, void * userdata) const { + wgpuBufferMapReadAsync(Get(), callback, reinterpret_cast(userdata)); + } + void Buffer::MapWriteAsync(BufferMapWriteCallback callback, void * userdata) const { + wgpuBufferMapWriteAsync(Get(), callback, reinterpret_cast(userdata)); + } + void Buffer::SetSubData(uint64_t start, uint64_t count, void const * data) const { + wgpuBufferSetSubData(Get(), start, count, reinterpret_cast(data)); + } + void Buffer::Unmap() const { + wgpuBufferUnmap(Get()); + } + void Buffer::WGPUReference(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferReference(handle); + } + } + void Buffer::WGPURelease(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferRelease(handle); + } + } + + + static_assert(sizeof(CommandBuffer) == sizeof(WGPUCommandBuffer), "sizeof mismatch for CommandBuffer"); + static_assert(alignof(CommandBuffer) == alignof(WGPUCommandBuffer), "alignof mismatch for CommandBuffer"); + + + + void CommandBuffer::WGPUReference(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferReference(handle); + } + } + void CommandBuffer::WGPURelease(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferRelease(handle); + } + } + + + static_assert(sizeof(CommandEncoder) == sizeof(WGPUCommandEncoder), "sizeof mismatch for CommandEncoder"); + static_assert(alignof(CommandEncoder) == alignof(WGPUCommandEncoder), "alignof mismatch for CommandEncoder"); + + + + ComputePassEncoder CommandEncoder::BeginComputePass(ComputePassDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderBeginComputePass(Get(), reinterpret_cast(descriptor)); + return ComputePassEncoder::Acquire(result); + } + RenderPassEncoder CommandEncoder::BeginRenderPass(RenderPassDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderBeginRenderPass(Get(), reinterpret_cast(descriptor)); + return RenderPassEncoder::Acquire(result); + } + void CommandEncoder::CopyBufferToBuffer(Buffer const& source, uint64_t sourceOffset, Buffer const& destination, uint64_t destinationOffset, uint64_t size) const { + wgpuCommandEncoderCopyBufferToBuffer(Get(), source.Get(), sourceOffset, destination.Get(), destinationOffset, size); + } + void CommandEncoder::CopyBufferToTexture(BufferCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyBufferToTexture(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + void CommandEncoder::CopyTextureToBuffer(TextureCopyView const * source, BufferCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyTextureToBuffer(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + void CommandEncoder::CopyTextureToTexture(TextureCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyTextureToTexture(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + CommandBuffer CommandEncoder::Finish(CommandBufferDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderFinish(Get(), reinterpret_cast(descriptor)); + return CommandBuffer::Acquire(result); + } + void CommandEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuCommandEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void CommandEncoder::PopDebugGroup() const { + wgpuCommandEncoderPopDebugGroup(Get()); + } + void CommandEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuCommandEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void CommandEncoder::WGPUReference(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderReference(handle); + } + } + void CommandEncoder::WGPURelease(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderRelease(handle); + } + } + + + static_assert(sizeof(ComputePassEncoder) == sizeof(WGPUComputePassEncoder), "sizeof mismatch for ComputePassEncoder"); + static_assert(alignof(ComputePassEncoder) == alignof(WGPUComputePassEncoder), "alignof mismatch for ComputePassEncoder"); + + + + void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) const { + wgpuComputePassEncoderDispatch(Get(), x, y, z); + } + void ComputePassEncoder::DispatchIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuComputePassEncoderDispatchIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void ComputePassEncoder::EndPass() const { + wgpuComputePassEncoderEndPass(Get()); + } + void ComputePassEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuComputePassEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void ComputePassEncoder::PopDebugGroup() const { + wgpuComputePassEncoderPopDebugGroup(Get()); + } + void ComputePassEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuComputePassEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void ComputePassEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuComputePassEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void ComputePassEncoder::SetPipeline(ComputePipeline const& pipeline) const { + wgpuComputePassEncoderSetPipeline(Get(), pipeline.Get()); + } + void ComputePassEncoder::WGPUReference(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderReference(handle); + } + } + void ComputePassEncoder::WGPURelease(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderRelease(handle); + } + } + + + static_assert(sizeof(ComputePipeline) == sizeof(WGPUComputePipeline), "sizeof mismatch for ComputePipeline"); + static_assert(alignof(ComputePipeline) == alignof(WGPUComputePipeline), "alignof mismatch for ComputePipeline"); + + + + BindGroupLayout ComputePipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuComputePipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); + } + void ComputePipeline::WGPUReference(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineReference(handle); + } + } + void ComputePipeline::WGPURelease(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineRelease(handle); + } + } + + + static_assert(sizeof(Device) == sizeof(WGPUDevice), "sizeof mismatch for Device"); + static_assert(alignof(Device) == alignof(WGPUDevice), "alignof mismatch for Device"); + + + + BindGroup Device::CreateBindGroup(BindGroupDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBindGroup(Get(), reinterpret_cast(descriptor)); + return BindGroup::Acquire(result); + } + BindGroupLayout Device::CreateBindGroupLayout(BindGroupLayoutDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBindGroupLayout(Get(), reinterpret_cast(descriptor)); + return BindGroupLayout::Acquire(result); + } + Buffer Device::CreateBuffer(BufferDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBuffer(Get(), reinterpret_cast(descriptor)); + return Buffer::Acquire(result); + } + CreateBufferMappedResult Device::CreateBufferMapped(BufferDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBufferMapped(Get(), reinterpret_cast(descriptor)); + return CreateBufferMappedResult { + Buffer::Acquire(result.buffer), + result.dataLength, + result.data + }; + } + CommandEncoder Device::CreateCommandEncoder(CommandEncoderDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateCommandEncoder(Get(), reinterpret_cast(descriptor)); + return CommandEncoder::Acquire(result); + } + ComputePipeline Device::CreateComputePipeline(ComputePipelineDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateComputePipeline(Get(), reinterpret_cast(descriptor)); + return ComputePipeline::Acquire(result); + } + PipelineLayout Device::CreatePipelineLayout(PipelineLayoutDescriptor const * descriptor) const { + auto result = wgpuDeviceCreatePipelineLayout(Get(), reinterpret_cast(descriptor)); + return PipelineLayout::Acquire(result); + } + RenderBundleEncoder Device::CreateRenderBundleEncoder(RenderBundleEncoderDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateRenderBundleEncoder(Get(), reinterpret_cast(descriptor)); + return RenderBundleEncoder::Acquire(result); + } + RenderPipeline Device::CreateRenderPipeline(RenderPipelineDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateRenderPipeline(Get(), reinterpret_cast(descriptor)); + return RenderPipeline::Acquire(result); + } + Sampler Device::CreateSampler(SamplerDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateSampler(Get(), reinterpret_cast(descriptor)); + return Sampler::Acquire(result); + } + ShaderModule Device::CreateShaderModule(ShaderModuleDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateShaderModule(Get(), reinterpret_cast(descriptor)); + return ShaderModule::Acquire(result); + } + SwapChain Device::CreateSwapChain(Surface const& surface, SwapChainDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateSwapChain(Get(), surface.Get(), reinterpret_cast(descriptor)); + return SwapChain::Acquire(result); + } + Texture Device::CreateTexture(TextureDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateTexture(Get(), reinterpret_cast(descriptor)); + return Texture::Acquire(result); + } + Queue Device::GetDefaultQueue() const { + auto result = wgpuDeviceGetDefaultQueue(Get()); + return Queue::Acquire(result); + } + void Device::InjectError(ErrorType type, char const * message) const { + wgpuDeviceInjectError(Get(), static_cast(type), reinterpret_cast(message)); + } + void Device::LoseForTesting() const { + wgpuDeviceLoseForTesting(Get()); + } + bool Device::PopErrorScope(ErrorCallback callback, void * userdata) const { + auto result = wgpuDevicePopErrorScope(Get(), callback, reinterpret_cast(userdata)); + return result; + } + void Device::PushErrorScope(ErrorFilter filter) const { + wgpuDevicePushErrorScope(Get(), static_cast(filter)); + } + void Device::SetDeviceLostCallback(DeviceLostCallback callback, void * userdata) const { + wgpuDeviceSetDeviceLostCallback(Get(), callback, reinterpret_cast(userdata)); + } + void Device::SetUncapturedErrorCallback(ErrorCallback callback, void * userdata) const { + wgpuDeviceSetUncapturedErrorCallback(Get(), callback, reinterpret_cast(userdata)); + } + void Device::Tick() const { + wgpuDeviceTick(Get()); + } + void Device::WGPUReference(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceReference(handle); + } + } + void Device::WGPURelease(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceRelease(handle); + } + } + + + static_assert(sizeof(Fence) == sizeof(WGPUFence), "sizeof mismatch for Fence"); + static_assert(alignof(Fence) == alignof(WGPUFence), "alignof mismatch for Fence"); + + + + uint64_t Fence::GetCompletedValue() const { + auto result = wgpuFenceGetCompletedValue(Get()); + return result; + } + void Fence::OnCompletion(uint64_t value, FenceOnCompletionCallback callback, void * userdata) const { + wgpuFenceOnCompletion(Get(), value, callback, reinterpret_cast(userdata)); + } + void Fence::WGPUReference(WGPUFence handle) { + if (handle != nullptr) { + wgpuFenceReference(handle); + } + } + void Fence::WGPURelease(WGPUFence handle) { + if (handle != nullptr) { + wgpuFenceRelease(handle); + } + } + + + static_assert(sizeof(Instance) == sizeof(WGPUInstance), "sizeof mismatch for Instance"); + static_assert(alignof(Instance) == alignof(WGPUInstance), "alignof mismatch for Instance"); + + + + Surface Instance::CreateSurface(SurfaceDescriptor const * descriptor) const { + auto result = wgpuInstanceCreateSurface(Get(), reinterpret_cast(descriptor)); + return Surface::Acquire(result); + } + void Instance::WGPUReference(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceReference(handle); + } + } + void Instance::WGPURelease(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceRelease(handle); + } + } + + + static_assert(sizeof(PipelineLayout) == sizeof(WGPUPipelineLayout), "sizeof mismatch for PipelineLayout"); + static_assert(alignof(PipelineLayout) == alignof(WGPUPipelineLayout), "alignof mismatch for PipelineLayout"); + + + + void PipelineLayout::WGPUReference(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutReference(handle); + } + } + void PipelineLayout::WGPURelease(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutRelease(handle); + } + } + + + static_assert(sizeof(Queue) == sizeof(WGPUQueue), "sizeof mismatch for Queue"); + static_assert(alignof(Queue) == alignof(WGPUQueue), "alignof mismatch for Queue"); + + + + Fence Queue::CreateFence(FenceDescriptor const * descriptor) const { + auto result = wgpuQueueCreateFence(Get(), reinterpret_cast(descriptor)); + return Fence::Acquire(result); + } + void Queue::Signal(Fence const& fence, uint64_t signalValue) const { + wgpuQueueSignal(Get(), fence.Get(), signalValue); + } + void Queue::Submit(uint32_t commandCount, CommandBuffer const * commands) const { + wgpuQueueSubmit(Get(), commandCount, reinterpret_cast(commands)); + } + void Queue::WGPUReference(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueReference(handle); + } + } + void Queue::WGPURelease(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueRelease(handle); + } + } + + + static_assert(sizeof(RenderBundle) == sizeof(WGPURenderBundle), "sizeof mismatch for RenderBundle"); + static_assert(alignof(RenderBundle) == alignof(WGPURenderBundle), "alignof mismatch for RenderBundle"); + + + + void RenderBundle::WGPUReference(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleReference(handle); + } + } + void RenderBundle::WGPURelease(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleRelease(handle); + } + } + + + static_assert(sizeof(RenderBundleEncoder) == sizeof(WGPURenderBundleEncoder), "sizeof mismatch for RenderBundleEncoder"); + static_assert(alignof(RenderBundleEncoder) == alignof(WGPURenderBundleEncoder), "alignof mismatch for RenderBundleEncoder"); + + + + void RenderBundleEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const { + wgpuRenderBundleEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, firstInstance); + } + void RenderBundleEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) const { + wgpuRenderBundleEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + void RenderBundleEncoder::DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderBundleEncoder::DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + RenderBundle RenderBundleEncoder::Finish(RenderBundleDescriptor const * descriptor) const { + auto result = wgpuRenderBundleEncoderFinish(Get(), reinterpret_cast(descriptor)); + return RenderBundle::Acquire(result); + } + void RenderBundleEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuRenderBundleEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void RenderBundleEncoder::PopDebugGroup() const { + wgpuRenderBundleEncoderPopDebugGroup(Get()); + } + void RenderBundleEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuRenderBundleEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void RenderBundleEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuRenderBundleEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void RenderBundleEncoder::SetIndexBuffer(Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderBundleEncoderSetIndexBuffer(Get(), buffer.Get(), offset, size); + } + void RenderBundleEncoder::SetPipeline(RenderPipeline const& pipeline) const { + wgpuRenderBundleEncoderSetPipeline(Get(), pipeline.Get()); + } + void RenderBundleEncoder::SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderBundleEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); + } + void RenderBundleEncoder::WGPUReference(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderReference(handle); + } + } + void RenderBundleEncoder::WGPURelease(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderRelease(handle); + } + } + + + static_assert(sizeof(RenderPassEncoder) == sizeof(WGPURenderPassEncoder), "sizeof mismatch for RenderPassEncoder"); + static_assert(alignof(RenderPassEncoder) == alignof(WGPURenderPassEncoder), "alignof mismatch for RenderPassEncoder"); + + + + void RenderPassEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const { + wgpuRenderPassEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, firstInstance); + } + void RenderPassEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) const { + wgpuRenderPassEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + void RenderPassEncoder::DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderPassEncoder::DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderPassEncoder::EndPass() const { + wgpuRenderPassEncoderEndPass(Get()); + } + void RenderPassEncoder::ExecuteBundles(uint32_t bundlesCount, RenderBundle const * bundles) const { + wgpuRenderPassEncoderExecuteBundles(Get(), bundlesCount, reinterpret_cast(bundles)); + } + void RenderPassEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuRenderPassEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void RenderPassEncoder::PopDebugGroup() const { + wgpuRenderPassEncoderPopDebugGroup(Get()); + } + void RenderPassEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuRenderPassEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void RenderPassEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuRenderPassEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void RenderPassEncoder::SetBlendColor(Color const * color) const { + wgpuRenderPassEncoderSetBlendColor(Get(), reinterpret_cast(color)); + } + void RenderPassEncoder::SetIndexBuffer(Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetIndexBuffer(Get(), buffer.Get(), offset, size); + } + void RenderPassEncoder::SetPipeline(RenderPipeline const& pipeline) const { + wgpuRenderPassEncoderSetPipeline(Get(), pipeline.Get()); + } + void RenderPassEncoder::SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const { + wgpuRenderPassEncoderSetScissorRect(Get(), x, y, width, height); + } + void RenderPassEncoder::SetStencilReference(uint32_t reference) const { + wgpuRenderPassEncoderSetStencilReference(Get(), reference); + } + void RenderPassEncoder::SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); + } + void RenderPassEncoder::SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) const { + wgpuRenderPassEncoderSetViewport(Get(), x, y, width, height, minDepth, maxDepth); + } + void RenderPassEncoder::WGPUReference(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderReference(handle); + } + } + void RenderPassEncoder::WGPURelease(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderRelease(handle); + } + } + + + static_assert(sizeof(RenderPipeline) == sizeof(WGPURenderPipeline), "sizeof mismatch for RenderPipeline"); + static_assert(alignof(RenderPipeline) == alignof(WGPURenderPipeline), "alignof mismatch for RenderPipeline"); + + + + BindGroupLayout RenderPipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuRenderPipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); + } + void RenderPipeline::WGPUReference(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineReference(handle); + } + } + void RenderPipeline::WGPURelease(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineRelease(handle); + } + } + + + static_assert(sizeof(Sampler) == sizeof(WGPUSampler), "sizeof mismatch for Sampler"); + static_assert(alignof(Sampler) == alignof(WGPUSampler), "alignof mismatch for Sampler"); + + + + void Sampler::WGPUReference(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerReference(handle); + } + } + void Sampler::WGPURelease(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerRelease(handle); + } + } + + + static_assert(sizeof(ShaderModule) == sizeof(WGPUShaderModule), "sizeof mismatch for ShaderModule"); + static_assert(alignof(ShaderModule) == alignof(WGPUShaderModule), "alignof mismatch for ShaderModule"); + + + + void ShaderModule::WGPUReference(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleReference(handle); + } + } + void ShaderModule::WGPURelease(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleRelease(handle); + } + } + + + static_assert(sizeof(Surface) == sizeof(WGPUSurface), "sizeof mismatch for Surface"); + static_assert(alignof(Surface) == alignof(WGPUSurface), "alignof mismatch for Surface"); + + + + void Surface::WGPUReference(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceReference(handle); + } + } + void Surface::WGPURelease(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceRelease(handle); + } + } + + + static_assert(sizeof(SwapChain) == sizeof(WGPUSwapChain), "sizeof mismatch for SwapChain"); + static_assert(alignof(SwapChain) == alignof(WGPUSwapChain), "alignof mismatch for SwapChain"); + + + + void SwapChain::Configure(TextureFormat format, TextureUsage allowedUsage, uint32_t width, uint32_t height) const { + wgpuSwapChainConfigure(Get(), static_cast(format), static_cast(allowedUsage), width, height); + } + TextureView SwapChain::GetCurrentTextureView() const { + auto result = wgpuSwapChainGetCurrentTextureView(Get()); + return TextureView::Acquire(result); + } + void SwapChain::Present() const { + wgpuSwapChainPresent(Get()); + } + void SwapChain::WGPUReference(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainReference(handle); + } + } + void SwapChain::WGPURelease(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainRelease(handle); + } + } + + + static_assert(sizeof(Texture) == sizeof(WGPUTexture), "sizeof mismatch for Texture"); + static_assert(alignof(Texture) == alignof(WGPUTexture), "alignof mismatch for Texture"); + + + + TextureView Texture::CreateView(TextureViewDescriptor const * descriptor) const { + auto result = wgpuTextureCreateView(Get(), reinterpret_cast(descriptor)); + return TextureView::Acquire(result); + } + void Texture::Destroy() const { + wgpuTextureDestroy(Get()); + } + void Texture::WGPUReference(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureReference(handle); + } + } + void Texture::WGPURelease(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureRelease(handle); + } + } + + + static_assert(sizeof(TextureView) == sizeof(WGPUTextureView), "sizeof mismatch for TextureView"); + static_assert(alignof(TextureView) == alignof(WGPUTextureView), "alignof mismatch for TextureView"); + + + + void TextureView::WGPUReference(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewReference(handle); + } + } + void TextureView::WGPURelease(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewRelease(handle); + } + } + + + Instance CreateInstance(const InstanceDescriptor* descriptor) { + const WGPUInstanceDescriptor* cDescriptor = + reinterpret_cast(descriptor); + return Instance::Acquire(wgpuCreateInstance(cDescriptor)); + } + + Proc GetProcAddress(Device const& device, const char* procName) { + return reinterpret_cast(wgpuGetProcAddress(device.Get(), procName)); + } + +} diff --git a/3rdparty/include/webgpu/lib/libVkLayer_khronos_validation.so b/3rdparty/include/webgpu/lib/libVkLayer_khronos_validation.so new file mode 100755 index 000000000000..9504c7fcf5bc Binary files /dev/null and b/3rdparty/include/webgpu/lib/libVkLayer_khronos_validation.so differ diff --git a/3rdparty/include/webgpu/lib/libc++.so b/3rdparty/include/webgpu/lib/libc++.so new file mode 100755 index 000000000000..3a41dc8dfd00 Binary files /dev/null and b/3rdparty/include/webgpu/lib/libc++.so differ diff --git a/3rdparty/include/webgpu/lib/libdawn_native.so b/3rdparty/include/webgpu/lib/libdawn_native.so new file mode 100755 index 000000000000..9e3a67ed4323 Binary files /dev/null and b/3rdparty/include/webgpu/lib/libdawn_native.so differ diff --git a/3rdparty/include/webgpu/lib/libdawn_proc.so b/3rdparty/include/webgpu/lib/libdawn_proc.so new file mode 100755 index 000000000000..943f1f6f1d06 Binary files /dev/null and b/3rdparty/include/webgpu/lib/libdawn_proc.so differ diff --git a/3rdparty/include/webgpu/lib/libdawn_wire.so b/3rdparty/include/webgpu/lib/libdawn_wire.so new file mode 100755 index 000000000000..31eb1272cf1d Binary files /dev/null and b/3rdparty/include/webgpu/lib/libdawn_wire.so differ diff --git a/3rdparty/include/webgpu/lib/libshaderc.so b/3rdparty/include/webgpu/lib/libshaderc.so new file mode 100755 index 000000000000..956a15386775 Binary files /dev/null and b/3rdparty/include/webgpu/lib/libshaderc.so differ diff --git a/3rdparty/include/webgpu/lib/libshaderc_spvc.so b/3rdparty/include/webgpu/lib/libshaderc_spvc.so new file mode 100755 index 000000000000..edddd9b3aa4d Binary files /dev/null and b/3rdparty/include/webgpu/lib/libshaderc_spvc.so differ diff --git a/3rdparty/include/webgpu/lib/webgpu_cpp.cpp b/3rdparty/include/webgpu/lib/webgpu_cpp.cpp new file mode 100644 index 000000000000..fd324184007c --- /dev/null +++ b/3rdparty/include/webgpu/lib/webgpu_cpp.cpp @@ -0,0 +1,1746 @@ + +#include "dawn/webgpu_cpp.h" + +namespace wgpu { + + + static_assert(sizeof(AdapterType) == sizeof(WGPUAdapterType), "sizeof mismatch for AdapterType"); + static_assert(alignof(AdapterType) == alignof(WGPUAdapterType), "alignof mismatch for AdapterType"); + + static_assert(static_cast(AdapterType::DiscreteGPU) == WGPUAdapterType_DiscreteGPU, "value mismatch for AdapterType::DiscreteGPU"); + static_assert(static_cast(AdapterType::IntegratedGPU) == WGPUAdapterType_IntegratedGPU, "value mismatch for AdapterType::IntegratedGPU"); + static_assert(static_cast(AdapterType::CPU) == WGPUAdapterType_CPU, "value mismatch for AdapterType::CPU"); + static_assert(static_cast(AdapterType::Unknown) == WGPUAdapterType_Unknown, "value mismatch for AdapterType::Unknown"); + + + static_assert(sizeof(AddressMode) == sizeof(WGPUAddressMode), "sizeof mismatch for AddressMode"); + static_assert(alignof(AddressMode) == alignof(WGPUAddressMode), "alignof mismatch for AddressMode"); + + static_assert(static_cast(AddressMode::Repeat) == WGPUAddressMode_Repeat, "value mismatch for AddressMode::Repeat"); + static_assert(static_cast(AddressMode::MirrorRepeat) == WGPUAddressMode_MirrorRepeat, "value mismatch for AddressMode::MirrorRepeat"); + static_assert(static_cast(AddressMode::ClampToEdge) == WGPUAddressMode_ClampToEdge, "value mismatch for AddressMode::ClampToEdge"); + + + static_assert(sizeof(BackendType) == sizeof(WGPUBackendType), "sizeof mismatch for BackendType"); + static_assert(alignof(BackendType) == alignof(WGPUBackendType), "alignof mismatch for BackendType"); + + static_assert(static_cast(BackendType::Null) == WGPUBackendType_Null, "value mismatch for BackendType::Null"); + static_assert(static_cast(BackendType::D3D11) == WGPUBackendType_D3D11, "value mismatch for BackendType::D3D11"); + static_assert(static_cast(BackendType::D3D12) == WGPUBackendType_D3D12, "value mismatch for BackendType::D3D12"); + static_assert(static_cast(BackendType::Metal) == WGPUBackendType_Metal, "value mismatch for BackendType::Metal"); + static_assert(static_cast(BackendType::Vulkan) == WGPUBackendType_Vulkan, "value mismatch for BackendType::Vulkan"); + static_assert(static_cast(BackendType::OpenGL) == WGPUBackendType_OpenGL, "value mismatch for BackendType::OpenGL"); + static_assert(static_cast(BackendType::OpenGLES) == WGPUBackendType_OpenGLES, "value mismatch for BackendType::OpenGLES"); + + + static_assert(sizeof(BindingType) == sizeof(WGPUBindingType), "sizeof mismatch for BindingType"); + static_assert(alignof(BindingType) == alignof(WGPUBindingType), "alignof mismatch for BindingType"); + + static_assert(static_cast(BindingType::UniformBuffer) == WGPUBindingType_UniformBuffer, "value mismatch for BindingType::UniformBuffer"); + static_assert(static_cast(BindingType::StorageBuffer) == WGPUBindingType_StorageBuffer, "value mismatch for BindingType::StorageBuffer"); + static_assert(static_cast(BindingType::ReadonlyStorageBuffer) == WGPUBindingType_ReadonlyStorageBuffer, "value mismatch for BindingType::ReadonlyStorageBuffer"); + static_assert(static_cast(BindingType::Sampler) == WGPUBindingType_Sampler, "value mismatch for BindingType::Sampler"); + static_assert(static_cast(BindingType::ComparisonSampler) == WGPUBindingType_ComparisonSampler, "value mismatch for BindingType::ComparisonSampler"); + static_assert(static_cast(BindingType::SampledTexture) == WGPUBindingType_SampledTexture, "value mismatch for BindingType::SampledTexture"); + static_assert(static_cast(BindingType::StorageTexture) == WGPUBindingType_StorageTexture, "value mismatch for BindingType::StorageTexture"); + static_assert(static_cast(BindingType::ReadonlyStorageTexture) == WGPUBindingType_ReadonlyStorageTexture, "value mismatch for BindingType::ReadonlyStorageTexture"); + static_assert(static_cast(BindingType::WriteonlyStorageTexture) == WGPUBindingType_WriteonlyStorageTexture, "value mismatch for BindingType::WriteonlyStorageTexture"); + + + static_assert(sizeof(BlendFactor) == sizeof(WGPUBlendFactor), "sizeof mismatch for BlendFactor"); + static_assert(alignof(BlendFactor) == alignof(WGPUBlendFactor), "alignof mismatch for BlendFactor"); + + static_assert(static_cast(BlendFactor::Zero) == WGPUBlendFactor_Zero, "value mismatch for BlendFactor::Zero"); + static_assert(static_cast(BlendFactor::One) == WGPUBlendFactor_One, "value mismatch for BlendFactor::One"); + static_assert(static_cast(BlendFactor::SrcColor) == WGPUBlendFactor_SrcColor, "value mismatch for BlendFactor::SrcColor"); + static_assert(static_cast(BlendFactor::OneMinusSrcColor) == WGPUBlendFactor_OneMinusSrcColor, "value mismatch for BlendFactor::OneMinusSrcColor"); + static_assert(static_cast(BlendFactor::SrcAlpha) == WGPUBlendFactor_SrcAlpha, "value mismatch for BlendFactor::SrcAlpha"); + static_assert(static_cast(BlendFactor::OneMinusSrcAlpha) == WGPUBlendFactor_OneMinusSrcAlpha, "value mismatch for BlendFactor::OneMinusSrcAlpha"); + static_assert(static_cast(BlendFactor::DstColor) == WGPUBlendFactor_DstColor, "value mismatch for BlendFactor::DstColor"); + static_assert(static_cast(BlendFactor::OneMinusDstColor) == WGPUBlendFactor_OneMinusDstColor, "value mismatch for BlendFactor::OneMinusDstColor"); + static_assert(static_cast(BlendFactor::DstAlpha) == WGPUBlendFactor_DstAlpha, "value mismatch for BlendFactor::DstAlpha"); + static_assert(static_cast(BlendFactor::OneMinusDstAlpha) == WGPUBlendFactor_OneMinusDstAlpha, "value mismatch for BlendFactor::OneMinusDstAlpha"); + static_assert(static_cast(BlendFactor::SrcAlphaSaturated) == WGPUBlendFactor_SrcAlphaSaturated, "value mismatch for BlendFactor::SrcAlphaSaturated"); + static_assert(static_cast(BlendFactor::BlendColor) == WGPUBlendFactor_BlendColor, "value mismatch for BlendFactor::BlendColor"); + static_assert(static_cast(BlendFactor::OneMinusBlendColor) == WGPUBlendFactor_OneMinusBlendColor, "value mismatch for BlendFactor::OneMinusBlendColor"); + + + static_assert(sizeof(BlendOperation) == sizeof(WGPUBlendOperation), "sizeof mismatch for BlendOperation"); + static_assert(alignof(BlendOperation) == alignof(WGPUBlendOperation), "alignof mismatch for BlendOperation"); + + static_assert(static_cast(BlendOperation::Add) == WGPUBlendOperation_Add, "value mismatch for BlendOperation::Add"); + static_assert(static_cast(BlendOperation::Subtract) == WGPUBlendOperation_Subtract, "value mismatch for BlendOperation::Subtract"); + static_assert(static_cast(BlendOperation::ReverseSubtract) == WGPUBlendOperation_ReverseSubtract, "value mismatch for BlendOperation::ReverseSubtract"); + static_assert(static_cast(BlendOperation::Min) == WGPUBlendOperation_Min, "value mismatch for BlendOperation::Min"); + static_assert(static_cast(BlendOperation::Max) == WGPUBlendOperation_Max, "value mismatch for BlendOperation::Max"); + + + static_assert(sizeof(BufferMapAsyncStatus) == sizeof(WGPUBufferMapAsyncStatus), "sizeof mismatch for BufferMapAsyncStatus"); + static_assert(alignof(BufferMapAsyncStatus) == alignof(WGPUBufferMapAsyncStatus), "alignof mismatch for BufferMapAsyncStatus"); + + static_assert(static_cast(BufferMapAsyncStatus::Success) == WGPUBufferMapAsyncStatus_Success, "value mismatch for BufferMapAsyncStatus::Success"); + static_assert(static_cast(BufferMapAsyncStatus::Error) == WGPUBufferMapAsyncStatus_Error, "value mismatch for BufferMapAsyncStatus::Error"); + static_assert(static_cast(BufferMapAsyncStatus::Unknown) == WGPUBufferMapAsyncStatus_Unknown, "value mismatch for BufferMapAsyncStatus::Unknown"); + static_assert(static_cast(BufferMapAsyncStatus::DeviceLost) == WGPUBufferMapAsyncStatus_DeviceLost, "value mismatch for BufferMapAsyncStatus::DeviceLost"); + + + static_assert(sizeof(CompareFunction) == sizeof(WGPUCompareFunction), "sizeof mismatch for CompareFunction"); + static_assert(alignof(CompareFunction) == alignof(WGPUCompareFunction), "alignof mismatch for CompareFunction"); + + static_assert(static_cast(CompareFunction::Undefined) == WGPUCompareFunction_Undefined, "value mismatch for CompareFunction::Undefined"); + static_assert(static_cast(CompareFunction::Never) == WGPUCompareFunction_Never, "value mismatch for CompareFunction::Never"); + static_assert(static_cast(CompareFunction::Less) == WGPUCompareFunction_Less, "value mismatch for CompareFunction::Less"); + static_assert(static_cast(CompareFunction::LessEqual) == WGPUCompareFunction_LessEqual, "value mismatch for CompareFunction::LessEqual"); + static_assert(static_cast(CompareFunction::Greater) == WGPUCompareFunction_Greater, "value mismatch for CompareFunction::Greater"); + static_assert(static_cast(CompareFunction::GreaterEqual) == WGPUCompareFunction_GreaterEqual, "value mismatch for CompareFunction::GreaterEqual"); + static_assert(static_cast(CompareFunction::Equal) == WGPUCompareFunction_Equal, "value mismatch for CompareFunction::Equal"); + static_assert(static_cast(CompareFunction::NotEqual) == WGPUCompareFunction_NotEqual, "value mismatch for CompareFunction::NotEqual"); + static_assert(static_cast(CompareFunction::Always) == WGPUCompareFunction_Always, "value mismatch for CompareFunction::Always"); + + + static_assert(sizeof(CullMode) == sizeof(WGPUCullMode), "sizeof mismatch for CullMode"); + static_assert(alignof(CullMode) == alignof(WGPUCullMode), "alignof mismatch for CullMode"); + + static_assert(static_cast(CullMode::None) == WGPUCullMode_None, "value mismatch for CullMode::None"); + static_assert(static_cast(CullMode::Front) == WGPUCullMode_Front, "value mismatch for CullMode::Front"); + static_assert(static_cast(CullMode::Back) == WGPUCullMode_Back, "value mismatch for CullMode::Back"); + + + static_assert(sizeof(ErrorFilter) == sizeof(WGPUErrorFilter), "sizeof mismatch for ErrorFilter"); + static_assert(alignof(ErrorFilter) == alignof(WGPUErrorFilter), "alignof mismatch for ErrorFilter"); + + static_assert(static_cast(ErrorFilter::None) == WGPUErrorFilter_None, "value mismatch for ErrorFilter::None"); + static_assert(static_cast(ErrorFilter::Validation) == WGPUErrorFilter_Validation, "value mismatch for ErrorFilter::Validation"); + static_assert(static_cast(ErrorFilter::OutOfMemory) == WGPUErrorFilter_OutOfMemory, "value mismatch for ErrorFilter::OutOfMemory"); + + + static_assert(sizeof(ErrorType) == sizeof(WGPUErrorType), "sizeof mismatch for ErrorType"); + static_assert(alignof(ErrorType) == alignof(WGPUErrorType), "alignof mismatch for ErrorType"); + + static_assert(static_cast(ErrorType::NoError) == WGPUErrorType_NoError, "value mismatch for ErrorType::NoError"); + static_assert(static_cast(ErrorType::Validation) == WGPUErrorType_Validation, "value mismatch for ErrorType::Validation"); + static_assert(static_cast(ErrorType::OutOfMemory) == WGPUErrorType_OutOfMemory, "value mismatch for ErrorType::OutOfMemory"); + static_assert(static_cast(ErrorType::Unknown) == WGPUErrorType_Unknown, "value mismatch for ErrorType::Unknown"); + static_assert(static_cast(ErrorType::DeviceLost) == WGPUErrorType_DeviceLost, "value mismatch for ErrorType::DeviceLost"); + + + static_assert(sizeof(FenceCompletionStatus) == sizeof(WGPUFenceCompletionStatus), "sizeof mismatch for FenceCompletionStatus"); + static_assert(alignof(FenceCompletionStatus) == alignof(WGPUFenceCompletionStatus), "alignof mismatch for FenceCompletionStatus"); + + static_assert(static_cast(FenceCompletionStatus::Success) == WGPUFenceCompletionStatus_Success, "value mismatch for FenceCompletionStatus::Success"); + static_assert(static_cast(FenceCompletionStatus::Error) == WGPUFenceCompletionStatus_Error, "value mismatch for FenceCompletionStatus::Error"); + static_assert(static_cast(FenceCompletionStatus::Unknown) == WGPUFenceCompletionStatus_Unknown, "value mismatch for FenceCompletionStatus::Unknown"); + static_assert(static_cast(FenceCompletionStatus::DeviceLost) == WGPUFenceCompletionStatus_DeviceLost, "value mismatch for FenceCompletionStatus::DeviceLost"); + + + static_assert(sizeof(FilterMode) == sizeof(WGPUFilterMode), "sizeof mismatch for FilterMode"); + static_assert(alignof(FilterMode) == alignof(WGPUFilterMode), "alignof mismatch for FilterMode"); + + static_assert(static_cast(FilterMode::Nearest) == WGPUFilterMode_Nearest, "value mismatch for FilterMode::Nearest"); + static_assert(static_cast(FilterMode::Linear) == WGPUFilterMode_Linear, "value mismatch for FilterMode::Linear"); + + + static_assert(sizeof(FrontFace) == sizeof(WGPUFrontFace), "sizeof mismatch for FrontFace"); + static_assert(alignof(FrontFace) == alignof(WGPUFrontFace), "alignof mismatch for FrontFace"); + + static_assert(static_cast(FrontFace::CCW) == WGPUFrontFace_CCW, "value mismatch for FrontFace::CCW"); + static_assert(static_cast(FrontFace::CW) == WGPUFrontFace_CW, "value mismatch for FrontFace::CW"); + + + static_assert(sizeof(IndexFormat) == sizeof(WGPUIndexFormat), "sizeof mismatch for IndexFormat"); + static_assert(alignof(IndexFormat) == alignof(WGPUIndexFormat), "alignof mismatch for IndexFormat"); + + static_assert(static_cast(IndexFormat::Uint16) == WGPUIndexFormat_Uint16, "value mismatch for IndexFormat::Uint16"); + static_assert(static_cast(IndexFormat::Uint32) == WGPUIndexFormat_Uint32, "value mismatch for IndexFormat::Uint32"); + + + static_assert(sizeof(InputStepMode) == sizeof(WGPUInputStepMode), "sizeof mismatch for InputStepMode"); + static_assert(alignof(InputStepMode) == alignof(WGPUInputStepMode), "alignof mismatch for InputStepMode"); + + static_assert(static_cast(InputStepMode::Vertex) == WGPUInputStepMode_Vertex, "value mismatch for InputStepMode::Vertex"); + static_assert(static_cast(InputStepMode::Instance) == WGPUInputStepMode_Instance, "value mismatch for InputStepMode::Instance"); + + + static_assert(sizeof(LoadOp) == sizeof(WGPULoadOp), "sizeof mismatch for LoadOp"); + static_assert(alignof(LoadOp) == alignof(WGPULoadOp), "alignof mismatch for LoadOp"); + + static_assert(static_cast(LoadOp::Clear) == WGPULoadOp_Clear, "value mismatch for LoadOp::Clear"); + static_assert(static_cast(LoadOp::Load) == WGPULoadOp_Load, "value mismatch for LoadOp::Load"); + + + static_assert(sizeof(PresentMode) == sizeof(WGPUPresentMode), "sizeof mismatch for PresentMode"); + static_assert(alignof(PresentMode) == alignof(WGPUPresentMode), "alignof mismatch for PresentMode"); + + static_assert(static_cast(PresentMode::Immediate) == WGPUPresentMode_Immediate, "value mismatch for PresentMode::Immediate"); + static_assert(static_cast(PresentMode::Mailbox) == WGPUPresentMode_Mailbox, "value mismatch for PresentMode::Mailbox"); + static_assert(static_cast(PresentMode::Fifo) == WGPUPresentMode_Fifo, "value mismatch for PresentMode::Fifo"); + + + static_assert(sizeof(PrimitiveTopology) == sizeof(WGPUPrimitiveTopology), "sizeof mismatch for PrimitiveTopology"); + static_assert(alignof(PrimitiveTopology) == alignof(WGPUPrimitiveTopology), "alignof mismatch for PrimitiveTopology"); + + static_assert(static_cast(PrimitiveTopology::PointList) == WGPUPrimitiveTopology_PointList, "value mismatch for PrimitiveTopology::PointList"); + static_assert(static_cast(PrimitiveTopology::LineList) == WGPUPrimitiveTopology_LineList, "value mismatch for PrimitiveTopology::LineList"); + static_assert(static_cast(PrimitiveTopology::LineStrip) == WGPUPrimitiveTopology_LineStrip, "value mismatch for PrimitiveTopology::LineStrip"); + static_assert(static_cast(PrimitiveTopology::TriangleList) == WGPUPrimitiveTopology_TriangleList, "value mismatch for PrimitiveTopology::TriangleList"); + static_assert(static_cast(PrimitiveTopology::TriangleStrip) == WGPUPrimitiveTopology_TriangleStrip, "value mismatch for PrimitiveTopology::TriangleStrip"); + + + static_assert(sizeof(SType) == sizeof(WGPUSType), "sizeof mismatch for SType"); + static_assert(alignof(SType) == alignof(WGPUSType), "alignof mismatch for SType"); + + static_assert(static_cast(SType::Invalid) == WGPUSType_Invalid, "value mismatch for SType::Invalid"); + static_assert(static_cast(SType::SurfaceDescriptorFromMetalLayer) == WGPUSType_SurfaceDescriptorFromMetalLayer, "value mismatch for SType::SurfaceDescriptorFromMetalLayer"); + static_assert(static_cast(SType::SurfaceDescriptorFromWindowsHWND) == WGPUSType_SurfaceDescriptorFromWindowsHWND, "value mismatch for SType::SurfaceDescriptorFromWindowsHWND"); + static_assert(static_cast(SType::SurfaceDescriptorFromXlib) == WGPUSType_SurfaceDescriptorFromXlib, "value mismatch for SType::SurfaceDescriptorFromXlib"); + static_assert(static_cast(SType::SurfaceDescriptorFromHTMLCanvasId) == WGPUSType_SurfaceDescriptorFromHTMLCanvasId, "value mismatch for SType::SurfaceDescriptorFromHTMLCanvasId"); + static_assert(static_cast(SType::ShaderModuleSPIRVDescriptor) == WGPUSType_ShaderModuleSPIRVDescriptor, "value mismatch for SType::ShaderModuleSPIRVDescriptor"); + static_assert(static_cast(SType::ShaderModuleWGSLDescriptor) == WGPUSType_ShaderModuleWGSLDescriptor, "value mismatch for SType::ShaderModuleWGSLDescriptor"); + static_assert(static_cast(SType::SamplerDescriptorDummyAnisotropicFiltering) == WGPUSType_SamplerDescriptorDummyAnisotropicFiltering, "value mismatch for SType::SamplerDescriptorDummyAnisotropicFiltering"); + static_assert(static_cast(SType::RenderPipelineDescriptorDummyExtension) == WGPUSType_RenderPipelineDescriptorDummyExtension, "value mismatch for SType::RenderPipelineDescriptorDummyExtension"); + + + static_assert(sizeof(StencilOperation) == sizeof(WGPUStencilOperation), "sizeof mismatch for StencilOperation"); + static_assert(alignof(StencilOperation) == alignof(WGPUStencilOperation), "alignof mismatch for StencilOperation"); + + static_assert(static_cast(StencilOperation::Keep) == WGPUStencilOperation_Keep, "value mismatch for StencilOperation::Keep"); + static_assert(static_cast(StencilOperation::Zero) == WGPUStencilOperation_Zero, "value mismatch for StencilOperation::Zero"); + static_assert(static_cast(StencilOperation::Replace) == WGPUStencilOperation_Replace, "value mismatch for StencilOperation::Replace"); + static_assert(static_cast(StencilOperation::Invert) == WGPUStencilOperation_Invert, "value mismatch for StencilOperation::Invert"); + static_assert(static_cast(StencilOperation::IncrementClamp) == WGPUStencilOperation_IncrementClamp, "value mismatch for StencilOperation::IncrementClamp"); + static_assert(static_cast(StencilOperation::DecrementClamp) == WGPUStencilOperation_DecrementClamp, "value mismatch for StencilOperation::DecrementClamp"); + static_assert(static_cast(StencilOperation::IncrementWrap) == WGPUStencilOperation_IncrementWrap, "value mismatch for StencilOperation::IncrementWrap"); + static_assert(static_cast(StencilOperation::DecrementWrap) == WGPUStencilOperation_DecrementWrap, "value mismatch for StencilOperation::DecrementWrap"); + + + static_assert(sizeof(StoreOp) == sizeof(WGPUStoreOp), "sizeof mismatch for StoreOp"); + static_assert(alignof(StoreOp) == alignof(WGPUStoreOp), "alignof mismatch for StoreOp"); + + static_assert(static_cast(StoreOp::Store) == WGPUStoreOp_Store, "value mismatch for StoreOp::Store"); + static_assert(static_cast(StoreOp::Clear) == WGPUStoreOp_Clear, "value mismatch for StoreOp::Clear"); + + + static_assert(sizeof(TextureAspect) == sizeof(WGPUTextureAspect), "sizeof mismatch for TextureAspect"); + static_assert(alignof(TextureAspect) == alignof(WGPUTextureAspect), "alignof mismatch for TextureAspect"); + + static_assert(static_cast(TextureAspect::All) == WGPUTextureAspect_All, "value mismatch for TextureAspect::All"); + static_assert(static_cast(TextureAspect::StencilOnly) == WGPUTextureAspect_StencilOnly, "value mismatch for TextureAspect::StencilOnly"); + static_assert(static_cast(TextureAspect::DepthOnly) == WGPUTextureAspect_DepthOnly, "value mismatch for TextureAspect::DepthOnly"); + + + static_assert(sizeof(TextureComponentType) == sizeof(WGPUTextureComponentType), "sizeof mismatch for TextureComponentType"); + static_assert(alignof(TextureComponentType) == alignof(WGPUTextureComponentType), "alignof mismatch for TextureComponentType"); + + static_assert(static_cast(TextureComponentType::Float) == WGPUTextureComponentType_Float, "value mismatch for TextureComponentType::Float"); + static_assert(static_cast(TextureComponentType::Sint) == WGPUTextureComponentType_Sint, "value mismatch for TextureComponentType::Sint"); + static_assert(static_cast(TextureComponentType::Uint) == WGPUTextureComponentType_Uint, "value mismatch for TextureComponentType::Uint"); + + + static_assert(sizeof(TextureDimension) == sizeof(WGPUTextureDimension), "sizeof mismatch for TextureDimension"); + static_assert(alignof(TextureDimension) == alignof(WGPUTextureDimension), "alignof mismatch for TextureDimension"); + + static_assert(static_cast(TextureDimension::e1D) == WGPUTextureDimension_1D, "value mismatch for TextureDimension::e1D"); + static_assert(static_cast(TextureDimension::e2D) == WGPUTextureDimension_2D, "value mismatch for TextureDimension::e2D"); + static_assert(static_cast(TextureDimension::e3D) == WGPUTextureDimension_3D, "value mismatch for TextureDimension::e3D"); + + + static_assert(sizeof(TextureFormat) == sizeof(WGPUTextureFormat), "sizeof mismatch for TextureFormat"); + static_assert(alignof(TextureFormat) == alignof(WGPUTextureFormat), "alignof mismatch for TextureFormat"); + + static_assert(static_cast(TextureFormat::Undefined) == WGPUTextureFormat_Undefined, "value mismatch for TextureFormat::Undefined"); + static_assert(static_cast(TextureFormat::R8Unorm) == WGPUTextureFormat_R8Unorm, "value mismatch for TextureFormat::R8Unorm"); + static_assert(static_cast(TextureFormat::R8Snorm) == WGPUTextureFormat_R8Snorm, "value mismatch for TextureFormat::R8Snorm"); + static_assert(static_cast(TextureFormat::R8Uint) == WGPUTextureFormat_R8Uint, "value mismatch for TextureFormat::R8Uint"); + static_assert(static_cast(TextureFormat::R8Sint) == WGPUTextureFormat_R8Sint, "value mismatch for TextureFormat::R8Sint"); + static_assert(static_cast(TextureFormat::R16Uint) == WGPUTextureFormat_R16Uint, "value mismatch for TextureFormat::R16Uint"); + static_assert(static_cast(TextureFormat::R16Sint) == WGPUTextureFormat_R16Sint, "value mismatch for TextureFormat::R16Sint"); + static_assert(static_cast(TextureFormat::R16Float) == WGPUTextureFormat_R16Float, "value mismatch for TextureFormat::R16Float"); + static_assert(static_cast(TextureFormat::RG8Unorm) == WGPUTextureFormat_RG8Unorm, "value mismatch for TextureFormat::RG8Unorm"); + static_assert(static_cast(TextureFormat::RG8Snorm) == WGPUTextureFormat_RG8Snorm, "value mismatch for TextureFormat::RG8Snorm"); + static_assert(static_cast(TextureFormat::RG8Uint) == WGPUTextureFormat_RG8Uint, "value mismatch for TextureFormat::RG8Uint"); + static_assert(static_cast(TextureFormat::RG8Sint) == WGPUTextureFormat_RG8Sint, "value mismatch for TextureFormat::RG8Sint"); + static_assert(static_cast(TextureFormat::R32Float) == WGPUTextureFormat_R32Float, "value mismatch for TextureFormat::R32Float"); + static_assert(static_cast(TextureFormat::R32Uint) == WGPUTextureFormat_R32Uint, "value mismatch for TextureFormat::R32Uint"); + static_assert(static_cast(TextureFormat::R32Sint) == WGPUTextureFormat_R32Sint, "value mismatch for TextureFormat::R32Sint"); + static_assert(static_cast(TextureFormat::RG16Uint) == WGPUTextureFormat_RG16Uint, "value mismatch for TextureFormat::RG16Uint"); + static_assert(static_cast(TextureFormat::RG16Sint) == WGPUTextureFormat_RG16Sint, "value mismatch for TextureFormat::RG16Sint"); + static_assert(static_cast(TextureFormat::RG16Float) == WGPUTextureFormat_RG16Float, "value mismatch for TextureFormat::RG16Float"); + static_assert(static_cast(TextureFormat::RGBA8Unorm) == WGPUTextureFormat_RGBA8Unorm, "value mismatch for TextureFormat::RGBA8Unorm"); + static_assert(static_cast(TextureFormat::RGBA8UnormSrgb) == WGPUTextureFormat_RGBA8UnormSrgb, "value mismatch for TextureFormat::RGBA8UnormSrgb"); + static_assert(static_cast(TextureFormat::RGBA8Snorm) == WGPUTextureFormat_RGBA8Snorm, "value mismatch for TextureFormat::RGBA8Snorm"); + static_assert(static_cast(TextureFormat::RGBA8Uint) == WGPUTextureFormat_RGBA8Uint, "value mismatch for TextureFormat::RGBA8Uint"); + static_assert(static_cast(TextureFormat::RGBA8Sint) == WGPUTextureFormat_RGBA8Sint, "value mismatch for TextureFormat::RGBA8Sint"); + static_assert(static_cast(TextureFormat::BGRA8Unorm) == WGPUTextureFormat_BGRA8Unorm, "value mismatch for TextureFormat::BGRA8Unorm"); + static_assert(static_cast(TextureFormat::BGRA8UnormSrgb) == WGPUTextureFormat_BGRA8UnormSrgb, "value mismatch for TextureFormat::BGRA8UnormSrgb"); + static_assert(static_cast(TextureFormat::RGB10A2Unorm) == WGPUTextureFormat_RGB10A2Unorm, "value mismatch for TextureFormat::RGB10A2Unorm"); + static_assert(static_cast(TextureFormat::RG11B10Float) == WGPUTextureFormat_RG11B10Float, "value mismatch for TextureFormat::RG11B10Float"); + static_assert(static_cast(TextureFormat::RG32Float) == WGPUTextureFormat_RG32Float, "value mismatch for TextureFormat::RG32Float"); + static_assert(static_cast(TextureFormat::RG32Uint) == WGPUTextureFormat_RG32Uint, "value mismatch for TextureFormat::RG32Uint"); + static_assert(static_cast(TextureFormat::RG32Sint) == WGPUTextureFormat_RG32Sint, "value mismatch for TextureFormat::RG32Sint"); + static_assert(static_cast(TextureFormat::RGBA16Uint) == WGPUTextureFormat_RGBA16Uint, "value mismatch for TextureFormat::RGBA16Uint"); + static_assert(static_cast(TextureFormat::RGBA16Sint) == WGPUTextureFormat_RGBA16Sint, "value mismatch for TextureFormat::RGBA16Sint"); + static_assert(static_cast(TextureFormat::RGBA16Float) == WGPUTextureFormat_RGBA16Float, "value mismatch for TextureFormat::RGBA16Float"); + static_assert(static_cast(TextureFormat::RGBA32Float) == WGPUTextureFormat_RGBA32Float, "value mismatch for TextureFormat::RGBA32Float"); + static_assert(static_cast(TextureFormat::RGBA32Uint) == WGPUTextureFormat_RGBA32Uint, "value mismatch for TextureFormat::RGBA32Uint"); + static_assert(static_cast(TextureFormat::RGBA32Sint) == WGPUTextureFormat_RGBA32Sint, "value mismatch for TextureFormat::RGBA32Sint"); + static_assert(static_cast(TextureFormat::Depth32Float) == WGPUTextureFormat_Depth32Float, "value mismatch for TextureFormat::Depth32Float"); + static_assert(static_cast(TextureFormat::Depth24Plus) == WGPUTextureFormat_Depth24Plus, "value mismatch for TextureFormat::Depth24Plus"); + static_assert(static_cast(TextureFormat::Depth24PlusStencil8) == WGPUTextureFormat_Depth24PlusStencil8, "value mismatch for TextureFormat::Depth24PlusStencil8"); + static_assert(static_cast(TextureFormat::BC1RGBAUnorm) == WGPUTextureFormat_BC1RGBAUnorm, "value mismatch for TextureFormat::BC1RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC1RGBAUnormSrgb) == WGPUTextureFormat_BC1RGBAUnormSrgb, "value mismatch for TextureFormat::BC1RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC2RGBAUnorm) == WGPUTextureFormat_BC2RGBAUnorm, "value mismatch for TextureFormat::BC2RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC2RGBAUnormSrgb) == WGPUTextureFormat_BC2RGBAUnormSrgb, "value mismatch for TextureFormat::BC2RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC3RGBAUnorm) == WGPUTextureFormat_BC3RGBAUnorm, "value mismatch for TextureFormat::BC3RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC3RGBAUnormSrgb) == WGPUTextureFormat_BC3RGBAUnormSrgb, "value mismatch for TextureFormat::BC3RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC4RUnorm) == WGPUTextureFormat_BC4RUnorm, "value mismatch for TextureFormat::BC4RUnorm"); + static_assert(static_cast(TextureFormat::BC4RSnorm) == WGPUTextureFormat_BC4RSnorm, "value mismatch for TextureFormat::BC4RSnorm"); + static_assert(static_cast(TextureFormat::BC5RGUnorm) == WGPUTextureFormat_BC5RGUnorm, "value mismatch for TextureFormat::BC5RGUnorm"); + static_assert(static_cast(TextureFormat::BC5RGSnorm) == WGPUTextureFormat_BC5RGSnorm, "value mismatch for TextureFormat::BC5RGSnorm"); + static_assert(static_cast(TextureFormat::BC6HRGBUfloat) == WGPUTextureFormat_BC6HRGBUfloat, "value mismatch for TextureFormat::BC6HRGBUfloat"); + static_assert(static_cast(TextureFormat::BC6HRGBSfloat) == WGPUTextureFormat_BC6HRGBSfloat, "value mismatch for TextureFormat::BC6HRGBSfloat"); + static_assert(static_cast(TextureFormat::BC7RGBAUnorm) == WGPUTextureFormat_BC7RGBAUnorm, "value mismatch for TextureFormat::BC7RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC7RGBAUnormSrgb) == WGPUTextureFormat_BC7RGBAUnormSrgb, "value mismatch for TextureFormat::BC7RGBAUnormSrgb"); + + + static_assert(sizeof(TextureViewDimension) == sizeof(WGPUTextureViewDimension), "sizeof mismatch for TextureViewDimension"); + static_assert(alignof(TextureViewDimension) == alignof(WGPUTextureViewDimension), "alignof mismatch for TextureViewDimension"); + + static_assert(static_cast(TextureViewDimension::Undefined) == WGPUTextureViewDimension_Undefined, "value mismatch for TextureViewDimension::Undefined"); + static_assert(static_cast(TextureViewDimension::e1D) == WGPUTextureViewDimension_1D, "value mismatch for TextureViewDimension::e1D"); + static_assert(static_cast(TextureViewDimension::e2D) == WGPUTextureViewDimension_2D, "value mismatch for TextureViewDimension::e2D"); + static_assert(static_cast(TextureViewDimension::e2DArray) == WGPUTextureViewDimension_2DArray, "value mismatch for TextureViewDimension::e2DArray"); + static_assert(static_cast(TextureViewDimension::Cube) == WGPUTextureViewDimension_Cube, "value mismatch for TextureViewDimension::Cube"); + static_assert(static_cast(TextureViewDimension::CubeArray) == WGPUTextureViewDimension_CubeArray, "value mismatch for TextureViewDimension::CubeArray"); + static_assert(static_cast(TextureViewDimension::e3D) == WGPUTextureViewDimension_3D, "value mismatch for TextureViewDimension::e3D"); + + + static_assert(sizeof(VertexFormat) == sizeof(WGPUVertexFormat), "sizeof mismatch for VertexFormat"); + static_assert(alignof(VertexFormat) == alignof(WGPUVertexFormat), "alignof mismatch for VertexFormat"); + + static_assert(static_cast(VertexFormat::UChar2) == WGPUVertexFormat_UChar2, "value mismatch for VertexFormat::UChar2"); + static_assert(static_cast(VertexFormat::UChar4) == WGPUVertexFormat_UChar4, "value mismatch for VertexFormat::UChar4"); + static_assert(static_cast(VertexFormat::Char2) == WGPUVertexFormat_Char2, "value mismatch for VertexFormat::Char2"); + static_assert(static_cast(VertexFormat::Char4) == WGPUVertexFormat_Char4, "value mismatch for VertexFormat::Char4"); + static_assert(static_cast(VertexFormat::UChar2Norm) == WGPUVertexFormat_UChar2Norm, "value mismatch for VertexFormat::UChar2Norm"); + static_assert(static_cast(VertexFormat::UChar4Norm) == WGPUVertexFormat_UChar4Norm, "value mismatch for VertexFormat::UChar4Norm"); + static_assert(static_cast(VertexFormat::Char2Norm) == WGPUVertexFormat_Char2Norm, "value mismatch for VertexFormat::Char2Norm"); + static_assert(static_cast(VertexFormat::Char4Norm) == WGPUVertexFormat_Char4Norm, "value mismatch for VertexFormat::Char4Norm"); + static_assert(static_cast(VertexFormat::UShort2) == WGPUVertexFormat_UShort2, "value mismatch for VertexFormat::UShort2"); + static_assert(static_cast(VertexFormat::UShort4) == WGPUVertexFormat_UShort4, "value mismatch for VertexFormat::UShort4"); + static_assert(static_cast(VertexFormat::Short2) == WGPUVertexFormat_Short2, "value mismatch for VertexFormat::Short2"); + static_assert(static_cast(VertexFormat::Short4) == WGPUVertexFormat_Short4, "value mismatch for VertexFormat::Short4"); + static_assert(static_cast(VertexFormat::UShort2Norm) == WGPUVertexFormat_UShort2Norm, "value mismatch for VertexFormat::UShort2Norm"); + static_assert(static_cast(VertexFormat::UShort4Norm) == WGPUVertexFormat_UShort4Norm, "value mismatch for VertexFormat::UShort4Norm"); + static_assert(static_cast(VertexFormat::Short2Norm) == WGPUVertexFormat_Short2Norm, "value mismatch for VertexFormat::Short2Norm"); + static_assert(static_cast(VertexFormat::Short4Norm) == WGPUVertexFormat_Short4Norm, "value mismatch for VertexFormat::Short4Norm"); + static_assert(static_cast(VertexFormat::Half2) == WGPUVertexFormat_Half2, "value mismatch for VertexFormat::Half2"); + static_assert(static_cast(VertexFormat::Half4) == WGPUVertexFormat_Half4, "value mismatch for VertexFormat::Half4"); + static_assert(static_cast(VertexFormat::Float) == WGPUVertexFormat_Float, "value mismatch for VertexFormat::Float"); + static_assert(static_cast(VertexFormat::Float2) == WGPUVertexFormat_Float2, "value mismatch for VertexFormat::Float2"); + static_assert(static_cast(VertexFormat::Float3) == WGPUVertexFormat_Float3, "value mismatch for VertexFormat::Float3"); + static_assert(static_cast(VertexFormat::Float4) == WGPUVertexFormat_Float4, "value mismatch for VertexFormat::Float4"); + static_assert(static_cast(VertexFormat::UInt) == WGPUVertexFormat_UInt, "value mismatch for VertexFormat::UInt"); + static_assert(static_cast(VertexFormat::UInt2) == WGPUVertexFormat_UInt2, "value mismatch for VertexFormat::UInt2"); + static_assert(static_cast(VertexFormat::UInt3) == WGPUVertexFormat_UInt3, "value mismatch for VertexFormat::UInt3"); + static_assert(static_cast(VertexFormat::UInt4) == WGPUVertexFormat_UInt4, "value mismatch for VertexFormat::UInt4"); + static_assert(static_cast(VertexFormat::Int) == WGPUVertexFormat_Int, "value mismatch for VertexFormat::Int"); + static_assert(static_cast(VertexFormat::Int2) == WGPUVertexFormat_Int2, "value mismatch for VertexFormat::Int2"); + static_assert(static_cast(VertexFormat::Int3) == WGPUVertexFormat_Int3, "value mismatch for VertexFormat::Int3"); + static_assert(static_cast(VertexFormat::Int4) == WGPUVertexFormat_Int4, "value mismatch for VertexFormat::Int4"); + + + + static_assert(sizeof(BufferUsage) == sizeof(WGPUBufferUsageFlags), "sizeof mismatch for BufferUsage"); + static_assert(alignof(BufferUsage) == alignof(WGPUBufferUsageFlags), "alignof mismatch for BufferUsage"); + + static_assert(static_cast(BufferUsage::None) == WGPUBufferUsage_None, "value mismatch for BufferUsage::None"); + static_assert(static_cast(BufferUsage::MapRead) == WGPUBufferUsage_MapRead, "value mismatch for BufferUsage::MapRead"); + static_assert(static_cast(BufferUsage::MapWrite) == WGPUBufferUsage_MapWrite, "value mismatch for BufferUsage::MapWrite"); + static_assert(static_cast(BufferUsage::CopySrc) == WGPUBufferUsage_CopySrc, "value mismatch for BufferUsage::CopySrc"); + static_assert(static_cast(BufferUsage::CopyDst) == WGPUBufferUsage_CopyDst, "value mismatch for BufferUsage::CopyDst"); + static_assert(static_cast(BufferUsage::Index) == WGPUBufferUsage_Index, "value mismatch for BufferUsage::Index"); + static_assert(static_cast(BufferUsage::Vertex) == WGPUBufferUsage_Vertex, "value mismatch for BufferUsage::Vertex"); + static_assert(static_cast(BufferUsage::Uniform) == WGPUBufferUsage_Uniform, "value mismatch for BufferUsage::Uniform"); + static_assert(static_cast(BufferUsage::Storage) == WGPUBufferUsage_Storage, "value mismatch for BufferUsage::Storage"); + static_assert(static_cast(BufferUsage::Indirect) == WGPUBufferUsage_Indirect, "value mismatch for BufferUsage::Indirect"); + + + static_assert(sizeof(ColorWriteMask) == sizeof(WGPUColorWriteMaskFlags), "sizeof mismatch for ColorWriteMask"); + static_assert(alignof(ColorWriteMask) == alignof(WGPUColorWriteMaskFlags), "alignof mismatch for ColorWriteMask"); + + static_assert(static_cast(ColorWriteMask::None) == WGPUColorWriteMask_None, "value mismatch for ColorWriteMask::None"); + static_assert(static_cast(ColorWriteMask::Red) == WGPUColorWriteMask_Red, "value mismatch for ColorWriteMask::Red"); + static_assert(static_cast(ColorWriteMask::Green) == WGPUColorWriteMask_Green, "value mismatch for ColorWriteMask::Green"); + static_assert(static_cast(ColorWriteMask::Blue) == WGPUColorWriteMask_Blue, "value mismatch for ColorWriteMask::Blue"); + static_assert(static_cast(ColorWriteMask::Alpha) == WGPUColorWriteMask_Alpha, "value mismatch for ColorWriteMask::Alpha"); + static_assert(static_cast(ColorWriteMask::All) == WGPUColorWriteMask_All, "value mismatch for ColorWriteMask::All"); + + + static_assert(sizeof(ShaderStage) == sizeof(WGPUShaderStageFlags), "sizeof mismatch for ShaderStage"); + static_assert(alignof(ShaderStage) == alignof(WGPUShaderStageFlags), "alignof mismatch for ShaderStage"); + + static_assert(static_cast(ShaderStage::None) == WGPUShaderStage_None, "value mismatch for ShaderStage::None"); + static_assert(static_cast(ShaderStage::Vertex) == WGPUShaderStage_Vertex, "value mismatch for ShaderStage::Vertex"); + static_assert(static_cast(ShaderStage::Fragment) == WGPUShaderStage_Fragment, "value mismatch for ShaderStage::Fragment"); + static_assert(static_cast(ShaderStage::Compute) == WGPUShaderStage_Compute, "value mismatch for ShaderStage::Compute"); + + + static_assert(sizeof(TextureUsage) == sizeof(WGPUTextureUsageFlags), "sizeof mismatch for TextureUsage"); + static_assert(alignof(TextureUsage) == alignof(WGPUTextureUsageFlags), "alignof mismatch for TextureUsage"); + + static_assert(static_cast(TextureUsage::None) == WGPUTextureUsage_None, "value mismatch for TextureUsage::None"); + static_assert(static_cast(TextureUsage::CopySrc) == WGPUTextureUsage_CopySrc, "value mismatch for TextureUsage::CopySrc"); + static_assert(static_cast(TextureUsage::CopyDst) == WGPUTextureUsage_CopyDst, "value mismatch for TextureUsage::CopyDst"); + static_assert(static_cast(TextureUsage::Sampled) == WGPUTextureUsage_Sampled, "value mismatch for TextureUsage::Sampled"); + static_assert(static_cast(TextureUsage::Storage) == WGPUTextureUsage_Storage, "value mismatch for TextureUsage::Storage"); + static_assert(static_cast(TextureUsage::OutputAttachment) == WGPUTextureUsage_OutputAttachment, "value mismatch for TextureUsage::OutputAttachment"); + static_assert(static_cast(TextureUsage::Present) == WGPUTextureUsage_Present, "value mismatch for TextureUsage::Present"); + + + static_assert(sizeof(ChainedStruct) == sizeof(WGPUChainedStruct), + "sizeof mismatch for ChainedStruct"); + static_assert(alignof(ChainedStruct) == alignof(WGPUChainedStruct), + "alignof mismatch for ChainedStruct"); + static_assert(offsetof(ChainedStruct, nextInChain) == offsetof(WGPUChainedStruct, next), + "offsetof mismatch for ChainedStruct::nextInChain"); + static_assert(offsetof(ChainedStruct, sType) == offsetof(WGPUChainedStruct, sType), + "offsetof mismatch for ChainedStruct::sType"); + + + static_assert(sizeof(AdapterProperties) == sizeof(WGPUAdapterProperties), "sizeof mismatch for AdapterProperties"); + static_assert(alignof(AdapterProperties) == alignof(WGPUAdapterProperties), "alignof mismatch for AdapterProperties"); + + static_assert(offsetof(AdapterProperties, nextInChain) == offsetof(WGPUAdapterProperties, nextInChain), + "offsetof mismatch for AdapterProperties::nextInChain"); + static_assert(offsetof(AdapterProperties, deviceID) == offsetof(WGPUAdapterProperties, deviceID), + "offsetof mismatch for AdapterProperties::deviceID"); + static_assert(offsetof(AdapterProperties, vendorID) == offsetof(WGPUAdapterProperties, vendorID), + "offsetof mismatch for AdapterProperties::vendorID"); + static_assert(offsetof(AdapterProperties, name) == offsetof(WGPUAdapterProperties, name), + "offsetof mismatch for AdapterProperties::name"); + static_assert(offsetof(AdapterProperties, adapterType) == offsetof(WGPUAdapterProperties, adapterType), + "offsetof mismatch for AdapterProperties::adapterType"); + static_assert(offsetof(AdapterProperties, backendType) == offsetof(WGPUAdapterProperties, backendType), + "offsetof mismatch for AdapterProperties::backendType"); + + + static_assert(sizeof(BindGroupEntry) == sizeof(WGPUBindGroupEntry), "sizeof mismatch for BindGroupEntry"); + static_assert(alignof(BindGroupEntry) == alignof(WGPUBindGroupEntry), "alignof mismatch for BindGroupEntry"); + + static_assert(offsetof(BindGroupEntry, binding) == offsetof(WGPUBindGroupEntry, binding), + "offsetof mismatch for BindGroupEntry::binding"); + static_assert(offsetof(BindGroupEntry, buffer) == offsetof(WGPUBindGroupEntry, buffer), + "offsetof mismatch for BindGroupEntry::buffer"); + static_assert(offsetof(BindGroupEntry, offset) == offsetof(WGPUBindGroupEntry, offset), + "offsetof mismatch for BindGroupEntry::offset"); + static_assert(offsetof(BindGroupEntry, size) == offsetof(WGPUBindGroupEntry, size), + "offsetof mismatch for BindGroupEntry::size"); + static_assert(offsetof(BindGroupEntry, sampler) == offsetof(WGPUBindGroupEntry, sampler), + "offsetof mismatch for BindGroupEntry::sampler"); + static_assert(offsetof(BindGroupEntry, textureView) == offsetof(WGPUBindGroupEntry, textureView), + "offsetof mismatch for BindGroupEntry::textureView"); + + + static_assert(sizeof(BindGroupLayoutEntry) == sizeof(WGPUBindGroupLayoutEntry), "sizeof mismatch for BindGroupLayoutEntry"); + static_assert(alignof(BindGroupLayoutEntry) == alignof(WGPUBindGroupLayoutEntry), "alignof mismatch for BindGroupLayoutEntry"); + + static_assert(offsetof(BindGroupLayoutEntry, binding) == offsetof(WGPUBindGroupLayoutEntry, binding), + "offsetof mismatch for BindGroupLayoutEntry::binding"); + static_assert(offsetof(BindGroupLayoutEntry, visibility) == offsetof(WGPUBindGroupLayoutEntry, visibility), + "offsetof mismatch for BindGroupLayoutEntry::visibility"); + static_assert(offsetof(BindGroupLayoutEntry, type) == offsetof(WGPUBindGroupLayoutEntry, type), + "offsetof mismatch for BindGroupLayoutEntry::type"); + static_assert(offsetof(BindGroupLayoutEntry, hasDynamicOffset) == offsetof(WGPUBindGroupLayoutEntry, hasDynamicOffset), + "offsetof mismatch for BindGroupLayoutEntry::hasDynamicOffset"); + static_assert(offsetof(BindGroupLayoutEntry, multisampled) == offsetof(WGPUBindGroupLayoutEntry, multisampled), + "offsetof mismatch for BindGroupLayoutEntry::multisampled"); + static_assert(offsetof(BindGroupLayoutEntry, viewDimension) == offsetof(WGPUBindGroupLayoutEntry, viewDimension), + "offsetof mismatch for BindGroupLayoutEntry::viewDimension"); + static_assert(offsetof(BindGroupLayoutEntry, textureComponentType) == offsetof(WGPUBindGroupLayoutEntry, textureComponentType), + "offsetof mismatch for BindGroupLayoutEntry::textureComponentType"); + static_assert(offsetof(BindGroupLayoutEntry, storageTextureFormat) == offsetof(WGPUBindGroupLayoutEntry, storageTextureFormat), + "offsetof mismatch for BindGroupLayoutEntry::storageTextureFormat"); + + + static_assert(sizeof(BlendDescriptor) == sizeof(WGPUBlendDescriptor), "sizeof mismatch for BlendDescriptor"); + static_assert(alignof(BlendDescriptor) == alignof(WGPUBlendDescriptor), "alignof mismatch for BlendDescriptor"); + + static_assert(offsetof(BlendDescriptor, operation) == offsetof(WGPUBlendDescriptor, operation), + "offsetof mismatch for BlendDescriptor::operation"); + static_assert(offsetof(BlendDescriptor, srcFactor) == offsetof(WGPUBlendDescriptor, srcFactor), + "offsetof mismatch for BlendDescriptor::srcFactor"); + static_assert(offsetof(BlendDescriptor, dstFactor) == offsetof(WGPUBlendDescriptor, dstFactor), + "offsetof mismatch for BlendDescriptor::dstFactor"); + + + static_assert(sizeof(BufferCopyView) == sizeof(WGPUBufferCopyView), "sizeof mismatch for BufferCopyView"); + static_assert(alignof(BufferCopyView) == alignof(WGPUBufferCopyView), "alignof mismatch for BufferCopyView"); + + static_assert(offsetof(BufferCopyView, nextInChain) == offsetof(WGPUBufferCopyView, nextInChain), + "offsetof mismatch for BufferCopyView::nextInChain"); + static_assert(offsetof(BufferCopyView, buffer) == offsetof(WGPUBufferCopyView, buffer), + "offsetof mismatch for BufferCopyView::buffer"); + static_assert(offsetof(BufferCopyView, offset) == offsetof(WGPUBufferCopyView, offset), + "offsetof mismatch for BufferCopyView::offset"); + static_assert(offsetof(BufferCopyView, bytesPerRow) == offsetof(WGPUBufferCopyView, bytesPerRow), + "offsetof mismatch for BufferCopyView::bytesPerRow"); + static_assert(offsetof(BufferCopyView, rowsPerImage) == offsetof(WGPUBufferCopyView, rowsPerImage), + "offsetof mismatch for BufferCopyView::rowsPerImage"); + + + static_assert(sizeof(BufferDescriptor) == sizeof(WGPUBufferDescriptor), "sizeof mismatch for BufferDescriptor"); + static_assert(alignof(BufferDescriptor) == alignof(WGPUBufferDescriptor), "alignof mismatch for BufferDescriptor"); + + static_assert(offsetof(BufferDescriptor, nextInChain) == offsetof(WGPUBufferDescriptor, nextInChain), + "offsetof mismatch for BufferDescriptor::nextInChain"); + static_assert(offsetof(BufferDescriptor, label) == offsetof(WGPUBufferDescriptor, label), + "offsetof mismatch for BufferDescriptor::label"); + static_assert(offsetof(BufferDescriptor, usage) == offsetof(WGPUBufferDescriptor, usage), + "offsetof mismatch for BufferDescriptor::usage"); + static_assert(offsetof(BufferDescriptor, size) == offsetof(WGPUBufferDescriptor, size), + "offsetof mismatch for BufferDescriptor::size"); + + + static_assert(sizeof(Color) == sizeof(WGPUColor), "sizeof mismatch for Color"); + static_assert(alignof(Color) == alignof(WGPUColor), "alignof mismatch for Color"); + + static_assert(offsetof(Color, r) == offsetof(WGPUColor, r), + "offsetof mismatch for Color::r"); + static_assert(offsetof(Color, g) == offsetof(WGPUColor, g), + "offsetof mismatch for Color::g"); + static_assert(offsetof(Color, b) == offsetof(WGPUColor, b), + "offsetof mismatch for Color::b"); + static_assert(offsetof(Color, a) == offsetof(WGPUColor, a), + "offsetof mismatch for Color::a"); + + + static_assert(sizeof(CommandBufferDescriptor) == sizeof(WGPUCommandBufferDescriptor), "sizeof mismatch for CommandBufferDescriptor"); + static_assert(alignof(CommandBufferDescriptor) == alignof(WGPUCommandBufferDescriptor), "alignof mismatch for CommandBufferDescriptor"); + + static_assert(offsetof(CommandBufferDescriptor, nextInChain) == offsetof(WGPUCommandBufferDescriptor, nextInChain), + "offsetof mismatch for CommandBufferDescriptor::nextInChain"); + static_assert(offsetof(CommandBufferDescriptor, label) == offsetof(WGPUCommandBufferDescriptor, label), + "offsetof mismatch for CommandBufferDescriptor::label"); + + + static_assert(sizeof(CommandEncoderDescriptor) == sizeof(WGPUCommandEncoderDescriptor), "sizeof mismatch for CommandEncoderDescriptor"); + static_assert(alignof(CommandEncoderDescriptor) == alignof(WGPUCommandEncoderDescriptor), "alignof mismatch for CommandEncoderDescriptor"); + + static_assert(offsetof(CommandEncoderDescriptor, nextInChain) == offsetof(WGPUCommandEncoderDescriptor, nextInChain), + "offsetof mismatch for CommandEncoderDescriptor::nextInChain"); + static_assert(offsetof(CommandEncoderDescriptor, label) == offsetof(WGPUCommandEncoderDescriptor, label), + "offsetof mismatch for CommandEncoderDescriptor::label"); + + + static_assert(sizeof(ComputePassDescriptor) == sizeof(WGPUComputePassDescriptor), "sizeof mismatch for ComputePassDescriptor"); + static_assert(alignof(ComputePassDescriptor) == alignof(WGPUComputePassDescriptor), "alignof mismatch for ComputePassDescriptor"); + + static_assert(offsetof(ComputePassDescriptor, nextInChain) == offsetof(WGPUComputePassDescriptor, nextInChain), + "offsetof mismatch for ComputePassDescriptor::nextInChain"); + static_assert(offsetof(ComputePassDescriptor, label) == offsetof(WGPUComputePassDescriptor, label), + "offsetof mismatch for ComputePassDescriptor::label"); + + + static_assert(sizeof(CreateBufferMappedResult) == sizeof(WGPUCreateBufferMappedResult), "sizeof mismatch for CreateBufferMappedResult"); + static_assert(alignof(CreateBufferMappedResult) == alignof(WGPUCreateBufferMappedResult), "alignof mismatch for CreateBufferMappedResult"); + + static_assert(offsetof(CreateBufferMappedResult, buffer) == offsetof(WGPUCreateBufferMappedResult, buffer), + "offsetof mismatch for CreateBufferMappedResult::buffer"); + static_assert(offsetof(CreateBufferMappedResult, dataLength) == offsetof(WGPUCreateBufferMappedResult, dataLength), + "offsetof mismatch for CreateBufferMappedResult::dataLength"); + static_assert(offsetof(CreateBufferMappedResult, data) == offsetof(WGPUCreateBufferMappedResult, data), + "offsetof mismatch for CreateBufferMappedResult::data"); + + + static_assert(sizeof(DeviceProperties) == sizeof(WGPUDeviceProperties), "sizeof mismatch for DeviceProperties"); + static_assert(alignof(DeviceProperties) == alignof(WGPUDeviceProperties), "alignof mismatch for DeviceProperties"); + + static_assert(offsetof(DeviceProperties, textureCompressionBC) == offsetof(WGPUDeviceProperties, textureCompressionBC), + "offsetof mismatch for DeviceProperties::textureCompressionBC"); + static_assert(offsetof(DeviceProperties, shaderFloat16) == offsetof(WGPUDeviceProperties, shaderFloat16), + "offsetof mismatch for DeviceProperties::shaderFloat16"); + static_assert(offsetof(DeviceProperties, pipelineStatisticsQuery) == offsetof(WGPUDeviceProperties, pipelineStatisticsQuery), + "offsetof mismatch for DeviceProperties::pipelineStatisticsQuery"); + static_assert(offsetof(DeviceProperties, timestampQuery) == offsetof(WGPUDeviceProperties, timestampQuery), + "offsetof mismatch for DeviceProperties::timestampQuery"); + + + static_assert(sizeof(Extent3D) == sizeof(WGPUExtent3D), "sizeof mismatch for Extent3D"); + static_assert(alignof(Extent3D) == alignof(WGPUExtent3D), "alignof mismatch for Extent3D"); + + static_assert(offsetof(Extent3D, width) == offsetof(WGPUExtent3D, width), + "offsetof mismatch for Extent3D::width"); + static_assert(offsetof(Extent3D, height) == offsetof(WGPUExtent3D, height), + "offsetof mismatch for Extent3D::height"); + static_assert(offsetof(Extent3D, depth) == offsetof(WGPUExtent3D, depth), + "offsetof mismatch for Extent3D::depth"); + + + static_assert(sizeof(FenceDescriptor) == sizeof(WGPUFenceDescriptor), "sizeof mismatch for FenceDescriptor"); + static_assert(alignof(FenceDescriptor) == alignof(WGPUFenceDescriptor), "alignof mismatch for FenceDescriptor"); + + static_assert(offsetof(FenceDescriptor, nextInChain) == offsetof(WGPUFenceDescriptor, nextInChain), + "offsetof mismatch for FenceDescriptor::nextInChain"); + static_assert(offsetof(FenceDescriptor, label) == offsetof(WGPUFenceDescriptor, label), + "offsetof mismatch for FenceDescriptor::label"); + static_assert(offsetof(FenceDescriptor, initialValue) == offsetof(WGPUFenceDescriptor, initialValue), + "offsetof mismatch for FenceDescriptor::initialValue"); + + + static_assert(sizeof(InstanceDescriptor) == sizeof(WGPUInstanceDescriptor), "sizeof mismatch for InstanceDescriptor"); + static_assert(alignof(InstanceDescriptor) == alignof(WGPUInstanceDescriptor), "alignof mismatch for InstanceDescriptor"); + + static_assert(offsetof(InstanceDescriptor, nextInChain) == offsetof(WGPUInstanceDescriptor, nextInChain), + "offsetof mismatch for InstanceDescriptor::nextInChain"); + + + static_assert(sizeof(Origin3D) == sizeof(WGPUOrigin3D), "sizeof mismatch for Origin3D"); + static_assert(alignof(Origin3D) == alignof(WGPUOrigin3D), "alignof mismatch for Origin3D"); + + static_assert(offsetof(Origin3D, x) == offsetof(WGPUOrigin3D, x), + "offsetof mismatch for Origin3D::x"); + static_assert(offsetof(Origin3D, y) == offsetof(WGPUOrigin3D, y), + "offsetof mismatch for Origin3D::y"); + static_assert(offsetof(Origin3D, z) == offsetof(WGPUOrigin3D, z), + "offsetof mismatch for Origin3D::z"); + + + static_assert(sizeof(PipelineLayoutDescriptor) == sizeof(WGPUPipelineLayoutDescriptor), "sizeof mismatch for PipelineLayoutDescriptor"); + static_assert(alignof(PipelineLayoutDescriptor) == alignof(WGPUPipelineLayoutDescriptor), "alignof mismatch for PipelineLayoutDescriptor"); + + static_assert(offsetof(PipelineLayoutDescriptor, nextInChain) == offsetof(WGPUPipelineLayoutDescriptor, nextInChain), + "offsetof mismatch for PipelineLayoutDescriptor::nextInChain"); + static_assert(offsetof(PipelineLayoutDescriptor, label) == offsetof(WGPUPipelineLayoutDescriptor, label), + "offsetof mismatch for PipelineLayoutDescriptor::label"); + static_assert(offsetof(PipelineLayoutDescriptor, bindGroupLayoutCount) == offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayoutCount), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayoutCount"); + static_assert(offsetof(PipelineLayoutDescriptor, bindGroupLayouts) == offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayouts), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayouts"); + + + static_assert(sizeof(ProgrammableStageDescriptor) == sizeof(WGPUProgrammableStageDescriptor), "sizeof mismatch for ProgrammableStageDescriptor"); + static_assert(alignof(ProgrammableStageDescriptor) == alignof(WGPUProgrammableStageDescriptor), "alignof mismatch for ProgrammableStageDescriptor"); + + static_assert(offsetof(ProgrammableStageDescriptor, nextInChain) == offsetof(WGPUProgrammableStageDescriptor, nextInChain), + "offsetof mismatch for ProgrammableStageDescriptor::nextInChain"); + static_assert(offsetof(ProgrammableStageDescriptor, module) == offsetof(WGPUProgrammableStageDescriptor, module), + "offsetof mismatch for ProgrammableStageDescriptor::module"); + static_assert(offsetof(ProgrammableStageDescriptor, entryPoint) == offsetof(WGPUProgrammableStageDescriptor, entryPoint), + "offsetof mismatch for ProgrammableStageDescriptor::entryPoint"); + + + static_assert(sizeof(RasterizationStateDescriptor) == sizeof(WGPURasterizationStateDescriptor), "sizeof mismatch for RasterizationStateDescriptor"); + static_assert(alignof(RasterizationStateDescriptor) == alignof(WGPURasterizationStateDescriptor), "alignof mismatch for RasterizationStateDescriptor"); + + static_assert(offsetof(RasterizationStateDescriptor, nextInChain) == offsetof(WGPURasterizationStateDescriptor, nextInChain), + "offsetof mismatch for RasterizationStateDescriptor::nextInChain"); + static_assert(offsetof(RasterizationStateDescriptor, frontFace) == offsetof(WGPURasterizationStateDescriptor, frontFace), + "offsetof mismatch for RasterizationStateDescriptor::frontFace"); + static_assert(offsetof(RasterizationStateDescriptor, cullMode) == offsetof(WGPURasterizationStateDescriptor, cullMode), + "offsetof mismatch for RasterizationStateDescriptor::cullMode"); + static_assert(offsetof(RasterizationStateDescriptor, depthBias) == offsetof(WGPURasterizationStateDescriptor, depthBias), + "offsetof mismatch for RasterizationStateDescriptor::depthBias"); + static_assert(offsetof(RasterizationStateDescriptor, depthBiasSlopeScale) == offsetof(WGPURasterizationStateDescriptor, depthBiasSlopeScale), + "offsetof mismatch for RasterizationStateDescriptor::depthBiasSlopeScale"); + static_assert(offsetof(RasterizationStateDescriptor, depthBiasClamp) == offsetof(WGPURasterizationStateDescriptor, depthBiasClamp), + "offsetof mismatch for RasterizationStateDescriptor::depthBiasClamp"); + + + static_assert(sizeof(RenderBundleDescriptor) == sizeof(WGPURenderBundleDescriptor), "sizeof mismatch for RenderBundleDescriptor"); + static_assert(alignof(RenderBundleDescriptor) == alignof(WGPURenderBundleDescriptor), "alignof mismatch for RenderBundleDescriptor"); + + static_assert(offsetof(RenderBundleDescriptor, nextInChain) == offsetof(WGPURenderBundleDescriptor, nextInChain), + "offsetof mismatch for RenderBundleDescriptor::nextInChain"); + static_assert(offsetof(RenderBundleDescriptor, label) == offsetof(WGPURenderBundleDescriptor, label), + "offsetof mismatch for RenderBundleDescriptor::label"); + + + static_assert(sizeof(RenderBundleEncoderDescriptor) == sizeof(WGPURenderBundleEncoderDescriptor), "sizeof mismatch for RenderBundleEncoderDescriptor"); + static_assert(alignof(RenderBundleEncoderDescriptor) == alignof(WGPURenderBundleEncoderDescriptor), "alignof mismatch for RenderBundleEncoderDescriptor"); + + static_assert(offsetof(RenderBundleEncoderDescriptor, nextInChain) == offsetof(WGPURenderBundleEncoderDescriptor, nextInChain), + "offsetof mismatch for RenderBundleEncoderDescriptor::nextInChain"); + static_assert(offsetof(RenderBundleEncoderDescriptor, label) == offsetof(WGPURenderBundleEncoderDescriptor, label), + "offsetof mismatch for RenderBundleEncoderDescriptor::label"); + static_assert(offsetof(RenderBundleEncoderDescriptor, colorFormatsCount) == offsetof(WGPURenderBundleEncoderDescriptor, colorFormatsCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormatsCount"); + static_assert(offsetof(RenderBundleEncoderDescriptor, colorFormats) == offsetof(WGPURenderBundleEncoderDescriptor, colorFormats), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormats"); + static_assert(offsetof(RenderBundleEncoderDescriptor, depthStencilFormat) == offsetof(WGPURenderBundleEncoderDescriptor, depthStencilFormat), + "offsetof mismatch for RenderBundleEncoderDescriptor::depthStencilFormat"); + static_assert(offsetof(RenderBundleEncoderDescriptor, sampleCount) == offsetof(WGPURenderBundleEncoderDescriptor, sampleCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::sampleCount"); + + + static_assert(sizeof(RenderPassDepthStencilAttachmentDescriptor) == sizeof(WGPURenderPassDepthStencilAttachmentDescriptor), "sizeof mismatch for RenderPassDepthStencilAttachmentDescriptor"); + static_assert(alignof(RenderPassDepthStencilAttachmentDescriptor) == alignof(WGPURenderPassDepthStencilAttachmentDescriptor), "alignof mismatch for RenderPassDepthStencilAttachmentDescriptor"); + + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, attachment) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, attachment), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::attachment"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, depthLoadOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, depthLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::depthLoadOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, depthStoreOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, depthStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::depthStoreOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, clearDepth) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, clearDepth), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::clearDepth"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, stencilLoadOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, stencilLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::stencilLoadOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, stencilStoreOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, stencilStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::stencilStoreOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, clearStencil) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, clearStencil), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::clearStencil"); + + + static_assert(sizeof(SamplerDescriptor) == sizeof(WGPUSamplerDescriptor), "sizeof mismatch for SamplerDescriptor"); + static_assert(alignof(SamplerDescriptor) == alignof(WGPUSamplerDescriptor), "alignof mismatch for SamplerDescriptor"); + + static_assert(offsetof(SamplerDescriptor, nextInChain) == offsetof(WGPUSamplerDescriptor, nextInChain), + "offsetof mismatch for SamplerDescriptor::nextInChain"); + static_assert(offsetof(SamplerDescriptor, label) == offsetof(WGPUSamplerDescriptor, label), + "offsetof mismatch for SamplerDescriptor::label"); + static_assert(offsetof(SamplerDescriptor, addressModeU) == offsetof(WGPUSamplerDescriptor, addressModeU), + "offsetof mismatch for SamplerDescriptor::addressModeU"); + static_assert(offsetof(SamplerDescriptor, addressModeV) == offsetof(WGPUSamplerDescriptor, addressModeV), + "offsetof mismatch for SamplerDescriptor::addressModeV"); + static_assert(offsetof(SamplerDescriptor, addressModeW) == offsetof(WGPUSamplerDescriptor, addressModeW), + "offsetof mismatch for SamplerDescriptor::addressModeW"); + static_assert(offsetof(SamplerDescriptor, magFilter) == offsetof(WGPUSamplerDescriptor, magFilter), + "offsetof mismatch for SamplerDescriptor::magFilter"); + static_assert(offsetof(SamplerDescriptor, minFilter) == offsetof(WGPUSamplerDescriptor, minFilter), + "offsetof mismatch for SamplerDescriptor::minFilter"); + static_assert(offsetof(SamplerDescriptor, mipmapFilter) == offsetof(WGPUSamplerDescriptor, mipmapFilter), + "offsetof mismatch for SamplerDescriptor::mipmapFilter"); + static_assert(offsetof(SamplerDescriptor, lodMinClamp) == offsetof(WGPUSamplerDescriptor, lodMinClamp), + "offsetof mismatch for SamplerDescriptor::lodMinClamp"); + static_assert(offsetof(SamplerDescriptor, lodMaxClamp) == offsetof(WGPUSamplerDescriptor, lodMaxClamp), + "offsetof mismatch for SamplerDescriptor::lodMaxClamp"); + static_assert(offsetof(SamplerDescriptor, compare) == offsetof(WGPUSamplerDescriptor, compare), + "offsetof mismatch for SamplerDescriptor::compare"); + + + static_assert(sizeof(SamplerDescriptorDummyAnisotropicFiltering) == sizeof(WGPUSamplerDescriptorDummyAnisotropicFiltering), "sizeof mismatch for SamplerDescriptorDummyAnisotropicFiltering"); + static_assert(alignof(SamplerDescriptorDummyAnisotropicFiltering) == alignof(WGPUSamplerDescriptorDummyAnisotropicFiltering), "alignof mismatch for SamplerDescriptorDummyAnisotropicFiltering"); + + static_assert(offsetof(SamplerDescriptorDummyAnisotropicFiltering, maxAnisotropy) == offsetof(WGPUSamplerDescriptorDummyAnisotropicFiltering, maxAnisotropy), + "offsetof mismatch for SamplerDescriptorDummyAnisotropicFiltering::maxAnisotropy"); + + + static_assert(sizeof(ShaderModuleDescriptor) == sizeof(WGPUShaderModuleDescriptor), "sizeof mismatch for ShaderModuleDescriptor"); + static_assert(alignof(ShaderModuleDescriptor) == alignof(WGPUShaderModuleDescriptor), "alignof mismatch for ShaderModuleDescriptor"); + + static_assert(offsetof(ShaderModuleDescriptor, nextInChain) == offsetof(WGPUShaderModuleDescriptor, nextInChain), + "offsetof mismatch for ShaderModuleDescriptor::nextInChain"); + static_assert(offsetof(ShaderModuleDescriptor, label) == offsetof(WGPUShaderModuleDescriptor, label), + "offsetof mismatch for ShaderModuleDescriptor::label"); + + + static_assert(sizeof(ShaderModuleSPIRVDescriptor) == sizeof(WGPUShaderModuleSPIRVDescriptor), "sizeof mismatch for ShaderModuleSPIRVDescriptor"); + static_assert(alignof(ShaderModuleSPIRVDescriptor) == alignof(WGPUShaderModuleSPIRVDescriptor), "alignof mismatch for ShaderModuleSPIRVDescriptor"); + + static_assert(offsetof(ShaderModuleSPIRVDescriptor, codeSize) == offsetof(WGPUShaderModuleSPIRVDescriptor, codeSize), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::codeSize"); + static_assert(offsetof(ShaderModuleSPIRVDescriptor, code) == offsetof(WGPUShaderModuleSPIRVDescriptor, code), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::code"); + + + static_assert(sizeof(ShaderModuleWGSLDescriptor) == sizeof(WGPUShaderModuleWGSLDescriptor), "sizeof mismatch for ShaderModuleWGSLDescriptor"); + static_assert(alignof(ShaderModuleWGSLDescriptor) == alignof(WGPUShaderModuleWGSLDescriptor), "alignof mismatch for ShaderModuleWGSLDescriptor"); + + static_assert(offsetof(ShaderModuleWGSLDescriptor, source) == offsetof(WGPUShaderModuleWGSLDescriptor, source), + "offsetof mismatch for ShaderModuleWGSLDescriptor::source"); + + + static_assert(sizeof(StencilStateFaceDescriptor) == sizeof(WGPUStencilStateFaceDescriptor), "sizeof mismatch for StencilStateFaceDescriptor"); + static_assert(alignof(StencilStateFaceDescriptor) == alignof(WGPUStencilStateFaceDescriptor), "alignof mismatch for StencilStateFaceDescriptor"); + + static_assert(offsetof(StencilStateFaceDescriptor, compare) == offsetof(WGPUStencilStateFaceDescriptor, compare), + "offsetof mismatch for StencilStateFaceDescriptor::compare"); + static_assert(offsetof(StencilStateFaceDescriptor, failOp) == offsetof(WGPUStencilStateFaceDescriptor, failOp), + "offsetof mismatch for StencilStateFaceDescriptor::failOp"); + static_assert(offsetof(StencilStateFaceDescriptor, depthFailOp) == offsetof(WGPUStencilStateFaceDescriptor, depthFailOp), + "offsetof mismatch for StencilStateFaceDescriptor::depthFailOp"); + static_assert(offsetof(StencilStateFaceDescriptor, passOp) == offsetof(WGPUStencilStateFaceDescriptor, passOp), + "offsetof mismatch for StencilStateFaceDescriptor::passOp"); + + + static_assert(sizeof(SurfaceDescriptor) == sizeof(WGPUSurfaceDescriptor), "sizeof mismatch for SurfaceDescriptor"); + static_assert(alignof(SurfaceDescriptor) == alignof(WGPUSurfaceDescriptor), "alignof mismatch for SurfaceDescriptor"); + + static_assert(offsetof(SurfaceDescriptor, nextInChain) == offsetof(WGPUSurfaceDescriptor, nextInChain), + "offsetof mismatch for SurfaceDescriptor::nextInChain"); + static_assert(offsetof(SurfaceDescriptor, label) == offsetof(WGPUSurfaceDescriptor, label), + "offsetof mismatch for SurfaceDescriptor::label"); + + + static_assert(sizeof(SurfaceDescriptorFromHTMLCanvasId) == sizeof(WGPUSurfaceDescriptorFromHTMLCanvasId), "sizeof mismatch for SurfaceDescriptorFromHTMLCanvasId"); + static_assert(alignof(SurfaceDescriptorFromHTMLCanvasId) == alignof(WGPUSurfaceDescriptorFromHTMLCanvasId), "alignof mismatch for SurfaceDescriptorFromHTMLCanvasId"); + + static_assert(offsetof(SurfaceDescriptorFromHTMLCanvasId, id) == offsetof(WGPUSurfaceDescriptorFromHTMLCanvasId, id), + "offsetof mismatch for SurfaceDescriptorFromHTMLCanvasId::id"); + + + static_assert(sizeof(SurfaceDescriptorFromMetalLayer) == sizeof(WGPUSurfaceDescriptorFromMetalLayer), "sizeof mismatch for SurfaceDescriptorFromMetalLayer"); + static_assert(alignof(SurfaceDescriptorFromMetalLayer) == alignof(WGPUSurfaceDescriptorFromMetalLayer), "alignof mismatch for SurfaceDescriptorFromMetalLayer"); + + static_assert(offsetof(SurfaceDescriptorFromMetalLayer, layer) == offsetof(WGPUSurfaceDescriptorFromMetalLayer, layer), + "offsetof mismatch for SurfaceDescriptorFromMetalLayer::layer"); + + + static_assert(sizeof(SurfaceDescriptorFromWindowsHWND) == sizeof(WGPUSurfaceDescriptorFromWindowsHWND), "sizeof mismatch for SurfaceDescriptorFromWindowsHWND"); + static_assert(alignof(SurfaceDescriptorFromWindowsHWND) == alignof(WGPUSurfaceDescriptorFromWindowsHWND), "alignof mismatch for SurfaceDescriptorFromWindowsHWND"); + + static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hinstance) == offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hinstance), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hinstance"); + static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hwnd) == offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hwnd), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hwnd"); + + + static_assert(sizeof(SurfaceDescriptorFromXlib) == sizeof(WGPUSurfaceDescriptorFromXlib), "sizeof mismatch for SurfaceDescriptorFromXlib"); + static_assert(alignof(SurfaceDescriptorFromXlib) == alignof(WGPUSurfaceDescriptorFromXlib), "alignof mismatch for SurfaceDescriptorFromXlib"); + + static_assert(offsetof(SurfaceDescriptorFromXlib, display) == offsetof(WGPUSurfaceDescriptorFromXlib, display), + "offsetof mismatch for SurfaceDescriptorFromXlib::display"); + static_assert(offsetof(SurfaceDescriptorFromXlib, window) == offsetof(WGPUSurfaceDescriptorFromXlib, window), + "offsetof mismatch for SurfaceDescriptorFromXlib::window"); + + + static_assert(sizeof(SwapChainDescriptor) == sizeof(WGPUSwapChainDescriptor), "sizeof mismatch for SwapChainDescriptor"); + static_assert(alignof(SwapChainDescriptor) == alignof(WGPUSwapChainDescriptor), "alignof mismatch for SwapChainDescriptor"); + + static_assert(offsetof(SwapChainDescriptor, nextInChain) == offsetof(WGPUSwapChainDescriptor, nextInChain), + "offsetof mismatch for SwapChainDescriptor::nextInChain"); + static_assert(offsetof(SwapChainDescriptor, label) == offsetof(WGPUSwapChainDescriptor, label), + "offsetof mismatch for SwapChainDescriptor::label"); + static_assert(offsetof(SwapChainDescriptor, usage) == offsetof(WGPUSwapChainDescriptor, usage), + "offsetof mismatch for SwapChainDescriptor::usage"); + static_assert(offsetof(SwapChainDescriptor, format) == offsetof(WGPUSwapChainDescriptor, format), + "offsetof mismatch for SwapChainDescriptor::format"); + static_assert(offsetof(SwapChainDescriptor, width) == offsetof(WGPUSwapChainDescriptor, width), + "offsetof mismatch for SwapChainDescriptor::width"); + static_assert(offsetof(SwapChainDescriptor, height) == offsetof(WGPUSwapChainDescriptor, height), + "offsetof mismatch for SwapChainDescriptor::height"); + static_assert(offsetof(SwapChainDescriptor, presentMode) == offsetof(WGPUSwapChainDescriptor, presentMode), + "offsetof mismatch for SwapChainDescriptor::presentMode"); + static_assert(offsetof(SwapChainDescriptor, implementation) == offsetof(WGPUSwapChainDescriptor, implementation), + "offsetof mismatch for SwapChainDescriptor::implementation"); + + + static_assert(sizeof(TextureViewDescriptor) == sizeof(WGPUTextureViewDescriptor), "sizeof mismatch for TextureViewDescriptor"); + static_assert(alignof(TextureViewDescriptor) == alignof(WGPUTextureViewDescriptor), "alignof mismatch for TextureViewDescriptor"); + + static_assert(offsetof(TextureViewDescriptor, nextInChain) == offsetof(WGPUTextureViewDescriptor, nextInChain), + "offsetof mismatch for TextureViewDescriptor::nextInChain"); + static_assert(offsetof(TextureViewDescriptor, label) == offsetof(WGPUTextureViewDescriptor, label), + "offsetof mismatch for TextureViewDescriptor::label"); + static_assert(offsetof(TextureViewDescriptor, format) == offsetof(WGPUTextureViewDescriptor, format), + "offsetof mismatch for TextureViewDescriptor::format"); + static_assert(offsetof(TextureViewDescriptor, dimension) == offsetof(WGPUTextureViewDescriptor, dimension), + "offsetof mismatch for TextureViewDescriptor::dimension"); + static_assert(offsetof(TextureViewDescriptor, baseMipLevel) == offsetof(WGPUTextureViewDescriptor, baseMipLevel), + "offsetof mismatch for TextureViewDescriptor::baseMipLevel"); + static_assert(offsetof(TextureViewDescriptor, mipLevelCount) == offsetof(WGPUTextureViewDescriptor, mipLevelCount), + "offsetof mismatch for TextureViewDescriptor::mipLevelCount"); + static_assert(offsetof(TextureViewDescriptor, baseArrayLayer) == offsetof(WGPUTextureViewDescriptor, baseArrayLayer), + "offsetof mismatch for TextureViewDescriptor::baseArrayLayer"); + static_assert(offsetof(TextureViewDescriptor, arrayLayerCount) == offsetof(WGPUTextureViewDescriptor, arrayLayerCount), + "offsetof mismatch for TextureViewDescriptor::arrayLayerCount"); + static_assert(offsetof(TextureViewDescriptor, aspect) == offsetof(WGPUTextureViewDescriptor, aspect), + "offsetof mismatch for TextureViewDescriptor::aspect"); + + + static_assert(sizeof(VertexAttributeDescriptor) == sizeof(WGPUVertexAttributeDescriptor), "sizeof mismatch for VertexAttributeDescriptor"); + static_assert(alignof(VertexAttributeDescriptor) == alignof(WGPUVertexAttributeDescriptor), "alignof mismatch for VertexAttributeDescriptor"); + + static_assert(offsetof(VertexAttributeDescriptor, format) == offsetof(WGPUVertexAttributeDescriptor, format), + "offsetof mismatch for VertexAttributeDescriptor::format"); + static_assert(offsetof(VertexAttributeDescriptor, offset) == offsetof(WGPUVertexAttributeDescriptor, offset), + "offsetof mismatch for VertexAttributeDescriptor::offset"); + static_assert(offsetof(VertexAttributeDescriptor, shaderLocation) == offsetof(WGPUVertexAttributeDescriptor, shaderLocation), + "offsetof mismatch for VertexAttributeDescriptor::shaderLocation"); + + + static_assert(sizeof(BindGroupDescriptor) == sizeof(WGPUBindGroupDescriptor), "sizeof mismatch for BindGroupDescriptor"); + static_assert(alignof(BindGroupDescriptor) == alignof(WGPUBindGroupDescriptor), "alignof mismatch for BindGroupDescriptor"); + + static_assert(offsetof(BindGroupDescriptor, nextInChain) == offsetof(WGPUBindGroupDescriptor, nextInChain), + "offsetof mismatch for BindGroupDescriptor::nextInChain"); + static_assert(offsetof(BindGroupDescriptor, label) == offsetof(WGPUBindGroupDescriptor, label), + "offsetof mismatch for BindGroupDescriptor::label"); + static_assert(offsetof(BindGroupDescriptor, layout) == offsetof(WGPUBindGroupDescriptor, layout), + "offsetof mismatch for BindGroupDescriptor::layout"); + static_assert(offsetof(BindGroupDescriptor, entryCount) == offsetof(WGPUBindGroupDescriptor, entryCount), + "offsetof mismatch for BindGroupDescriptor::entryCount"); + static_assert(offsetof(BindGroupDescriptor, entries) == offsetof(WGPUBindGroupDescriptor, entries), + "offsetof mismatch for BindGroupDescriptor::entries"); + + + static_assert(sizeof(BindGroupLayoutDescriptor) == sizeof(WGPUBindGroupLayoutDescriptor), "sizeof mismatch for BindGroupLayoutDescriptor"); + static_assert(alignof(BindGroupLayoutDescriptor) == alignof(WGPUBindGroupLayoutDescriptor), "alignof mismatch for BindGroupLayoutDescriptor"); + + static_assert(offsetof(BindGroupLayoutDescriptor, nextInChain) == offsetof(WGPUBindGroupLayoutDescriptor, nextInChain), + "offsetof mismatch for BindGroupLayoutDescriptor::nextInChain"); + static_assert(offsetof(BindGroupLayoutDescriptor, label) == offsetof(WGPUBindGroupLayoutDescriptor, label), + "offsetof mismatch for BindGroupLayoutDescriptor::label"); + static_assert(offsetof(BindGroupLayoutDescriptor, entryCount) == offsetof(WGPUBindGroupLayoutDescriptor, entryCount), + "offsetof mismatch for BindGroupLayoutDescriptor::entryCount"); + static_assert(offsetof(BindGroupLayoutDescriptor, entries) == offsetof(WGPUBindGroupLayoutDescriptor, entries), + "offsetof mismatch for BindGroupLayoutDescriptor::entries"); + + + static_assert(sizeof(ColorStateDescriptor) == sizeof(WGPUColorStateDescriptor), "sizeof mismatch for ColorStateDescriptor"); + static_assert(alignof(ColorStateDescriptor) == alignof(WGPUColorStateDescriptor), "alignof mismatch for ColorStateDescriptor"); + + static_assert(offsetof(ColorStateDescriptor, nextInChain) == offsetof(WGPUColorStateDescriptor, nextInChain), + "offsetof mismatch for ColorStateDescriptor::nextInChain"); + static_assert(offsetof(ColorStateDescriptor, format) == offsetof(WGPUColorStateDescriptor, format), + "offsetof mismatch for ColorStateDescriptor::format"); + static_assert(offsetof(ColorStateDescriptor, alphaBlend) == offsetof(WGPUColorStateDescriptor, alphaBlend), + "offsetof mismatch for ColorStateDescriptor::alphaBlend"); + static_assert(offsetof(ColorStateDescriptor, colorBlend) == offsetof(WGPUColorStateDescriptor, colorBlend), + "offsetof mismatch for ColorStateDescriptor::colorBlend"); + static_assert(offsetof(ColorStateDescriptor, writeMask) == offsetof(WGPUColorStateDescriptor, writeMask), + "offsetof mismatch for ColorStateDescriptor::writeMask"); + + + static_assert(sizeof(ComputePipelineDescriptor) == sizeof(WGPUComputePipelineDescriptor), "sizeof mismatch for ComputePipelineDescriptor"); + static_assert(alignof(ComputePipelineDescriptor) == alignof(WGPUComputePipelineDescriptor), "alignof mismatch for ComputePipelineDescriptor"); + + static_assert(offsetof(ComputePipelineDescriptor, nextInChain) == offsetof(WGPUComputePipelineDescriptor, nextInChain), + "offsetof mismatch for ComputePipelineDescriptor::nextInChain"); + static_assert(offsetof(ComputePipelineDescriptor, label) == offsetof(WGPUComputePipelineDescriptor, label), + "offsetof mismatch for ComputePipelineDescriptor::label"); + static_assert(offsetof(ComputePipelineDescriptor, layout) == offsetof(WGPUComputePipelineDescriptor, layout), + "offsetof mismatch for ComputePipelineDescriptor::layout"); + static_assert(offsetof(ComputePipelineDescriptor, computeStage) == offsetof(WGPUComputePipelineDescriptor, computeStage), + "offsetof mismatch for ComputePipelineDescriptor::computeStage"); + + + static_assert(sizeof(DepthStencilStateDescriptor) == sizeof(WGPUDepthStencilStateDescriptor), "sizeof mismatch for DepthStencilStateDescriptor"); + static_assert(alignof(DepthStencilStateDescriptor) == alignof(WGPUDepthStencilStateDescriptor), "alignof mismatch for DepthStencilStateDescriptor"); + + static_assert(offsetof(DepthStencilStateDescriptor, nextInChain) == offsetof(WGPUDepthStencilStateDescriptor, nextInChain), + "offsetof mismatch for DepthStencilStateDescriptor::nextInChain"); + static_assert(offsetof(DepthStencilStateDescriptor, format) == offsetof(WGPUDepthStencilStateDescriptor, format), + "offsetof mismatch for DepthStencilStateDescriptor::format"); + static_assert(offsetof(DepthStencilStateDescriptor, depthWriteEnabled) == offsetof(WGPUDepthStencilStateDescriptor, depthWriteEnabled), + "offsetof mismatch for DepthStencilStateDescriptor::depthWriteEnabled"); + static_assert(offsetof(DepthStencilStateDescriptor, depthCompare) == offsetof(WGPUDepthStencilStateDescriptor, depthCompare), + "offsetof mismatch for DepthStencilStateDescriptor::depthCompare"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilFront) == offsetof(WGPUDepthStencilStateDescriptor, stencilFront), + "offsetof mismatch for DepthStencilStateDescriptor::stencilFront"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilBack) == offsetof(WGPUDepthStencilStateDescriptor, stencilBack), + "offsetof mismatch for DepthStencilStateDescriptor::stencilBack"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilReadMask) == offsetof(WGPUDepthStencilStateDescriptor, stencilReadMask), + "offsetof mismatch for DepthStencilStateDescriptor::stencilReadMask"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilWriteMask) == offsetof(WGPUDepthStencilStateDescriptor, stencilWriteMask), + "offsetof mismatch for DepthStencilStateDescriptor::stencilWriteMask"); + + + static_assert(sizeof(RenderPassColorAttachmentDescriptor) == sizeof(WGPURenderPassColorAttachmentDescriptor), "sizeof mismatch for RenderPassColorAttachmentDescriptor"); + static_assert(alignof(RenderPassColorAttachmentDescriptor) == alignof(WGPURenderPassColorAttachmentDescriptor), "alignof mismatch for RenderPassColorAttachmentDescriptor"); + + static_assert(offsetof(RenderPassColorAttachmentDescriptor, attachment) == offsetof(WGPURenderPassColorAttachmentDescriptor, attachment), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::attachment"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, resolveTarget) == offsetof(WGPURenderPassColorAttachmentDescriptor, resolveTarget), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::resolveTarget"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, loadOp) == offsetof(WGPURenderPassColorAttachmentDescriptor, loadOp), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::loadOp"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, storeOp) == offsetof(WGPURenderPassColorAttachmentDescriptor, storeOp), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::storeOp"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, clearColor) == offsetof(WGPURenderPassColorAttachmentDescriptor, clearColor), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::clearColor"); + + + static_assert(sizeof(RenderPipelineDescriptorDummyExtension) == sizeof(WGPURenderPipelineDescriptorDummyExtension), "sizeof mismatch for RenderPipelineDescriptorDummyExtension"); + static_assert(alignof(RenderPipelineDescriptorDummyExtension) == alignof(WGPURenderPipelineDescriptorDummyExtension), "alignof mismatch for RenderPipelineDescriptorDummyExtension"); + + static_assert(offsetof(RenderPipelineDescriptorDummyExtension, dummyStage) == offsetof(WGPURenderPipelineDescriptorDummyExtension, dummyStage), + "offsetof mismatch for RenderPipelineDescriptorDummyExtension::dummyStage"); + + + static_assert(sizeof(TextureCopyView) == sizeof(WGPUTextureCopyView), "sizeof mismatch for TextureCopyView"); + static_assert(alignof(TextureCopyView) == alignof(WGPUTextureCopyView), "alignof mismatch for TextureCopyView"); + + static_assert(offsetof(TextureCopyView, nextInChain) == offsetof(WGPUTextureCopyView, nextInChain), + "offsetof mismatch for TextureCopyView::nextInChain"); + static_assert(offsetof(TextureCopyView, texture) == offsetof(WGPUTextureCopyView, texture), + "offsetof mismatch for TextureCopyView::texture"); + static_assert(offsetof(TextureCopyView, mipLevel) == offsetof(WGPUTextureCopyView, mipLevel), + "offsetof mismatch for TextureCopyView::mipLevel"); + static_assert(offsetof(TextureCopyView, arrayLayer) == offsetof(WGPUTextureCopyView, arrayLayer), + "offsetof mismatch for TextureCopyView::arrayLayer"); + static_assert(offsetof(TextureCopyView, origin) == offsetof(WGPUTextureCopyView, origin), + "offsetof mismatch for TextureCopyView::origin"); + + + static_assert(sizeof(TextureDescriptor) == sizeof(WGPUTextureDescriptor), "sizeof mismatch for TextureDescriptor"); + static_assert(alignof(TextureDescriptor) == alignof(WGPUTextureDescriptor), "alignof mismatch for TextureDescriptor"); + + static_assert(offsetof(TextureDescriptor, nextInChain) == offsetof(WGPUTextureDescriptor, nextInChain), + "offsetof mismatch for TextureDescriptor::nextInChain"); + static_assert(offsetof(TextureDescriptor, label) == offsetof(WGPUTextureDescriptor, label), + "offsetof mismatch for TextureDescriptor::label"); + static_assert(offsetof(TextureDescriptor, usage) == offsetof(WGPUTextureDescriptor, usage), + "offsetof mismatch for TextureDescriptor::usage"); + static_assert(offsetof(TextureDescriptor, dimension) == offsetof(WGPUTextureDescriptor, dimension), + "offsetof mismatch for TextureDescriptor::dimension"); + static_assert(offsetof(TextureDescriptor, size) == offsetof(WGPUTextureDescriptor, size), + "offsetof mismatch for TextureDescriptor::size"); + static_assert(offsetof(TextureDescriptor, arrayLayerCount) == offsetof(WGPUTextureDescriptor, arrayLayerCount), + "offsetof mismatch for TextureDescriptor::arrayLayerCount"); + static_assert(offsetof(TextureDescriptor, format) == offsetof(WGPUTextureDescriptor, format), + "offsetof mismatch for TextureDescriptor::format"); + static_assert(offsetof(TextureDescriptor, mipLevelCount) == offsetof(WGPUTextureDescriptor, mipLevelCount), + "offsetof mismatch for TextureDescriptor::mipLevelCount"); + static_assert(offsetof(TextureDescriptor, sampleCount) == offsetof(WGPUTextureDescriptor, sampleCount), + "offsetof mismatch for TextureDescriptor::sampleCount"); + + + static_assert(sizeof(VertexBufferLayoutDescriptor) == sizeof(WGPUVertexBufferLayoutDescriptor), "sizeof mismatch for VertexBufferLayoutDescriptor"); + static_assert(alignof(VertexBufferLayoutDescriptor) == alignof(WGPUVertexBufferLayoutDescriptor), "alignof mismatch for VertexBufferLayoutDescriptor"); + + static_assert(offsetof(VertexBufferLayoutDescriptor, arrayStride) == offsetof(WGPUVertexBufferLayoutDescriptor, arrayStride), + "offsetof mismatch for VertexBufferLayoutDescriptor::arrayStride"); + static_assert(offsetof(VertexBufferLayoutDescriptor, stepMode) == offsetof(WGPUVertexBufferLayoutDescriptor, stepMode), + "offsetof mismatch for VertexBufferLayoutDescriptor::stepMode"); + static_assert(offsetof(VertexBufferLayoutDescriptor, attributeCount) == offsetof(WGPUVertexBufferLayoutDescriptor, attributeCount), + "offsetof mismatch for VertexBufferLayoutDescriptor::attributeCount"); + static_assert(offsetof(VertexBufferLayoutDescriptor, attributes) == offsetof(WGPUVertexBufferLayoutDescriptor, attributes), + "offsetof mismatch for VertexBufferLayoutDescriptor::attributes"); + + + static_assert(sizeof(RenderPassDescriptor) == sizeof(WGPURenderPassDescriptor), "sizeof mismatch for RenderPassDescriptor"); + static_assert(alignof(RenderPassDescriptor) == alignof(WGPURenderPassDescriptor), "alignof mismatch for RenderPassDescriptor"); + + static_assert(offsetof(RenderPassDescriptor, nextInChain) == offsetof(WGPURenderPassDescriptor, nextInChain), + "offsetof mismatch for RenderPassDescriptor::nextInChain"); + static_assert(offsetof(RenderPassDescriptor, label) == offsetof(WGPURenderPassDescriptor, label), + "offsetof mismatch for RenderPassDescriptor::label"); + static_assert(offsetof(RenderPassDescriptor, colorAttachmentCount) == offsetof(WGPURenderPassDescriptor, colorAttachmentCount), + "offsetof mismatch for RenderPassDescriptor::colorAttachmentCount"); + static_assert(offsetof(RenderPassDescriptor, colorAttachments) == offsetof(WGPURenderPassDescriptor, colorAttachments), + "offsetof mismatch for RenderPassDescriptor::colorAttachments"); + static_assert(offsetof(RenderPassDescriptor, depthStencilAttachment) == offsetof(WGPURenderPassDescriptor, depthStencilAttachment), + "offsetof mismatch for RenderPassDescriptor::depthStencilAttachment"); + + + static_assert(sizeof(VertexStateDescriptor) == sizeof(WGPUVertexStateDescriptor), "sizeof mismatch for VertexStateDescriptor"); + static_assert(alignof(VertexStateDescriptor) == alignof(WGPUVertexStateDescriptor), "alignof mismatch for VertexStateDescriptor"); + + static_assert(offsetof(VertexStateDescriptor, nextInChain) == offsetof(WGPUVertexStateDescriptor, nextInChain), + "offsetof mismatch for VertexStateDescriptor::nextInChain"); + static_assert(offsetof(VertexStateDescriptor, indexFormat) == offsetof(WGPUVertexStateDescriptor, indexFormat), + "offsetof mismatch for VertexStateDescriptor::indexFormat"); + static_assert(offsetof(VertexStateDescriptor, vertexBufferCount) == offsetof(WGPUVertexStateDescriptor, vertexBufferCount), + "offsetof mismatch for VertexStateDescriptor::vertexBufferCount"); + static_assert(offsetof(VertexStateDescriptor, vertexBuffers) == offsetof(WGPUVertexStateDescriptor, vertexBuffers), + "offsetof mismatch for VertexStateDescriptor::vertexBuffers"); + + + static_assert(sizeof(RenderPipelineDescriptor) == sizeof(WGPURenderPipelineDescriptor), "sizeof mismatch for RenderPipelineDescriptor"); + static_assert(alignof(RenderPipelineDescriptor) == alignof(WGPURenderPipelineDescriptor), "alignof mismatch for RenderPipelineDescriptor"); + + static_assert(offsetof(RenderPipelineDescriptor, nextInChain) == offsetof(WGPURenderPipelineDescriptor, nextInChain), + "offsetof mismatch for RenderPipelineDescriptor::nextInChain"); + static_assert(offsetof(RenderPipelineDescriptor, label) == offsetof(WGPURenderPipelineDescriptor, label), + "offsetof mismatch for RenderPipelineDescriptor::label"); + static_assert(offsetof(RenderPipelineDescriptor, layout) == offsetof(WGPURenderPipelineDescriptor, layout), + "offsetof mismatch for RenderPipelineDescriptor::layout"); + static_assert(offsetof(RenderPipelineDescriptor, vertexStage) == offsetof(WGPURenderPipelineDescriptor, vertexStage), + "offsetof mismatch for RenderPipelineDescriptor::vertexStage"); + static_assert(offsetof(RenderPipelineDescriptor, fragmentStage) == offsetof(WGPURenderPipelineDescriptor, fragmentStage), + "offsetof mismatch for RenderPipelineDescriptor::fragmentStage"); + static_assert(offsetof(RenderPipelineDescriptor, vertexState) == offsetof(WGPURenderPipelineDescriptor, vertexState), + "offsetof mismatch for RenderPipelineDescriptor::vertexState"); + static_assert(offsetof(RenderPipelineDescriptor, primitiveTopology) == offsetof(WGPURenderPipelineDescriptor, primitiveTopology), + "offsetof mismatch for RenderPipelineDescriptor::primitiveTopology"); + static_assert(offsetof(RenderPipelineDescriptor, rasterizationState) == offsetof(WGPURenderPipelineDescriptor, rasterizationState), + "offsetof mismatch for RenderPipelineDescriptor::rasterizationState"); + static_assert(offsetof(RenderPipelineDescriptor, sampleCount) == offsetof(WGPURenderPipelineDescriptor, sampleCount), + "offsetof mismatch for RenderPipelineDescriptor::sampleCount"); + static_assert(offsetof(RenderPipelineDescriptor, depthStencilState) == offsetof(WGPURenderPipelineDescriptor, depthStencilState), + "offsetof mismatch for RenderPipelineDescriptor::depthStencilState"); + static_assert(offsetof(RenderPipelineDescriptor, colorStateCount) == offsetof(WGPURenderPipelineDescriptor, colorStateCount), + "offsetof mismatch for RenderPipelineDescriptor::colorStateCount"); + static_assert(offsetof(RenderPipelineDescriptor, colorStates) == offsetof(WGPURenderPipelineDescriptor, colorStates), + "offsetof mismatch for RenderPipelineDescriptor::colorStates"); + static_assert(offsetof(RenderPipelineDescriptor, sampleMask) == offsetof(WGPURenderPipelineDescriptor, sampleMask), + "offsetof mismatch for RenderPipelineDescriptor::sampleMask"); + static_assert(offsetof(RenderPipelineDescriptor, alphaToCoverageEnabled) == offsetof(WGPURenderPipelineDescriptor, alphaToCoverageEnabled), + "offsetof mismatch for RenderPipelineDescriptor::alphaToCoverageEnabled"); + + + + static_assert(sizeof(BindGroup) == sizeof(WGPUBindGroup), "sizeof mismatch for BindGroup"); + static_assert(alignof(BindGroup) == alignof(WGPUBindGroup), "alignof mismatch for BindGroup"); + + + + void BindGroup::WGPUReference(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupReference(handle); + } + } + void BindGroup::WGPURelease(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupRelease(handle); + } + } + + + static_assert(sizeof(BindGroupLayout) == sizeof(WGPUBindGroupLayout), "sizeof mismatch for BindGroupLayout"); + static_assert(alignof(BindGroupLayout) == alignof(WGPUBindGroupLayout), "alignof mismatch for BindGroupLayout"); + + + + void BindGroupLayout::WGPUReference(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutReference(handle); + } + } + void BindGroupLayout::WGPURelease(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutRelease(handle); + } + } + + + static_assert(sizeof(Buffer) == sizeof(WGPUBuffer), "sizeof mismatch for Buffer"); + static_assert(alignof(Buffer) == alignof(WGPUBuffer), "alignof mismatch for Buffer"); + + + + void Buffer::Destroy() const { + wgpuBufferDestroy(Get()); + } + void Buffer::MapReadAsync(BufferMapReadCallback callback, void * userdata) const { + wgpuBufferMapReadAsync(Get(), callback, reinterpret_cast(userdata)); + } + void Buffer::MapWriteAsync(BufferMapWriteCallback callback, void * userdata) const { + wgpuBufferMapWriteAsync(Get(), callback, reinterpret_cast(userdata)); + } + void Buffer::SetSubData(uint64_t start, uint64_t count, void const * data) const { + wgpuBufferSetSubData(Get(), start, count, reinterpret_cast(data)); + } + void Buffer::Unmap() const { + wgpuBufferUnmap(Get()); + } + void Buffer::WGPUReference(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferReference(handle); + } + } + void Buffer::WGPURelease(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferRelease(handle); + } + } + + + static_assert(sizeof(CommandBuffer) == sizeof(WGPUCommandBuffer), "sizeof mismatch for CommandBuffer"); + static_assert(alignof(CommandBuffer) == alignof(WGPUCommandBuffer), "alignof mismatch for CommandBuffer"); + + + + void CommandBuffer::WGPUReference(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferReference(handle); + } + } + void CommandBuffer::WGPURelease(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferRelease(handle); + } + } + + + static_assert(sizeof(CommandEncoder) == sizeof(WGPUCommandEncoder), "sizeof mismatch for CommandEncoder"); + static_assert(alignof(CommandEncoder) == alignof(WGPUCommandEncoder), "alignof mismatch for CommandEncoder"); + + + + ComputePassEncoder CommandEncoder::BeginComputePass(ComputePassDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderBeginComputePass(Get(), reinterpret_cast(descriptor)); + return ComputePassEncoder::Acquire(result); + } + RenderPassEncoder CommandEncoder::BeginRenderPass(RenderPassDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderBeginRenderPass(Get(), reinterpret_cast(descriptor)); + return RenderPassEncoder::Acquire(result); + } + void CommandEncoder::CopyBufferToBuffer(Buffer const& source, uint64_t sourceOffset, Buffer const& destination, uint64_t destinationOffset, uint64_t size) const { + wgpuCommandEncoderCopyBufferToBuffer(Get(), source.Get(), sourceOffset, destination.Get(), destinationOffset, size); + } + void CommandEncoder::CopyBufferToTexture(BufferCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyBufferToTexture(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + void CommandEncoder::CopyTextureToBuffer(TextureCopyView const * source, BufferCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyTextureToBuffer(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + void CommandEncoder::CopyTextureToTexture(TextureCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyTextureToTexture(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + CommandBuffer CommandEncoder::Finish(CommandBufferDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderFinish(Get(), reinterpret_cast(descriptor)); + return CommandBuffer::Acquire(result); + } + void CommandEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuCommandEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void CommandEncoder::PopDebugGroup() const { + wgpuCommandEncoderPopDebugGroup(Get()); + } + void CommandEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuCommandEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void CommandEncoder::WGPUReference(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderReference(handle); + } + } + void CommandEncoder::WGPURelease(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderRelease(handle); + } + } + + + static_assert(sizeof(ComputePassEncoder) == sizeof(WGPUComputePassEncoder), "sizeof mismatch for ComputePassEncoder"); + static_assert(alignof(ComputePassEncoder) == alignof(WGPUComputePassEncoder), "alignof mismatch for ComputePassEncoder"); + + + + void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) const { + wgpuComputePassEncoderDispatch(Get(), x, y, z); + } + void ComputePassEncoder::DispatchIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuComputePassEncoderDispatchIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void ComputePassEncoder::EndPass() const { + wgpuComputePassEncoderEndPass(Get()); + } + void ComputePassEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuComputePassEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void ComputePassEncoder::PopDebugGroup() const { + wgpuComputePassEncoderPopDebugGroup(Get()); + } + void ComputePassEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuComputePassEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void ComputePassEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuComputePassEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void ComputePassEncoder::SetPipeline(ComputePipeline const& pipeline) const { + wgpuComputePassEncoderSetPipeline(Get(), pipeline.Get()); + } + void ComputePassEncoder::WGPUReference(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderReference(handle); + } + } + void ComputePassEncoder::WGPURelease(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderRelease(handle); + } + } + + + static_assert(sizeof(ComputePipeline) == sizeof(WGPUComputePipeline), "sizeof mismatch for ComputePipeline"); + static_assert(alignof(ComputePipeline) == alignof(WGPUComputePipeline), "alignof mismatch for ComputePipeline"); + + + + BindGroupLayout ComputePipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuComputePipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); + } + void ComputePipeline::WGPUReference(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineReference(handle); + } + } + void ComputePipeline::WGPURelease(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineRelease(handle); + } + } + + + static_assert(sizeof(Device) == sizeof(WGPUDevice), "sizeof mismatch for Device"); + static_assert(alignof(Device) == alignof(WGPUDevice), "alignof mismatch for Device"); + + + + BindGroup Device::CreateBindGroup(BindGroupDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBindGroup(Get(), reinterpret_cast(descriptor)); + return BindGroup::Acquire(result); + } + BindGroupLayout Device::CreateBindGroupLayout(BindGroupLayoutDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBindGroupLayout(Get(), reinterpret_cast(descriptor)); + return BindGroupLayout::Acquire(result); + } + Buffer Device::CreateBuffer(BufferDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBuffer(Get(), reinterpret_cast(descriptor)); + return Buffer::Acquire(result); + } + CreateBufferMappedResult Device::CreateBufferMapped(BufferDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBufferMapped(Get(), reinterpret_cast(descriptor)); + return CreateBufferMappedResult { + Buffer::Acquire(result.buffer), + result.dataLength, + result.data + }; + } + CommandEncoder Device::CreateCommandEncoder(CommandEncoderDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateCommandEncoder(Get(), reinterpret_cast(descriptor)); + return CommandEncoder::Acquire(result); + } + ComputePipeline Device::CreateComputePipeline(ComputePipelineDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateComputePipeline(Get(), reinterpret_cast(descriptor)); + return ComputePipeline::Acquire(result); + } + PipelineLayout Device::CreatePipelineLayout(PipelineLayoutDescriptor const * descriptor) const { + auto result = wgpuDeviceCreatePipelineLayout(Get(), reinterpret_cast(descriptor)); + return PipelineLayout::Acquire(result); + } + RenderBundleEncoder Device::CreateRenderBundleEncoder(RenderBundleEncoderDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateRenderBundleEncoder(Get(), reinterpret_cast(descriptor)); + return RenderBundleEncoder::Acquire(result); + } + RenderPipeline Device::CreateRenderPipeline(RenderPipelineDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateRenderPipeline(Get(), reinterpret_cast(descriptor)); + return RenderPipeline::Acquire(result); + } + Sampler Device::CreateSampler(SamplerDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateSampler(Get(), reinterpret_cast(descriptor)); + return Sampler::Acquire(result); + } + ShaderModule Device::CreateShaderModule(ShaderModuleDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateShaderModule(Get(), reinterpret_cast(descriptor)); + return ShaderModule::Acquire(result); + } + SwapChain Device::CreateSwapChain(Surface const& surface, SwapChainDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateSwapChain(Get(), surface.Get(), reinterpret_cast(descriptor)); + return SwapChain::Acquire(result); + } + Texture Device::CreateTexture(TextureDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateTexture(Get(), reinterpret_cast(descriptor)); + return Texture::Acquire(result); + } + Queue Device::GetDefaultQueue() const { + auto result = wgpuDeviceGetDefaultQueue(Get()); + return Queue::Acquire(result); + } + void Device::InjectError(ErrorType type, char const * message) const { + wgpuDeviceInjectError(Get(), static_cast(type), reinterpret_cast(message)); + } + void Device::LoseForTesting() const { + wgpuDeviceLoseForTesting(Get()); + } + bool Device::PopErrorScope(ErrorCallback callback, void * userdata) const { + auto result = wgpuDevicePopErrorScope(Get(), callback, reinterpret_cast(userdata)); + return result; + } + void Device::PushErrorScope(ErrorFilter filter) const { + wgpuDevicePushErrorScope(Get(), static_cast(filter)); + } + void Device::SetDeviceLostCallback(DeviceLostCallback callback, void * userdata) const { + wgpuDeviceSetDeviceLostCallback(Get(), callback, reinterpret_cast(userdata)); + } + void Device::SetUncapturedErrorCallback(ErrorCallback callback, void * userdata) const { + wgpuDeviceSetUncapturedErrorCallback(Get(), callback, reinterpret_cast(userdata)); + } + void Device::Tick() const { + wgpuDeviceTick(Get()); + } + void Device::WGPUReference(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceReference(handle); + } + } + void Device::WGPURelease(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceRelease(handle); + } + } + + + static_assert(sizeof(Fence) == sizeof(WGPUFence), "sizeof mismatch for Fence"); + static_assert(alignof(Fence) == alignof(WGPUFence), "alignof mismatch for Fence"); + + + + uint64_t Fence::GetCompletedValue() const { + auto result = wgpuFenceGetCompletedValue(Get()); + return result; + } + void Fence::OnCompletion(uint64_t value, FenceOnCompletionCallback callback, void * userdata) const { + wgpuFenceOnCompletion(Get(), value, callback, reinterpret_cast(userdata)); + } + void Fence::WGPUReference(WGPUFence handle) { + if (handle != nullptr) { + wgpuFenceReference(handle); + } + } + void Fence::WGPURelease(WGPUFence handle) { + if (handle != nullptr) { + wgpuFenceRelease(handle); + } + } + + + static_assert(sizeof(Instance) == sizeof(WGPUInstance), "sizeof mismatch for Instance"); + static_assert(alignof(Instance) == alignof(WGPUInstance), "alignof mismatch for Instance"); + + + + Surface Instance::CreateSurface(SurfaceDescriptor const * descriptor) const { + auto result = wgpuInstanceCreateSurface(Get(), reinterpret_cast(descriptor)); + return Surface::Acquire(result); + } + void Instance::WGPUReference(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceReference(handle); + } + } + void Instance::WGPURelease(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceRelease(handle); + } + } + + + static_assert(sizeof(PipelineLayout) == sizeof(WGPUPipelineLayout), "sizeof mismatch for PipelineLayout"); + static_assert(alignof(PipelineLayout) == alignof(WGPUPipelineLayout), "alignof mismatch for PipelineLayout"); + + + + void PipelineLayout::WGPUReference(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutReference(handle); + } + } + void PipelineLayout::WGPURelease(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutRelease(handle); + } + } + + + static_assert(sizeof(Queue) == sizeof(WGPUQueue), "sizeof mismatch for Queue"); + static_assert(alignof(Queue) == alignof(WGPUQueue), "alignof mismatch for Queue"); + + + + Fence Queue::CreateFence(FenceDescriptor const * descriptor) const { + auto result = wgpuQueueCreateFence(Get(), reinterpret_cast(descriptor)); + return Fence::Acquire(result); + } + void Queue::Signal(Fence const& fence, uint64_t signalValue) const { + wgpuQueueSignal(Get(), fence.Get(), signalValue); + } + void Queue::Submit(uint32_t commandCount, CommandBuffer const * commands) const { + wgpuQueueSubmit(Get(), commandCount, reinterpret_cast(commands)); + } + void Queue::WGPUReference(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueReference(handle); + } + } + void Queue::WGPURelease(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueRelease(handle); + } + } + + + static_assert(sizeof(RenderBundle) == sizeof(WGPURenderBundle), "sizeof mismatch for RenderBundle"); + static_assert(alignof(RenderBundle) == alignof(WGPURenderBundle), "alignof mismatch for RenderBundle"); + + + + void RenderBundle::WGPUReference(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleReference(handle); + } + } + void RenderBundle::WGPURelease(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleRelease(handle); + } + } + + + static_assert(sizeof(RenderBundleEncoder) == sizeof(WGPURenderBundleEncoder), "sizeof mismatch for RenderBundleEncoder"); + static_assert(alignof(RenderBundleEncoder) == alignof(WGPURenderBundleEncoder), "alignof mismatch for RenderBundleEncoder"); + + + + void RenderBundleEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const { + wgpuRenderBundleEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, firstInstance); + } + void RenderBundleEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) const { + wgpuRenderBundleEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + void RenderBundleEncoder::DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderBundleEncoder::DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + RenderBundle RenderBundleEncoder::Finish(RenderBundleDescriptor const * descriptor) const { + auto result = wgpuRenderBundleEncoderFinish(Get(), reinterpret_cast(descriptor)); + return RenderBundle::Acquire(result); + } + void RenderBundleEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuRenderBundleEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void RenderBundleEncoder::PopDebugGroup() const { + wgpuRenderBundleEncoderPopDebugGroup(Get()); + } + void RenderBundleEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuRenderBundleEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void RenderBundleEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuRenderBundleEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void RenderBundleEncoder::SetIndexBuffer(Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderBundleEncoderSetIndexBuffer(Get(), buffer.Get(), offset, size); + } + void RenderBundleEncoder::SetPipeline(RenderPipeline const& pipeline) const { + wgpuRenderBundleEncoderSetPipeline(Get(), pipeline.Get()); + } + void RenderBundleEncoder::SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderBundleEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); + } + void RenderBundleEncoder::WGPUReference(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderReference(handle); + } + } + void RenderBundleEncoder::WGPURelease(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderRelease(handle); + } + } + + + static_assert(sizeof(RenderPassEncoder) == sizeof(WGPURenderPassEncoder), "sizeof mismatch for RenderPassEncoder"); + static_assert(alignof(RenderPassEncoder) == alignof(WGPURenderPassEncoder), "alignof mismatch for RenderPassEncoder"); + + + + void RenderPassEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const { + wgpuRenderPassEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, firstInstance); + } + void RenderPassEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) const { + wgpuRenderPassEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + void RenderPassEncoder::DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderPassEncoder::DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderPassEncoder::EndPass() const { + wgpuRenderPassEncoderEndPass(Get()); + } + void RenderPassEncoder::ExecuteBundles(uint32_t bundlesCount, RenderBundle const * bundles) const { + wgpuRenderPassEncoderExecuteBundles(Get(), bundlesCount, reinterpret_cast(bundles)); + } + void RenderPassEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuRenderPassEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void RenderPassEncoder::PopDebugGroup() const { + wgpuRenderPassEncoderPopDebugGroup(Get()); + } + void RenderPassEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuRenderPassEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void RenderPassEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuRenderPassEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void RenderPassEncoder::SetBlendColor(Color const * color) const { + wgpuRenderPassEncoderSetBlendColor(Get(), reinterpret_cast(color)); + } + void RenderPassEncoder::SetIndexBuffer(Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetIndexBuffer(Get(), buffer.Get(), offset, size); + } + void RenderPassEncoder::SetPipeline(RenderPipeline const& pipeline) const { + wgpuRenderPassEncoderSetPipeline(Get(), pipeline.Get()); + } + void RenderPassEncoder::SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const { + wgpuRenderPassEncoderSetScissorRect(Get(), x, y, width, height); + } + void RenderPassEncoder::SetStencilReference(uint32_t reference) const { + wgpuRenderPassEncoderSetStencilReference(Get(), reference); + } + void RenderPassEncoder::SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); + } + void RenderPassEncoder::SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) const { + wgpuRenderPassEncoderSetViewport(Get(), x, y, width, height, minDepth, maxDepth); + } + void RenderPassEncoder::WGPUReference(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderReference(handle); + } + } + void RenderPassEncoder::WGPURelease(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderRelease(handle); + } + } + + + static_assert(sizeof(RenderPipeline) == sizeof(WGPURenderPipeline), "sizeof mismatch for RenderPipeline"); + static_assert(alignof(RenderPipeline) == alignof(WGPURenderPipeline), "alignof mismatch for RenderPipeline"); + + + + BindGroupLayout RenderPipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuRenderPipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); + } + void RenderPipeline::WGPUReference(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineReference(handle); + } + } + void RenderPipeline::WGPURelease(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineRelease(handle); + } + } + + + static_assert(sizeof(Sampler) == sizeof(WGPUSampler), "sizeof mismatch for Sampler"); + static_assert(alignof(Sampler) == alignof(WGPUSampler), "alignof mismatch for Sampler"); + + + + void Sampler::WGPUReference(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerReference(handle); + } + } + void Sampler::WGPURelease(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerRelease(handle); + } + } + + + static_assert(sizeof(ShaderModule) == sizeof(WGPUShaderModule), "sizeof mismatch for ShaderModule"); + static_assert(alignof(ShaderModule) == alignof(WGPUShaderModule), "alignof mismatch for ShaderModule"); + + + + void ShaderModule::WGPUReference(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleReference(handle); + } + } + void ShaderModule::WGPURelease(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleRelease(handle); + } + } + + + static_assert(sizeof(Surface) == sizeof(WGPUSurface), "sizeof mismatch for Surface"); + static_assert(alignof(Surface) == alignof(WGPUSurface), "alignof mismatch for Surface"); + + + + void Surface::WGPUReference(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceReference(handle); + } + } + void Surface::WGPURelease(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceRelease(handle); + } + } + + + static_assert(sizeof(SwapChain) == sizeof(WGPUSwapChain), "sizeof mismatch for SwapChain"); + static_assert(alignof(SwapChain) == alignof(WGPUSwapChain), "alignof mismatch for SwapChain"); + + + + void SwapChain::Configure(TextureFormat format, TextureUsage allowedUsage, uint32_t width, uint32_t height) const { + wgpuSwapChainConfigure(Get(), static_cast(format), static_cast(allowedUsage), width, height); + } + TextureView SwapChain::GetCurrentTextureView() const { + auto result = wgpuSwapChainGetCurrentTextureView(Get()); + return TextureView::Acquire(result); + } + void SwapChain::Present() const { + wgpuSwapChainPresent(Get()); + } + void SwapChain::WGPUReference(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainReference(handle); + } + } + void SwapChain::WGPURelease(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainRelease(handle); + } + } + + + static_assert(sizeof(Texture) == sizeof(WGPUTexture), "sizeof mismatch for Texture"); + static_assert(alignof(Texture) == alignof(WGPUTexture), "alignof mismatch for Texture"); + + + + TextureView Texture::CreateView(TextureViewDescriptor const * descriptor) const { + auto result = wgpuTextureCreateView(Get(), reinterpret_cast(descriptor)); + return TextureView::Acquire(result); + } + void Texture::Destroy() const { + wgpuTextureDestroy(Get()); + } + void Texture::WGPUReference(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureReference(handle); + } + } + void Texture::WGPURelease(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureRelease(handle); + } + } + + + static_assert(sizeof(TextureView) == sizeof(WGPUTextureView), "sizeof mismatch for TextureView"); + static_assert(alignof(TextureView) == alignof(WGPUTextureView), "alignof mismatch for TextureView"); + + + + void TextureView::WGPUReference(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewReference(handle); + } + } + void TextureView::WGPURelease(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewRelease(handle); + } + } + + + Instance CreateInstance(const InstanceDescriptor* descriptor) { + const WGPUInstanceDescriptor* cDescriptor = + reinterpret_cast(descriptor); + return Instance::Acquire(wgpuCreateInstance(cDescriptor)); + } + + Proc GetProcAddress(Device const& device, const char* procName) { + return reinterpret_cast(wgpuGetProcAddress(device.Get(), procName)); + } + +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c0b3880fc6e..7480337153d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,6 +279,9 @@ OCV_OPTION(WITH_HALIDE "Include Halide support" OFF OCV_OPTION(WITH_VULKAN "Include Vulkan support" OFF VISIBLE_IF TRUE VERIFY HAVE_VULKAN) +OCV_OPTION(WITH_WEBGPU "Include WebGPU-Dawn support" OFF + VISIBLE_IF TRUE + VERIFY HAVE_WEBGPU) OCV_OPTION(WITH_INF_ENGINE "Include Intel Inference Engine support" OFF VISIBLE_IF TRUE VERIFY INF_ENGINE_TARGET) @@ -744,6 +747,11 @@ if(WITH_VULKAN) include(cmake/OpenCVDetectVulkan.cmake) endif() +# ---WEBGPU --- +if(WITH_WEBGPU) + include(cmake/OpenCVDetectWebGPU.cmake) +endif() + # --- Inference Engine --- if(WITH_INF_ENGINE) include(cmake/OpenCVDetectInferenceEngine.cmake) @@ -1532,6 +1540,11 @@ if(WITH_VULKAN OR HAVE_VULKAN) endif() endif() +if(WITH_WEBGPU OR HAVE_WEBGPU) + status("") + status(" WebGPU-Dawn Support:" HAVE_WEBGPU THEN "YES" ELSE "NO") +endif() + if(WITH_OPENCL OR HAVE_OPENCL) ocv_build_features_string(opencl_features IF HAVE_OPENCL_SVM THEN "SVM" diff --git a/cmake/OpenCVDetectWebGPU.cmake b/cmake/OpenCVDetectWebGPU.cmake new file mode 100644 index 000000000000..1a8235f5e3f3 --- /dev/null +++ b/cmake/OpenCVDetectWebGPU.cmake @@ -0,0 +1,25 @@ +ocv_clear_vars(HAVE_WEBGPU) +if(WITH_WEBGPU) + set(WEBGPU_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/3rdparty/include/webgpu/include") + set(WEBGPU_LIBRARIES "${PROJECT_SOURCE_DIR}/3rdparty/include/webgpu/lib") +endif() + +try_compile(VALID_WEBGPU + "${OpenCV_BINARY_DIR}" + "${OpenCV_SOURCE_DIR}/cmake/checks/webgpu.cpp" + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${WEBGPU_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${WEBGPU_LIBRARIES}" + OUTPUT_VARIABLE TRY_OUT + ) +if(NOT ${VALID_WEBGPU}) + message(WARNING "Can't use WebGPU-Dawn") + return() +endif() +message(AUTHOR_WARNING "try_compile webgpu.cpp succeed") + +set(HAVE_WEBGPU 1) + +if(HAVE_WEBGPU) + include_directories(${WEBGPU_INCLUDE_DIRS}) + link_directories(${WEBGPU_LIBRARIES}) + link_libraries(dawn_proc dawn_native dawn_wire) +endif() \ No newline at end of file diff --git a/cmake/checks/webgpu.cpp b/cmake/checks/webgpu.cpp new file mode 100644 index 000000000000..079a754a0d4c --- /dev/null +++ b/cmake/checks/webgpu.cpp @@ -0,0 +1,8 @@ +#include + +int main(int /*argc*/, char** /*argv*/) +{ + wgpu::Device device1; + device1.Release(); + return 0; +} \ No newline at end of file diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index f2b171a0963d..6c9ead65b89e 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -71,6 +71,9 @@ /* Vulkan support */ #cmakedefine HAVE_VULKAN +/* WebGPU-Dawn support */ +#cmakedefine HAVE_WEBGPU + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 diff --git a/modules/dnn/include/opencv2/dnn/dnn.hpp b/modules/dnn/include/opencv2/dnn/dnn.hpp index 3b12508c740b..957b8abc9b03 100644 --- a/modules/dnn/include/opencv2/dnn/dnn.hpp +++ b/modules/dnn/include/opencv2/dnn/dnn.hpp @@ -74,6 +74,7 @@ CV__DNN_INLINE_NS_BEGIN DNN_BACKEND_OPENCV, DNN_BACKEND_VKCOM, DNN_BACKEND_CUDA, + DNN_BACKEND_WGPU, #ifdef __OPENCV_BUILD DNN_BACKEND_INFERENCE_ENGINE_NGRAPH = 1000000, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType() DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType() @@ -93,7 +94,8 @@ CV__DNN_INLINE_NS_BEGIN DNN_TARGET_VULKAN, DNN_TARGET_FPGA, //!< FPGA device with CPU fallbacks using Inference Engine's Heterogeneous plugin. DNN_TARGET_CUDA, - DNN_TARGET_CUDA_FP16 + DNN_TARGET_CUDA_FP16, + DNN_TARGET_WGPU }; CV_EXPORTS std::vector< std::pair > getAvailableBackends(); @@ -285,6 +287,8 @@ CV__DNN_INLINE_NS_BEGIN virtual Ptr initVkCom(const std::vector > &inputs); + virtual Ptr initWGPU(const std::vector > &inputs); + /** * @brief Returns a CUDA backend node * diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 6190112d67b3..15c64c1d5b89 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -45,6 +45,7 @@ #include "ie_ngraph.hpp" #include "op_vkcom.hpp" #include "op_cuda.hpp" +#include "op_webgpu.hpp" #include "halide_scheduler.hpp" @@ -242,6 +243,11 @@ class BackendRegistry backends.push_back(std::make_pair(DNN_BACKEND_VKCOM, DNN_TARGET_VULKAN)); #endif +#ifdef HAVE_WEBGPU + if(haveWGPU()) + backends.push_back(std::make_pair(DNN_BACKEND_WGPU, DNN_TARGET_WGPU)); +#endif + #ifdef HAVE_CUDA if (haveCUDA()) { backends.push_back(std::make_pair(DNN_BACKEND_CUDA, DNN_TARGET_CUDA)); @@ -1117,6 +1123,13 @@ static Ptr wrapMat(int backendId, int targetId, cv::Mat& m) #ifdef HAVE_VULKAN return Ptr(new VkComBackendWrapper(m)); #endif // HAVE_VULKAN + } + else if (backendId == DNN_BACKEND_WGPU) + { + CV_Assert(haveWGPU()); +#ifdef HAVE_WEBGPU + return Ptr(new WGPUBackendWrapper(m)); +#endif // HAVE_WEBGPU } else if (backendId == DNN_BACKEND_CUDA) { @@ -1265,6 +1278,12 @@ struct Net::Impl : public detail::NetImplBase #ifdef HAVE_VULKAN return Ptr(new VkComBackendWrapper(baseBuffer, host)); #endif + } + else if (preferableBackend == DNN_BACKEND_WGPU) + { +#ifdef HAVE_WEBGPU + return Ptr(new WGPUBackendWrapper(baseBuffer, host)); +#endif } else if (preferableBackend == DNN_BACKEND_CUDA) { @@ -1407,6 +1426,8 @@ struct Net::Impl : public detail::NetImplBase } CV_Assert(preferableBackend != DNN_BACKEND_VKCOM || preferableTarget == DNN_TARGET_VULKAN); + CV_Assert(preferableBackend != DNN_BACKEND_WGPU || + preferableTarget == DNN_TARGET_WGPU); CV_Assert(preferableBackend != DNN_BACKEND_CUDA || IS_DNN_CUDA_TARGET(preferableTarget)); if (!netWasAllocated || this->blobsToKeep != blobsToKeep_) @@ -1443,6 +1464,11 @@ struct Net::Impl : public detail::NetImplBase preferableBackend = DNN_BACKEND_OPENCV; preferableTarget = DNN_TARGET_CPU; } + if (preferableBackend == DNN_BACKEND_WGPU && !haveWGPU()) + { + preferableBackend = DNN_BACKEND_OPENCV; + preferableTarget = DNN_TARGET_CPU; + } if (preferableBackend == DNN_BACKEND_CUDA && !haveCUDA()) { @@ -1629,6 +1655,8 @@ struct Net::Impl : public detail::NetImplBase } else if (preferableBackend == DNN_BACKEND_VKCOM) initVkComBackend(); + else if (preferableBackend == DNN_BACKEND_WGPU) + initWGPUBackend(); else if (preferableBackend == DNN_BACKEND_CUDA) initCUDABackend(); else @@ -2358,6 +2386,40 @@ struct Net::Impl : public detail::NetImplBase #endif } + void initWGPUBackend() + { + CV_TRACE_FUNCTION(); + CV_Assert(preferableBackend == DNN_BACKEND_WGPU); +#ifdef HAVE_WEBGPU + if (!haveWGPU()) + return; + + MapIdToLayerData::iterator it = layers.begin(); + for (; it != layers.end(); it++) + { + LayerData &ld = it->second; + Ptr layer = ld.layerInstance; + if (!layer->supportBackend(preferableBackend)) + { + continue; + } + + ld.skip = false; + + try + { + ld.backendNodes[DNN_BACKEND_WGPU] = + layer->initWGPU(ld.inputBlobsWrappers); + } + catch (const cv::Exception& e) + { + CV_LOG_ERROR(NULL, "initWGPU failed, fallback to CPU implementation. " << e.what()); + ld.backendNodes[DNN_BACKEND_WGPU] = Ptr(); + } + } +#endif + } + void initCUDABackend() { CV_Assert(haveCUDA()); @@ -3145,6 +3207,19 @@ struct Net::Impl : public detail::NetImplBase forwardLayer(ld); } } + else if (preferableBackend == DNN_BACKEND_WGPU) + { + try + { + forwardWGPU(ld.outputBlobsWrappers, node); + } + catch (const cv::Exception& e) + { + CV_LOG_ERROR(NULL, "forwardWGPU failed, fallback to CPU implementation. " << e.what()); + it->second = Ptr(); + forwardLayer(ld); + } + } else { CV_Error(Error::StsNotImplemented, "Unknown backend identifier"); @@ -4165,7 +4240,7 @@ string Net::Impl::dump() prevNode = itBackend->second; } } - string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151"}; + string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151", "#b3e4ff"}; string backend; switch (prefBackend) { @@ -4177,6 +4252,7 @@ string Net::Impl::dump() case DNN_BACKEND_OPENCV: backend = "OCV/"; break; case DNN_BACKEND_VKCOM: backend = "VULKAN/"; break; case DNN_BACKEND_CUDA: backend = "CUDA/"; break; + case DNN_BACKEND_WGPU: backend = "WEBGPU/"; break; // don't use default: } out << "digraph G {\n"; @@ -4314,6 +4390,7 @@ string Net::Impl::dump() case DNN_TARGET_FPGA: out << "FPGA"; colorId = 4; break; case DNN_TARGET_CUDA: out << "CUDA"; colorId = 5; break; case DNN_TARGET_CUDA_FP16: out << "CUDA_FP16"; colorId = 6; break; + case DNN_TARGET_WGPU: out<< "WEBGPU"; colorId = 8; break; // don't use default: } out << "\\n"; // align center @@ -4743,6 +4820,13 @@ Ptr Layer::initVkCom(const std::vector > &) return Ptr(); } +Ptr Layer::initWGPU(const std::vector >& ) +{ + CV_Error(Error::StsNotImplemented, "WebGPU pipeline of " + type + + " layers is not defined."); + return Ptr(); +} + Ptr Layer::initHalide(const std::vector > &) { CV_Error(Error::StsNotImplemented, "Halide pipeline of " + type + diff --git a/modules/dnn/src/layers/softmax_layer.cpp b/modules/dnn/src/layers/softmax_layer.cpp index 6715c86e39cb..2ffdd57949ac 100644 --- a/modules/dnn/src/layers/softmax_layer.cpp +++ b/modules/dnn/src/layers/softmax_layer.cpp @@ -47,7 +47,7 @@ #include "../op_inf_engine.hpp" #include "../ie_ngraph.hpp" #include "../op_vkcom.hpp" - +#include "../op_webgpu.hpp" #include #include using std::max; @@ -102,7 +102,8 @@ class SoftMaxLayerImpl CV_FINAL : public SoftmaxLayer (backendId == DNN_BACKEND_HALIDE && haveHalide() && axisRaw == 1) || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH || (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && haveInfEngine() && !logSoftMax) || - (backendId == DNN_BACKEND_VKCOM && haveVulkan()); + (backendId == DNN_BACKEND_VKCOM && haveVulkan()) || + (backendId == DNN_BACKEND_WGPU && haveWGPU()); } #ifdef HAVE_OPENCL @@ -322,6 +323,16 @@ class SoftMaxLayerImpl CV_FINAL : public SoftmaxLayer return Ptr(); } + virtual Ptr initWGPU(const std::vector > &inputs) CV_OVERRIDE + { +// #ifdef HAVE_WEBGPU + webgpu::Tensor in = WGPUTensor(inputs[0]); + int cAxis = clamp(axisRaw, in.dimNum()); + std::shared_ptr op(new webgpu::OpSoftmax(cAxis, logSoftMax)); + return Ptr(new WGPUBackendNode(inputs, op)); +// #endif // HAVE_WEBGPU + return Ptr(); + } virtual Ptr initHalide(const std::vector > &inputs) CV_OVERRIDE { diff --git a/modules/dnn/src/op_webgpu.cpp b/modules/dnn/src/op_webgpu.cpp new file mode 100644 index 000000000000..ddc876e2978e --- /dev/null +++ b/modules/dnn/src/op_webgpu.cpp @@ -0,0 +1,158 @@ +#include "precomp.hpp" +#include +#include "op_webgpu.hpp" + +namespace cv +{ +namespace dnn +{ +// #ifdef HAVE_WEBGPU +void copyToTensor(webgpu::Tensor &dst, const Mat &src) +{ + CV_Assert(src.isContinuous() && src.type() == CV_32F); + + std::vector mat_shape = shape(src); + dst.reshape((const char*)src.data, mat_shape); +} + +void copyToMat(Mat &dst, webgpu::Tensor &src) +{ + CV_Assert(dst.type() == CV_32F); + + std::vector shape = src.getShape(); + void *data = const_cast(src.mapRead() ); + Mat tmp(shape, CV_32F, data); + tmp.copyTo(dst); + src.unMap(); +} + +webgpu::Tensor WGPUTensor(const Ptr& ptr) +{ + CV_Assert(!ptr.empty()); + return ptr.dynamicCast()->getTensor(); +} + +std::vector WGPUTensors(const std::vector >& ptrs) +{ + std::vector vec; + vec.reserve(ptrs.size()); + for(const Ptr& ptr : ptrs) { + vec.push_back(WGPUTensor(ptr)); + } + return vec; +} + +WGPUBackendWrapper::WGPUBackendWrapper(Mat& m) +: BackendWrapper(DNN_BACKEND_WGPU, DNN_TARGET_WGPU) +{ + copyToTensor(tensor, m); + host = &m; + hostDirty = false; + deviceDirty = false; +} + +WGPUBackendWrapper::WGPUBackendWrapper(const Ptr& baseBuffer, Mat& m) + : BackendWrapper(DNN_BACKEND_WGPU, DNN_TARGET_WGPU) +{ + Ptr base = baseBuffer.dynamicCast(); + CV_Assert(!base.empty()); + + host = &m; + tensor = base->tensor; + CV_Assert(tensor.count() >= m.total()); + tensor.reshape(0, shape(m)); + hostDirty = false; + deviceDirty = false; +} + +void WGPUBackendWrapper::copyToHost() +{ + if(deviceDirty) + { + copyToMat(*host, tensor); + deviceDirty = false; + } +} + +void WGPUBackendWrapper::copyToDevice() +{ + if(hostDirty) + { + copyToTensor(tensor, *host); + hostDirty = false; + } +} + +void WGPUBackendWrapper::setHostDirty() +{ + hostDirty = true; +} + +void WGPUBackendWrapper::setDeviceDirty() +{ + deviceDirty = true; +} + +webgpu::Tensor WGPUBackendWrapper::getTensor() +{ + return tensor; +} + +WGPUBackendNode::WGPUBackendNode(const std::vector >& inputsWrapper, + const std::shared_ptr &op, + const std::vector >& blobsWrapper) + :BackendNode(DNN_BACKEND_WGPU) +{ + operation = op; + inputsWrapper_ = inputsWrapper; + ins = WGPUTensors(inputsWrapper_); + if(!blobsWrapper.empty()) { + blobs = WGPUTensors(blobsWrapper); + } +} + +bool WGPUBackendNode::forward(std::vector& outs) +{ + for(int i = 0; i < inputsWrapper_.size(); i ++) { + inputsWrapper_[i].dynamicCast()->copyToDevice(); + } + + return operation->forward(ins, blobs, outs); +} + +// #endif //HAVE_WEBGPU + +void setBackendWrappersDirty(std::vector >& ptrs) +{ + for (const Ptr& ptr : ptrs) + { + ptr.dynamicCast()->setDeviceDirty(); + } +} + +void forwardWGPU(std::vector > &outputs, + const Ptr& node) +{ +// #ifdef HAVE_WEBGPU + CV_Assert(!node.empty()); + + Ptr node_ = node.dynamicCast(); + std::vector outs = WGPUTensors(outputs); + node_->forward(outs); + setBackendWrappersDirty(outputs); + +// #endif +} + + bool haveWGPU() + { +#ifdef HAVE_WEBGPU + return webgpu::isAvailable(); +#else + return false; +#endif // HAVE_WEBGPU + } + +} //namespace dnn + +} //namespace cv \ No newline at end of file diff --git a/modules/dnn/src/op_webgpu.hpp b/modules/dnn/src/op_webgpu.hpp new file mode 100644 index 000000000000..089da35e09fd --- /dev/null +++ b/modules/dnn/src/op_webgpu.hpp @@ -0,0 +1,66 @@ +#ifndef OPENCV_DNN_OP_WEBGPU_HPP +#define OPENCV_DNN_OP_WEBGPU_HPP + +#include +// #ifdef HAVE_WEBGP&U +#include "webgpu/include/wgpucom.hpp" +// #endif // HAVE_WEBGPU + +namespace cv +{ +namespace dnn +{ +// #ifdef HAVE_WEBGPU + std::vector WGPUTensors( + const std::vector >& ptrs); + webgpu::Tensor WGPUTensor(const Ptr& ptr); + void copyToTensor(webgpu::Tensor &dst, const Mat &src); + + void copyToMat(Mat &dst, const webgpu::Tensor &src); + + class WGPUBackendWrapper : public BackendWrapper + { + public: + WGPUBackendWrapper(Mat& m); + WGPUBackendWrapper(const Ptr& baseBuffer, Mat& m); + + virtual void copyToHost() CV_OVERRIDE; + virtual void setHostDirty() CV_OVERRIDE; + void setDeviceDirty(); + void copyToDevice(); + webgpu::Tensor getTensor(); + + private: + webgpu::Tensor tensor; + Mat* host; + bool hostDirty; + bool deviceDirty; + }; + + class WGPUBackendNode : public BackendNode + { + public: + WGPUBackendNode(const std::vector >& inputsWrapper, + const std::shared_ptr &op, + const std::vector >& blobsWrapper = + std::vector >()); + + bool forward(std::vector& outs); + + private: + std::vector ins; + std::vector blobs; + std::vector > inputsWrapper_; + std::shared_ptr operation; + }; +// #endif //HAVE_WEBGPU + + void forwardWGPU(std::vector > &outputs, + const Ptr& node); + + bool haveWGPU(); +} // namespace dnn + +} //namespace cv + +#endif //OPENCV_DNN_OP_WEBGPU_HPP diff --git a/modules/dnn/src/precomp.hpp b/modules/dnn/src/precomp.hpp index eacbd6566c04..4390264e5590 100644 --- a/modules/dnn/src/precomp.hpp +++ b/modules/dnn/src/precomp.hpp @@ -40,7 +40,6 @@ //M*/ #include -#include "cvconfig.h" #ifndef CV_OCL4DNN #define CV_OCL4DNN 0 @@ -66,11 +65,6 @@ #undef HAVE_CUDA #endif -#include -#include - #include #include -#include - -#include "dnn_common.hpp" +#include \ No newline at end of file diff --git a/modules/dnn/src/webgpu/dawn/dawnUtils.cpp b/modules/dnn/src/webgpu/dawn/dawnUtils.cpp new file mode 100644 index 000000000000..22862d45936f --- /dev/null +++ b/modules/dnn/src/webgpu/dawn/dawnUtils.cpp @@ -0,0 +1,118 @@ +#include +// #ifdef HAVE_WEBGPU +#include +#include +#include +#include +#include "opencv2/core/base.hpp" +#include "dawnUtils.hpp" +// #endif +#include +#include +#include +#include +#include +#include +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU + +static dawn_native::Instance* instance; +static wgpu::BackendType backendType = wgpu::BackendType::Vulkan; + +void PrintDeviceError(WGPUErrorType errorType, const char* message, void*) { + String errorTypeName = ""; + switch (errorType) { + case WGPUErrorType_Validation: + errorTypeName = "WGPUErrorTyp Validation"; + break; + case WGPUErrorType_OutOfMemory: + errorTypeName = "WGPUErrorTyp Out of memory"; + break; + case WGPUErrorType_Unknown: + errorTypeName = "WGPUErrorTyp Unknown"; + break; + case WGPUErrorType_DeviceLost: + errorTypeName = "WGPUErrorTyp Device lost"; + break; + default: + errorTypeName = "WGPUErrorTyp Unknown"; + return; + } + errorTypeName += " Error message:"; + errorTypeName += message; + CV_Error(Error::StsError, errorTypeName); +} + +wgpu::Device createCppDawnDevice() { + instance = new dawn_native::Instance(); + instance->DiscoverDefaultAdapters(); + // Get an adapter for the backend to use, and create the device. + dawn_native::Adapter backendAdapter; + { + std::vector adapters = instance->GetAdapters(); + auto adapterIt = std::find_if(adapters.begin(), adapters.end(), + [](const dawn_native::Adapter adapter) -> bool { + wgpu::AdapterProperties properties; + adapter.GetProperties(&properties); + return properties.backendType == backendType; + }); + backendAdapter = *adapterIt; + } + WGPUDevice backendDevice = backendAdapter.CreateDevice(); + DawnProcTable backendProcs = dawn_native::GetProcs(); + dawnProcSetProcs(&backendProcs); + backendProcs.deviceSetUncapturedErrorCallback(backendDevice, PrintDeviceError, nullptr); + return wgpu::Device::Acquire(backendDevice); +} + +wgpu::Buffer CreateBufferFromData(const wgpu::Device& device, + const void* data, + size_t size, + wgpu::BufferUsage usage) { + wgpu::BufferDescriptor descriptor; + descriptor.size = size; + descriptor.usage = usage | wgpu::BufferUsage::CopyDst; + + wgpu::Buffer buffer = device.CreateBuffer(&descriptor); + buffer.SetSubData(0, size, data); + return buffer; +} + +wgpu::CreateBufferMappedResult CreateBufferMappedFromData(const wgpu::Device& device, + const void* data, + size_t size, + wgpu::BufferUsage usage){ + wgpu::BufferDescriptor descriptor = {}; + descriptor.size = size; + descriptor.usage = usage | wgpu::BufferUsage::CopyDst; + wgpu::CreateBufferMappedResult result = device.CreateBufferMapped(&descriptor); + if(data) { memcpy(result.data, data, size); } + return result; +} + +wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device, + const wgpu::BindGroupLayout* bindGroupLayout) { + wgpu::PipelineLayoutDescriptor descriptor; + if (bindGroupLayout != nullptr) { + descriptor.bindGroupLayoutCount = 1; + descriptor.bindGroupLayouts = bindGroupLayout; + } else { + descriptor.bindGroupLayoutCount = 0; + descriptor.bindGroupLayouts = nullptr; + } + return device.CreatePipelineLayout(&descriptor); +} + +wgpu::BindGroupLayout MakeBindGroupLayout( + const wgpu::Device& device, + std::vector entriesInitializer) { + wgpu::BindGroupLayoutDescriptor descriptor; + descriptor.entryCount = static_cast(entriesInitializer.size()); + descriptor.entries = entriesInitializer.data(); + return device.CreateBindGroupLayout(&descriptor); +} + +// #endif //HAVE_WEBGPU + +}}} //namespace cv::dnn::webgpu \ No newline at end of file diff --git a/modules/dnn/src/webgpu/dawn/dawnUtils.hpp b/modules/dnn/src/webgpu/dawn/dawnUtils.hpp new file mode 100644 index 000000000000..ca7151ad9983 --- /dev/null +++ b/modules/dnn/src/webgpu/dawn/dawnUtils.hpp @@ -0,0 +1,32 @@ +// #ifdef HAVE_WEBGPU +#include +// #endif +#include +#include +#include +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU + +wgpu::Device createCppDawnDevice(); + +wgpu::Buffer CreateBufferFromData(const wgpu::Device& device, + const void* data, + size_t size, + wgpu::BufferUsage usage); + +wgpu::CreateBufferMappedResult CreateBufferMappedFromData(const wgpu::Device& device, + const void* data, + size_t size, + wgpu::BufferUsage usage); + +wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device, + const wgpu::BindGroupLayout* bindGroupLayout); + +wgpu::BindGroupLayout MakeBindGroupLayout( + const wgpu::Device& device, + std::vector entriesInitializer); + +// #endif //HAVE_WEBGPU + +}}} // namespace cv::dnn::webgpu \ No newline at end of file diff --git a/modules/dnn/src/webgpu/dawnAPITest/CMakeLists.txt b/modules/dnn/src/webgpu/dawnAPITest/CMakeLists.txt new file mode 100644 index 000000000000..41ed5c90fe09 --- /dev/null +++ b/modules/dnn/src/webgpu/dawnAPITest/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.10) +project(WEBGPU VERSION 1.0) +set(OPENCV_SOURCE_DIR "/home/webml/GSoC/Forked/opencv") + +set(WEBGPU_INCLUDE_DIRS "${OPENCV_SOURCE_DIR}/3rdparty/include/webgpu/include") +set(WEBGPU_LIBRARIES "${OPENCV_SOURCE_DIR}/3rdparty/include/webgpu/lib") + +add_executable(WEBGPU helloCompute.cpp ${WEBGPU_LIBRARIES}/webgpu_cpp.cpp) +set_property(TARGET WEBGPU PROPERTY CXX_STANDARD 14) +include_directories(${WEBGPU_INCLUDE_DIRS} ) +target_link_directories(WEBGPU PUBLIC ${WEBGPU_LIBRARIES}) +target_link_libraries(WEBGPU PUBLIC dawn_wire dawn_proc dawn_native ) \ No newline at end of file diff --git a/modules/dnn/src/webgpu/dawnAPITest/helloCompute.cpp b/modules/dnn/src/webgpu/dawnAPITest/helloCompute.cpp new file mode 100644 index 000000000000..1e6b93ad359e --- /dev/null +++ b/modules/dnn/src/webgpu/dawnAPITest/helloCompute.cpp @@ -0,0 +1,319 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// Refer to https://developers.google.com/web/updates/2019/08/get-started-with-gpu-compute-on-the-web +const char* computeShaderCode = R"(#version 450 + + layout(std430, set = 0, binding = 0) readonly buffer FirstMatrix { + vec2 size; + float numbers[]; + } firstMatrix; + + layout(std430, set = 0, binding = 1) readonly buffer SecondMatrix { + vec2 size; + float numbers[]; + } secondMatrix; + + layout(std430, set = 0, binding = 2) buffer ResultMatrix { + vec2 size; + float numbers[]; + } resultMatrix; + + void main() { + resultMatrix.size = vec2(firstMatrix.size.x, secondMatrix.size.y); + + ivec2 resultCell = ivec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y); + float result = 0.0; + for (int i = 0; i < firstMatrix.size.y; i++) { + int a = i + resultCell.x * int(firstMatrix.size.y); + int b = resultCell.y + i * int(secondMatrix.size.y); + result += firstMatrix.numbers[a] * secondMatrix.numbers[b]; + } + + int index = resultCell.y + resultCell.x * int(secondMatrix.size.y); + resultMatrix.numbers[index] = result; + } +)"; +const uint32_t shaderBuffer[705] = { + 0x07230203,0x00010000,0x00080009,0x0000006a,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x00000026,0x00060010,0x00000004, + 0x00000011,0x00000001,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000009,0x75736552,0x614d746c,0x78697274, + 0x00000000,0x00050006,0x00000009,0x00000000,0x657a6973,0x00000000,0x00050006,0x00000009, + 0x00000001,0x626d756e,0x00737265,0x00060005,0x0000000b,0x75736572,0x614d746c,0x78697274, + 0x00000000,0x00050005,0x0000000f,0x73726946,0x74614d74,0x00786972,0x00050006,0x0000000f, + 0x00000000,0x657a6973,0x00000000,0x00050006,0x0000000f,0x00000001,0x626d756e,0x00737265, + 0x00050005,0x00000011,0x73726966,0x74614d74,0x00786972,0x00060005,0x00000018,0x6f636553, + 0x614d646e,0x78697274,0x00000000,0x00050006,0x00000018,0x00000000,0x657a6973,0x00000000, + 0x00050006,0x00000018,0x00000001,0x626d756e,0x00737265,0x00060005,0x0000001a,0x6f636573, + 0x614d646e,0x78697274,0x00000000,0x00050005,0x00000023,0x75736572,0x6543746c,0x00006c6c, + 0x00080005,0x00000026,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044, + 0x00040005,0x00000030,0x75736572,0x0000746c,0x00030005,0x00000033,0x00000069,0x00030005, + 0x0000003f,0x00000061,0x00030005,0x00000048,0x00000062,0x00040005,0x0000005d,0x65646e69, + 0x00000078,0x00040047,0x00000008,0x00000006,0x00000004,0x00050048,0x00000009,0x00000000, + 0x00000023,0x00000000,0x00050048,0x00000009,0x00000001,0x00000023,0x00000008,0x00030047, + 0x00000009,0x00000003,0x00040047,0x0000000b,0x00000022,0x00000000,0x00040047,0x0000000b, + 0x00000021,0x00000002,0x00040047,0x0000000e,0x00000006,0x00000004,0x00040048,0x0000000f, + 0x00000000,0x00000018,0x00050048,0x0000000f,0x00000000,0x00000023,0x00000000,0x00040048, + 0x0000000f,0x00000001,0x00000018,0x00050048,0x0000000f,0x00000001,0x00000023,0x00000008, + 0x00030047,0x0000000f,0x00000003,0x00040047,0x00000011,0x00000022,0x00000000,0x00040047, + 0x00000011,0x00000021,0x00000000,0x00040047,0x00000017,0x00000006,0x00000004,0x00040048, + 0x00000018,0x00000000,0x00000018,0x00050048,0x00000018,0x00000000,0x00000023,0x00000000, + 0x00040048,0x00000018,0x00000001,0x00000018,0x00050048,0x00000018,0x00000001,0x00000023, + 0x00000008,0x00030047,0x00000018,0x00000003,0x00040047,0x0000001a,0x00000022,0x00000000, + 0x00040047,0x0000001a,0x00000021,0x00000001,0x00040047,0x00000026,0x0000000b,0x0000001c, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040017,0x00000007,0x00000006,0x00000002,0x0003001d,0x00000008,0x00000006,0x0004001e, + 0x00000009,0x00000007,0x00000008,0x00040020,0x0000000a,0x00000002,0x00000009,0x0004003b, + 0x0000000a,0x0000000b,0x00000002,0x00040015,0x0000000c,0x00000020,0x00000001,0x0004002b, + 0x0000000c,0x0000000d,0x00000000,0x0003001d,0x0000000e,0x00000006,0x0004001e,0x0000000f, + 0x00000007,0x0000000e,0x00040020,0x00000010,0x00000002,0x0000000f,0x0004003b,0x00000010, + 0x00000011,0x00000002,0x00040015,0x00000012,0x00000020,0x00000000,0x0004002b,0x00000012, + 0x00000013,0x00000000,0x00040020,0x00000014,0x00000002,0x00000006,0x0003001d,0x00000017, + 0x00000006,0x0004001e,0x00000018,0x00000007,0x00000017,0x00040020,0x00000019,0x00000002, + 0x00000018,0x0004003b,0x00000019,0x0000001a,0x00000002,0x0004002b,0x00000012,0x0000001b, + 0x00000001,0x00040020,0x0000001f,0x00000002,0x00000007,0x00040017,0x00000021,0x0000000c, + 0x00000002,0x00040020,0x00000022,0x00000007,0x00000021,0x00040017,0x00000024,0x00000012, + 0x00000003,0x00040020,0x00000025,0x00000001,0x00000024,0x0004003b,0x00000025,0x00000026, + 0x00000001,0x00040020,0x00000027,0x00000001,0x00000012,0x00040020,0x0000002f,0x00000007, + 0x00000006,0x0004002b,0x00000006,0x00000031,0x00000000,0x00040020,0x00000032,0x00000007, + 0x0000000c,0x00020014,0x0000003d,0x0004002b,0x0000000c,0x00000051,0x00000001,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000022, + 0x00000023,0x00000007,0x0004003b,0x0000002f,0x00000030,0x00000007,0x0004003b,0x00000032, + 0x00000033,0x00000007,0x0004003b,0x00000032,0x0000003f,0x00000007,0x0004003b,0x00000032, + 0x00000048,0x00000007,0x0004003b,0x00000032,0x0000005d,0x00000007,0x00060041,0x00000014, + 0x00000015,0x00000011,0x0000000d,0x00000013,0x0004003d,0x00000006,0x00000016,0x00000015, + 0x00060041,0x00000014,0x0000001c,0x0000001a,0x0000000d,0x0000001b,0x0004003d,0x00000006, + 0x0000001d,0x0000001c,0x00050050,0x00000007,0x0000001e,0x00000016,0x0000001d,0x00050041, + 0x0000001f,0x00000020,0x0000000b,0x0000000d,0x0003003e,0x00000020,0x0000001e,0x00050041, + 0x00000027,0x00000028,0x00000026,0x00000013,0x0004003d,0x00000012,0x00000029,0x00000028, + 0x0004007c,0x0000000c,0x0000002a,0x00000029,0x00050041,0x00000027,0x0000002b,0x00000026, + 0x0000001b,0x0004003d,0x00000012,0x0000002c,0x0000002b,0x0004007c,0x0000000c,0x0000002d, + 0x0000002c,0x00050050,0x00000021,0x0000002e,0x0000002a,0x0000002d,0x0003003e,0x00000023, + 0x0000002e,0x0003003e,0x00000030,0x00000031,0x0003003e,0x00000033,0x0000000d,0x000200f9, + 0x00000034,0x000200f8,0x00000034,0x000400f6,0x00000036,0x00000037,0x00000000,0x000200f9, + 0x00000038,0x000200f8,0x00000038,0x0004003d,0x0000000c,0x00000039,0x00000033,0x0004006f, + 0x00000006,0x0000003a,0x00000039,0x00060041,0x00000014,0x0000003b,0x00000011,0x0000000d, + 0x0000001b,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x000500b8,0x0000003d,0x0000003e, + 0x0000003a,0x0000003c,0x000400fa,0x0000003e,0x00000035,0x00000036,0x000200f8,0x00000035, + 0x0004003d,0x0000000c,0x00000040,0x00000033,0x00050041,0x00000032,0x00000041,0x00000023, + 0x00000013,0x0004003d,0x0000000c,0x00000042,0x00000041,0x00060041,0x00000014,0x00000043, + 0x00000011,0x0000000d,0x0000001b,0x0004003d,0x00000006,0x00000044,0x00000043,0x0004006e, + 0x0000000c,0x00000045,0x00000044,0x00050084,0x0000000c,0x00000046,0x00000042,0x00000045, + 0x00050080,0x0000000c,0x00000047,0x00000040,0x00000046,0x0003003e,0x0000003f,0x00000047, + 0x00050041,0x00000032,0x00000049,0x00000023,0x0000001b,0x0004003d,0x0000000c,0x0000004a, + 0x00000049,0x0004003d,0x0000000c,0x0000004b,0x00000033,0x00060041,0x00000014,0x0000004c, + 0x0000001a,0x0000000d,0x0000001b,0x0004003d,0x00000006,0x0000004d,0x0000004c,0x0004006e, + 0x0000000c,0x0000004e,0x0000004d,0x00050084,0x0000000c,0x0000004f,0x0000004b,0x0000004e, + 0x00050080,0x0000000c,0x00000050,0x0000004a,0x0000004f,0x0003003e,0x00000048,0x00000050, + 0x0004003d,0x0000000c,0x00000052,0x0000003f,0x00060041,0x00000014,0x00000053,0x00000011, + 0x00000051,0x00000052,0x0004003d,0x00000006,0x00000054,0x00000053,0x0004003d,0x0000000c, + 0x00000055,0x00000048,0x00060041,0x00000014,0x00000056,0x0000001a,0x00000051,0x00000055, + 0x0004003d,0x00000006,0x00000057,0x00000056,0x00050085,0x00000006,0x00000058,0x00000054, + 0x00000057,0x0004003d,0x00000006,0x00000059,0x00000030,0x00050081,0x00000006,0x0000005a, + 0x00000059,0x00000058,0x0003003e,0x00000030,0x0000005a,0x000200f9,0x00000037,0x000200f8, + 0x00000037,0x0004003d,0x0000000c,0x0000005b,0x00000033,0x00050080,0x0000000c,0x0000005c, + 0x0000005b,0x00000051,0x0003003e,0x00000033,0x0000005c,0x000200f9,0x00000034,0x000200f8, + 0x00000036,0x00050041,0x00000032,0x0000005e,0x00000023,0x0000001b,0x0004003d,0x0000000c, + 0x0000005f,0x0000005e,0x00050041,0x00000032,0x00000060,0x00000023,0x00000013,0x0004003d, + 0x0000000c,0x00000061,0x00000060,0x00060041,0x00000014,0x00000062,0x0000001a,0x0000000d, + 0x0000001b,0x0004003d,0x00000006,0x00000063,0x00000062,0x0004006e,0x0000000c,0x00000064, + 0x00000063,0x00050084,0x0000000c,0x00000065,0x00000061,0x00000064,0x00050080,0x0000000c, + 0x00000066,0x0000005f,0x00000065,0x0003003e,0x0000005d,0x00000066,0x0004003d,0x0000000c, + 0x00000067,0x0000005d,0x0004003d,0x00000006,0x00000068,0x00000030,0x00060041,0x00000014, + 0x00000069,0x0000000b,0x00000051,0x00000067,0x0003003e,0x00000069,0x00000068,0x000100fd, + 0x00010038 +}; + +void PrintDeviceError(WGPUErrorType errorType, const char* message, void*) { + std::string errorTypeName = ""; + switch (errorType) { + case WGPUErrorType_Validation: + errorTypeName = "WGPUErrorTyp Validation"; + break; + case WGPUErrorType_OutOfMemory: + errorTypeName = "WGPUErrorTyp Out of memory"; + break; + case WGPUErrorType_Unknown: + errorTypeName = "WGPUErrorTyp Unknown"; + break; + case WGPUErrorType_DeviceLost: + errorTypeName = "WGPUErrorTyp Device lost"; + break; + default : + errorTypeName = "WGPUErrorTyp Unknown"; + return; + } + std::cout<<"Device error:" << errorTypeName< instance; + instance = std::make_unique(); + instance->DiscoverDefaultAdapters(); + // Get an adapter for the backend to use, and create the device. + dawn_native::Adapter backendAdapter; + { + std::vector adapters = instance->GetAdapters(); + auto adapterIt = std::find_if(adapters.begin(), adapters.end(), + [](const dawn_native::Adapter adapter) -> bool { + wgpu::AdapterProperties properties; + adapter.GetProperties(&properties); + return properties.backendType == backendType; + }); + backendAdapter = *adapterIt; + } + WGPUDevice backendDevice = backendAdapter.CreateDevice(); + DawnProcTable backendProcs = dawn_native::GetProcs(); + dawnProcSetProcs(&backendProcs); + backendProcs.deviceSetUncapturedErrorCallback(backendDevice, PrintDeviceError, nullptr); + return wgpu::Device::Acquire(backendDevice); +} + +wgpu::CreateBufferMappedResult createBufferMappedFromData(wgpu::Device& device, + const void* data, + size_t size, + wgpu::BufferUsage usage){ + wgpu::BufferDescriptor descriptor = {}; + descriptor.size = size; + descriptor.usage = usage | wgpu::BufferUsage::CopyDst; + wgpu::CreateBufferMappedResult result = device.CreateBufferMapped(&descriptor); + memcpy(result.data, data, size); + return result; +} + +void readBufferMapReadCallback(WGPUBufferMapAsyncStatus status, + const void* ptr, + uint64_t dataLength, + void* userdata) { + (void)status; + (void)userdata; + printf("resultMatrix: ["); + size_t num = dataLength / sizeof(float); + for (size_t i = 0; i < num; ++i) { + printf("%f", ((const float*)ptr)[i]); + if (i != num - 1) + printf(", "); + } + printf("]\n"); +} + +int main(int /*argc*/, char** /*argv*/) +{ + wgpu::Device device = createCppDawnDevice(); + wgpu::Queue queue = device.GetDefaultQueue(); + // create buffer + wgpu::Buffer inputsBuffer1, inputsBuffer2; + wgpu::Buffer resultBuffer,gpuReadBuffer; + float const inputData1[] = { 2 /* rows */, 4 /* columns */, + 1, 2, 3, 4, 5, 6, 7, 8}; + float const inputData2[] = { 4 /* rows */, 2 /* columns */, + 1, 2, 3, 4, 5, 6, 7, 8}; + + wgpu::BufferDescriptor desc0 = {}; + desc0.size = sizeof(inputData1); + desc0.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst; + inputsBuffer1 =device.CreateBuffer(&desc0); + inputsBuffer1.SetSubData(0, sizeof(inputData1), inputData1); + + wgpu::BufferDescriptor desc1 = {}; + desc1.size = sizeof(inputData2); + desc1.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst; + inputsBuffer2 =device.CreateBuffer(&desc1); + inputsBuffer2.SetSubData(0, sizeof(inputData2), inputData2); + + wgpu::BufferDescriptor desc2 = {}; + desc2.size = sizeof(float) * 6; + desc2.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc; + resultBuffer = device.CreateBuffer(& desc2); + + wgpu::BufferDescriptor desc3 = {}; + desc3.size = sizeof(float) * 6; + desc3.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead; + gpuReadBuffer = device.CreateBuffer(& desc3); + + std::cout << "buffer create succeed" < bglEntries { + {0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}, + {1, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}, + {2, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}; + wgpu::BindGroupLayoutDescriptor bglDesc; + bglDesc.entryCount = static_cast(bglEntries.size()); + bglDesc.entries = bglEntries.data(); + wgpu::BindGroupLayout bgl = device.CreateBindGroupLayout(&bglDesc); + + std::vector bgEntries { + { 0, inputsBuffer1, 0, sizeof(inputData1), nullptr, nullptr }, + { 1, inputsBuffer2, 0, sizeof(inputData2), nullptr, nullptr }, + { 2, resultBuffer, 0, sizeof(float) * 6, nullptr, nullptr } }; + wgpu::BindGroupDescriptor bgDesc; + bgDesc.layout = bgl; + bgDesc.entryCount = bgEntries.size(); + bgDesc.entries = bgEntries.data(); + wgpu::BindGroup bg = device.CreateBindGroup(&bgDesc); + std::cout<<"create BindGroup succeed"< +#include +#include "../include/op_softmax.hpp" +#include "../src/context.hpp" +#include "../include/wgpucom.hpp" +#include +#include "../src/common.hpp" +#include +using namespace cv::dnn; +void printData(const void * data, int num) { + printf("resultMatrix: ["); + for (size_t i = 0; i < num; ++i) { + printf("%f", ((const float*)data)[i]); + if (i != num - 1) + printf(", "); + } + printf("]\n"); +} +int main(int argc, char** argv ) +{ + webgpu::isAvailable(); + float inputData1[] = {1, 2, 3, 4, 5, 6, 7, 8}; + std::vector shape = {2,4,1}; // outer_size * channels * channel_size + + webgpu::Tensor input(inputData1, shape, webgpu::Format::wFormatFp32); + webgpu::Tensor out(nullptr, shape, webgpu::Format::wFormatFp32); + + webgpu::OpSoftmax op1(1, false); + op1.forward(input, out); + + const void * result = out.getBuffer()->MapReadAsyncAndWait(); + out.unMap(); + printData(result, out.size()/sizeof(float)); + std::cout<<"Finish"< +#include +#include +// #endif +namespace cv { namespace dnn { namespace webgpu { + +class Buffer +{ +// #ifdef HAVE_WEBGPU +public: + Buffer(const std::shared_ptr device); + Buffer(const std::shared_ptr device, + const void* data, size_t size, + wgpu::BufferUsage usage = wgpu::BufferUsage::Storage | + wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::CopySrc); + Buffer(const void* data, size_t size, + wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst); + ~Buffer() + { + if(buffer_) buffer_.Release(); + if(gpuReadBuffer_) gpuReadBuffer_.Release(); + } + wgpu::Buffer * getWebGPUBuffer() { return & buffer_; } + wgpu::BufferUsage getBufferUsage() { return usage_;} + + static void BufferMapReadCallback(WGPUBufferMapAsyncStatus status, + const void* data, + uint64_t dataLength, + void* userdata) + { + static_cast(userdata)->mappedData = data; + } + void setBufferData(const void * data, size_t size); + const void* MapReadAsyncAndWait(); + void unMap() { if(gpuReadBuffer_) gpuReadBuffer_.Unmap(); } + size_t getSize() { return size_; } +private: + Buffer(); + std::shared_ptr device_; + wgpu::Buffer buffer_; + wgpu::Buffer gpuReadBuffer_ = nullptr; + wgpu::BufferUsage usage_; + size_t size_; + const void * mappedData = nullptr; +}; + +// #endif //HAVE_WEBGPU + +}}} //namespace cv::dnn::webgpu + +#endif //OPENCV_DNN_WEBGPU_OP_BASE_HPP \ No newline at end of file diff --git a/modules/dnn/src/webgpu/include/op_base.hpp b/modules/dnn/src/webgpu/include/op_base.hpp new file mode 100644 index 000000000000..90ba108371e1 --- /dev/null +++ b/modules/dnn/src/webgpu/include/op_base.hpp @@ -0,0 +1,60 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_DNN_WEBGPU_OP_BASE_HPP +#define OPENCV_DNN_WEBGPU_OP_BASE_HPP + +#include "../../precomp.hpp" +#include "wgpucom.hpp" +#include "../dawn/dawnUtils.hpp" +#include "tensor.hpp" + +namespace cv { namespace dnn { namespace webgpu { +// #ifdef HAVE_WEBGPU +class Context; +class Tensor; +class OpBase +{ +public: + OpBase(); + virtual ~OpBase(); + virtual bool forward(std::vector& ins, + std::vector& blobs, + std::vector& outs) = 0; + +protected: + void createBindGroupLayout(int buffer_num); + void createBindGroup(); + void createShaderModule(const uint32_t* spv, + uint32_t size, + const std::string& source = std::string()); + void createComputePipeline(); + void createCommandBuffer(); + void runCommandBuffer(); + wgpu::FenceCompletionStatus WaitForCompletedValue(wgpu::Fence fence, + uint64_t completedValue); + + std::shared_ptr device_; + wgpu::ComputePipeline pipeline_; + wgpu::CommandBuffer cmd_buffer_; + wgpu::BindGroupLayout bindgrouplayout_; + wgpu::BindGroup bindgroup_; + wgpu::ShaderModule module_; + wgpu::PipelineLayout pipeline_layout_; + std::vector bgEntries; + + bool needsUniform = true; + uint32_t group_x_; + uint32_t group_y_; + uint32_t group_z_; + std::string type_; +}; +// #endif //HAVE_WEBGPU + +}}} //namespace cv::dnn::webgpu + +#endif //OPENCV_DNN_WEBGPU_OP_BASE_HPP diff --git a/modules/dnn/src/webgpu/include/op_softmax.hpp b/modules/dnn/src/webgpu/include/op_softmax.hpp new file mode 100644 index 000000000000..5f2d5424d9b0 --- /dev/null +++ b/modules/dnn/src/webgpu/include/op_softmax.hpp @@ -0,0 +1,48 @@ +#ifndef OPENCV_DNN_WGPU_OP_SOFTMAX_HPP +#define OPENCV_DNN_WGPU_OP_SOFTMAX_HPP +#include "wgpucom.hpp" +#include "op_base.hpp" +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU + +struct SoftmaxShaderConfig +{ + int local_size_x; + int local_size_y; + int local_size_z; + int block_height; + int block_width; + int block_depth; +}; + +class OpSoftmax: public OpBase +{ +public: + OpSoftmax(const int axis, const bool log_softmax = false); + ~OpSoftmax(); + void reshapeOutTensor(Tensor& in, Tensor& out); + bool forward(Tensor& in, Tensor& out); + virtual bool forward(std::vector& ins, + std::vector& blobs, + std::vector& outs) CV_OVERRIDE; +private: + bool init(const int axis, const bool log_softmax); + bool computeGroupCount(); + + int axis_; + int channels_; + int channel_size_; + int outer_size_; + bool log_softmax_; + Tensor* max_tensor_ = nullptr; + Tensor* sum_tensor_ = nullptr; + Buffer* uniformBuffer_; + SoftmaxShaderConfig config_; +}; + +// #endif // HAVE_WEBGPU + +}}} // namespace cv::dnn::webgpu + +#endif // OPENCV_DNN_WGPU_OP_SOFTMAX_HPP diff --git a/modules/dnn/src/webgpu/include/tensor.hpp b/modules/dnn/src/webgpu/include/tensor.hpp new file mode 100644 index 000000000000..505fe5395a69 --- /dev/null +++ b/modules/dnn/src/webgpu/include/tensor.hpp @@ -0,0 +1,49 @@ +#ifndef OPENCV_DNN_WEBGPU_TENSOR_HPP +#define OPENCV_DNN_WEBGPU_TENSOR_HPP +// #ifdef HAVE_WEBGPU +#include +// #endif +#include"buffer.hpp" +#include"wgpucom.hpp" +#include +namespace cv { namespace dnn { namespace webgpu { +// #ifdef HAVE_WEBGPU +class Buffer; +class Tensor{ +public: + Tensor(Format fmt = wFormatFp32); + Tensor(const void* data, std::vector& shape, + Format fmt = wFormatFp32); + const void* mapRead(); + void unMap(); + Shape getShape() const; + int dimSize(const int dim) const; + int dimNum() const; + int count(const int start_axis = 0, const int end_axis = -1) const; + // Change shape and format to as passed in. + // Copy data if data != NULL + // Allocate new internal buffer if new size > old size or alloc flag is true + Tensor reshape(const void* data, const std::vector& shape, + bool alloc = false, + Format fmt = wFormatInvalid); + Tensor fillData(const void * data); + int getFormat() const; + size_t size() const { return size_in_byte_; } + bool isEmpty() { return size_in_byte_ == 0 ? true : false; } + void copyTo(Tensor& dst); + std::shared_ptr getBuffer() { return buffer_; } +private: + std::shared_ptr device_; + std::vector shape_; + size_t size_in_byte_; + std::shared_ptr buffer_; + Format format_; + wgpu::BufferUsage usage_ = wgpu::BufferUsage::Storage | + wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; +}; + +// #endif //HAVE_WEBGPU + +}}} //namespace cv::dnn:webgpu + +#endif // OPENCV_DNN_WEBGPU_TENSOR_HPP \ No newline at end of file diff --git a/modules/dnn/src/webgpu/include/wgpucom.hpp b/modules/dnn/src/webgpu/include/wgpucom.hpp new file mode 100644 index 000000000000..6e5d1dde5bf7 --- /dev/null +++ b/modules/dnn/src/webgpu/include/wgpucom.hpp @@ -0,0 +1,67 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_DNN_WEBGPU_HPP +#define OPENCV_DNN_WEBGPU_HPP + +#include + +namespace cv { namespace dnn { namespace webgpu { +//#ifndef HAVE_WEBGPU +enum Format +{ + wFormatInvalid = -1, + wFormatFp16, + wFormatFp32, + wFormatFp64, + wFormatInt32, + wFormatNum +}; + +enum OpType +{ + wOpTypeConv, + wOpTypePool, + wOpTypeDWConv, + wOpTypeLRN, + wOpTypeConcat, + wOpTypeSoftmax, + wOpTypeReLU, + wOpTypePriorBox, + wOpTypePermute, + wOpTypeNum +}; + +enum PaddingMode +{ + wPaddingModeSame, + wPaddingModeValid, + wPaddingModeCaffe, + wPaddingModeNum +}; + +enum FusedActivationType +{ + wNone, + wRelu, + wRelu1, + wRelu6, + wActivationNum +}; + +typedef std::vector Shape; +bool isAvailable(); +//#endif //HAVE_WEBGPU + +}}} //namespace cv::dnn::webgpu + +#include "tensor.hpp" +#include "buffer.hpp" +#include "op_base.hpp" +#include "op_softmax.hpp" + +#endif// OPENCV_DNN_WEBGPU_HPP \ No newline at end of file diff --git a/modules/dnn/src/webgpu/shader/softmax.comp b/modules/dnn/src/webgpu/shader/softmax.comp new file mode 100644 index 000000000000..e5000dfdc6e8 --- /dev/null +++ b/modules/dnn/src/webgpu/shader/softmax.comp @@ -0,0 +1,78 @@ + +#version 450 +#define LOCAL_SZ_X 256 + +layout(binding = 0) buffer buf0{ + float input_buffer[]; // outer_size * channels * channel_size +}; +layout(binding = 1) buffer buf1{ + float max_buffer[]; // outer_size * channel_size +}; +layout(binding = 2) buffer buf2{ + float sum_buffer[]; // outer_size * channel_size +}; +layout(binding = 3) buffer buf3{ + float output_buffer[]; // outer_size * channels * channel_size +}; +layout(binding = 4) uniform pushBlock { + int channel_size; + int outer_size; + int channels; + int logsoftmax; +} p; +layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + int gid = int(gl_GlobalInvocationID.x); + if (gid >= p.outer_size) return; + + int global_off = gid * p.channels * p.channel_size; + int reduced_buffer_off = gid * p.channel_size; + + // find the max along channel + int index = global_off; + for (int i = 0; i < p.channel_size; ++i) + { + max_buffer[reduced_buffer_off + i] = input_buffer[index]; + index++; + } + for (int c = 1; c < p.channels; ++c) + { + for (int i = 0; i < p.channel_size; ++i) + { + max_buffer[reduced_buffer_off + i] = max(max_buffer[reduced_buffer_off + i], input_buffer[index]); + index++; + } + } + + // subtract, exp and accumulate along channel + for (int i = 0; i < p.channel_size; ++i) + sum_buffer[reduced_buffer_off + i] = 0.f; + + index = global_off; + for (int c = 0; c < p.channels; ++c) + { + for (int i = 0; i < p.channel_size; ++i) + { + float exp_val = exp(input_buffer[index] - max_buffer[reduced_buffer_off + i]); + output_buffer[index] = exp_val; + sum_buffer[reduced_buffer_off + i] += exp_val; + index++; + } + } + + // divide by computed sum + index = global_off; + for (int c = 0; c < p.channels; ++c) + { + for (int i = 0; i < p.channel_size; ++i) + { + float v = output_buffer[index] / sum_buffer[reduced_buffer_off + i]; + if (p.logsoftmax == 1) + v = log(v); + output_buffer[index] = v; + index++; + } + } +} diff --git a/modules/dnn/src/webgpu/shader/softmax_spv.cpp b/modules/dnn/src/webgpu/shader/softmax_spv.cpp new file mode 100644 index 000000000000..b41426363613 --- /dev/null +++ b/modules/dnn/src/webgpu/shader/softmax_spv.cpp @@ -0,0 +1,203 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#include "../../precomp.hpp" + +namespace cv { namespace dnn { namespace webgpu { + +extern const unsigned int softmax_spv[1500] = { + 0x07230203,0x00010000,0x00080009,0x000000f4,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, + 0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00646967,0x00080005,0x0000000c, + 0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005,0x00000013, + 0x68737570,0x636f6c42,0x0000006b,0x00070006,0x00000013,0x00000000,0x6e616863,0x5f6c656e, + 0x657a6973,0x00000000,0x00060006,0x00000013,0x00000001,0x6574756f,0x69735f72,0x0000657a, + 0x00060006,0x00000013,0x00000002,0x6e616863,0x736c656e,0x00000000,0x00060006,0x00000013, + 0x00000003,0x73676f6c,0x6d74666f,0x00007861,0x00030005,0x00000015,0x00000070,0x00050005, + 0x0000001f,0x626f6c67,0x6f5f6c61,0x00006666,0x00070005,0x00000029,0x75646572,0x5f646563, + 0x66667562,0x6f5f7265,0x00006666,0x00040005,0x0000002e,0x65646e69,0x00000078,0x00030005, + 0x00000030,0x00000069,0x00040005,0x0000003c,0x31667562,0x00000000,0x00060006,0x0000003c, + 0x00000000,0x5f78616d,0x66667562,0x00007265,0x00030005,0x0000003e,0x00000000,0x00040005, + 0x00000043,0x30667562,0x00000000,0x00070006,0x00000043,0x00000000,0x75706e69,0x75625f74, + 0x72656666,0x00000000,0x00030005,0x00000045,0x00000000,0x00030005,0x0000004f,0x00000063, + 0x00030005,0x00000059,0x00000069,0x00030005,0x00000076,0x00000069,0x00040005,0x00000081, + 0x32667562,0x00000000,0x00060006,0x00000081,0x00000000,0x5f6d7573,0x66667562,0x00007265, + 0x00030005,0x00000083,0x00000000,0x00030005,0x0000008c,0x00000063,0x00030005,0x00000096, + 0x00000069,0x00040005,0x000000a1,0x5f707865,0x006c6176,0x00040005,0x000000ad,0x33667562, + 0x00000000,0x00070006,0x000000ad,0x00000000,0x7074756f,0x625f7475,0x65666675,0x00000072, + 0x00030005,0x000000af,0x00000000,0x00030005,0x000000c2,0x00000063,0x00030005,0x000000cc, + 0x00000069,0x00030005,0x000000d6,0x00000076,0x00040047,0x0000000c,0x0000000b,0x0000001c, + 0x00050048,0x00000013,0x00000000,0x00000023,0x00000000,0x00050048,0x00000013,0x00000001, + 0x00000023,0x00000004,0x00050048,0x00000013,0x00000002,0x00000023,0x00000008,0x00050048, + 0x00000013,0x00000003,0x00000023,0x0000000c,0x00030047,0x00000013,0x00000002,0x00040047, + 0x00000015,0x00000022,0x00000000,0x00040047,0x00000015,0x00000021,0x00000004,0x00040047, + 0x0000003b,0x00000006,0x00000004,0x00050048,0x0000003c,0x00000000,0x00000023,0x00000000, + 0x00030047,0x0000003c,0x00000003,0x00040047,0x0000003e,0x00000022,0x00000000,0x00040047, + 0x0000003e,0x00000021,0x00000001,0x00040047,0x00000042,0x00000006,0x00000004,0x00050048, + 0x00000043,0x00000000,0x00000023,0x00000000,0x00030047,0x00000043,0x00000003,0x00040047, + 0x00000045,0x00000022,0x00000000,0x00040047,0x00000045,0x00000021,0x00000000,0x00040047, + 0x00000080,0x00000006,0x00000004,0x00050048,0x00000081,0x00000000,0x00000023,0x00000000, + 0x00030047,0x00000081,0x00000003,0x00040047,0x00000083,0x00000022,0x00000000,0x00040047, + 0x00000083,0x00000021,0x00000002,0x00040047,0x000000ac,0x00000006,0x00000004,0x00050048, + 0x000000ad,0x00000000,0x00000023,0x00000000,0x00030047,0x000000ad,0x00000003,0x00040047, + 0x000000af,0x00000022,0x00000000,0x00040047,0x000000af,0x00000021,0x00000003,0x00040047, + 0x000000f3,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, + 0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007,0x00000006, + 0x00040015,0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009,0x00000003, + 0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000001, + 0x0004002b,0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001,0x00000009, + 0x0006001e,0x00000013,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020,0x00000014, + 0x00000002,0x00000013,0x0004003b,0x00000014,0x00000015,0x00000002,0x0004002b,0x00000006, + 0x00000016,0x00000001,0x00040020,0x00000017,0x00000002,0x00000006,0x00020014,0x0000001a, + 0x0004002b,0x00000006,0x00000021,0x00000002,0x0004002b,0x00000006,0x00000025,0x00000000, + 0x00030016,0x0000003a,0x00000020,0x0003001d,0x0000003b,0x0000003a,0x0003001e,0x0000003c, + 0x0000003b,0x00040020,0x0000003d,0x00000002,0x0000003c,0x0004003b,0x0000003d,0x0000003e, + 0x00000002,0x0003001d,0x00000042,0x0000003a,0x0003001e,0x00000043,0x00000042,0x00040020, + 0x00000044,0x00000002,0x00000043,0x0004003b,0x00000044,0x00000045,0x00000002,0x00040020, + 0x00000047,0x00000002,0x0000003a,0x0003001d,0x00000080,0x0000003a,0x0003001e,0x00000081, + 0x00000080,0x00040020,0x00000082,0x00000002,0x00000081,0x0004003b,0x00000082,0x00000083, + 0x00000002,0x0004002b,0x0000003a,0x00000087,0x00000000,0x00040020,0x000000a0,0x00000007, + 0x0000003a,0x0003001d,0x000000ac,0x0000003a,0x0003001e,0x000000ad,0x000000ac,0x00040020, + 0x000000ae,0x00000002,0x000000ad,0x0004003b,0x000000ae,0x000000af,0x00000002,0x0004002b, + 0x00000006,0x000000e0,0x00000003,0x0004002b,0x00000009,0x000000f1,0x00000100,0x0004002b, + 0x00000009,0x000000f2,0x00000001,0x0006002c,0x0000000a,0x000000f3,0x000000f1,0x000000f2, + 0x000000f2,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x00000007,0x00000008,0x00000007,0x0004003b,0x00000007,0x0000001f,0x00000007, + 0x0004003b,0x00000007,0x00000029,0x00000007,0x0004003b,0x00000007,0x0000002e,0x00000007, + 0x0004003b,0x00000007,0x00000030,0x00000007,0x0004003b,0x00000007,0x0000004f,0x00000007, + 0x0004003b,0x00000007,0x00000059,0x00000007,0x0004003b,0x00000007,0x00000076,0x00000007, + 0x0004003b,0x00000007,0x0000008c,0x00000007,0x0004003b,0x00000007,0x00000096,0x00000007, + 0x0004003b,0x000000a0,0x000000a1,0x00000007,0x0004003b,0x00000007,0x000000c2,0x00000007, + 0x0004003b,0x00000007,0x000000cc,0x00000007,0x0004003b,0x000000a0,0x000000d6,0x00000007, + 0x00050041,0x0000000e,0x0000000f,0x0000000c,0x0000000d,0x0004003d,0x00000009,0x00000010, + 0x0000000f,0x0004007c,0x00000006,0x00000011,0x00000010,0x0003003e,0x00000008,0x00000011, + 0x0004003d,0x00000006,0x00000012,0x00000008,0x00050041,0x00000017,0x00000018,0x00000015, + 0x00000016,0x0004003d,0x00000006,0x00000019,0x00000018,0x000500af,0x0000001a,0x0000001b, + 0x00000012,0x00000019,0x000300f7,0x0000001d,0x00000000,0x000400fa,0x0000001b,0x0000001c, + 0x0000001d,0x000200f8,0x0000001c,0x000100fd,0x000200f8,0x0000001d,0x0004003d,0x00000006, + 0x00000020,0x00000008,0x00050041,0x00000017,0x00000022,0x00000015,0x00000021,0x0004003d, + 0x00000006,0x00000023,0x00000022,0x00050084,0x00000006,0x00000024,0x00000020,0x00000023, + 0x00050041,0x00000017,0x00000026,0x00000015,0x00000025,0x0004003d,0x00000006,0x00000027, + 0x00000026,0x00050084,0x00000006,0x00000028,0x00000024,0x00000027,0x0003003e,0x0000001f, + 0x00000028,0x0004003d,0x00000006,0x0000002a,0x00000008,0x00050041,0x00000017,0x0000002b, + 0x00000015,0x00000025,0x0004003d,0x00000006,0x0000002c,0x0000002b,0x00050084,0x00000006, + 0x0000002d,0x0000002a,0x0000002c,0x0003003e,0x00000029,0x0000002d,0x0004003d,0x00000006, + 0x0000002f,0x0000001f,0x0003003e,0x0000002e,0x0000002f,0x0003003e,0x00000030,0x00000025, + 0x000200f9,0x00000031,0x000200f8,0x00000031,0x000400f6,0x00000033,0x00000034,0x00000000, + 0x000200f9,0x00000035,0x000200f8,0x00000035,0x0004003d,0x00000006,0x00000036,0x00000030, + 0x00050041,0x00000017,0x00000037,0x00000015,0x00000025,0x0004003d,0x00000006,0x00000038, + 0x00000037,0x000500b1,0x0000001a,0x00000039,0x00000036,0x00000038,0x000400fa,0x00000039, + 0x00000032,0x00000033,0x000200f8,0x00000032,0x0004003d,0x00000006,0x0000003f,0x00000029, + 0x0004003d,0x00000006,0x00000040,0x00000030,0x00050080,0x00000006,0x00000041,0x0000003f, + 0x00000040,0x0004003d,0x00000006,0x00000046,0x0000002e,0x00060041,0x00000047,0x00000048, + 0x00000045,0x00000025,0x00000046,0x0004003d,0x0000003a,0x00000049,0x00000048,0x00060041, + 0x00000047,0x0000004a,0x0000003e,0x00000025,0x00000041,0x0003003e,0x0000004a,0x00000049, + 0x0004003d,0x00000006,0x0000004b,0x0000002e,0x00050080,0x00000006,0x0000004c,0x0000004b, + 0x00000016,0x0003003e,0x0000002e,0x0000004c,0x000200f9,0x00000034,0x000200f8,0x00000034, + 0x0004003d,0x00000006,0x0000004d,0x00000030,0x00050080,0x00000006,0x0000004e,0x0000004d, + 0x00000016,0x0003003e,0x00000030,0x0000004e,0x000200f9,0x00000031,0x000200f8,0x00000033, + 0x0003003e,0x0000004f,0x00000016,0x000200f9,0x00000050,0x000200f8,0x00000050,0x000400f6, + 0x00000052,0x00000053,0x00000000,0x000200f9,0x00000054,0x000200f8,0x00000054,0x0004003d, + 0x00000006,0x00000055,0x0000004f,0x00050041,0x00000017,0x00000056,0x00000015,0x00000021, + 0x0004003d,0x00000006,0x00000057,0x00000056,0x000500b1,0x0000001a,0x00000058,0x00000055, + 0x00000057,0x000400fa,0x00000058,0x00000051,0x00000052,0x000200f8,0x00000051,0x0003003e, + 0x00000059,0x00000025,0x000200f9,0x0000005a,0x000200f8,0x0000005a,0x000400f6,0x0000005c, + 0x0000005d,0x00000000,0x000200f9,0x0000005e,0x000200f8,0x0000005e,0x0004003d,0x00000006, + 0x0000005f,0x00000059,0x00050041,0x00000017,0x00000060,0x00000015,0x00000025,0x0004003d, + 0x00000006,0x00000061,0x00000060,0x000500b1,0x0000001a,0x00000062,0x0000005f,0x00000061, + 0x000400fa,0x00000062,0x0000005b,0x0000005c,0x000200f8,0x0000005b,0x0004003d,0x00000006, + 0x00000063,0x00000029,0x0004003d,0x00000006,0x00000064,0x00000059,0x00050080,0x00000006, + 0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006,0x00000066,0x00000029,0x0004003d, + 0x00000006,0x00000067,0x00000059,0x00050080,0x00000006,0x00000068,0x00000066,0x00000067, + 0x00060041,0x00000047,0x00000069,0x0000003e,0x00000025,0x00000068,0x0004003d,0x0000003a, + 0x0000006a,0x00000069,0x0004003d,0x00000006,0x0000006b,0x0000002e,0x00060041,0x00000047, + 0x0000006c,0x00000045,0x00000025,0x0000006b,0x0004003d,0x0000003a,0x0000006d,0x0000006c, + 0x0007000c,0x0000003a,0x0000006e,0x00000001,0x00000028,0x0000006a,0x0000006d,0x00060041, + 0x00000047,0x0000006f,0x0000003e,0x00000025,0x00000065,0x0003003e,0x0000006f,0x0000006e, + 0x0004003d,0x00000006,0x00000070,0x0000002e,0x00050080,0x00000006,0x00000071,0x00000070, + 0x00000016,0x0003003e,0x0000002e,0x00000071,0x000200f9,0x0000005d,0x000200f8,0x0000005d, + 0x0004003d,0x00000006,0x00000072,0x00000059,0x00050080,0x00000006,0x00000073,0x00000072, + 0x00000016,0x0003003e,0x00000059,0x00000073,0x000200f9,0x0000005a,0x000200f8,0x0000005c, + 0x000200f9,0x00000053,0x000200f8,0x00000053,0x0004003d,0x00000006,0x00000074,0x0000004f, + 0x00050080,0x00000006,0x00000075,0x00000074,0x00000016,0x0003003e,0x0000004f,0x00000075, + 0x000200f9,0x00000050,0x000200f8,0x00000052,0x0003003e,0x00000076,0x00000025,0x000200f9, + 0x00000077,0x000200f8,0x00000077,0x000400f6,0x00000079,0x0000007a,0x00000000,0x000200f9, + 0x0000007b,0x000200f8,0x0000007b,0x0004003d,0x00000006,0x0000007c,0x00000076,0x00050041, + 0x00000017,0x0000007d,0x00000015,0x00000025,0x0004003d,0x00000006,0x0000007e,0x0000007d, + 0x000500b1,0x0000001a,0x0000007f,0x0000007c,0x0000007e,0x000400fa,0x0000007f,0x00000078, + 0x00000079,0x000200f8,0x00000078,0x0004003d,0x00000006,0x00000084,0x00000029,0x0004003d, + 0x00000006,0x00000085,0x00000076,0x00050080,0x00000006,0x00000086,0x00000084,0x00000085, + 0x00060041,0x00000047,0x00000088,0x00000083,0x00000025,0x00000086,0x0003003e,0x00000088, + 0x00000087,0x000200f9,0x0000007a,0x000200f8,0x0000007a,0x0004003d,0x00000006,0x00000089, + 0x00000076,0x00050080,0x00000006,0x0000008a,0x00000089,0x00000016,0x0003003e,0x00000076, + 0x0000008a,0x000200f9,0x00000077,0x000200f8,0x00000079,0x0004003d,0x00000006,0x0000008b, + 0x0000001f,0x0003003e,0x0000002e,0x0000008b,0x0003003e,0x0000008c,0x00000025,0x000200f9, + 0x0000008d,0x000200f8,0x0000008d,0x000400f6,0x0000008f,0x00000090,0x00000000,0x000200f9, + 0x00000091,0x000200f8,0x00000091,0x0004003d,0x00000006,0x00000092,0x0000008c,0x00050041, + 0x00000017,0x00000093,0x00000015,0x00000021,0x0004003d,0x00000006,0x00000094,0x00000093, + 0x000500b1,0x0000001a,0x00000095,0x00000092,0x00000094,0x000400fa,0x00000095,0x0000008e, + 0x0000008f,0x000200f8,0x0000008e,0x0003003e,0x00000096,0x00000025,0x000200f9,0x00000097, + 0x000200f8,0x00000097,0x000400f6,0x00000099,0x0000009a,0x00000000,0x000200f9,0x0000009b, + 0x000200f8,0x0000009b,0x0004003d,0x00000006,0x0000009c,0x00000096,0x00050041,0x00000017, + 0x0000009d,0x00000015,0x00000025,0x0004003d,0x00000006,0x0000009e,0x0000009d,0x000500b1, + 0x0000001a,0x0000009f,0x0000009c,0x0000009e,0x000400fa,0x0000009f,0x00000098,0x00000099, + 0x000200f8,0x00000098,0x0004003d,0x00000006,0x000000a2,0x0000002e,0x00060041,0x00000047, + 0x000000a3,0x00000045,0x00000025,0x000000a2,0x0004003d,0x0000003a,0x000000a4,0x000000a3, + 0x0004003d,0x00000006,0x000000a5,0x00000029,0x0004003d,0x00000006,0x000000a6,0x00000096, + 0x00050080,0x00000006,0x000000a7,0x000000a5,0x000000a6,0x00060041,0x00000047,0x000000a8, + 0x0000003e,0x00000025,0x000000a7,0x0004003d,0x0000003a,0x000000a9,0x000000a8,0x00050083, + 0x0000003a,0x000000aa,0x000000a4,0x000000a9,0x0006000c,0x0000003a,0x000000ab,0x00000001, + 0x0000001b,0x000000aa,0x0003003e,0x000000a1,0x000000ab,0x0004003d,0x00000006,0x000000b0, + 0x0000002e,0x0004003d,0x0000003a,0x000000b1,0x000000a1,0x00060041,0x00000047,0x000000b2, + 0x000000af,0x00000025,0x000000b0,0x0003003e,0x000000b2,0x000000b1,0x0004003d,0x00000006, + 0x000000b3,0x00000029,0x0004003d,0x00000006,0x000000b4,0x00000096,0x00050080,0x00000006, + 0x000000b5,0x000000b3,0x000000b4,0x0004003d,0x0000003a,0x000000b6,0x000000a1,0x00060041, + 0x00000047,0x000000b7,0x00000083,0x00000025,0x000000b5,0x0004003d,0x0000003a,0x000000b8, + 0x000000b7,0x00050081,0x0000003a,0x000000b9,0x000000b8,0x000000b6,0x00060041,0x00000047, + 0x000000ba,0x00000083,0x00000025,0x000000b5,0x0003003e,0x000000ba,0x000000b9,0x0004003d, + 0x00000006,0x000000bb,0x0000002e,0x00050080,0x00000006,0x000000bc,0x000000bb,0x00000016, + 0x0003003e,0x0000002e,0x000000bc,0x000200f9,0x0000009a,0x000200f8,0x0000009a,0x0004003d, + 0x00000006,0x000000bd,0x00000096,0x00050080,0x00000006,0x000000be,0x000000bd,0x00000016, + 0x0003003e,0x00000096,0x000000be,0x000200f9,0x00000097,0x000200f8,0x00000099,0x000200f9, + 0x00000090,0x000200f8,0x00000090,0x0004003d,0x00000006,0x000000bf,0x0000008c,0x00050080, + 0x00000006,0x000000c0,0x000000bf,0x00000016,0x0003003e,0x0000008c,0x000000c0,0x000200f9, + 0x0000008d,0x000200f8,0x0000008f,0x0004003d,0x00000006,0x000000c1,0x0000001f,0x0003003e, + 0x0000002e,0x000000c1,0x0003003e,0x000000c2,0x00000025,0x000200f9,0x000000c3,0x000200f8, + 0x000000c3,0x000400f6,0x000000c5,0x000000c6,0x00000000,0x000200f9,0x000000c7,0x000200f8, + 0x000000c7,0x0004003d,0x00000006,0x000000c8,0x000000c2,0x00050041,0x00000017,0x000000c9, + 0x00000015,0x00000021,0x0004003d,0x00000006,0x000000ca,0x000000c9,0x000500b1,0x0000001a, + 0x000000cb,0x000000c8,0x000000ca,0x000400fa,0x000000cb,0x000000c4,0x000000c5,0x000200f8, + 0x000000c4,0x0003003e,0x000000cc,0x00000025,0x000200f9,0x000000cd,0x000200f8,0x000000cd, + 0x000400f6,0x000000cf,0x000000d0,0x00000000,0x000200f9,0x000000d1,0x000200f8,0x000000d1, + 0x0004003d,0x00000006,0x000000d2,0x000000cc,0x00050041,0x00000017,0x000000d3,0x00000015, + 0x00000025,0x0004003d,0x00000006,0x000000d4,0x000000d3,0x000500b1,0x0000001a,0x000000d5, + 0x000000d2,0x000000d4,0x000400fa,0x000000d5,0x000000ce,0x000000cf,0x000200f8,0x000000ce, + 0x0004003d,0x00000006,0x000000d7,0x0000002e,0x00060041,0x00000047,0x000000d8,0x000000af, + 0x00000025,0x000000d7,0x0004003d,0x0000003a,0x000000d9,0x000000d8,0x0004003d,0x00000006, + 0x000000da,0x00000029,0x0004003d,0x00000006,0x000000db,0x000000cc,0x00050080,0x00000006, + 0x000000dc,0x000000da,0x000000db,0x00060041,0x00000047,0x000000dd,0x00000083,0x00000025, + 0x000000dc,0x0004003d,0x0000003a,0x000000de,0x000000dd,0x00050088,0x0000003a,0x000000df, + 0x000000d9,0x000000de,0x0003003e,0x000000d6,0x000000df,0x00050041,0x00000017,0x000000e1, + 0x00000015,0x000000e0,0x0004003d,0x00000006,0x000000e2,0x000000e1,0x000500aa,0x0000001a, + 0x000000e3,0x000000e2,0x00000016,0x000300f7,0x000000e5,0x00000000,0x000400fa,0x000000e3, + 0x000000e4,0x000000e5,0x000200f8,0x000000e4,0x0004003d,0x0000003a,0x000000e6,0x000000d6, + 0x0006000c,0x0000003a,0x000000e7,0x00000001,0x0000001c,0x000000e6,0x0003003e,0x000000d6, + 0x000000e7,0x000200f9,0x000000e5,0x000200f8,0x000000e5,0x0004003d,0x00000006,0x000000e8, + 0x0000002e,0x0004003d,0x0000003a,0x000000e9,0x000000d6,0x00060041,0x00000047,0x000000ea, + 0x000000af,0x00000025,0x000000e8,0x0003003e,0x000000ea,0x000000e9,0x0004003d,0x00000006, + 0x000000eb,0x0000002e,0x00050080,0x00000006,0x000000ec,0x000000eb,0x00000016,0x0003003e, + 0x0000002e,0x000000ec,0x000200f9,0x000000d0,0x000200f8,0x000000d0,0x0004003d,0x00000006, + 0x000000ed,0x000000cc,0x00050080,0x00000006,0x000000ee,0x000000ed,0x00000016,0x0003003e, + 0x000000cc,0x000000ee,0x000200f9,0x000000cd,0x000200f8,0x000000cf,0x000200f9,0x000000c6, + 0x000200f8,0x000000c6,0x0004003d,0x00000006,0x000000ef,0x000000c2,0x00050080,0x00000006, + 0x000000f0,0x000000ef,0x00000016,0x0003003e,0x000000c2,0x000000f0,0x000200f9,0x000000c3, + 0x000200f8,0x000000c5,0x000100fd,0x00010038 +}; + +}}} // namespace cv::dnn::webgpu diff --git a/modules/dnn/src/webgpu/shader/spirv_generator.py b/modules/dnn/src/webgpu/shader/spirv_generator.py new file mode 100644 index 000000000000..483c011bdfc8 --- /dev/null +++ b/modules/dnn/src/webgpu/shader/spirv_generator.py @@ -0,0 +1,88 @@ +# Iterate all GLSL shaders (with suffix '.comp') in current directory. +# +# Use glslangValidator to compile them to SPIR-V shaders and write them +# into .cpp files as unsigned int array. +# +# Also generate a header file 'spv_shader.hpp' to extern declare these shaders. + +import re +import os +import sys + +dir = "./" +license_decl = \ +'// This file is part of OpenCV project.\n'\ +'// It is subject to the license terms in the LICENSE file found in the top-level directory\n'\ +'// of this distribution and at http://opencv.org/license.html.\n'\ +'//\n'\ +'// Copyright (C) 2018, Intel Corporation, all rights reserved.\n'\ +'// Third party copyrights are property of their respective owners.\n\n' +precomp = '#include \"../../precomp.hpp\"\n' +ns_head = '\nnamespace cv { namespace dnn { namespace webgpu {\n\n' +ns_tail = '\n}}} // namespace cv::dnn::webgpu\n' + +headfile = open('spv_shader.hpp', 'w') +headfile.write(license_decl) +headfile.write('#ifndef OPENCV_DNN_SPV_SHADER_HPP\n') +headfile.write('#define OPENCV_DNN_SPV_SHADER_HPP\n\n') +headfile.write(ns_head) + +cmd_remove = '' +null_out = '' +if sys.platform.find('win32') != -1: + cmd_remove = 'del' + null_out = ' >>nul 2>nul' +elif sys.platform.find('linux') != -1: + cmd_remove = 'rm' + null_out = ' > /dev/null 2>&1' + +list = os.listdir(dir) +for i in range(0, len(list)): + if (os.path.splitext(list[i])[-1] != '.comp'): + continue + prefix = os.path.splitext(list[i])[0] + path = os.path.join(dir, list[i]) + + + bin_file = prefix + '.tmp' + cmd = ' ./glslangValidator -V ' + path + ' -S comp -o ' + bin_file + print('compiling') + if os.system(cmd) != 0: + continue + size = os.path.getsize(bin_file) + + spv_txt_file = prefix + '.spv' + cmd = './glslangValidator -V ' + path + ' -S comp -o ' + spv_txt_file + ' -x' + null_out + os.system(cmd) + + infile_name = spv_txt_file + outfile_name = prefix + '_spv.cpp' + array_name = prefix + '_spv' + infile = open(infile_name, 'r') + outfile = open(outfile_name, 'w') + + outfile.write(license_decl) + outfile.write(precomp) + outfile.write(ns_head) + # xxx.spv ==> xxx_spv.cpp + fmt = 'extern const unsigned int %s[%d] = {\n' % (array_name, size/4) + outfile.write(fmt) + for eachLine in infile: + if(re.match(r'^.*\/\/', eachLine)): + continue + newline = ' ' + eachLine.replace('\t','') + outfile.write(newline) + infile.close() + outfile.write("};\n") + outfile.write(ns_tail) + + # write a line into header file + fmt = 'extern const unsigned int %s[%d];\n' % (array_name, size/4) + headfile.write(fmt) + + os.system(cmd_remove + ' ' + bin_file) + os.system(cmd_remove + ' ' + spv_txt_file) + +headfile.write(ns_tail) +headfile.write('\n#endif /* OPENCV_DNN_SPV_SHADER_HPP */\n') +headfile.close() diff --git a/modules/dnn/src/webgpu/shader/spv_shader.hpp b/modules/dnn/src/webgpu/shader/spv_shader.hpp new file mode 100644 index 000000000000..9a2d3b31035d --- /dev/null +++ b/modules/dnn/src/webgpu/shader/spv_shader.hpp @@ -0,0 +1,18 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_DNN_SPV_SHADER_HPP +#define OPENCV_DNN_SPV_SHADER_HPP + + +namespace cv { namespace dnn { namespace webgpu { + +extern const unsigned int softmax_spv[1500]; + +}}} // namespace cv::dnn::webgpu + +#endif /* OPENCV_DNN_SPV_SHADER_HPP */ diff --git a/modules/dnn/src/webgpu/src/buffer.cpp b/modules/dnn/src/webgpu/src/buffer.cpp new file mode 100644 index 000000000000..77fb4f4dcdaa --- /dev/null +++ b/modules/dnn/src/webgpu/src/buffer.cpp @@ -0,0 +1,77 @@ +#include "../include/buffer.hpp" +#include "../dawn/dawnUtils.hpp" +#include "common.hpp" +#include +namespace cv { namespace dnn { namespace webgpu { +// #ifdef HAVE_WEBGPU + +Buffer::Buffer(std::shared_ptr device) +{ + device_ = device; + usage_ = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst | + wgpu::BufferUsage::CopySrc; +} + +Buffer::Buffer(std::shared_ptr device, + const void* data, size_t size, + wgpu::BufferUsage usage) +{ + device_ = device; + usage_ = usage; + size_ = size; + wgpu::BufferDescriptor descriptor = {}; + descriptor.size = size; + descriptor.usage = usage; + buffer_ = device_->CreateBuffer(& descriptor); + if(data) buffer_.SetSubData(0, size_, data); +} + +Buffer::Buffer(const void* data, size_t size, + wgpu::BufferUsage usage) +{ + createContext(); + device_ = wDevice; + usage_ = usage; + size_ = size; + wgpu::BufferDescriptor descriptor = {}; + descriptor.size = size; + descriptor.usage = usage; + buffer_ = device_->CreateBuffer(& descriptor); + if(data) buffer_.SetSubData(0, size_, data); +} + +void Buffer::setBufferData(const void * data, size_t size) +{ + size_ = size; + buffer_.SetSubData(0, size_, data); +} + +const void* Buffer::MapReadAsyncAndWait() +{ + if(! gpuReadBuffer_) + { + wgpu::BufferDescriptor desc = {}; + desc.size = size_; + desc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead; + gpuReadBuffer_ = device_->CreateBuffer(& desc); + } + wgpu::CommandEncoder encoder = device_->CreateCommandEncoder(); + encoder.CopyBufferToBuffer(buffer_, 0, + gpuReadBuffer_, 0, size_); + wgpu::CommandBuffer cmdBuffer = encoder.Finish(); + encoder.Release(); + wQueue->Submit(1, &cmdBuffer); + cmdBuffer.Release(); + gpuReadBuffer_.MapReadAsync(BufferMapReadCallback, this); + usleep(100); + while(mappedData == nullptr) + { + device_->Tick(); + usleep(100); + } + return mappedData; +} + +// #endif //HAVE_WEBGPU + +}}} //namespace cv::dnn::webgpu diff --git a/modules/dnn/src/webgpu/src/common.hpp b/modules/dnn/src/webgpu/src/common.hpp new file mode 100644 index 000000000000..c0db85896e0a --- /dev/null +++ b/modules/dnn/src/webgpu/src/common.hpp @@ -0,0 +1,43 @@ +#ifndef OPENCV_DNN_WEBGPU_COMMON_HPP +#define OPENCV_DNN_WEBGPU_COMMON_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// #ifdef HAVE_WEBGPU +#include +// #endif +#include "opencv2/core/utils/logger.hpp" +#include "../shader/spv_shader.hpp" +#include "../../precomp.hpp" +#include "../include/wgpucom.hpp" +#include "context.hpp" +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU + +extern std::shared_ptr wDevice; +extern std::shared_ptr wQueue; +extern cv::Mutex wContextMtx; + +enum ShapeIdx +{ + kShapeIdxBatch = 0, + kShapeIdxChannel, + kShapeIdxHeight, + kShapeIdxWidth, +}; + + +// #endif //HAVE_WEBGPU + +}}} // namespace cv::dnn::vkcom + +#endif // OPENCV_DNN_WEBGPU_COMMON_HPP \ No newline at end of file diff --git a/modules/dnn/src/webgpu/src/context.cpp b/modules/dnn/src/webgpu/src/context.cpp new file mode 100644 index 000000000000..8791e9fa6525 --- /dev/null +++ b/modules/dnn/src/webgpu/src/context.cpp @@ -0,0 +1,53 @@ +#include "../../precomp.hpp" +#include "common.hpp" +#include "context.hpp" +#include +#include "../dawn/dawnUtils.hpp" +#include +namespace cv { namespace dnn { namespace webgpu { +// #ifdef HAVE_WEBGPU + +std::shared_ptr wCtx; +std::shared_ptr wDevice; +std::shared_ptr wQueue; +cv::Mutex wContextMtx; + +// internally used +void createContext() +{ + cv::AutoLock lock(wContextMtx); + if (!wCtx && !wDevice) + { + wCtx.reset(new Context()); + } +} + +bool isAvailable() +{ + try + { + createContext(); + } + catch (const cv::Exception& e) + { + CV_LOG_ERROR(NULL, + "Failed to init WebGPU-Dawn environment. " << e.what()); + return false; + } + + return true; +} +Context::Context() +{ + wDevice = std::make_shared(createCppDawnDevice()); + wQueue = std::make_shared(wDevice->GetDefaultQueue()); +} +Context::~Context() +{ + wDevice->Release(); + wQueue->Release(); +} + +// #endif + +}}} // namespace cv::dnn::webgpu \ No newline at end of file diff --git a/modules/dnn/src/webgpu/src/context.hpp b/modules/dnn/src/webgpu/src/context.hpp new file mode 100644 index 000000000000..1588fab79192 --- /dev/null +++ b/modules/dnn/src/webgpu/src/context.hpp @@ -0,0 +1,20 @@ +#ifndef OPENCV_DNN_WEBGPU_CONTEXT_HPP +#define OPENCV_DNN_WEBGPU_CONTEXT_HPP + +namespace cv { namespace dnn { namespace webgpu { +class Context +{ +// #ifdef HAVE_WEBGPU + +public: + Context(); + ~Context(); +}; + +void createContext(); + +// #endif //HAVE_WEBGPU + +}}} // namespace cv::dnn::webgpu + +#endif // OPENCV_DNN_WEBGPU_CONTEXT_HPP diff --git a/modules/dnn/src/webgpu/src/internal.cpp b/modules/dnn/src/webgpu/src/internal.cpp new file mode 100644 index 000000000000..a888810de1a5 --- /dev/null +++ b/modules/dnn/src/webgpu/src/internal.cpp @@ -0,0 +1,163 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#include "../../precomp.hpp" +#include "common.hpp" +#include "internal.hpp" + +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU + +// std::vector compile(const std::string& name, +// shaderc_shader_kind kind, +// const std::string& data) +// { +// std::vector result; +// #ifdef USE_SHADERC +// shaderc::Compiler compiler; +// shaderc::CompileOptions options; + +// // Like -DMY_DEFINE=1 +// //options.AddMacroDefinition("MY_DEFINE", "1"); +// options.SetGenerateDebugInfo(); +// options.SetTargetEnvironment(shaderc_target_env_vulkan, +// shaderc_env_version_vulkan_1_1); +// shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv( +// data.c_str(), data.size(), kind, name.c_str(), options); + +// if (module.GetCompilationStatus() != +// shaderc_compilation_status_success) { +// std::cerr << module.GetErrorMessage(); +// } + +// //std::vector result(module.cbegin(), module.cend()); +// result.assign(module.cbegin(), module.cend()); +// return result; +// #else +// assert(0); +// return result; +// #endif +// } + +void bindTensor(Tensor& tensor, uint32_t binding, + std::vector& bgEntries) +{ + wgpu::BindGroupEntry bgEntry = {}; + bgEntry.binding = binding; + bgEntry.buffer = * tensor.getBuffer()->getWebGPUBuffer(); + bgEntry.offset = 0; + bgEntry.size = tensor.size(); + bgEntry.sampler = nullptr; + bgEntry.textureView = nullptr; + bgEntries.push_back(bgEntry); +} + +void bindUniform(Buffer& buffer, uint32_t binding, + std::vector& bgEntries) +{ + wgpu::BindGroupEntry bgEntry = {}; + bgEntry.binding = binding; + bgEntry.buffer = * buffer.getWebGPUBuffer(); + bgEntry.offset = 0; + bgEntry.size = buffer.getSize(); + bgEntry.sampler = nullptr; + bgEntry.textureView = nullptr; + bgEntries.push_back(bgEntry); +} + +void computeConvOutputShapeAndPadding(const PaddingMode& padding_mode, + int& padding_top, int& padding_left, + const int& in_h, const int& in_w, + const int& filter_h, const int& filter_w, + const int& dilation_h, const int& dilation_w, + const int& stride_h, const int& stride_w, + int& out_h, int& out_w) +{ + if (padding_mode == wPaddingModeValid) + { + padding_top = 0; + padding_left = 0; + out_h = ceil((in_h - (filter_h - 1) * dilation_h) / stride_h); + out_w = ceil((in_w - (filter_w - 1) * dilation_w) / stride_w); + } + else if (padding_mode == wPaddingModeSame) + { + padding_top = ((filter_h - 1) * dilation_h + 1) / 2; + padding_left = ((filter_w - 1) * dilation_w + 1) / 2; + out_h = ceil(in_h / stride_h); + out_w = ceil(in_w / stride_w); + } + else if (padding_mode == wPaddingModeCaffe) + { + const int filter_h_actual = dilation_h * (filter_h - 1) + 1; + const int filter_w_actual = dilation_w * (filter_w - 1) + 1; + out_h = (in_h + 2 * padding_top - filter_h_actual) / stride_h + 1; + out_w = (in_w + 2 * padding_left - filter_w_actual) / stride_w + 1; + } + else + { + CV_Error(Error::StsError, format("Invalid padding mode:%d", padding_mode)); + } +} + +void computePoolOutputShape(const PaddingMode& padding_mode, + const int& padding_top, const int& padding_left, + const int& in_h, const int& in_w, + const int& filter_h, const int& filter_w, + const int& stride_h, const int& stride_w, + int& out_h, int& out_w) +{ + if (padding_mode == wPaddingModeValid) + { + assert(padding_top == 0); + assert(padding_left == 0); + out_h = ceil((in_h - (filter_h - 1)) / stride_h); + out_w = ceil((in_h - (filter_w - 1)) / stride_w); + } + else if (padding_mode == wPaddingModeSame) + { + const int padding_top_ = filter_h / 2; + const int padding_left_ = filter_w / 2; + CV_Assert(padding_top == padding_top_); + CV_Assert(padding_left == padding_left_); + out_h = ceil(in_h / stride_h); + out_w = ceil(in_h / stride_w); + } + else if (padding_mode == wPaddingModeCaffe) + { + int out_h_ = static_cast(ceil(static_cast( + in_h + 2 * padding_top - filter_h) / stride_h)) + 1; + int out_w_ = static_cast(ceil(static_cast( + in_h + 2 * padding_left - filter_w) / stride_w)) + 1; + + if (padding_top || padding_left) + { + // If we have padding, ensure that the last pooling starts strictly + // inside the image (instead of at the padding); otherwise clip the last. + if ((out_h_ - 1) * stride_h >= in_h + padding_top) { + --out_h_; + } + if ((out_w - 1) * stride_h >= in_h + padding_left) { + --out_w; + } + assert((out_h_ - 1) * stride_h < in_h + padding_top); + assert((out_w_ - 1) * stride_w < in_h + padding_left); + } + out_h = out_h_; + out_w = out_w_; + } + else + { + CV_Error(Error::StsError, format("Invalid padding mode:%d", padding_mode)); + } +} + +// #endif + +}}} //namespace cv::dnn::webgpu + diff --git a/modules/dnn/src/webgpu/src/internal.hpp b/modules/dnn/src/webgpu/src/internal.hpp new file mode 100644 index 000000000000..94b1bf316fb3 --- /dev/null +++ b/modules/dnn/src/webgpu/src/internal.hpp @@ -0,0 +1,83 @@ +#ifndef OPENCV_DNN_WEBGPU_INTERNAL_HPP +#define OPENCV_DNN_WEBGPU_INTERNAL_HPP + +#include +#include "../include/wgpucom.hpp" +#include "context.hpp" + +#ifdef USE_SHADERC +#include "shaderc/shaderc.hpp" +#else +typedef int shaderc_shader_kind; +#define shaderc_compute_shader 0 +#endif + +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU +std::vector compile(const std::string& name, + shaderc_shader_kind kind, + const std::string& data); +void bindTensor(Tensor& tensor, uint32_t binding, + std::vector& bgEntries); +void bindUniform(Buffer& buffer, uint32_t binding, + std::vector& bgEntries); +void computeConvOutputShapeAndPadding(const PaddingMode& padding_mode, + int& padding_top, int& padding_left, + const int& in_h, const int& in_w, + const int& filter_h, const int& filter_w, + const int& dilation_h, const int& dilation_w, + const int& stride_h, const int& stride_w, + int& out_h, int& out_w); + +void computePoolOutputShape(const PaddingMode& padding_mode, + const int& padding_top, const int& padding_left, + const int& in_h, const int& in_w, + const int& filter_h, const int& filter_w, + const int& stride_h, const int& stride_w, + int& out_h, int& out_w); +inline bool checkFormat(Format fmt) +{ + return (fmt > -1 && fmt < wFormatNum) ? true : false; +} + +inline size_t elementSize(Format fmt) +{ + if (fmt == wFormatFp32 || fmt == wFormatInt32) + { + return 4; + } + else if (fmt >= 0 && fmt < wFormatNum) + { + CV_LOG_WARNING(NULL, format("Unsupported format %d", fmt)); + } + else + { + CV_Error(Error::StsError, format("Invalid format %d", fmt)); + } + return 0; +} + +inline int shapeCount(const Shape& shape, int start = -1, int end = -1) +{ + if (start == -1) start = 0; + if (end == -1) end = (int)shape.size(); + + if (shape.empty()) + return 0; + + int elems = 1; + assert(start <= (int)shape.size() && + end <= (int)shape.size() && + start <= end); + for(int i = start; i < end; i++) + { + elems *= shape[i]; + } + return elems; +} +// #endif //HAVE_WEBGPU + +}}} //namespace::dnn::webgpu + +#endif //OPENCV_DNN_WEBGPU_INTERNEL_HPP \ No newline at end of file diff --git a/modules/dnn/src/webgpu/src/op_base.cpp b/modules/dnn/src/webgpu/src/op_base.cpp new file mode 100644 index 000000000000..ac104d3da555 --- /dev/null +++ b/modules/dnn/src/webgpu/src/op_base.cpp @@ -0,0 +1,140 @@ +#include "../../precomp.hpp" +#include "common.hpp" +#include "internal.hpp" +#include "../include/op_base.hpp" +#include "../dawn/dawnUtils.hpp" +#include + +namespace cv { namespace dnn { namespace webgpu { +// #ifdef HAVE_WEBGPU +OpBase::OpBase() +{ + createContext(); + device_ = wDevice; + pipeline_ = nullptr; + cmd_buffer_ = nullptr; + bindgrouplayout_ = nullptr; + bindgroup_ = nullptr; + module_ = nullptr; + pipeline_layout_ = nullptr; +} + +OpBase::~OpBase() +{ + module_.Release(); + bindgrouplayout_.Release(); + bindgroup_.Release(); + pipeline_.Release(); + pipeline_layout_.Release(); + cmd_buffer_.Release(); +} +// the wgpu::BindingType has to be specified +// UniformBuffer | StorageBuffer | ReadOnlyStorageBuffer | MapReadBuffer +void OpBase::createBindGroupLayout(int buffer_num) +{ + if(buffer_num <= 0) + return; + std::vector entriesInitializer; + for(int i = 0; i < buffer_num ; i++) { + wgpu::BindGroupLayoutEntry entry = {}; + entry.binding = i; + entry.visibility = wgpu::ShaderStage::Compute; + entry.type = wgpu::BindingType::StorageBuffer; + entriesInitializer.push_back(entry); + } + if(needsUniform) { + wgpu::BindGroupLayoutEntry entry = {}; + entry.binding = buffer_num; + entry.visibility = wgpu::ShaderStage::Compute; + entry.type = wgpu::BindingType::UniformBuffer; + entriesInitializer.push_back(entry); + } + wgpu::BindGroupLayoutDescriptor descriptor; + descriptor.entryCount = entriesInitializer.size(); + descriptor.entries = entriesInitializer.data(); + bindgrouplayout_ = device_->CreateBindGroupLayout(&descriptor); +} + +void OpBase::createBindGroup() +{ + wgpu::BindGroupDescriptor bgDesc; + bgDesc.layout = bindgrouplayout_; + bgDesc.entryCount = bgEntries.size(); + bgDesc.entries = bgEntries.data(); + bindgroup_ = device_->CreateBindGroup(&bgDesc); +} + +void OpBase::createShaderModule(const uint32_t* spv, uint32_t size, + const std::string& source) +{ + wgpu::ShaderModuleSPIRVDescriptor spirvDesc; + if(spv) { + spirvDesc.sType = wgpu::SType::ShaderModuleSPIRVDescriptor; + spirvDesc.codeSize = size; + spirvDesc.code = spv; + } + // TODO: dynamically compile glsl + // else { + // std::vector code; + // code = compile("shader", shaderc_compute_shader, source); + // spirvDesc.codeSize =static_cast(code.size()); + // spirvDesc.code = code.data(); + // } + wgpu::ShaderModuleDescriptor descriptor; + descriptor.label = nullptr; + descriptor.nextInChain = &spirvDesc; + module_ = device_->CreateShaderModule(&descriptor); +} + +void OpBase::createComputePipeline() +{ + wgpu::PipelineLayoutDescriptor descriptor; + descriptor.bindGroupLayoutCount = 1; + descriptor.bindGroupLayouts = &bindgrouplayout_; + pipeline_layout_ = device_->CreatePipelineLayout(&descriptor); + + wgpu::ComputePipelineDescriptor csDesc; + csDesc.layout = pipeline_layout_; + csDesc.computeStage.module = module_; + csDesc.computeStage.entryPoint = "main"; + pipeline_ = device_->CreateComputePipeline(&csDesc); +} + +void OpBase::createCommandBuffer() +{ + wgpu::CommandEncoder encoder = device_->CreateCommandEncoder(); + cv::AutoLock lock(wContextMtx); + wgpu::ComputePassEncoder pass = encoder.BeginComputePass(); + pass.SetPipeline(pipeline_); + pass.SetBindGroup(0, bindgroup_); + pass.Dispatch(group_x_, group_y_, group_z_); + pass.EndPass(); + + cmd_buffer_ = encoder.Finish(); +} + +wgpu::FenceCompletionStatus OpBase::WaitForCompletedValue( + wgpu::Fence fence, uint64_t completedValue) +{ + if (fence.GetCompletedValue() < completedValue) + { + device_->Tick(); + usleep(100); + } + if(fence.GetCompletedValue() != completedValue) + { + return wgpu::FenceCompletionStatus::Error; + } + + return wgpu::FenceCompletionStatus::Success; +} + +void OpBase::runCommandBuffer() +{ + cv::AutoLock lock(wContextMtx); + wQueue->Submit(1, &cmd_buffer_); +} + +// #endif //HAVE_WEBGPU + +}}} // namsspace cv::dnn::webgpu \ No newline at end of file diff --git a/modules/dnn/src/webgpu/src/op_softmax.cpp b/modules/dnn/src/webgpu/src/op_softmax.cpp new file mode 100644 index 000000000000..94f0245b0a42 --- /dev/null +++ b/modules/dnn/src/webgpu/src/op_softmax.cpp @@ -0,0 +1,115 @@ +#include "../../precomp.hpp" +#include "common.hpp" +#include "internal.hpp" +#include "../include/op_softmax.hpp" + +namespace cv { namespace dnn { namespace webgpu { + +// #ifdef HAVE_WEBGPU + +#define LOCAL_SZ_X 256 +#define LOCAL_SZ_Y 1 +#define LOCAL_SZ_Z 1 + +struct SoftmaxParam +{ + int channel_size; + int outer_size; + int channels; + int logsoftmax; +}; + +OpSoftmax::OpSoftmax(const int axis, const bool log_softmax) +{ + init(axis, log_softmax); + type_ = "Softmax"; + needsUniform = true; +} + +OpSoftmax::~OpSoftmax() +{ + if (max_tensor_) + delete max_tensor_; + if (sum_tensor_) + delete sum_tensor_; + if(uniformBuffer_) + uniformBuffer_->getWebGPUBuffer()->Release(); +} + +void OpSoftmax::reshapeOutTensor(Tensor& in, Tensor& out) +{ + Shape shape = in.getShape(); + out.reshape(NULL, shape); +} + +bool OpSoftmax::init(const int axis, const bool log_softmax) +{ + axis_ = axis; + log_softmax_ = log_softmax; + max_tensor_ = NULL; + sum_tensor_ = NULL; + createBindGroupLayout(4); + return true; +} + +bool OpSoftmax::forward(std::vector& ins, + std::vector& blobs, + std::vector& outs) +{ + return forward(ins[0], outs[0]); +} + +bool OpSoftmax::forward(Tensor& in, Tensor& out) +{ + channels_ = in.dimSize(axis_); + channel_size_ = in.count(axis_+1); + outer_size_ = in.count(0, axis_); + + if (pipeline_ == nullptr) + { + config_.local_size_x = LOCAL_SZ_X; + config_.local_size_y = LOCAL_SZ_Y; + config_.local_size_z = LOCAL_SZ_Z; + config_.block_height = 1; + config_.block_width = 1; + config_.block_depth = 1; + createShaderModule(softmax_spv, sizeof(softmax_spv)/sizeof(uint32_t)); + createComputePipeline(); + computeGroupCount(); + } + if (max_tensor_ == NULL || sum_tensor_ == NULL) + { + std::vector shape = {outer_size_, channel_size_}; + max_tensor_ = new Tensor(NULL, shape); + sum_tensor_ = new Tensor(NULL, shape); + } + if(needsUniform) + { + SoftmaxParam param = {channel_size_, outer_size_, channels_, + log_softmax_ == true ? 1 : 0}; + uniformBuffer_ = new Buffer(¶m, sizeof(SoftmaxParam)); + } + + bindTensor(in, 0, bgEntries); + bindTensor(*max_tensor_, 1, bgEntries); + bindTensor(*sum_tensor_, 2, bgEntries); + bindTensor(out, 3, bgEntries); + bindUniform(* uniformBuffer_, 4, bgEntries); + + createBindGroup(); + createCommandBuffer(); + runCommandBuffer(); + return true; +} + +bool OpSoftmax::computeGroupCount() +{ + group_x_ = alignSize(outer_size_, config_.local_size_x) / config_.local_size_x; + group_y_ = 1; + group_z_ = 1; + return true; +} + +// #endif // HAVE_WEBGPU + +}}} // namespace cv::dnn::webgpu diff --git a/modules/dnn/src/webgpu/src/tensor.cpp b/modules/dnn/src/webgpu/src/tensor.cpp new file mode 100644 index 000000000000..e9dd135216a5 --- /dev/null +++ b/modules/dnn/src/webgpu/src/tensor.cpp @@ -0,0 +1,106 @@ +#include "../include/tensor.hpp" +#include "common.hpp" +#include "internal.hpp" +#include +namespace cv { namespace dnn { namespace webgpu { +// #ifdef HAVE_WEBGPU +Tensor::Tensor(Format fmt) : size_in_byte_(0), format_(fmt) +{ + createContext(); + device_ = wDevice; +} + +Tensor::Tensor(const void* data, std::vector& shape, Format fmt) +{ + createContext(); + device_ = wDevice; + size_in_byte_ = 0; + format_ = fmt; + reshape(data, shape); +} + +const void* Tensor::mapRead() +{ + return buffer_->MapReadAsyncAndWait(); + +} + +void Tensor::unMap() +{ + buffer_->unMap(); +} + +Shape Tensor::getShape() const{ + return shape_; +} + +int Tensor::count(const int start_axis, const int end_axis) const +{ + return shapeCount(shape_, start_axis, end_axis); +} + +int Tensor::dimSize(const int axis) const +{ + CV_Assert(axis >= 0); + CV_Assert(axis < shape_.size()); + + return shape_[axis]; +} + +int Tensor::dimNum() const +{ + return shape_.size(); +} + +Tensor Tensor::reshape(const void* data, const std::vector& shape, + bool alloc, Format fmt) +{ + if (device_ == nullptr) + { + CV_Error(Error::StsError, "device is NULL"); + return *this; + } + CV_Assert(shape.size() > 0 && shape.size() <= 6); + + if (shape_ != shape) shape_ = shape; + if (checkFormat(fmt) && fmt != format_) format_ = fmt; + + size_t new_size = shapeCount(shape_) * elementSize(format_); + if (alloc || new_size > size_in_byte_) + alloc = true; + size_in_byte_ = new_size; + if(alloc) + { + buffer_.reset(new Buffer(device_, data, size_in_byte_, usage_)); + return * this; + } + fillData(data); + return * this; +} + +Tensor Tensor::fillData(const void * data) +{ + if (!buffer_) + { + buffer_.reset(new Buffer(device_, data, size_in_byte_, usage_)); + } + else if (data) + { + buffer_->setBufferData(data, size_in_byte_); + } + return * this; +} + +int Tensor::getFormat() const +{ + return format_; +} + +void Tensor::copyTo(Tensor & dst) +{ + dst.reshape(buffer_->MapReadAsyncAndWait(), shape_, true, format_); +} + +// #endif //HAVE_WEBGPU + +}}} //namespace cv::dnn:webgpu \ No newline at end of file diff --git a/modules/dnn/src/webgpu/src/webgpu_cpp.cpp b/modules/dnn/src/webgpu/src/webgpu_cpp.cpp new file mode 100644 index 000000000000..fd324184007c --- /dev/null +++ b/modules/dnn/src/webgpu/src/webgpu_cpp.cpp @@ -0,0 +1,1746 @@ + +#include "dawn/webgpu_cpp.h" + +namespace wgpu { + + + static_assert(sizeof(AdapterType) == sizeof(WGPUAdapterType), "sizeof mismatch for AdapterType"); + static_assert(alignof(AdapterType) == alignof(WGPUAdapterType), "alignof mismatch for AdapterType"); + + static_assert(static_cast(AdapterType::DiscreteGPU) == WGPUAdapterType_DiscreteGPU, "value mismatch for AdapterType::DiscreteGPU"); + static_assert(static_cast(AdapterType::IntegratedGPU) == WGPUAdapterType_IntegratedGPU, "value mismatch for AdapterType::IntegratedGPU"); + static_assert(static_cast(AdapterType::CPU) == WGPUAdapterType_CPU, "value mismatch for AdapterType::CPU"); + static_assert(static_cast(AdapterType::Unknown) == WGPUAdapterType_Unknown, "value mismatch for AdapterType::Unknown"); + + + static_assert(sizeof(AddressMode) == sizeof(WGPUAddressMode), "sizeof mismatch for AddressMode"); + static_assert(alignof(AddressMode) == alignof(WGPUAddressMode), "alignof mismatch for AddressMode"); + + static_assert(static_cast(AddressMode::Repeat) == WGPUAddressMode_Repeat, "value mismatch for AddressMode::Repeat"); + static_assert(static_cast(AddressMode::MirrorRepeat) == WGPUAddressMode_MirrorRepeat, "value mismatch for AddressMode::MirrorRepeat"); + static_assert(static_cast(AddressMode::ClampToEdge) == WGPUAddressMode_ClampToEdge, "value mismatch for AddressMode::ClampToEdge"); + + + static_assert(sizeof(BackendType) == sizeof(WGPUBackendType), "sizeof mismatch for BackendType"); + static_assert(alignof(BackendType) == alignof(WGPUBackendType), "alignof mismatch for BackendType"); + + static_assert(static_cast(BackendType::Null) == WGPUBackendType_Null, "value mismatch for BackendType::Null"); + static_assert(static_cast(BackendType::D3D11) == WGPUBackendType_D3D11, "value mismatch for BackendType::D3D11"); + static_assert(static_cast(BackendType::D3D12) == WGPUBackendType_D3D12, "value mismatch for BackendType::D3D12"); + static_assert(static_cast(BackendType::Metal) == WGPUBackendType_Metal, "value mismatch for BackendType::Metal"); + static_assert(static_cast(BackendType::Vulkan) == WGPUBackendType_Vulkan, "value mismatch for BackendType::Vulkan"); + static_assert(static_cast(BackendType::OpenGL) == WGPUBackendType_OpenGL, "value mismatch for BackendType::OpenGL"); + static_assert(static_cast(BackendType::OpenGLES) == WGPUBackendType_OpenGLES, "value mismatch for BackendType::OpenGLES"); + + + static_assert(sizeof(BindingType) == sizeof(WGPUBindingType), "sizeof mismatch for BindingType"); + static_assert(alignof(BindingType) == alignof(WGPUBindingType), "alignof mismatch for BindingType"); + + static_assert(static_cast(BindingType::UniformBuffer) == WGPUBindingType_UniformBuffer, "value mismatch for BindingType::UniformBuffer"); + static_assert(static_cast(BindingType::StorageBuffer) == WGPUBindingType_StorageBuffer, "value mismatch for BindingType::StorageBuffer"); + static_assert(static_cast(BindingType::ReadonlyStorageBuffer) == WGPUBindingType_ReadonlyStorageBuffer, "value mismatch for BindingType::ReadonlyStorageBuffer"); + static_assert(static_cast(BindingType::Sampler) == WGPUBindingType_Sampler, "value mismatch for BindingType::Sampler"); + static_assert(static_cast(BindingType::ComparisonSampler) == WGPUBindingType_ComparisonSampler, "value mismatch for BindingType::ComparisonSampler"); + static_assert(static_cast(BindingType::SampledTexture) == WGPUBindingType_SampledTexture, "value mismatch for BindingType::SampledTexture"); + static_assert(static_cast(BindingType::StorageTexture) == WGPUBindingType_StorageTexture, "value mismatch for BindingType::StorageTexture"); + static_assert(static_cast(BindingType::ReadonlyStorageTexture) == WGPUBindingType_ReadonlyStorageTexture, "value mismatch for BindingType::ReadonlyStorageTexture"); + static_assert(static_cast(BindingType::WriteonlyStorageTexture) == WGPUBindingType_WriteonlyStorageTexture, "value mismatch for BindingType::WriteonlyStorageTexture"); + + + static_assert(sizeof(BlendFactor) == sizeof(WGPUBlendFactor), "sizeof mismatch for BlendFactor"); + static_assert(alignof(BlendFactor) == alignof(WGPUBlendFactor), "alignof mismatch for BlendFactor"); + + static_assert(static_cast(BlendFactor::Zero) == WGPUBlendFactor_Zero, "value mismatch for BlendFactor::Zero"); + static_assert(static_cast(BlendFactor::One) == WGPUBlendFactor_One, "value mismatch for BlendFactor::One"); + static_assert(static_cast(BlendFactor::SrcColor) == WGPUBlendFactor_SrcColor, "value mismatch for BlendFactor::SrcColor"); + static_assert(static_cast(BlendFactor::OneMinusSrcColor) == WGPUBlendFactor_OneMinusSrcColor, "value mismatch for BlendFactor::OneMinusSrcColor"); + static_assert(static_cast(BlendFactor::SrcAlpha) == WGPUBlendFactor_SrcAlpha, "value mismatch for BlendFactor::SrcAlpha"); + static_assert(static_cast(BlendFactor::OneMinusSrcAlpha) == WGPUBlendFactor_OneMinusSrcAlpha, "value mismatch for BlendFactor::OneMinusSrcAlpha"); + static_assert(static_cast(BlendFactor::DstColor) == WGPUBlendFactor_DstColor, "value mismatch for BlendFactor::DstColor"); + static_assert(static_cast(BlendFactor::OneMinusDstColor) == WGPUBlendFactor_OneMinusDstColor, "value mismatch for BlendFactor::OneMinusDstColor"); + static_assert(static_cast(BlendFactor::DstAlpha) == WGPUBlendFactor_DstAlpha, "value mismatch for BlendFactor::DstAlpha"); + static_assert(static_cast(BlendFactor::OneMinusDstAlpha) == WGPUBlendFactor_OneMinusDstAlpha, "value mismatch for BlendFactor::OneMinusDstAlpha"); + static_assert(static_cast(BlendFactor::SrcAlphaSaturated) == WGPUBlendFactor_SrcAlphaSaturated, "value mismatch for BlendFactor::SrcAlphaSaturated"); + static_assert(static_cast(BlendFactor::BlendColor) == WGPUBlendFactor_BlendColor, "value mismatch for BlendFactor::BlendColor"); + static_assert(static_cast(BlendFactor::OneMinusBlendColor) == WGPUBlendFactor_OneMinusBlendColor, "value mismatch for BlendFactor::OneMinusBlendColor"); + + + static_assert(sizeof(BlendOperation) == sizeof(WGPUBlendOperation), "sizeof mismatch for BlendOperation"); + static_assert(alignof(BlendOperation) == alignof(WGPUBlendOperation), "alignof mismatch for BlendOperation"); + + static_assert(static_cast(BlendOperation::Add) == WGPUBlendOperation_Add, "value mismatch for BlendOperation::Add"); + static_assert(static_cast(BlendOperation::Subtract) == WGPUBlendOperation_Subtract, "value mismatch for BlendOperation::Subtract"); + static_assert(static_cast(BlendOperation::ReverseSubtract) == WGPUBlendOperation_ReverseSubtract, "value mismatch for BlendOperation::ReverseSubtract"); + static_assert(static_cast(BlendOperation::Min) == WGPUBlendOperation_Min, "value mismatch for BlendOperation::Min"); + static_assert(static_cast(BlendOperation::Max) == WGPUBlendOperation_Max, "value mismatch for BlendOperation::Max"); + + + static_assert(sizeof(BufferMapAsyncStatus) == sizeof(WGPUBufferMapAsyncStatus), "sizeof mismatch for BufferMapAsyncStatus"); + static_assert(alignof(BufferMapAsyncStatus) == alignof(WGPUBufferMapAsyncStatus), "alignof mismatch for BufferMapAsyncStatus"); + + static_assert(static_cast(BufferMapAsyncStatus::Success) == WGPUBufferMapAsyncStatus_Success, "value mismatch for BufferMapAsyncStatus::Success"); + static_assert(static_cast(BufferMapAsyncStatus::Error) == WGPUBufferMapAsyncStatus_Error, "value mismatch for BufferMapAsyncStatus::Error"); + static_assert(static_cast(BufferMapAsyncStatus::Unknown) == WGPUBufferMapAsyncStatus_Unknown, "value mismatch for BufferMapAsyncStatus::Unknown"); + static_assert(static_cast(BufferMapAsyncStatus::DeviceLost) == WGPUBufferMapAsyncStatus_DeviceLost, "value mismatch for BufferMapAsyncStatus::DeviceLost"); + + + static_assert(sizeof(CompareFunction) == sizeof(WGPUCompareFunction), "sizeof mismatch for CompareFunction"); + static_assert(alignof(CompareFunction) == alignof(WGPUCompareFunction), "alignof mismatch for CompareFunction"); + + static_assert(static_cast(CompareFunction::Undefined) == WGPUCompareFunction_Undefined, "value mismatch for CompareFunction::Undefined"); + static_assert(static_cast(CompareFunction::Never) == WGPUCompareFunction_Never, "value mismatch for CompareFunction::Never"); + static_assert(static_cast(CompareFunction::Less) == WGPUCompareFunction_Less, "value mismatch for CompareFunction::Less"); + static_assert(static_cast(CompareFunction::LessEqual) == WGPUCompareFunction_LessEqual, "value mismatch for CompareFunction::LessEqual"); + static_assert(static_cast(CompareFunction::Greater) == WGPUCompareFunction_Greater, "value mismatch for CompareFunction::Greater"); + static_assert(static_cast(CompareFunction::GreaterEqual) == WGPUCompareFunction_GreaterEqual, "value mismatch for CompareFunction::GreaterEqual"); + static_assert(static_cast(CompareFunction::Equal) == WGPUCompareFunction_Equal, "value mismatch for CompareFunction::Equal"); + static_assert(static_cast(CompareFunction::NotEqual) == WGPUCompareFunction_NotEqual, "value mismatch for CompareFunction::NotEqual"); + static_assert(static_cast(CompareFunction::Always) == WGPUCompareFunction_Always, "value mismatch for CompareFunction::Always"); + + + static_assert(sizeof(CullMode) == sizeof(WGPUCullMode), "sizeof mismatch for CullMode"); + static_assert(alignof(CullMode) == alignof(WGPUCullMode), "alignof mismatch for CullMode"); + + static_assert(static_cast(CullMode::None) == WGPUCullMode_None, "value mismatch for CullMode::None"); + static_assert(static_cast(CullMode::Front) == WGPUCullMode_Front, "value mismatch for CullMode::Front"); + static_assert(static_cast(CullMode::Back) == WGPUCullMode_Back, "value mismatch for CullMode::Back"); + + + static_assert(sizeof(ErrorFilter) == sizeof(WGPUErrorFilter), "sizeof mismatch for ErrorFilter"); + static_assert(alignof(ErrorFilter) == alignof(WGPUErrorFilter), "alignof mismatch for ErrorFilter"); + + static_assert(static_cast(ErrorFilter::None) == WGPUErrorFilter_None, "value mismatch for ErrorFilter::None"); + static_assert(static_cast(ErrorFilter::Validation) == WGPUErrorFilter_Validation, "value mismatch for ErrorFilter::Validation"); + static_assert(static_cast(ErrorFilter::OutOfMemory) == WGPUErrorFilter_OutOfMemory, "value mismatch for ErrorFilter::OutOfMemory"); + + + static_assert(sizeof(ErrorType) == sizeof(WGPUErrorType), "sizeof mismatch for ErrorType"); + static_assert(alignof(ErrorType) == alignof(WGPUErrorType), "alignof mismatch for ErrorType"); + + static_assert(static_cast(ErrorType::NoError) == WGPUErrorType_NoError, "value mismatch for ErrorType::NoError"); + static_assert(static_cast(ErrorType::Validation) == WGPUErrorType_Validation, "value mismatch for ErrorType::Validation"); + static_assert(static_cast(ErrorType::OutOfMemory) == WGPUErrorType_OutOfMemory, "value mismatch for ErrorType::OutOfMemory"); + static_assert(static_cast(ErrorType::Unknown) == WGPUErrorType_Unknown, "value mismatch for ErrorType::Unknown"); + static_assert(static_cast(ErrorType::DeviceLost) == WGPUErrorType_DeviceLost, "value mismatch for ErrorType::DeviceLost"); + + + static_assert(sizeof(FenceCompletionStatus) == sizeof(WGPUFenceCompletionStatus), "sizeof mismatch for FenceCompletionStatus"); + static_assert(alignof(FenceCompletionStatus) == alignof(WGPUFenceCompletionStatus), "alignof mismatch for FenceCompletionStatus"); + + static_assert(static_cast(FenceCompletionStatus::Success) == WGPUFenceCompletionStatus_Success, "value mismatch for FenceCompletionStatus::Success"); + static_assert(static_cast(FenceCompletionStatus::Error) == WGPUFenceCompletionStatus_Error, "value mismatch for FenceCompletionStatus::Error"); + static_assert(static_cast(FenceCompletionStatus::Unknown) == WGPUFenceCompletionStatus_Unknown, "value mismatch for FenceCompletionStatus::Unknown"); + static_assert(static_cast(FenceCompletionStatus::DeviceLost) == WGPUFenceCompletionStatus_DeviceLost, "value mismatch for FenceCompletionStatus::DeviceLost"); + + + static_assert(sizeof(FilterMode) == sizeof(WGPUFilterMode), "sizeof mismatch for FilterMode"); + static_assert(alignof(FilterMode) == alignof(WGPUFilterMode), "alignof mismatch for FilterMode"); + + static_assert(static_cast(FilterMode::Nearest) == WGPUFilterMode_Nearest, "value mismatch for FilterMode::Nearest"); + static_assert(static_cast(FilterMode::Linear) == WGPUFilterMode_Linear, "value mismatch for FilterMode::Linear"); + + + static_assert(sizeof(FrontFace) == sizeof(WGPUFrontFace), "sizeof mismatch for FrontFace"); + static_assert(alignof(FrontFace) == alignof(WGPUFrontFace), "alignof mismatch for FrontFace"); + + static_assert(static_cast(FrontFace::CCW) == WGPUFrontFace_CCW, "value mismatch for FrontFace::CCW"); + static_assert(static_cast(FrontFace::CW) == WGPUFrontFace_CW, "value mismatch for FrontFace::CW"); + + + static_assert(sizeof(IndexFormat) == sizeof(WGPUIndexFormat), "sizeof mismatch for IndexFormat"); + static_assert(alignof(IndexFormat) == alignof(WGPUIndexFormat), "alignof mismatch for IndexFormat"); + + static_assert(static_cast(IndexFormat::Uint16) == WGPUIndexFormat_Uint16, "value mismatch for IndexFormat::Uint16"); + static_assert(static_cast(IndexFormat::Uint32) == WGPUIndexFormat_Uint32, "value mismatch for IndexFormat::Uint32"); + + + static_assert(sizeof(InputStepMode) == sizeof(WGPUInputStepMode), "sizeof mismatch for InputStepMode"); + static_assert(alignof(InputStepMode) == alignof(WGPUInputStepMode), "alignof mismatch for InputStepMode"); + + static_assert(static_cast(InputStepMode::Vertex) == WGPUInputStepMode_Vertex, "value mismatch for InputStepMode::Vertex"); + static_assert(static_cast(InputStepMode::Instance) == WGPUInputStepMode_Instance, "value mismatch for InputStepMode::Instance"); + + + static_assert(sizeof(LoadOp) == sizeof(WGPULoadOp), "sizeof mismatch for LoadOp"); + static_assert(alignof(LoadOp) == alignof(WGPULoadOp), "alignof mismatch for LoadOp"); + + static_assert(static_cast(LoadOp::Clear) == WGPULoadOp_Clear, "value mismatch for LoadOp::Clear"); + static_assert(static_cast(LoadOp::Load) == WGPULoadOp_Load, "value mismatch for LoadOp::Load"); + + + static_assert(sizeof(PresentMode) == sizeof(WGPUPresentMode), "sizeof mismatch for PresentMode"); + static_assert(alignof(PresentMode) == alignof(WGPUPresentMode), "alignof mismatch for PresentMode"); + + static_assert(static_cast(PresentMode::Immediate) == WGPUPresentMode_Immediate, "value mismatch for PresentMode::Immediate"); + static_assert(static_cast(PresentMode::Mailbox) == WGPUPresentMode_Mailbox, "value mismatch for PresentMode::Mailbox"); + static_assert(static_cast(PresentMode::Fifo) == WGPUPresentMode_Fifo, "value mismatch for PresentMode::Fifo"); + + + static_assert(sizeof(PrimitiveTopology) == sizeof(WGPUPrimitiveTopology), "sizeof mismatch for PrimitiveTopology"); + static_assert(alignof(PrimitiveTopology) == alignof(WGPUPrimitiveTopology), "alignof mismatch for PrimitiveTopology"); + + static_assert(static_cast(PrimitiveTopology::PointList) == WGPUPrimitiveTopology_PointList, "value mismatch for PrimitiveTopology::PointList"); + static_assert(static_cast(PrimitiveTopology::LineList) == WGPUPrimitiveTopology_LineList, "value mismatch for PrimitiveTopology::LineList"); + static_assert(static_cast(PrimitiveTopology::LineStrip) == WGPUPrimitiveTopology_LineStrip, "value mismatch for PrimitiveTopology::LineStrip"); + static_assert(static_cast(PrimitiveTopology::TriangleList) == WGPUPrimitiveTopology_TriangleList, "value mismatch for PrimitiveTopology::TriangleList"); + static_assert(static_cast(PrimitiveTopology::TriangleStrip) == WGPUPrimitiveTopology_TriangleStrip, "value mismatch for PrimitiveTopology::TriangleStrip"); + + + static_assert(sizeof(SType) == sizeof(WGPUSType), "sizeof mismatch for SType"); + static_assert(alignof(SType) == alignof(WGPUSType), "alignof mismatch for SType"); + + static_assert(static_cast(SType::Invalid) == WGPUSType_Invalid, "value mismatch for SType::Invalid"); + static_assert(static_cast(SType::SurfaceDescriptorFromMetalLayer) == WGPUSType_SurfaceDescriptorFromMetalLayer, "value mismatch for SType::SurfaceDescriptorFromMetalLayer"); + static_assert(static_cast(SType::SurfaceDescriptorFromWindowsHWND) == WGPUSType_SurfaceDescriptorFromWindowsHWND, "value mismatch for SType::SurfaceDescriptorFromWindowsHWND"); + static_assert(static_cast(SType::SurfaceDescriptorFromXlib) == WGPUSType_SurfaceDescriptorFromXlib, "value mismatch for SType::SurfaceDescriptorFromXlib"); + static_assert(static_cast(SType::SurfaceDescriptorFromHTMLCanvasId) == WGPUSType_SurfaceDescriptorFromHTMLCanvasId, "value mismatch for SType::SurfaceDescriptorFromHTMLCanvasId"); + static_assert(static_cast(SType::ShaderModuleSPIRVDescriptor) == WGPUSType_ShaderModuleSPIRVDescriptor, "value mismatch for SType::ShaderModuleSPIRVDescriptor"); + static_assert(static_cast(SType::ShaderModuleWGSLDescriptor) == WGPUSType_ShaderModuleWGSLDescriptor, "value mismatch for SType::ShaderModuleWGSLDescriptor"); + static_assert(static_cast(SType::SamplerDescriptorDummyAnisotropicFiltering) == WGPUSType_SamplerDescriptorDummyAnisotropicFiltering, "value mismatch for SType::SamplerDescriptorDummyAnisotropicFiltering"); + static_assert(static_cast(SType::RenderPipelineDescriptorDummyExtension) == WGPUSType_RenderPipelineDescriptorDummyExtension, "value mismatch for SType::RenderPipelineDescriptorDummyExtension"); + + + static_assert(sizeof(StencilOperation) == sizeof(WGPUStencilOperation), "sizeof mismatch for StencilOperation"); + static_assert(alignof(StencilOperation) == alignof(WGPUStencilOperation), "alignof mismatch for StencilOperation"); + + static_assert(static_cast(StencilOperation::Keep) == WGPUStencilOperation_Keep, "value mismatch for StencilOperation::Keep"); + static_assert(static_cast(StencilOperation::Zero) == WGPUStencilOperation_Zero, "value mismatch for StencilOperation::Zero"); + static_assert(static_cast(StencilOperation::Replace) == WGPUStencilOperation_Replace, "value mismatch for StencilOperation::Replace"); + static_assert(static_cast(StencilOperation::Invert) == WGPUStencilOperation_Invert, "value mismatch for StencilOperation::Invert"); + static_assert(static_cast(StencilOperation::IncrementClamp) == WGPUStencilOperation_IncrementClamp, "value mismatch for StencilOperation::IncrementClamp"); + static_assert(static_cast(StencilOperation::DecrementClamp) == WGPUStencilOperation_DecrementClamp, "value mismatch for StencilOperation::DecrementClamp"); + static_assert(static_cast(StencilOperation::IncrementWrap) == WGPUStencilOperation_IncrementWrap, "value mismatch for StencilOperation::IncrementWrap"); + static_assert(static_cast(StencilOperation::DecrementWrap) == WGPUStencilOperation_DecrementWrap, "value mismatch for StencilOperation::DecrementWrap"); + + + static_assert(sizeof(StoreOp) == sizeof(WGPUStoreOp), "sizeof mismatch for StoreOp"); + static_assert(alignof(StoreOp) == alignof(WGPUStoreOp), "alignof mismatch for StoreOp"); + + static_assert(static_cast(StoreOp::Store) == WGPUStoreOp_Store, "value mismatch for StoreOp::Store"); + static_assert(static_cast(StoreOp::Clear) == WGPUStoreOp_Clear, "value mismatch for StoreOp::Clear"); + + + static_assert(sizeof(TextureAspect) == sizeof(WGPUTextureAspect), "sizeof mismatch for TextureAspect"); + static_assert(alignof(TextureAspect) == alignof(WGPUTextureAspect), "alignof mismatch for TextureAspect"); + + static_assert(static_cast(TextureAspect::All) == WGPUTextureAspect_All, "value mismatch for TextureAspect::All"); + static_assert(static_cast(TextureAspect::StencilOnly) == WGPUTextureAspect_StencilOnly, "value mismatch for TextureAspect::StencilOnly"); + static_assert(static_cast(TextureAspect::DepthOnly) == WGPUTextureAspect_DepthOnly, "value mismatch for TextureAspect::DepthOnly"); + + + static_assert(sizeof(TextureComponentType) == sizeof(WGPUTextureComponentType), "sizeof mismatch for TextureComponentType"); + static_assert(alignof(TextureComponentType) == alignof(WGPUTextureComponentType), "alignof mismatch for TextureComponentType"); + + static_assert(static_cast(TextureComponentType::Float) == WGPUTextureComponentType_Float, "value mismatch for TextureComponentType::Float"); + static_assert(static_cast(TextureComponentType::Sint) == WGPUTextureComponentType_Sint, "value mismatch for TextureComponentType::Sint"); + static_assert(static_cast(TextureComponentType::Uint) == WGPUTextureComponentType_Uint, "value mismatch for TextureComponentType::Uint"); + + + static_assert(sizeof(TextureDimension) == sizeof(WGPUTextureDimension), "sizeof mismatch for TextureDimension"); + static_assert(alignof(TextureDimension) == alignof(WGPUTextureDimension), "alignof mismatch for TextureDimension"); + + static_assert(static_cast(TextureDimension::e1D) == WGPUTextureDimension_1D, "value mismatch for TextureDimension::e1D"); + static_assert(static_cast(TextureDimension::e2D) == WGPUTextureDimension_2D, "value mismatch for TextureDimension::e2D"); + static_assert(static_cast(TextureDimension::e3D) == WGPUTextureDimension_3D, "value mismatch for TextureDimension::e3D"); + + + static_assert(sizeof(TextureFormat) == sizeof(WGPUTextureFormat), "sizeof mismatch for TextureFormat"); + static_assert(alignof(TextureFormat) == alignof(WGPUTextureFormat), "alignof mismatch for TextureFormat"); + + static_assert(static_cast(TextureFormat::Undefined) == WGPUTextureFormat_Undefined, "value mismatch for TextureFormat::Undefined"); + static_assert(static_cast(TextureFormat::R8Unorm) == WGPUTextureFormat_R8Unorm, "value mismatch for TextureFormat::R8Unorm"); + static_assert(static_cast(TextureFormat::R8Snorm) == WGPUTextureFormat_R8Snorm, "value mismatch for TextureFormat::R8Snorm"); + static_assert(static_cast(TextureFormat::R8Uint) == WGPUTextureFormat_R8Uint, "value mismatch for TextureFormat::R8Uint"); + static_assert(static_cast(TextureFormat::R8Sint) == WGPUTextureFormat_R8Sint, "value mismatch for TextureFormat::R8Sint"); + static_assert(static_cast(TextureFormat::R16Uint) == WGPUTextureFormat_R16Uint, "value mismatch for TextureFormat::R16Uint"); + static_assert(static_cast(TextureFormat::R16Sint) == WGPUTextureFormat_R16Sint, "value mismatch for TextureFormat::R16Sint"); + static_assert(static_cast(TextureFormat::R16Float) == WGPUTextureFormat_R16Float, "value mismatch for TextureFormat::R16Float"); + static_assert(static_cast(TextureFormat::RG8Unorm) == WGPUTextureFormat_RG8Unorm, "value mismatch for TextureFormat::RG8Unorm"); + static_assert(static_cast(TextureFormat::RG8Snorm) == WGPUTextureFormat_RG8Snorm, "value mismatch for TextureFormat::RG8Snorm"); + static_assert(static_cast(TextureFormat::RG8Uint) == WGPUTextureFormat_RG8Uint, "value mismatch for TextureFormat::RG8Uint"); + static_assert(static_cast(TextureFormat::RG8Sint) == WGPUTextureFormat_RG8Sint, "value mismatch for TextureFormat::RG8Sint"); + static_assert(static_cast(TextureFormat::R32Float) == WGPUTextureFormat_R32Float, "value mismatch for TextureFormat::R32Float"); + static_assert(static_cast(TextureFormat::R32Uint) == WGPUTextureFormat_R32Uint, "value mismatch for TextureFormat::R32Uint"); + static_assert(static_cast(TextureFormat::R32Sint) == WGPUTextureFormat_R32Sint, "value mismatch for TextureFormat::R32Sint"); + static_assert(static_cast(TextureFormat::RG16Uint) == WGPUTextureFormat_RG16Uint, "value mismatch for TextureFormat::RG16Uint"); + static_assert(static_cast(TextureFormat::RG16Sint) == WGPUTextureFormat_RG16Sint, "value mismatch for TextureFormat::RG16Sint"); + static_assert(static_cast(TextureFormat::RG16Float) == WGPUTextureFormat_RG16Float, "value mismatch for TextureFormat::RG16Float"); + static_assert(static_cast(TextureFormat::RGBA8Unorm) == WGPUTextureFormat_RGBA8Unorm, "value mismatch for TextureFormat::RGBA8Unorm"); + static_assert(static_cast(TextureFormat::RGBA8UnormSrgb) == WGPUTextureFormat_RGBA8UnormSrgb, "value mismatch for TextureFormat::RGBA8UnormSrgb"); + static_assert(static_cast(TextureFormat::RGBA8Snorm) == WGPUTextureFormat_RGBA8Snorm, "value mismatch for TextureFormat::RGBA8Snorm"); + static_assert(static_cast(TextureFormat::RGBA8Uint) == WGPUTextureFormat_RGBA8Uint, "value mismatch for TextureFormat::RGBA8Uint"); + static_assert(static_cast(TextureFormat::RGBA8Sint) == WGPUTextureFormat_RGBA8Sint, "value mismatch for TextureFormat::RGBA8Sint"); + static_assert(static_cast(TextureFormat::BGRA8Unorm) == WGPUTextureFormat_BGRA8Unorm, "value mismatch for TextureFormat::BGRA8Unorm"); + static_assert(static_cast(TextureFormat::BGRA8UnormSrgb) == WGPUTextureFormat_BGRA8UnormSrgb, "value mismatch for TextureFormat::BGRA8UnormSrgb"); + static_assert(static_cast(TextureFormat::RGB10A2Unorm) == WGPUTextureFormat_RGB10A2Unorm, "value mismatch for TextureFormat::RGB10A2Unorm"); + static_assert(static_cast(TextureFormat::RG11B10Float) == WGPUTextureFormat_RG11B10Float, "value mismatch for TextureFormat::RG11B10Float"); + static_assert(static_cast(TextureFormat::RG32Float) == WGPUTextureFormat_RG32Float, "value mismatch for TextureFormat::RG32Float"); + static_assert(static_cast(TextureFormat::RG32Uint) == WGPUTextureFormat_RG32Uint, "value mismatch for TextureFormat::RG32Uint"); + static_assert(static_cast(TextureFormat::RG32Sint) == WGPUTextureFormat_RG32Sint, "value mismatch for TextureFormat::RG32Sint"); + static_assert(static_cast(TextureFormat::RGBA16Uint) == WGPUTextureFormat_RGBA16Uint, "value mismatch for TextureFormat::RGBA16Uint"); + static_assert(static_cast(TextureFormat::RGBA16Sint) == WGPUTextureFormat_RGBA16Sint, "value mismatch for TextureFormat::RGBA16Sint"); + static_assert(static_cast(TextureFormat::RGBA16Float) == WGPUTextureFormat_RGBA16Float, "value mismatch for TextureFormat::RGBA16Float"); + static_assert(static_cast(TextureFormat::RGBA32Float) == WGPUTextureFormat_RGBA32Float, "value mismatch for TextureFormat::RGBA32Float"); + static_assert(static_cast(TextureFormat::RGBA32Uint) == WGPUTextureFormat_RGBA32Uint, "value mismatch for TextureFormat::RGBA32Uint"); + static_assert(static_cast(TextureFormat::RGBA32Sint) == WGPUTextureFormat_RGBA32Sint, "value mismatch for TextureFormat::RGBA32Sint"); + static_assert(static_cast(TextureFormat::Depth32Float) == WGPUTextureFormat_Depth32Float, "value mismatch for TextureFormat::Depth32Float"); + static_assert(static_cast(TextureFormat::Depth24Plus) == WGPUTextureFormat_Depth24Plus, "value mismatch for TextureFormat::Depth24Plus"); + static_assert(static_cast(TextureFormat::Depth24PlusStencil8) == WGPUTextureFormat_Depth24PlusStencil8, "value mismatch for TextureFormat::Depth24PlusStencil8"); + static_assert(static_cast(TextureFormat::BC1RGBAUnorm) == WGPUTextureFormat_BC1RGBAUnorm, "value mismatch for TextureFormat::BC1RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC1RGBAUnormSrgb) == WGPUTextureFormat_BC1RGBAUnormSrgb, "value mismatch for TextureFormat::BC1RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC2RGBAUnorm) == WGPUTextureFormat_BC2RGBAUnorm, "value mismatch for TextureFormat::BC2RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC2RGBAUnormSrgb) == WGPUTextureFormat_BC2RGBAUnormSrgb, "value mismatch for TextureFormat::BC2RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC3RGBAUnorm) == WGPUTextureFormat_BC3RGBAUnorm, "value mismatch for TextureFormat::BC3RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC3RGBAUnormSrgb) == WGPUTextureFormat_BC3RGBAUnormSrgb, "value mismatch for TextureFormat::BC3RGBAUnormSrgb"); + static_assert(static_cast(TextureFormat::BC4RUnorm) == WGPUTextureFormat_BC4RUnorm, "value mismatch for TextureFormat::BC4RUnorm"); + static_assert(static_cast(TextureFormat::BC4RSnorm) == WGPUTextureFormat_BC4RSnorm, "value mismatch for TextureFormat::BC4RSnorm"); + static_assert(static_cast(TextureFormat::BC5RGUnorm) == WGPUTextureFormat_BC5RGUnorm, "value mismatch for TextureFormat::BC5RGUnorm"); + static_assert(static_cast(TextureFormat::BC5RGSnorm) == WGPUTextureFormat_BC5RGSnorm, "value mismatch for TextureFormat::BC5RGSnorm"); + static_assert(static_cast(TextureFormat::BC6HRGBUfloat) == WGPUTextureFormat_BC6HRGBUfloat, "value mismatch for TextureFormat::BC6HRGBUfloat"); + static_assert(static_cast(TextureFormat::BC6HRGBSfloat) == WGPUTextureFormat_BC6HRGBSfloat, "value mismatch for TextureFormat::BC6HRGBSfloat"); + static_assert(static_cast(TextureFormat::BC7RGBAUnorm) == WGPUTextureFormat_BC7RGBAUnorm, "value mismatch for TextureFormat::BC7RGBAUnorm"); + static_assert(static_cast(TextureFormat::BC7RGBAUnormSrgb) == WGPUTextureFormat_BC7RGBAUnormSrgb, "value mismatch for TextureFormat::BC7RGBAUnormSrgb"); + + + static_assert(sizeof(TextureViewDimension) == sizeof(WGPUTextureViewDimension), "sizeof mismatch for TextureViewDimension"); + static_assert(alignof(TextureViewDimension) == alignof(WGPUTextureViewDimension), "alignof mismatch for TextureViewDimension"); + + static_assert(static_cast(TextureViewDimension::Undefined) == WGPUTextureViewDimension_Undefined, "value mismatch for TextureViewDimension::Undefined"); + static_assert(static_cast(TextureViewDimension::e1D) == WGPUTextureViewDimension_1D, "value mismatch for TextureViewDimension::e1D"); + static_assert(static_cast(TextureViewDimension::e2D) == WGPUTextureViewDimension_2D, "value mismatch for TextureViewDimension::e2D"); + static_assert(static_cast(TextureViewDimension::e2DArray) == WGPUTextureViewDimension_2DArray, "value mismatch for TextureViewDimension::e2DArray"); + static_assert(static_cast(TextureViewDimension::Cube) == WGPUTextureViewDimension_Cube, "value mismatch for TextureViewDimension::Cube"); + static_assert(static_cast(TextureViewDimension::CubeArray) == WGPUTextureViewDimension_CubeArray, "value mismatch for TextureViewDimension::CubeArray"); + static_assert(static_cast(TextureViewDimension::e3D) == WGPUTextureViewDimension_3D, "value mismatch for TextureViewDimension::e3D"); + + + static_assert(sizeof(VertexFormat) == sizeof(WGPUVertexFormat), "sizeof mismatch for VertexFormat"); + static_assert(alignof(VertexFormat) == alignof(WGPUVertexFormat), "alignof mismatch for VertexFormat"); + + static_assert(static_cast(VertexFormat::UChar2) == WGPUVertexFormat_UChar2, "value mismatch for VertexFormat::UChar2"); + static_assert(static_cast(VertexFormat::UChar4) == WGPUVertexFormat_UChar4, "value mismatch for VertexFormat::UChar4"); + static_assert(static_cast(VertexFormat::Char2) == WGPUVertexFormat_Char2, "value mismatch for VertexFormat::Char2"); + static_assert(static_cast(VertexFormat::Char4) == WGPUVertexFormat_Char4, "value mismatch for VertexFormat::Char4"); + static_assert(static_cast(VertexFormat::UChar2Norm) == WGPUVertexFormat_UChar2Norm, "value mismatch for VertexFormat::UChar2Norm"); + static_assert(static_cast(VertexFormat::UChar4Norm) == WGPUVertexFormat_UChar4Norm, "value mismatch for VertexFormat::UChar4Norm"); + static_assert(static_cast(VertexFormat::Char2Norm) == WGPUVertexFormat_Char2Norm, "value mismatch for VertexFormat::Char2Norm"); + static_assert(static_cast(VertexFormat::Char4Norm) == WGPUVertexFormat_Char4Norm, "value mismatch for VertexFormat::Char4Norm"); + static_assert(static_cast(VertexFormat::UShort2) == WGPUVertexFormat_UShort2, "value mismatch for VertexFormat::UShort2"); + static_assert(static_cast(VertexFormat::UShort4) == WGPUVertexFormat_UShort4, "value mismatch for VertexFormat::UShort4"); + static_assert(static_cast(VertexFormat::Short2) == WGPUVertexFormat_Short2, "value mismatch for VertexFormat::Short2"); + static_assert(static_cast(VertexFormat::Short4) == WGPUVertexFormat_Short4, "value mismatch for VertexFormat::Short4"); + static_assert(static_cast(VertexFormat::UShort2Norm) == WGPUVertexFormat_UShort2Norm, "value mismatch for VertexFormat::UShort2Norm"); + static_assert(static_cast(VertexFormat::UShort4Norm) == WGPUVertexFormat_UShort4Norm, "value mismatch for VertexFormat::UShort4Norm"); + static_assert(static_cast(VertexFormat::Short2Norm) == WGPUVertexFormat_Short2Norm, "value mismatch for VertexFormat::Short2Norm"); + static_assert(static_cast(VertexFormat::Short4Norm) == WGPUVertexFormat_Short4Norm, "value mismatch for VertexFormat::Short4Norm"); + static_assert(static_cast(VertexFormat::Half2) == WGPUVertexFormat_Half2, "value mismatch for VertexFormat::Half2"); + static_assert(static_cast(VertexFormat::Half4) == WGPUVertexFormat_Half4, "value mismatch for VertexFormat::Half4"); + static_assert(static_cast(VertexFormat::Float) == WGPUVertexFormat_Float, "value mismatch for VertexFormat::Float"); + static_assert(static_cast(VertexFormat::Float2) == WGPUVertexFormat_Float2, "value mismatch for VertexFormat::Float2"); + static_assert(static_cast(VertexFormat::Float3) == WGPUVertexFormat_Float3, "value mismatch for VertexFormat::Float3"); + static_assert(static_cast(VertexFormat::Float4) == WGPUVertexFormat_Float4, "value mismatch for VertexFormat::Float4"); + static_assert(static_cast(VertexFormat::UInt) == WGPUVertexFormat_UInt, "value mismatch for VertexFormat::UInt"); + static_assert(static_cast(VertexFormat::UInt2) == WGPUVertexFormat_UInt2, "value mismatch for VertexFormat::UInt2"); + static_assert(static_cast(VertexFormat::UInt3) == WGPUVertexFormat_UInt3, "value mismatch for VertexFormat::UInt3"); + static_assert(static_cast(VertexFormat::UInt4) == WGPUVertexFormat_UInt4, "value mismatch for VertexFormat::UInt4"); + static_assert(static_cast(VertexFormat::Int) == WGPUVertexFormat_Int, "value mismatch for VertexFormat::Int"); + static_assert(static_cast(VertexFormat::Int2) == WGPUVertexFormat_Int2, "value mismatch for VertexFormat::Int2"); + static_assert(static_cast(VertexFormat::Int3) == WGPUVertexFormat_Int3, "value mismatch for VertexFormat::Int3"); + static_assert(static_cast(VertexFormat::Int4) == WGPUVertexFormat_Int4, "value mismatch for VertexFormat::Int4"); + + + + static_assert(sizeof(BufferUsage) == sizeof(WGPUBufferUsageFlags), "sizeof mismatch for BufferUsage"); + static_assert(alignof(BufferUsage) == alignof(WGPUBufferUsageFlags), "alignof mismatch for BufferUsage"); + + static_assert(static_cast(BufferUsage::None) == WGPUBufferUsage_None, "value mismatch for BufferUsage::None"); + static_assert(static_cast(BufferUsage::MapRead) == WGPUBufferUsage_MapRead, "value mismatch for BufferUsage::MapRead"); + static_assert(static_cast(BufferUsage::MapWrite) == WGPUBufferUsage_MapWrite, "value mismatch for BufferUsage::MapWrite"); + static_assert(static_cast(BufferUsage::CopySrc) == WGPUBufferUsage_CopySrc, "value mismatch for BufferUsage::CopySrc"); + static_assert(static_cast(BufferUsage::CopyDst) == WGPUBufferUsage_CopyDst, "value mismatch for BufferUsage::CopyDst"); + static_assert(static_cast(BufferUsage::Index) == WGPUBufferUsage_Index, "value mismatch for BufferUsage::Index"); + static_assert(static_cast(BufferUsage::Vertex) == WGPUBufferUsage_Vertex, "value mismatch for BufferUsage::Vertex"); + static_assert(static_cast(BufferUsage::Uniform) == WGPUBufferUsage_Uniform, "value mismatch for BufferUsage::Uniform"); + static_assert(static_cast(BufferUsage::Storage) == WGPUBufferUsage_Storage, "value mismatch for BufferUsage::Storage"); + static_assert(static_cast(BufferUsage::Indirect) == WGPUBufferUsage_Indirect, "value mismatch for BufferUsage::Indirect"); + + + static_assert(sizeof(ColorWriteMask) == sizeof(WGPUColorWriteMaskFlags), "sizeof mismatch for ColorWriteMask"); + static_assert(alignof(ColorWriteMask) == alignof(WGPUColorWriteMaskFlags), "alignof mismatch for ColorWriteMask"); + + static_assert(static_cast(ColorWriteMask::None) == WGPUColorWriteMask_None, "value mismatch for ColorWriteMask::None"); + static_assert(static_cast(ColorWriteMask::Red) == WGPUColorWriteMask_Red, "value mismatch for ColorWriteMask::Red"); + static_assert(static_cast(ColorWriteMask::Green) == WGPUColorWriteMask_Green, "value mismatch for ColorWriteMask::Green"); + static_assert(static_cast(ColorWriteMask::Blue) == WGPUColorWriteMask_Blue, "value mismatch for ColorWriteMask::Blue"); + static_assert(static_cast(ColorWriteMask::Alpha) == WGPUColorWriteMask_Alpha, "value mismatch for ColorWriteMask::Alpha"); + static_assert(static_cast(ColorWriteMask::All) == WGPUColorWriteMask_All, "value mismatch for ColorWriteMask::All"); + + + static_assert(sizeof(ShaderStage) == sizeof(WGPUShaderStageFlags), "sizeof mismatch for ShaderStage"); + static_assert(alignof(ShaderStage) == alignof(WGPUShaderStageFlags), "alignof mismatch for ShaderStage"); + + static_assert(static_cast(ShaderStage::None) == WGPUShaderStage_None, "value mismatch for ShaderStage::None"); + static_assert(static_cast(ShaderStage::Vertex) == WGPUShaderStage_Vertex, "value mismatch for ShaderStage::Vertex"); + static_assert(static_cast(ShaderStage::Fragment) == WGPUShaderStage_Fragment, "value mismatch for ShaderStage::Fragment"); + static_assert(static_cast(ShaderStage::Compute) == WGPUShaderStage_Compute, "value mismatch for ShaderStage::Compute"); + + + static_assert(sizeof(TextureUsage) == sizeof(WGPUTextureUsageFlags), "sizeof mismatch for TextureUsage"); + static_assert(alignof(TextureUsage) == alignof(WGPUTextureUsageFlags), "alignof mismatch for TextureUsage"); + + static_assert(static_cast(TextureUsage::None) == WGPUTextureUsage_None, "value mismatch for TextureUsage::None"); + static_assert(static_cast(TextureUsage::CopySrc) == WGPUTextureUsage_CopySrc, "value mismatch for TextureUsage::CopySrc"); + static_assert(static_cast(TextureUsage::CopyDst) == WGPUTextureUsage_CopyDst, "value mismatch for TextureUsage::CopyDst"); + static_assert(static_cast(TextureUsage::Sampled) == WGPUTextureUsage_Sampled, "value mismatch for TextureUsage::Sampled"); + static_assert(static_cast(TextureUsage::Storage) == WGPUTextureUsage_Storage, "value mismatch for TextureUsage::Storage"); + static_assert(static_cast(TextureUsage::OutputAttachment) == WGPUTextureUsage_OutputAttachment, "value mismatch for TextureUsage::OutputAttachment"); + static_assert(static_cast(TextureUsage::Present) == WGPUTextureUsage_Present, "value mismatch for TextureUsage::Present"); + + + static_assert(sizeof(ChainedStruct) == sizeof(WGPUChainedStruct), + "sizeof mismatch for ChainedStruct"); + static_assert(alignof(ChainedStruct) == alignof(WGPUChainedStruct), + "alignof mismatch for ChainedStruct"); + static_assert(offsetof(ChainedStruct, nextInChain) == offsetof(WGPUChainedStruct, next), + "offsetof mismatch for ChainedStruct::nextInChain"); + static_assert(offsetof(ChainedStruct, sType) == offsetof(WGPUChainedStruct, sType), + "offsetof mismatch for ChainedStruct::sType"); + + + static_assert(sizeof(AdapterProperties) == sizeof(WGPUAdapterProperties), "sizeof mismatch for AdapterProperties"); + static_assert(alignof(AdapterProperties) == alignof(WGPUAdapterProperties), "alignof mismatch for AdapterProperties"); + + static_assert(offsetof(AdapterProperties, nextInChain) == offsetof(WGPUAdapterProperties, nextInChain), + "offsetof mismatch for AdapterProperties::nextInChain"); + static_assert(offsetof(AdapterProperties, deviceID) == offsetof(WGPUAdapterProperties, deviceID), + "offsetof mismatch for AdapterProperties::deviceID"); + static_assert(offsetof(AdapterProperties, vendorID) == offsetof(WGPUAdapterProperties, vendorID), + "offsetof mismatch for AdapterProperties::vendorID"); + static_assert(offsetof(AdapterProperties, name) == offsetof(WGPUAdapterProperties, name), + "offsetof mismatch for AdapterProperties::name"); + static_assert(offsetof(AdapterProperties, adapterType) == offsetof(WGPUAdapterProperties, adapterType), + "offsetof mismatch for AdapterProperties::adapterType"); + static_assert(offsetof(AdapterProperties, backendType) == offsetof(WGPUAdapterProperties, backendType), + "offsetof mismatch for AdapterProperties::backendType"); + + + static_assert(sizeof(BindGroupEntry) == sizeof(WGPUBindGroupEntry), "sizeof mismatch for BindGroupEntry"); + static_assert(alignof(BindGroupEntry) == alignof(WGPUBindGroupEntry), "alignof mismatch for BindGroupEntry"); + + static_assert(offsetof(BindGroupEntry, binding) == offsetof(WGPUBindGroupEntry, binding), + "offsetof mismatch for BindGroupEntry::binding"); + static_assert(offsetof(BindGroupEntry, buffer) == offsetof(WGPUBindGroupEntry, buffer), + "offsetof mismatch for BindGroupEntry::buffer"); + static_assert(offsetof(BindGroupEntry, offset) == offsetof(WGPUBindGroupEntry, offset), + "offsetof mismatch for BindGroupEntry::offset"); + static_assert(offsetof(BindGroupEntry, size) == offsetof(WGPUBindGroupEntry, size), + "offsetof mismatch for BindGroupEntry::size"); + static_assert(offsetof(BindGroupEntry, sampler) == offsetof(WGPUBindGroupEntry, sampler), + "offsetof mismatch for BindGroupEntry::sampler"); + static_assert(offsetof(BindGroupEntry, textureView) == offsetof(WGPUBindGroupEntry, textureView), + "offsetof mismatch for BindGroupEntry::textureView"); + + + static_assert(sizeof(BindGroupLayoutEntry) == sizeof(WGPUBindGroupLayoutEntry), "sizeof mismatch for BindGroupLayoutEntry"); + static_assert(alignof(BindGroupLayoutEntry) == alignof(WGPUBindGroupLayoutEntry), "alignof mismatch for BindGroupLayoutEntry"); + + static_assert(offsetof(BindGroupLayoutEntry, binding) == offsetof(WGPUBindGroupLayoutEntry, binding), + "offsetof mismatch for BindGroupLayoutEntry::binding"); + static_assert(offsetof(BindGroupLayoutEntry, visibility) == offsetof(WGPUBindGroupLayoutEntry, visibility), + "offsetof mismatch for BindGroupLayoutEntry::visibility"); + static_assert(offsetof(BindGroupLayoutEntry, type) == offsetof(WGPUBindGroupLayoutEntry, type), + "offsetof mismatch for BindGroupLayoutEntry::type"); + static_assert(offsetof(BindGroupLayoutEntry, hasDynamicOffset) == offsetof(WGPUBindGroupLayoutEntry, hasDynamicOffset), + "offsetof mismatch for BindGroupLayoutEntry::hasDynamicOffset"); + static_assert(offsetof(BindGroupLayoutEntry, multisampled) == offsetof(WGPUBindGroupLayoutEntry, multisampled), + "offsetof mismatch for BindGroupLayoutEntry::multisampled"); + static_assert(offsetof(BindGroupLayoutEntry, viewDimension) == offsetof(WGPUBindGroupLayoutEntry, viewDimension), + "offsetof mismatch for BindGroupLayoutEntry::viewDimension"); + static_assert(offsetof(BindGroupLayoutEntry, textureComponentType) == offsetof(WGPUBindGroupLayoutEntry, textureComponentType), + "offsetof mismatch for BindGroupLayoutEntry::textureComponentType"); + static_assert(offsetof(BindGroupLayoutEntry, storageTextureFormat) == offsetof(WGPUBindGroupLayoutEntry, storageTextureFormat), + "offsetof mismatch for BindGroupLayoutEntry::storageTextureFormat"); + + + static_assert(sizeof(BlendDescriptor) == sizeof(WGPUBlendDescriptor), "sizeof mismatch for BlendDescriptor"); + static_assert(alignof(BlendDescriptor) == alignof(WGPUBlendDescriptor), "alignof mismatch for BlendDescriptor"); + + static_assert(offsetof(BlendDescriptor, operation) == offsetof(WGPUBlendDescriptor, operation), + "offsetof mismatch for BlendDescriptor::operation"); + static_assert(offsetof(BlendDescriptor, srcFactor) == offsetof(WGPUBlendDescriptor, srcFactor), + "offsetof mismatch for BlendDescriptor::srcFactor"); + static_assert(offsetof(BlendDescriptor, dstFactor) == offsetof(WGPUBlendDescriptor, dstFactor), + "offsetof mismatch for BlendDescriptor::dstFactor"); + + + static_assert(sizeof(BufferCopyView) == sizeof(WGPUBufferCopyView), "sizeof mismatch for BufferCopyView"); + static_assert(alignof(BufferCopyView) == alignof(WGPUBufferCopyView), "alignof mismatch for BufferCopyView"); + + static_assert(offsetof(BufferCopyView, nextInChain) == offsetof(WGPUBufferCopyView, nextInChain), + "offsetof mismatch for BufferCopyView::nextInChain"); + static_assert(offsetof(BufferCopyView, buffer) == offsetof(WGPUBufferCopyView, buffer), + "offsetof mismatch for BufferCopyView::buffer"); + static_assert(offsetof(BufferCopyView, offset) == offsetof(WGPUBufferCopyView, offset), + "offsetof mismatch for BufferCopyView::offset"); + static_assert(offsetof(BufferCopyView, bytesPerRow) == offsetof(WGPUBufferCopyView, bytesPerRow), + "offsetof mismatch for BufferCopyView::bytesPerRow"); + static_assert(offsetof(BufferCopyView, rowsPerImage) == offsetof(WGPUBufferCopyView, rowsPerImage), + "offsetof mismatch for BufferCopyView::rowsPerImage"); + + + static_assert(sizeof(BufferDescriptor) == sizeof(WGPUBufferDescriptor), "sizeof mismatch for BufferDescriptor"); + static_assert(alignof(BufferDescriptor) == alignof(WGPUBufferDescriptor), "alignof mismatch for BufferDescriptor"); + + static_assert(offsetof(BufferDescriptor, nextInChain) == offsetof(WGPUBufferDescriptor, nextInChain), + "offsetof mismatch for BufferDescriptor::nextInChain"); + static_assert(offsetof(BufferDescriptor, label) == offsetof(WGPUBufferDescriptor, label), + "offsetof mismatch for BufferDescriptor::label"); + static_assert(offsetof(BufferDescriptor, usage) == offsetof(WGPUBufferDescriptor, usage), + "offsetof mismatch for BufferDescriptor::usage"); + static_assert(offsetof(BufferDescriptor, size) == offsetof(WGPUBufferDescriptor, size), + "offsetof mismatch for BufferDescriptor::size"); + + + static_assert(sizeof(Color) == sizeof(WGPUColor), "sizeof mismatch for Color"); + static_assert(alignof(Color) == alignof(WGPUColor), "alignof mismatch for Color"); + + static_assert(offsetof(Color, r) == offsetof(WGPUColor, r), + "offsetof mismatch for Color::r"); + static_assert(offsetof(Color, g) == offsetof(WGPUColor, g), + "offsetof mismatch for Color::g"); + static_assert(offsetof(Color, b) == offsetof(WGPUColor, b), + "offsetof mismatch for Color::b"); + static_assert(offsetof(Color, a) == offsetof(WGPUColor, a), + "offsetof mismatch for Color::a"); + + + static_assert(sizeof(CommandBufferDescriptor) == sizeof(WGPUCommandBufferDescriptor), "sizeof mismatch for CommandBufferDescriptor"); + static_assert(alignof(CommandBufferDescriptor) == alignof(WGPUCommandBufferDescriptor), "alignof mismatch for CommandBufferDescriptor"); + + static_assert(offsetof(CommandBufferDescriptor, nextInChain) == offsetof(WGPUCommandBufferDescriptor, nextInChain), + "offsetof mismatch for CommandBufferDescriptor::nextInChain"); + static_assert(offsetof(CommandBufferDescriptor, label) == offsetof(WGPUCommandBufferDescriptor, label), + "offsetof mismatch for CommandBufferDescriptor::label"); + + + static_assert(sizeof(CommandEncoderDescriptor) == sizeof(WGPUCommandEncoderDescriptor), "sizeof mismatch for CommandEncoderDescriptor"); + static_assert(alignof(CommandEncoderDescriptor) == alignof(WGPUCommandEncoderDescriptor), "alignof mismatch for CommandEncoderDescriptor"); + + static_assert(offsetof(CommandEncoderDescriptor, nextInChain) == offsetof(WGPUCommandEncoderDescriptor, nextInChain), + "offsetof mismatch for CommandEncoderDescriptor::nextInChain"); + static_assert(offsetof(CommandEncoderDescriptor, label) == offsetof(WGPUCommandEncoderDescriptor, label), + "offsetof mismatch for CommandEncoderDescriptor::label"); + + + static_assert(sizeof(ComputePassDescriptor) == sizeof(WGPUComputePassDescriptor), "sizeof mismatch for ComputePassDescriptor"); + static_assert(alignof(ComputePassDescriptor) == alignof(WGPUComputePassDescriptor), "alignof mismatch for ComputePassDescriptor"); + + static_assert(offsetof(ComputePassDescriptor, nextInChain) == offsetof(WGPUComputePassDescriptor, nextInChain), + "offsetof mismatch for ComputePassDescriptor::nextInChain"); + static_assert(offsetof(ComputePassDescriptor, label) == offsetof(WGPUComputePassDescriptor, label), + "offsetof mismatch for ComputePassDescriptor::label"); + + + static_assert(sizeof(CreateBufferMappedResult) == sizeof(WGPUCreateBufferMappedResult), "sizeof mismatch for CreateBufferMappedResult"); + static_assert(alignof(CreateBufferMappedResult) == alignof(WGPUCreateBufferMappedResult), "alignof mismatch for CreateBufferMappedResult"); + + static_assert(offsetof(CreateBufferMappedResult, buffer) == offsetof(WGPUCreateBufferMappedResult, buffer), + "offsetof mismatch for CreateBufferMappedResult::buffer"); + static_assert(offsetof(CreateBufferMappedResult, dataLength) == offsetof(WGPUCreateBufferMappedResult, dataLength), + "offsetof mismatch for CreateBufferMappedResult::dataLength"); + static_assert(offsetof(CreateBufferMappedResult, data) == offsetof(WGPUCreateBufferMappedResult, data), + "offsetof mismatch for CreateBufferMappedResult::data"); + + + static_assert(sizeof(DeviceProperties) == sizeof(WGPUDeviceProperties), "sizeof mismatch for DeviceProperties"); + static_assert(alignof(DeviceProperties) == alignof(WGPUDeviceProperties), "alignof mismatch for DeviceProperties"); + + static_assert(offsetof(DeviceProperties, textureCompressionBC) == offsetof(WGPUDeviceProperties, textureCompressionBC), + "offsetof mismatch for DeviceProperties::textureCompressionBC"); + static_assert(offsetof(DeviceProperties, shaderFloat16) == offsetof(WGPUDeviceProperties, shaderFloat16), + "offsetof mismatch for DeviceProperties::shaderFloat16"); + static_assert(offsetof(DeviceProperties, pipelineStatisticsQuery) == offsetof(WGPUDeviceProperties, pipelineStatisticsQuery), + "offsetof mismatch for DeviceProperties::pipelineStatisticsQuery"); + static_assert(offsetof(DeviceProperties, timestampQuery) == offsetof(WGPUDeviceProperties, timestampQuery), + "offsetof mismatch for DeviceProperties::timestampQuery"); + + + static_assert(sizeof(Extent3D) == sizeof(WGPUExtent3D), "sizeof mismatch for Extent3D"); + static_assert(alignof(Extent3D) == alignof(WGPUExtent3D), "alignof mismatch for Extent3D"); + + static_assert(offsetof(Extent3D, width) == offsetof(WGPUExtent3D, width), + "offsetof mismatch for Extent3D::width"); + static_assert(offsetof(Extent3D, height) == offsetof(WGPUExtent3D, height), + "offsetof mismatch for Extent3D::height"); + static_assert(offsetof(Extent3D, depth) == offsetof(WGPUExtent3D, depth), + "offsetof mismatch for Extent3D::depth"); + + + static_assert(sizeof(FenceDescriptor) == sizeof(WGPUFenceDescriptor), "sizeof mismatch for FenceDescriptor"); + static_assert(alignof(FenceDescriptor) == alignof(WGPUFenceDescriptor), "alignof mismatch for FenceDescriptor"); + + static_assert(offsetof(FenceDescriptor, nextInChain) == offsetof(WGPUFenceDescriptor, nextInChain), + "offsetof mismatch for FenceDescriptor::nextInChain"); + static_assert(offsetof(FenceDescriptor, label) == offsetof(WGPUFenceDescriptor, label), + "offsetof mismatch for FenceDescriptor::label"); + static_assert(offsetof(FenceDescriptor, initialValue) == offsetof(WGPUFenceDescriptor, initialValue), + "offsetof mismatch for FenceDescriptor::initialValue"); + + + static_assert(sizeof(InstanceDescriptor) == sizeof(WGPUInstanceDescriptor), "sizeof mismatch for InstanceDescriptor"); + static_assert(alignof(InstanceDescriptor) == alignof(WGPUInstanceDescriptor), "alignof mismatch for InstanceDescriptor"); + + static_assert(offsetof(InstanceDescriptor, nextInChain) == offsetof(WGPUInstanceDescriptor, nextInChain), + "offsetof mismatch for InstanceDescriptor::nextInChain"); + + + static_assert(sizeof(Origin3D) == sizeof(WGPUOrigin3D), "sizeof mismatch for Origin3D"); + static_assert(alignof(Origin3D) == alignof(WGPUOrigin3D), "alignof mismatch for Origin3D"); + + static_assert(offsetof(Origin3D, x) == offsetof(WGPUOrigin3D, x), + "offsetof mismatch for Origin3D::x"); + static_assert(offsetof(Origin3D, y) == offsetof(WGPUOrigin3D, y), + "offsetof mismatch for Origin3D::y"); + static_assert(offsetof(Origin3D, z) == offsetof(WGPUOrigin3D, z), + "offsetof mismatch for Origin3D::z"); + + + static_assert(sizeof(PipelineLayoutDescriptor) == sizeof(WGPUPipelineLayoutDescriptor), "sizeof mismatch for PipelineLayoutDescriptor"); + static_assert(alignof(PipelineLayoutDescriptor) == alignof(WGPUPipelineLayoutDescriptor), "alignof mismatch for PipelineLayoutDescriptor"); + + static_assert(offsetof(PipelineLayoutDescriptor, nextInChain) == offsetof(WGPUPipelineLayoutDescriptor, nextInChain), + "offsetof mismatch for PipelineLayoutDescriptor::nextInChain"); + static_assert(offsetof(PipelineLayoutDescriptor, label) == offsetof(WGPUPipelineLayoutDescriptor, label), + "offsetof mismatch for PipelineLayoutDescriptor::label"); + static_assert(offsetof(PipelineLayoutDescriptor, bindGroupLayoutCount) == offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayoutCount), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayoutCount"); + static_assert(offsetof(PipelineLayoutDescriptor, bindGroupLayouts) == offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayouts), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayouts"); + + + static_assert(sizeof(ProgrammableStageDescriptor) == sizeof(WGPUProgrammableStageDescriptor), "sizeof mismatch for ProgrammableStageDescriptor"); + static_assert(alignof(ProgrammableStageDescriptor) == alignof(WGPUProgrammableStageDescriptor), "alignof mismatch for ProgrammableStageDescriptor"); + + static_assert(offsetof(ProgrammableStageDescriptor, nextInChain) == offsetof(WGPUProgrammableStageDescriptor, nextInChain), + "offsetof mismatch for ProgrammableStageDescriptor::nextInChain"); + static_assert(offsetof(ProgrammableStageDescriptor, module) == offsetof(WGPUProgrammableStageDescriptor, module), + "offsetof mismatch for ProgrammableStageDescriptor::module"); + static_assert(offsetof(ProgrammableStageDescriptor, entryPoint) == offsetof(WGPUProgrammableStageDescriptor, entryPoint), + "offsetof mismatch for ProgrammableStageDescriptor::entryPoint"); + + + static_assert(sizeof(RasterizationStateDescriptor) == sizeof(WGPURasterizationStateDescriptor), "sizeof mismatch for RasterizationStateDescriptor"); + static_assert(alignof(RasterizationStateDescriptor) == alignof(WGPURasterizationStateDescriptor), "alignof mismatch for RasterizationStateDescriptor"); + + static_assert(offsetof(RasterizationStateDescriptor, nextInChain) == offsetof(WGPURasterizationStateDescriptor, nextInChain), + "offsetof mismatch for RasterizationStateDescriptor::nextInChain"); + static_assert(offsetof(RasterizationStateDescriptor, frontFace) == offsetof(WGPURasterizationStateDescriptor, frontFace), + "offsetof mismatch for RasterizationStateDescriptor::frontFace"); + static_assert(offsetof(RasterizationStateDescriptor, cullMode) == offsetof(WGPURasterizationStateDescriptor, cullMode), + "offsetof mismatch for RasterizationStateDescriptor::cullMode"); + static_assert(offsetof(RasterizationStateDescriptor, depthBias) == offsetof(WGPURasterizationStateDescriptor, depthBias), + "offsetof mismatch for RasterizationStateDescriptor::depthBias"); + static_assert(offsetof(RasterizationStateDescriptor, depthBiasSlopeScale) == offsetof(WGPURasterizationStateDescriptor, depthBiasSlopeScale), + "offsetof mismatch for RasterizationStateDescriptor::depthBiasSlopeScale"); + static_assert(offsetof(RasterizationStateDescriptor, depthBiasClamp) == offsetof(WGPURasterizationStateDescriptor, depthBiasClamp), + "offsetof mismatch for RasterizationStateDescriptor::depthBiasClamp"); + + + static_assert(sizeof(RenderBundleDescriptor) == sizeof(WGPURenderBundleDescriptor), "sizeof mismatch for RenderBundleDescriptor"); + static_assert(alignof(RenderBundleDescriptor) == alignof(WGPURenderBundleDescriptor), "alignof mismatch for RenderBundleDescriptor"); + + static_assert(offsetof(RenderBundleDescriptor, nextInChain) == offsetof(WGPURenderBundleDescriptor, nextInChain), + "offsetof mismatch for RenderBundleDescriptor::nextInChain"); + static_assert(offsetof(RenderBundleDescriptor, label) == offsetof(WGPURenderBundleDescriptor, label), + "offsetof mismatch for RenderBundleDescriptor::label"); + + + static_assert(sizeof(RenderBundleEncoderDescriptor) == sizeof(WGPURenderBundleEncoderDescriptor), "sizeof mismatch for RenderBundleEncoderDescriptor"); + static_assert(alignof(RenderBundleEncoderDescriptor) == alignof(WGPURenderBundleEncoderDescriptor), "alignof mismatch for RenderBundleEncoderDescriptor"); + + static_assert(offsetof(RenderBundleEncoderDescriptor, nextInChain) == offsetof(WGPURenderBundleEncoderDescriptor, nextInChain), + "offsetof mismatch for RenderBundleEncoderDescriptor::nextInChain"); + static_assert(offsetof(RenderBundleEncoderDescriptor, label) == offsetof(WGPURenderBundleEncoderDescriptor, label), + "offsetof mismatch for RenderBundleEncoderDescriptor::label"); + static_assert(offsetof(RenderBundleEncoderDescriptor, colorFormatsCount) == offsetof(WGPURenderBundleEncoderDescriptor, colorFormatsCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormatsCount"); + static_assert(offsetof(RenderBundleEncoderDescriptor, colorFormats) == offsetof(WGPURenderBundleEncoderDescriptor, colorFormats), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormats"); + static_assert(offsetof(RenderBundleEncoderDescriptor, depthStencilFormat) == offsetof(WGPURenderBundleEncoderDescriptor, depthStencilFormat), + "offsetof mismatch for RenderBundleEncoderDescriptor::depthStencilFormat"); + static_assert(offsetof(RenderBundleEncoderDescriptor, sampleCount) == offsetof(WGPURenderBundleEncoderDescriptor, sampleCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::sampleCount"); + + + static_assert(sizeof(RenderPassDepthStencilAttachmentDescriptor) == sizeof(WGPURenderPassDepthStencilAttachmentDescriptor), "sizeof mismatch for RenderPassDepthStencilAttachmentDescriptor"); + static_assert(alignof(RenderPassDepthStencilAttachmentDescriptor) == alignof(WGPURenderPassDepthStencilAttachmentDescriptor), "alignof mismatch for RenderPassDepthStencilAttachmentDescriptor"); + + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, attachment) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, attachment), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::attachment"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, depthLoadOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, depthLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::depthLoadOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, depthStoreOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, depthStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::depthStoreOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, clearDepth) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, clearDepth), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::clearDepth"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, stencilLoadOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, stencilLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::stencilLoadOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, stencilStoreOp) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, stencilStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::stencilStoreOp"); + static_assert(offsetof(RenderPassDepthStencilAttachmentDescriptor, clearStencil) == offsetof(WGPURenderPassDepthStencilAttachmentDescriptor, clearStencil), + "offsetof mismatch for RenderPassDepthStencilAttachmentDescriptor::clearStencil"); + + + static_assert(sizeof(SamplerDescriptor) == sizeof(WGPUSamplerDescriptor), "sizeof mismatch for SamplerDescriptor"); + static_assert(alignof(SamplerDescriptor) == alignof(WGPUSamplerDescriptor), "alignof mismatch for SamplerDescriptor"); + + static_assert(offsetof(SamplerDescriptor, nextInChain) == offsetof(WGPUSamplerDescriptor, nextInChain), + "offsetof mismatch for SamplerDescriptor::nextInChain"); + static_assert(offsetof(SamplerDescriptor, label) == offsetof(WGPUSamplerDescriptor, label), + "offsetof mismatch for SamplerDescriptor::label"); + static_assert(offsetof(SamplerDescriptor, addressModeU) == offsetof(WGPUSamplerDescriptor, addressModeU), + "offsetof mismatch for SamplerDescriptor::addressModeU"); + static_assert(offsetof(SamplerDescriptor, addressModeV) == offsetof(WGPUSamplerDescriptor, addressModeV), + "offsetof mismatch for SamplerDescriptor::addressModeV"); + static_assert(offsetof(SamplerDescriptor, addressModeW) == offsetof(WGPUSamplerDescriptor, addressModeW), + "offsetof mismatch for SamplerDescriptor::addressModeW"); + static_assert(offsetof(SamplerDescriptor, magFilter) == offsetof(WGPUSamplerDescriptor, magFilter), + "offsetof mismatch for SamplerDescriptor::magFilter"); + static_assert(offsetof(SamplerDescriptor, minFilter) == offsetof(WGPUSamplerDescriptor, minFilter), + "offsetof mismatch for SamplerDescriptor::minFilter"); + static_assert(offsetof(SamplerDescriptor, mipmapFilter) == offsetof(WGPUSamplerDescriptor, mipmapFilter), + "offsetof mismatch for SamplerDescriptor::mipmapFilter"); + static_assert(offsetof(SamplerDescriptor, lodMinClamp) == offsetof(WGPUSamplerDescriptor, lodMinClamp), + "offsetof mismatch for SamplerDescriptor::lodMinClamp"); + static_assert(offsetof(SamplerDescriptor, lodMaxClamp) == offsetof(WGPUSamplerDescriptor, lodMaxClamp), + "offsetof mismatch for SamplerDescriptor::lodMaxClamp"); + static_assert(offsetof(SamplerDescriptor, compare) == offsetof(WGPUSamplerDescriptor, compare), + "offsetof mismatch for SamplerDescriptor::compare"); + + + static_assert(sizeof(SamplerDescriptorDummyAnisotropicFiltering) == sizeof(WGPUSamplerDescriptorDummyAnisotropicFiltering), "sizeof mismatch for SamplerDescriptorDummyAnisotropicFiltering"); + static_assert(alignof(SamplerDescriptorDummyAnisotropicFiltering) == alignof(WGPUSamplerDescriptorDummyAnisotropicFiltering), "alignof mismatch for SamplerDescriptorDummyAnisotropicFiltering"); + + static_assert(offsetof(SamplerDescriptorDummyAnisotropicFiltering, maxAnisotropy) == offsetof(WGPUSamplerDescriptorDummyAnisotropicFiltering, maxAnisotropy), + "offsetof mismatch for SamplerDescriptorDummyAnisotropicFiltering::maxAnisotropy"); + + + static_assert(sizeof(ShaderModuleDescriptor) == sizeof(WGPUShaderModuleDescriptor), "sizeof mismatch for ShaderModuleDescriptor"); + static_assert(alignof(ShaderModuleDescriptor) == alignof(WGPUShaderModuleDescriptor), "alignof mismatch for ShaderModuleDescriptor"); + + static_assert(offsetof(ShaderModuleDescriptor, nextInChain) == offsetof(WGPUShaderModuleDescriptor, nextInChain), + "offsetof mismatch for ShaderModuleDescriptor::nextInChain"); + static_assert(offsetof(ShaderModuleDescriptor, label) == offsetof(WGPUShaderModuleDescriptor, label), + "offsetof mismatch for ShaderModuleDescriptor::label"); + + + static_assert(sizeof(ShaderModuleSPIRVDescriptor) == sizeof(WGPUShaderModuleSPIRVDescriptor), "sizeof mismatch for ShaderModuleSPIRVDescriptor"); + static_assert(alignof(ShaderModuleSPIRVDescriptor) == alignof(WGPUShaderModuleSPIRVDescriptor), "alignof mismatch for ShaderModuleSPIRVDescriptor"); + + static_assert(offsetof(ShaderModuleSPIRVDescriptor, codeSize) == offsetof(WGPUShaderModuleSPIRVDescriptor, codeSize), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::codeSize"); + static_assert(offsetof(ShaderModuleSPIRVDescriptor, code) == offsetof(WGPUShaderModuleSPIRVDescriptor, code), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::code"); + + + static_assert(sizeof(ShaderModuleWGSLDescriptor) == sizeof(WGPUShaderModuleWGSLDescriptor), "sizeof mismatch for ShaderModuleWGSLDescriptor"); + static_assert(alignof(ShaderModuleWGSLDescriptor) == alignof(WGPUShaderModuleWGSLDescriptor), "alignof mismatch for ShaderModuleWGSLDescriptor"); + + static_assert(offsetof(ShaderModuleWGSLDescriptor, source) == offsetof(WGPUShaderModuleWGSLDescriptor, source), + "offsetof mismatch for ShaderModuleWGSLDescriptor::source"); + + + static_assert(sizeof(StencilStateFaceDescriptor) == sizeof(WGPUStencilStateFaceDescriptor), "sizeof mismatch for StencilStateFaceDescriptor"); + static_assert(alignof(StencilStateFaceDescriptor) == alignof(WGPUStencilStateFaceDescriptor), "alignof mismatch for StencilStateFaceDescriptor"); + + static_assert(offsetof(StencilStateFaceDescriptor, compare) == offsetof(WGPUStencilStateFaceDescriptor, compare), + "offsetof mismatch for StencilStateFaceDescriptor::compare"); + static_assert(offsetof(StencilStateFaceDescriptor, failOp) == offsetof(WGPUStencilStateFaceDescriptor, failOp), + "offsetof mismatch for StencilStateFaceDescriptor::failOp"); + static_assert(offsetof(StencilStateFaceDescriptor, depthFailOp) == offsetof(WGPUStencilStateFaceDescriptor, depthFailOp), + "offsetof mismatch for StencilStateFaceDescriptor::depthFailOp"); + static_assert(offsetof(StencilStateFaceDescriptor, passOp) == offsetof(WGPUStencilStateFaceDescriptor, passOp), + "offsetof mismatch for StencilStateFaceDescriptor::passOp"); + + + static_assert(sizeof(SurfaceDescriptor) == sizeof(WGPUSurfaceDescriptor), "sizeof mismatch for SurfaceDescriptor"); + static_assert(alignof(SurfaceDescriptor) == alignof(WGPUSurfaceDescriptor), "alignof mismatch for SurfaceDescriptor"); + + static_assert(offsetof(SurfaceDescriptor, nextInChain) == offsetof(WGPUSurfaceDescriptor, nextInChain), + "offsetof mismatch for SurfaceDescriptor::nextInChain"); + static_assert(offsetof(SurfaceDescriptor, label) == offsetof(WGPUSurfaceDescriptor, label), + "offsetof mismatch for SurfaceDescriptor::label"); + + + static_assert(sizeof(SurfaceDescriptorFromHTMLCanvasId) == sizeof(WGPUSurfaceDescriptorFromHTMLCanvasId), "sizeof mismatch for SurfaceDescriptorFromHTMLCanvasId"); + static_assert(alignof(SurfaceDescriptorFromHTMLCanvasId) == alignof(WGPUSurfaceDescriptorFromHTMLCanvasId), "alignof mismatch for SurfaceDescriptorFromHTMLCanvasId"); + + static_assert(offsetof(SurfaceDescriptorFromHTMLCanvasId, id) == offsetof(WGPUSurfaceDescriptorFromHTMLCanvasId, id), + "offsetof mismatch for SurfaceDescriptorFromHTMLCanvasId::id"); + + + static_assert(sizeof(SurfaceDescriptorFromMetalLayer) == sizeof(WGPUSurfaceDescriptorFromMetalLayer), "sizeof mismatch for SurfaceDescriptorFromMetalLayer"); + static_assert(alignof(SurfaceDescriptorFromMetalLayer) == alignof(WGPUSurfaceDescriptorFromMetalLayer), "alignof mismatch for SurfaceDescriptorFromMetalLayer"); + + static_assert(offsetof(SurfaceDescriptorFromMetalLayer, layer) == offsetof(WGPUSurfaceDescriptorFromMetalLayer, layer), + "offsetof mismatch for SurfaceDescriptorFromMetalLayer::layer"); + + + static_assert(sizeof(SurfaceDescriptorFromWindowsHWND) == sizeof(WGPUSurfaceDescriptorFromWindowsHWND), "sizeof mismatch for SurfaceDescriptorFromWindowsHWND"); + static_assert(alignof(SurfaceDescriptorFromWindowsHWND) == alignof(WGPUSurfaceDescriptorFromWindowsHWND), "alignof mismatch for SurfaceDescriptorFromWindowsHWND"); + + static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hinstance) == offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hinstance), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hinstance"); + static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hwnd) == offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hwnd), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hwnd"); + + + static_assert(sizeof(SurfaceDescriptorFromXlib) == sizeof(WGPUSurfaceDescriptorFromXlib), "sizeof mismatch for SurfaceDescriptorFromXlib"); + static_assert(alignof(SurfaceDescriptorFromXlib) == alignof(WGPUSurfaceDescriptorFromXlib), "alignof mismatch for SurfaceDescriptorFromXlib"); + + static_assert(offsetof(SurfaceDescriptorFromXlib, display) == offsetof(WGPUSurfaceDescriptorFromXlib, display), + "offsetof mismatch for SurfaceDescriptorFromXlib::display"); + static_assert(offsetof(SurfaceDescriptorFromXlib, window) == offsetof(WGPUSurfaceDescriptorFromXlib, window), + "offsetof mismatch for SurfaceDescriptorFromXlib::window"); + + + static_assert(sizeof(SwapChainDescriptor) == sizeof(WGPUSwapChainDescriptor), "sizeof mismatch for SwapChainDescriptor"); + static_assert(alignof(SwapChainDescriptor) == alignof(WGPUSwapChainDescriptor), "alignof mismatch for SwapChainDescriptor"); + + static_assert(offsetof(SwapChainDescriptor, nextInChain) == offsetof(WGPUSwapChainDescriptor, nextInChain), + "offsetof mismatch for SwapChainDescriptor::nextInChain"); + static_assert(offsetof(SwapChainDescriptor, label) == offsetof(WGPUSwapChainDescriptor, label), + "offsetof mismatch for SwapChainDescriptor::label"); + static_assert(offsetof(SwapChainDescriptor, usage) == offsetof(WGPUSwapChainDescriptor, usage), + "offsetof mismatch for SwapChainDescriptor::usage"); + static_assert(offsetof(SwapChainDescriptor, format) == offsetof(WGPUSwapChainDescriptor, format), + "offsetof mismatch for SwapChainDescriptor::format"); + static_assert(offsetof(SwapChainDescriptor, width) == offsetof(WGPUSwapChainDescriptor, width), + "offsetof mismatch for SwapChainDescriptor::width"); + static_assert(offsetof(SwapChainDescriptor, height) == offsetof(WGPUSwapChainDescriptor, height), + "offsetof mismatch for SwapChainDescriptor::height"); + static_assert(offsetof(SwapChainDescriptor, presentMode) == offsetof(WGPUSwapChainDescriptor, presentMode), + "offsetof mismatch for SwapChainDescriptor::presentMode"); + static_assert(offsetof(SwapChainDescriptor, implementation) == offsetof(WGPUSwapChainDescriptor, implementation), + "offsetof mismatch for SwapChainDescriptor::implementation"); + + + static_assert(sizeof(TextureViewDescriptor) == sizeof(WGPUTextureViewDescriptor), "sizeof mismatch for TextureViewDescriptor"); + static_assert(alignof(TextureViewDescriptor) == alignof(WGPUTextureViewDescriptor), "alignof mismatch for TextureViewDescriptor"); + + static_assert(offsetof(TextureViewDescriptor, nextInChain) == offsetof(WGPUTextureViewDescriptor, nextInChain), + "offsetof mismatch for TextureViewDescriptor::nextInChain"); + static_assert(offsetof(TextureViewDescriptor, label) == offsetof(WGPUTextureViewDescriptor, label), + "offsetof mismatch for TextureViewDescriptor::label"); + static_assert(offsetof(TextureViewDescriptor, format) == offsetof(WGPUTextureViewDescriptor, format), + "offsetof mismatch for TextureViewDescriptor::format"); + static_assert(offsetof(TextureViewDescriptor, dimension) == offsetof(WGPUTextureViewDescriptor, dimension), + "offsetof mismatch for TextureViewDescriptor::dimension"); + static_assert(offsetof(TextureViewDescriptor, baseMipLevel) == offsetof(WGPUTextureViewDescriptor, baseMipLevel), + "offsetof mismatch for TextureViewDescriptor::baseMipLevel"); + static_assert(offsetof(TextureViewDescriptor, mipLevelCount) == offsetof(WGPUTextureViewDescriptor, mipLevelCount), + "offsetof mismatch for TextureViewDescriptor::mipLevelCount"); + static_assert(offsetof(TextureViewDescriptor, baseArrayLayer) == offsetof(WGPUTextureViewDescriptor, baseArrayLayer), + "offsetof mismatch for TextureViewDescriptor::baseArrayLayer"); + static_assert(offsetof(TextureViewDescriptor, arrayLayerCount) == offsetof(WGPUTextureViewDescriptor, arrayLayerCount), + "offsetof mismatch for TextureViewDescriptor::arrayLayerCount"); + static_assert(offsetof(TextureViewDescriptor, aspect) == offsetof(WGPUTextureViewDescriptor, aspect), + "offsetof mismatch for TextureViewDescriptor::aspect"); + + + static_assert(sizeof(VertexAttributeDescriptor) == sizeof(WGPUVertexAttributeDescriptor), "sizeof mismatch for VertexAttributeDescriptor"); + static_assert(alignof(VertexAttributeDescriptor) == alignof(WGPUVertexAttributeDescriptor), "alignof mismatch for VertexAttributeDescriptor"); + + static_assert(offsetof(VertexAttributeDescriptor, format) == offsetof(WGPUVertexAttributeDescriptor, format), + "offsetof mismatch for VertexAttributeDescriptor::format"); + static_assert(offsetof(VertexAttributeDescriptor, offset) == offsetof(WGPUVertexAttributeDescriptor, offset), + "offsetof mismatch for VertexAttributeDescriptor::offset"); + static_assert(offsetof(VertexAttributeDescriptor, shaderLocation) == offsetof(WGPUVertexAttributeDescriptor, shaderLocation), + "offsetof mismatch for VertexAttributeDescriptor::shaderLocation"); + + + static_assert(sizeof(BindGroupDescriptor) == sizeof(WGPUBindGroupDescriptor), "sizeof mismatch for BindGroupDescriptor"); + static_assert(alignof(BindGroupDescriptor) == alignof(WGPUBindGroupDescriptor), "alignof mismatch for BindGroupDescriptor"); + + static_assert(offsetof(BindGroupDescriptor, nextInChain) == offsetof(WGPUBindGroupDescriptor, nextInChain), + "offsetof mismatch for BindGroupDescriptor::nextInChain"); + static_assert(offsetof(BindGroupDescriptor, label) == offsetof(WGPUBindGroupDescriptor, label), + "offsetof mismatch for BindGroupDescriptor::label"); + static_assert(offsetof(BindGroupDescriptor, layout) == offsetof(WGPUBindGroupDescriptor, layout), + "offsetof mismatch for BindGroupDescriptor::layout"); + static_assert(offsetof(BindGroupDescriptor, entryCount) == offsetof(WGPUBindGroupDescriptor, entryCount), + "offsetof mismatch for BindGroupDescriptor::entryCount"); + static_assert(offsetof(BindGroupDescriptor, entries) == offsetof(WGPUBindGroupDescriptor, entries), + "offsetof mismatch for BindGroupDescriptor::entries"); + + + static_assert(sizeof(BindGroupLayoutDescriptor) == sizeof(WGPUBindGroupLayoutDescriptor), "sizeof mismatch for BindGroupLayoutDescriptor"); + static_assert(alignof(BindGroupLayoutDescriptor) == alignof(WGPUBindGroupLayoutDescriptor), "alignof mismatch for BindGroupLayoutDescriptor"); + + static_assert(offsetof(BindGroupLayoutDescriptor, nextInChain) == offsetof(WGPUBindGroupLayoutDescriptor, nextInChain), + "offsetof mismatch for BindGroupLayoutDescriptor::nextInChain"); + static_assert(offsetof(BindGroupLayoutDescriptor, label) == offsetof(WGPUBindGroupLayoutDescriptor, label), + "offsetof mismatch for BindGroupLayoutDescriptor::label"); + static_assert(offsetof(BindGroupLayoutDescriptor, entryCount) == offsetof(WGPUBindGroupLayoutDescriptor, entryCount), + "offsetof mismatch for BindGroupLayoutDescriptor::entryCount"); + static_assert(offsetof(BindGroupLayoutDescriptor, entries) == offsetof(WGPUBindGroupLayoutDescriptor, entries), + "offsetof mismatch for BindGroupLayoutDescriptor::entries"); + + + static_assert(sizeof(ColorStateDescriptor) == sizeof(WGPUColorStateDescriptor), "sizeof mismatch for ColorStateDescriptor"); + static_assert(alignof(ColorStateDescriptor) == alignof(WGPUColorStateDescriptor), "alignof mismatch for ColorStateDescriptor"); + + static_assert(offsetof(ColorStateDescriptor, nextInChain) == offsetof(WGPUColorStateDescriptor, nextInChain), + "offsetof mismatch for ColorStateDescriptor::nextInChain"); + static_assert(offsetof(ColorStateDescriptor, format) == offsetof(WGPUColorStateDescriptor, format), + "offsetof mismatch for ColorStateDescriptor::format"); + static_assert(offsetof(ColorStateDescriptor, alphaBlend) == offsetof(WGPUColorStateDescriptor, alphaBlend), + "offsetof mismatch for ColorStateDescriptor::alphaBlend"); + static_assert(offsetof(ColorStateDescriptor, colorBlend) == offsetof(WGPUColorStateDescriptor, colorBlend), + "offsetof mismatch for ColorStateDescriptor::colorBlend"); + static_assert(offsetof(ColorStateDescriptor, writeMask) == offsetof(WGPUColorStateDescriptor, writeMask), + "offsetof mismatch for ColorStateDescriptor::writeMask"); + + + static_assert(sizeof(ComputePipelineDescriptor) == sizeof(WGPUComputePipelineDescriptor), "sizeof mismatch for ComputePipelineDescriptor"); + static_assert(alignof(ComputePipelineDescriptor) == alignof(WGPUComputePipelineDescriptor), "alignof mismatch for ComputePipelineDescriptor"); + + static_assert(offsetof(ComputePipelineDescriptor, nextInChain) == offsetof(WGPUComputePipelineDescriptor, nextInChain), + "offsetof mismatch for ComputePipelineDescriptor::nextInChain"); + static_assert(offsetof(ComputePipelineDescriptor, label) == offsetof(WGPUComputePipelineDescriptor, label), + "offsetof mismatch for ComputePipelineDescriptor::label"); + static_assert(offsetof(ComputePipelineDescriptor, layout) == offsetof(WGPUComputePipelineDescriptor, layout), + "offsetof mismatch for ComputePipelineDescriptor::layout"); + static_assert(offsetof(ComputePipelineDescriptor, computeStage) == offsetof(WGPUComputePipelineDescriptor, computeStage), + "offsetof mismatch for ComputePipelineDescriptor::computeStage"); + + + static_assert(sizeof(DepthStencilStateDescriptor) == sizeof(WGPUDepthStencilStateDescriptor), "sizeof mismatch for DepthStencilStateDescriptor"); + static_assert(alignof(DepthStencilStateDescriptor) == alignof(WGPUDepthStencilStateDescriptor), "alignof mismatch for DepthStencilStateDescriptor"); + + static_assert(offsetof(DepthStencilStateDescriptor, nextInChain) == offsetof(WGPUDepthStencilStateDescriptor, nextInChain), + "offsetof mismatch for DepthStencilStateDescriptor::nextInChain"); + static_assert(offsetof(DepthStencilStateDescriptor, format) == offsetof(WGPUDepthStencilStateDescriptor, format), + "offsetof mismatch for DepthStencilStateDescriptor::format"); + static_assert(offsetof(DepthStencilStateDescriptor, depthWriteEnabled) == offsetof(WGPUDepthStencilStateDescriptor, depthWriteEnabled), + "offsetof mismatch for DepthStencilStateDescriptor::depthWriteEnabled"); + static_assert(offsetof(DepthStencilStateDescriptor, depthCompare) == offsetof(WGPUDepthStencilStateDescriptor, depthCompare), + "offsetof mismatch for DepthStencilStateDescriptor::depthCompare"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilFront) == offsetof(WGPUDepthStencilStateDescriptor, stencilFront), + "offsetof mismatch for DepthStencilStateDescriptor::stencilFront"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilBack) == offsetof(WGPUDepthStencilStateDescriptor, stencilBack), + "offsetof mismatch for DepthStencilStateDescriptor::stencilBack"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilReadMask) == offsetof(WGPUDepthStencilStateDescriptor, stencilReadMask), + "offsetof mismatch for DepthStencilStateDescriptor::stencilReadMask"); + static_assert(offsetof(DepthStencilStateDescriptor, stencilWriteMask) == offsetof(WGPUDepthStencilStateDescriptor, stencilWriteMask), + "offsetof mismatch for DepthStencilStateDescriptor::stencilWriteMask"); + + + static_assert(sizeof(RenderPassColorAttachmentDescriptor) == sizeof(WGPURenderPassColorAttachmentDescriptor), "sizeof mismatch for RenderPassColorAttachmentDescriptor"); + static_assert(alignof(RenderPassColorAttachmentDescriptor) == alignof(WGPURenderPassColorAttachmentDescriptor), "alignof mismatch for RenderPassColorAttachmentDescriptor"); + + static_assert(offsetof(RenderPassColorAttachmentDescriptor, attachment) == offsetof(WGPURenderPassColorAttachmentDescriptor, attachment), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::attachment"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, resolveTarget) == offsetof(WGPURenderPassColorAttachmentDescriptor, resolveTarget), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::resolveTarget"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, loadOp) == offsetof(WGPURenderPassColorAttachmentDescriptor, loadOp), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::loadOp"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, storeOp) == offsetof(WGPURenderPassColorAttachmentDescriptor, storeOp), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::storeOp"); + static_assert(offsetof(RenderPassColorAttachmentDescriptor, clearColor) == offsetof(WGPURenderPassColorAttachmentDescriptor, clearColor), + "offsetof mismatch for RenderPassColorAttachmentDescriptor::clearColor"); + + + static_assert(sizeof(RenderPipelineDescriptorDummyExtension) == sizeof(WGPURenderPipelineDescriptorDummyExtension), "sizeof mismatch for RenderPipelineDescriptorDummyExtension"); + static_assert(alignof(RenderPipelineDescriptorDummyExtension) == alignof(WGPURenderPipelineDescriptorDummyExtension), "alignof mismatch for RenderPipelineDescriptorDummyExtension"); + + static_assert(offsetof(RenderPipelineDescriptorDummyExtension, dummyStage) == offsetof(WGPURenderPipelineDescriptorDummyExtension, dummyStage), + "offsetof mismatch for RenderPipelineDescriptorDummyExtension::dummyStage"); + + + static_assert(sizeof(TextureCopyView) == sizeof(WGPUTextureCopyView), "sizeof mismatch for TextureCopyView"); + static_assert(alignof(TextureCopyView) == alignof(WGPUTextureCopyView), "alignof mismatch for TextureCopyView"); + + static_assert(offsetof(TextureCopyView, nextInChain) == offsetof(WGPUTextureCopyView, nextInChain), + "offsetof mismatch for TextureCopyView::nextInChain"); + static_assert(offsetof(TextureCopyView, texture) == offsetof(WGPUTextureCopyView, texture), + "offsetof mismatch for TextureCopyView::texture"); + static_assert(offsetof(TextureCopyView, mipLevel) == offsetof(WGPUTextureCopyView, mipLevel), + "offsetof mismatch for TextureCopyView::mipLevel"); + static_assert(offsetof(TextureCopyView, arrayLayer) == offsetof(WGPUTextureCopyView, arrayLayer), + "offsetof mismatch for TextureCopyView::arrayLayer"); + static_assert(offsetof(TextureCopyView, origin) == offsetof(WGPUTextureCopyView, origin), + "offsetof mismatch for TextureCopyView::origin"); + + + static_assert(sizeof(TextureDescriptor) == sizeof(WGPUTextureDescriptor), "sizeof mismatch for TextureDescriptor"); + static_assert(alignof(TextureDescriptor) == alignof(WGPUTextureDescriptor), "alignof mismatch for TextureDescriptor"); + + static_assert(offsetof(TextureDescriptor, nextInChain) == offsetof(WGPUTextureDescriptor, nextInChain), + "offsetof mismatch for TextureDescriptor::nextInChain"); + static_assert(offsetof(TextureDescriptor, label) == offsetof(WGPUTextureDescriptor, label), + "offsetof mismatch for TextureDescriptor::label"); + static_assert(offsetof(TextureDescriptor, usage) == offsetof(WGPUTextureDescriptor, usage), + "offsetof mismatch for TextureDescriptor::usage"); + static_assert(offsetof(TextureDescriptor, dimension) == offsetof(WGPUTextureDescriptor, dimension), + "offsetof mismatch for TextureDescriptor::dimension"); + static_assert(offsetof(TextureDescriptor, size) == offsetof(WGPUTextureDescriptor, size), + "offsetof mismatch for TextureDescriptor::size"); + static_assert(offsetof(TextureDescriptor, arrayLayerCount) == offsetof(WGPUTextureDescriptor, arrayLayerCount), + "offsetof mismatch for TextureDescriptor::arrayLayerCount"); + static_assert(offsetof(TextureDescriptor, format) == offsetof(WGPUTextureDescriptor, format), + "offsetof mismatch for TextureDescriptor::format"); + static_assert(offsetof(TextureDescriptor, mipLevelCount) == offsetof(WGPUTextureDescriptor, mipLevelCount), + "offsetof mismatch for TextureDescriptor::mipLevelCount"); + static_assert(offsetof(TextureDescriptor, sampleCount) == offsetof(WGPUTextureDescriptor, sampleCount), + "offsetof mismatch for TextureDescriptor::sampleCount"); + + + static_assert(sizeof(VertexBufferLayoutDescriptor) == sizeof(WGPUVertexBufferLayoutDescriptor), "sizeof mismatch for VertexBufferLayoutDescriptor"); + static_assert(alignof(VertexBufferLayoutDescriptor) == alignof(WGPUVertexBufferLayoutDescriptor), "alignof mismatch for VertexBufferLayoutDescriptor"); + + static_assert(offsetof(VertexBufferLayoutDescriptor, arrayStride) == offsetof(WGPUVertexBufferLayoutDescriptor, arrayStride), + "offsetof mismatch for VertexBufferLayoutDescriptor::arrayStride"); + static_assert(offsetof(VertexBufferLayoutDescriptor, stepMode) == offsetof(WGPUVertexBufferLayoutDescriptor, stepMode), + "offsetof mismatch for VertexBufferLayoutDescriptor::stepMode"); + static_assert(offsetof(VertexBufferLayoutDescriptor, attributeCount) == offsetof(WGPUVertexBufferLayoutDescriptor, attributeCount), + "offsetof mismatch for VertexBufferLayoutDescriptor::attributeCount"); + static_assert(offsetof(VertexBufferLayoutDescriptor, attributes) == offsetof(WGPUVertexBufferLayoutDescriptor, attributes), + "offsetof mismatch for VertexBufferLayoutDescriptor::attributes"); + + + static_assert(sizeof(RenderPassDescriptor) == sizeof(WGPURenderPassDescriptor), "sizeof mismatch for RenderPassDescriptor"); + static_assert(alignof(RenderPassDescriptor) == alignof(WGPURenderPassDescriptor), "alignof mismatch for RenderPassDescriptor"); + + static_assert(offsetof(RenderPassDescriptor, nextInChain) == offsetof(WGPURenderPassDescriptor, nextInChain), + "offsetof mismatch for RenderPassDescriptor::nextInChain"); + static_assert(offsetof(RenderPassDescriptor, label) == offsetof(WGPURenderPassDescriptor, label), + "offsetof mismatch for RenderPassDescriptor::label"); + static_assert(offsetof(RenderPassDescriptor, colorAttachmentCount) == offsetof(WGPURenderPassDescriptor, colorAttachmentCount), + "offsetof mismatch for RenderPassDescriptor::colorAttachmentCount"); + static_assert(offsetof(RenderPassDescriptor, colorAttachments) == offsetof(WGPURenderPassDescriptor, colorAttachments), + "offsetof mismatch for RenderPassDescriptor::colorAttachments"); + static_assert(offsetof(RenderPassDescriptor, depthStencilAttachment) == offsetof(WGPURenderPassDescriptor, depthStencilAttachment), + "offsetof mismatch for RenderPassDescriptor::depthStencilAttachment"); + + + static_assert(sizeof(VertexStateDescriptor) == sizeof(WGPUVertexStateDescriptor), "sizeof mismatch for VertexStateDescriptor"); + static_assert(alignof(VertexStateDescriptor) == alignof(WGPUVertexStateDescriptor), "alignof mismatch for VertexStateDescriptor"); + + static_assert(offsetof(VertexStateDescriptor, nextInChain) == offsetof(WGPUVertexStateDescriptor, nextInChain), + "offsetof mismatch for VertexStateDescriptor::nextInChain"); + static_assert(offsetof(VertexStateDescriptor, indexFormat) == offsetof(WGPUVertexStateDescriptor, indexFormat), + "offsetof mismatch for VertexStateDescriptor::indexFormat"); + static_assert(offsetof(VertexStateDescriptor, vertexBufferCount) == offsetof(WGPUVertexStateDescriptor, vertexBufferCount), + "offsetof mismatch for VertexStateDescriptor::vertexBufferCount"); + static_assert(offsetof(VertexStateDescriptor, vertexBuffers) == offsetof(WGPUVertexStateDescriptor, vertexBuffers), + "offsetof mismatch for VertexStateDescriptor::vertexBuffers"); + + + static_assert(sizeof(RenderPipelineDescriptor) == sizeof(WGPURenderPipelineDescriptor), "sizeof mismatch for RenderPipelineDescriptor"); + static_assert(alignof(RenderPipelineDescriptor) == alignof(WGPURenderPipelineDescriptor), "alignof mismatch for RenderPipelineDescriptor"); + + static_assert(offsetof(RenderPipelineDescriptor, nextInChain) == offsetof(WGPURenderPipelineDescriptor, nextInChain), + "offsetof mismatch for RenderPipelineDescriptor::nextInChain"); + static_assert(offsetof(RenderPipelineDescriptor, label) == offsetof(WGPURenderPipelineDescriptor, label), + "offsetof mismatch for RenderPipelineDescriptor::label"); + static_assert(offsetof(RenderPipelineDescriptor, layout) == offsetof(WGPURenderPipelineDescriptor, layout), + "offsetof mismatch for RenderPipelineDescriptor::layout"); + static_assert(offsetof(RenderPipelineDescriptor, vertexStage) == offsetof(WGPURenderPipelineDescriptor, vertexStage), + "offsetof mismatch for RenderPipelineDescriptor::vertexStage"); + static_assert(offsetof(RenderPipelineDescriptor, fragmentStage) == offsetof(WGPURenderPipelineDescriptor, fragmentStage), + "offsetof mismatch for RenderPipelineDescriptor::fragmentStage"); + static_assert(offsetof(RenderPipelineDescriptor, vertexState) == offsetof(WGPURenderPipelineDescriptor, vertexState), + "offsetof mismatch for RenderPipelineDescriptor::vertexState"); + static_assert(offsetof(RenderPipelineDescriptor, primitiveTopology) == offsetof(WGPURenderPipelineDescriptor, primitiveTopology), + "offsetof mismatch for RenderPipelineDescriptor::primitiveTopology"); + static_assert(offsetof(RenderPipelineDescriptor, rasterizationState) == offsetof(WGPURenderPipelineDescriptor, rasterizationState), + "offsetof mismatch for RenderPipelineDescriptor::rasterizationState"); + static_assert(offsetof(RenderPipelineDescriptor, sampleCount) == offsetof(WGPURenderPipelineDescriptor, sampleCount), + "offsetof mismatch for RenderPipelineDescriptor::sampleCount"); + static_assert(offsetof(RenderPipelineDescriptor, depthStencilState) == offsetof(WGPURenderPipelineDescriptor, depthStencilState), + "offsetof mismatch for RenderPipelineDescriptor::depthStencilState"); + static_assert(offsetof(RenderPipelineDescriptor, colorStateCount) == offsetof(WGPURenderPipelineDescriptor, colorStateCount), + "offsetof mismatch for RenderPipelineDescriptor::colorStateCount"); + static_assert(offsetof(RenderPipelineDescriptor, colorStates) == offsetof(WGPURenderPipelineDescriptor, colorStates), + "offsetof mismatch for RenderPipelineDescriptor::colorStates"); + static_assert(offsetof(RenderPipelineDescriptor, sampleMask) == offsetof(WGPURenderPipelineDescriptor, sampleMask), + "offsetof mismatch for RenderPipelineDescriptor::sampleMask"); + static_assert(offsetof(RenderPipelineDescriptor, alphaToCoverageEnabled) == offsetof(WGPURenderPipelineDescriptor, alphaToCoverageEnabled), + "offsetof mismatch for RenderPipelineDescriptor::alphaToCoverageEnabled"); + + + + static_assert(sizeof(BindGroup) == sizeof(WGPUBindGroup), "sizeof mismatch for BindGroup"); + static_assert(alignof(BindGroup) == alignof(WGPUBindGroup), "alignof mismatch for BindGroup"); + + + + void BindGroup::WGPUReference(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupReference(handle); + } + } + void BindGroup::WGPURelease(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupRelease(handle); + } + } + + + static_assert(sizeof(BindGroupLayout) == sizeof(WGPUBindGroupLayout), "sizeof mismatch for BindGroupLayout"); + static_assert(alignof(BindGroupLayout) == alignof(WGPUBindGroupLayout), "alignof mismatch for BindGroupLayout"); + + + + void BindGroupLayout::WGPUReference(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutReference(handle); + } + } + void BindGroupLayout::WGPURelease(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutRelease(handle); + } + } + + + static_assert(sizeof(Buffer) == sizeof(WGPUBuffer), "sizeof mismatch for Buffer"); + static_assert(alignof(Buffer) == alignof(WGPUBuffer), "alignof mismatch for Buffer"); + + + + void Buffer::Destroy() const { + wgpuBufferDestroy(Get()); + } + void Buffer::MapReadAsync(BufferMapReadCallback callback, void * userdata) const { + wgpuBufferMapReadAsync(Get(), callback, reinterpret_cast(userdata)); + } + void Buffer::MapWriteAsync(BufferMapWriteCallback callback, void * userdata) const { + wgpuBufferMapWriteAsync(Get(), callback, reinterpret_cast(userdata)); + } + void Buffer::SetSubData(uint64_t start, uint64_t count, void const * data) const { + wgpuBufferSetSubData(Get(), start, count, reinterpret_cast(data)); + } + void Buffer::Unmap() const { + wgpuBufferUnmap(Get()); + } + void Buffer::WGPUReference(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferReference(handle); + } + } + void Buffer::WGPURelease(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferRelease(handle); + } + } + + + static_assert(sizeof(CommandBuffer) == sizeof(WGPUCommandBuffer), "sizeof mismatch for CommandBuffer"); + static_assert(alignof(CommandBuffer) == alignof(WGPUCommandBuffer), "alignof mismatch for CommandBuffer"); + + + + void CommandBuffer::WGPUReference(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferReference(handle); + } + } + void CommandBuffer::WGPURelease(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferRelease(handle); + } + } + + + static_assert(sizeof(CommandEncoder) == sizeof(WGPUCommandEncoder), "sizeof mismatch for CommandEncoder"); + static_assert(alignof(CommandEncoder) == alignof(WGPUCommandEncoder), "alignof mismatch for CommandEncoder"); + + + + ComputePassEncoder CommandEncoder::BeginComputePass(ComputePassDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderBeginComputePass(Get(), reinterpret_cast(descriptor)); + return ComputePassEncoder::Acquire(result); + } + RenderPassEncoder CommandEncoder::BeginRenderPass(RenderPassDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderBeginRenderPass(Get(), reinterpret_cast(descriptor)); + return RenderPassEncoder::Acquire(result); + } + void CommandEncoder::CopyBufferToBuffer(Buffer const& source, uint64_t sourceOffset, Buffer const& destination, uint64_t destinationOffset, uint64_t size) const { + wgpuCommandEncoderCopyBufferToBuffer(Get(), source.Get(), sourceOffset, destination.Get(), destinationOffset, size); + } + void CommandEncoder::CopyBufferToTexture(BufferCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyBufferToTexture(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + void CommandEncoder::CopyTextureToBuffer(TextureCopyView const * source, BufferCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyTextureToBuffer(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + void CommandEncoder::CopyTextureToTexture(TextureCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const { + wgpuCommandEncoderCopyTextureToTexture(Get(), reinterpret_cast(source), reinterpret_cast(destination), reinterpret_cast(copySize)); + } + CommandBuffer CommandEncoder::Finish(CommandBufferDescriptor const * descriptor) const { + auto result = wgpuCommandEncoderFinish(Get(), reinterpret_cast(descriptor)); + return CommandBuffer::Acquire(result); + } + void CommandEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuCommandEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void CommandEncoder::PopDebugGroup() const { + wgpuCommandEncoderPopDebugGroup(Get()); + } + void CommandEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuCommandEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void CommandEncoder::WGPUReference(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderReference(handle); + } + } + void CommandEncoder::WGPURelease(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderRelease(handle); + } + } + + + static_assert(sizeof(ComputePassEncoder) == sizeof(WGPUComputePassEncoder), "sizeof mismatch for ComputePassEncoder"); + static_assert(alignof(ComputePassEncoder) == alignof(WGPUComputePassEncoder), "alignof mismatch for ComputePassEncoder"); + + + + void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) const { + wgpuComputePassEncoderDispatch(Get(), x, y, z); + } + void ComputePassEncoder::DispatchIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuComputePassEncoderDispatchIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void ComputePassEncoder::EndPass() const { + wgpuComputePassEncoderEndPass(Get()); + } + void ComputePassEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuComputePassEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void ComputePassEncoder::PopDebugGroup() const { + wgpuComputePassEncoderPopDebugGroup(Get()); + } + void ComputePassEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuComputePassEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void ComputePassEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuComputePassEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void ComputePassEncoder::SetPipeline(ComputePipeline const& pipeline) const { + wgpuComputePassEncoderSetPipeline(Get(), pipeline.Get()); + } + void ComputePassEncoder::WGPUReference(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderReference(handle); + } + } + void ComputePassEncoder::WGPURelease(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderRelease(handle); + } + } + + + static_assert(sizeof(ComputePipeline) == sizeof(WGPUComputePipeline), "sizeof mismatch for ComputePipeline"); + static_assert(alignof(ComputePipeline) == alignof(WGPUComputePipeline), "alignof mismatch for ComputePipeline"); + + + + BindGroupLayout ComputePipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuComputePipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); + } + void ComputePipeline::WGPUReference(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineReference(handle); + } + } + void ComputePipeline::WGPURelease(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineRelease(handle); + } + } + + + static_assert(sizeof(Device) == sizeof(WGPUDevice), "sizeof mismatch for Device"); + static_assert(alignof(Device) == alignof(WGPUDevice), "alignof mismatch for Device"); + + + + BindGroup Device::CreateBindGroup(BindGroupDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBindGroup(Get(), reinterpret_cast(descriptor)); + return BindGroup::Acquire(result); + } + BindGroupLayout Device::CreateBindGroupLayout(BindGroupLayoutDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBindGroupLayout(Get(), reinterpret_cast(descriptor)); + return BindGroupLayout::Acquire(result); + } + Buffer Device::CreateBuffer(BufferDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBuffer(Get(), reinterpret_cast(descriptor)); + return Buffer::Acquire(result); + } + CreateBufferMappedResult Device::CreateBufferMapped(BufferDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateBufferMapped(Get(), reinterpret_cast(descriptor)); + return CreateBufferMappedResult { + Buffer::Acquire(result.buffer), + result.dataLength, + result.data + }; + } + CommandEncoder Device::CreateCommandEncoder(CommandEncoderDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateCommandEncoder(Get(), reinterpret_cast(descriptor)); + return CommandEncoder::Acquire(result); + } + ComputePipeline Device::CreateComputePipeline(ComputePipelineDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateComputePipeline(Get(), reinterpret_cast(descriptor)); + return ComputePipeline::Acquire(result); + } + PipelineLayout Device::CreatePipelineLayout(PipelineLayoutDescriptor const * descriptor) const { + auto result = wgpuDeviceCreatePipelineLayout(Get(), reinterpret_cast(descriptor)); + return PipelineLayout::Acquire(result); + } + RenderBundleEncoder Device::CreateRenderBundleEncoder(RenderBundleEncoderDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateRenderBundleEncoder(Get(), reinterpret_cast(descriptor)); + return RenderBundleEncoder::Acquire(result); + } + RenderPipeline Device::CreateRenderPipeline(RenderPipelineDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateRenderPipeline(Get(), reinterpret_cast(descriptor)); + return RenderPipeline::Acquire(result); + } + Sampler Device::CreateSampler(SamplerDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateSampler(Get(), reinterpret_cast(descriptor)); + return Sampler::Acquire(result); + } + ShaderModule Device::CreateShaderModule(ShaderModuleDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateShaderModule(Get(), reinterpret_cast(descriptor)); + return ShaderModule::Acquire(result); + } + SwapChain Device::CreateSwapChain(Surface const& surface, SwapChainDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateSwapChain(Get(), surface.Get(), reinterpret_cast(descriptor)); + return SwapChain::Acquire(result); + } + Texture Device::CreateTexture(TextureDescriptor const * descriptor) const { + auto result = wgpuDeviceCreateTexture(Get(), reinterpret_cast(descriptor)); + return Texture::Acquire(result); + } + Queue Device::GetDefaultQueue() const { + auto result = wgpuDeviceGetDefaultQueue(Get()); + return Queue::Acquire(result); + } + void Device::InjectError(ErrorType type, char const * message) const { + wgpuDeviceInjectError(Get(), static_cast(type), reinterpret_cast(message)); + } + void Device::LoseForTesting() const { + wgpuDeviceLoseForTesting(Get()); + } + bool Device::PopErrorScope(ErrorCallback callback, void * userdata) const { + auto result = wgpuDevicePopErrorScope(Get(), callback, reinterpret_cast(userdata)); + return result; + } + void Device::PushErrorScope(ErrorFilter filter) const { + wgpuDevicePushErrorScope(Get(), static_cast(filter)); + } + void Device::SetDeviceLostCallback(DeviceLostCallback callback, void * userdata) const { + wgpuDeviceSetDeviceLostCallback(Get(), callback, reinterpret_cast(userdata)); + } + void Device::SetUncapturedErrorCallback(ErrorCallback callback, void * userdata) const { + wgpuDeviceSetUncapturedErrorCallback(Get(), callback, reinterpret_cast(userdata)); + } + void Device::Tick() const { + wgpuDeviceTick(Get()); + } + void Device::WGPUReference(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceReference(handle); + } + } + void Device::WGPURelease(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceRelease(handle); + } + } + + + static_assert(sizeof(Fence) == sizeof(WGPUFence), "sizeof mismatch for Fence"); + static_assert(alignof(Fence) == alignof(WGPUFence), "alignof mismatch for Fence"); + + + + uint64_t Fence::GetCompletedValue() const { + auto result = wgpuFenceGetCompletedValue(Get()); + return result; + } + void Fence::OnCompletion(uint64_t value, FenceOnCompletionCallback callback, void * userdata) const { + wgpuFenceOnCompletion(Get(), value, callback, reinterpret_cast(userdata)); + } + void Fence::WGPUReference(WGPUFence handle) { + if (handle != nullptr) { + wgpuFenceReference(handle); + } + } + void Fence::WGPURelease(WGPUFence handle) { + if (handle != nullptr) { + wgpuFenceRelease(handle); + } + } + + + static_assert(sizeof(Instance) == sizeof(WGPUInstance), "sizeof mismatch for Instance"); + static_assert(alignof(Instance) == alignof(WGPUInstance), "alignof mismatch for Instance"); + + + + Surface Instance::CreateSurface(SurfaceDescriptor const * descriptor) const { + auto result = wgpuInstanceCreateSurface(Get(), reinterpret_cast(descriptor)); + return Surface::Acquire(result); + } + void Instance::WGPUReference(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceReference(handle); + } + } + void Instance::WGPURelease(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceRelease(handle); + } + } + + + static_assert(sizeof(PipelineLayout) == sizeof(WGPUPipelineLayout), "sizeof mismatch for PipelineLayout"); + static_assert(alignof(PipelineLayout) == alignof(WGPUPipelineLayout), "alignof mismatch for PipelineLayout"); + + + + void PipelineLayout::WGPUReference(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutReference(handle); + } + } + void PipelineLayout::WGPURelease(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutRelease(handle); + } + } + + + static_assert(sizeof(Queue) == sizeof(WGPUQueue), "sizeof mismatch for Queue"); + static_assert(alignof(Queue) == alignof(WGPUQueue), "alignof mismatch for Queue"); + + + + Fence Queue::CreateFence(FenceDescriptor const * descriptor) const { + auto result = wgpuQueueCreateFence(Get(), reinterpret_cast(descriptor)); + return Fence::Acquire(result); + } + void Queue::Signal(Fence const& fence, uint64_t signalValue) const { + wgpuQueueSignal(Get(), fence.Get(), signalValue); + } + void Queue::Submit(uint32_t commandCount, CommandBuffer const * commands) const { + wgpuQueueSubmit(Get(), commandCount, reinterpret_cast(commands)); + } + void Queue::WGPUReference(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueReference(handle); + } + } + void Queue::WGPURelease(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueRelease(handle); + } + } + + + static_assert(sizeof(RenderBundle) == sizeof(WGPURenderBundle), "sizeof mismatch for RenderBundle"); + static_assert(alignof(RenderBundle) == alignof(WGPURenderBundle), "alignof mismatch for RenderBundle"); + + + + void RenderBundle::WGPUReference(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleReference(handle); + } + } + void RenderBundle::WGPURelease(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleRelease(handle); + } + } + + + static_assert(sizeof(RenderBundleEncoder) == sizeof(WGPURenderBundleEncoder), "sizeof mismatch for RenderBundleEncoder"); + static_assert(alignof(RenderBundleEncoder) == alignof(WGPURenderBundleEncoder), "alignof mismatch for RenderBundleEncoder"); + + + + void RenderBundleEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const { + wgpuRenderBundleEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, firstInstance); + } + void RenderBundleEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) const { + wgpuRenderBundleEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + void RenderBundleEncoder::DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderBundleEncoder::DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + RenderBundle RenderBundleEncoder::Finish(RenderBundleDescriptor const * descriptor) const { + auto result = wgpuRenderBundleEncoderFinish(Get(), reinterpret_cast(descriptor)); + return RenderBundle::Acquire(result); + } + void RenderBundleEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuRenderBundleEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void RenderBundleEncoder::PopDebugGroup() const { + wgpuRenderBundleEncoderPopDebugGroup(Get()); + } + void RenderBundleEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuRenderBundleEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void RenderBundleEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuRenderBundleEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void RenderBundleEncoder::SetIndexBuffer(Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderBundleEncoderSetIndexBuffer(Get(), buffer.Get(), offset, size); + } + void RenderBundleEncoder::SetPipeline(RenderPipeline const& pipeline) const { + wgpuRenderBundleEncoderSetPipeline(Get(), pipeline.Get()); + } + void RenderBundleEncoder::SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderBundleEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); + } + void RenderBundleEncoder::WGPUReference(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderReference(handle); + } + } + void RenderBundleEncoder::WGPURelease(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderRelease(handle); + } + } + + + static_assert(sizeof(RenderPassEncoder) == sizeof(WGPURenderPassEncoder), "sizeof mismatch for RenderPassEncoder"); + static_assert(alignof(RenderPassEncoder) == alignof(WGPURenderPassEncoder), "alignof mismatch for RenderPassEncoder"); + + + + void RenderPassEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const { + wgpuRenderPassEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, firstInstance); + } + void RenderPassEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) const { + wgpuRenderPassEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, baseVertex, firstInstance); + } + void RenderPassEncoder::DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderPassEncoder::DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndirect(Get(), indirectBuffer.Get(), indirectOffset); + } + void RenderPassEncoder::EndPass() const { + wgpuRenderPassEncoderEndPass(Get()); + } + void RenderPassEncoder::ExecuteBundles(uint32_t bundlesCount, RenderBundle const * bundles) const { + wgpuRenderPassEncoderExecuteBundles(Get(), bundlesCount, reinterpret_cast(bundles)); + } + void RenderPassEncoder::InsertDebugMarker(char const * groupLabel) const { + wgpuRenderPassEncoderInsertDebugMarker(Get(), reinterpret_cast(groupLabel)); + } + void RenderPassEncoder::PopDebugGroup() const { + wgpuRenderPassEncoderPopDebugGroup(Get()); + } + void RenderPassEncoder::PushDebugGroup(char const * groupLabel) const { + wgpuRenderPassEncoderPushDebugGroup(Get(), reinterpret_cast(groupLabel)); + } + void RenderPassEncoder::SetBindGroup(uint32_t groupIndex, BindGroup const& group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) const { + wgpuRenderPassEncoderSetBindGroup(Get(), groupIndex, group.Get(), dynamicOffsetCount, reinterpret_cast(dynamicOffsets)); + } + void RenderPassEncoder::SetBlendColor(Color const * color) const { + wgpuRenderPassEncoderSetBlendColor(Get(), reinterpret_cast(color)); + } + void RenderPassEncoder::SetIndexBuffer(Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetIndexBuffer(Get(), buffer.Get(), offset, size); + } + void RenderPassEncoder::SetPipeline(RenderPipeline const& pipeline) const { + wgpuRenderPassEncoderSetPipeline(Get(), pipeline.Get()); + } + void RenderPassEncoder::SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const { + wgpuRenderPassEncoderSetScissorRect(Get(), x, y, width, height); + } + void RenderPassEncoder::SetStencilReference(uint32_t reference) const { + wgpuRenderPassEncoderSetStencilReference(Get(), reference); + } + void RenderPassEncoder::SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); + } + void RenderPassEncoder::SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) const { + wgpuRenderPassEncoderSetViewport(Get(), x, y, width, height, minDepth, maxDepth); + } + void RenderPassEncoder::WGPUReference(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderReference(handle); + } + } + void RenderPassEncoder::WGPURelease(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderRelease(handle); + } + } + + + static_assert(sizeof(RenderPipeline) == sizeof(WGPURenderPipeline), "sizeof mismatch for RenderPipeline"); + static_assert(alignof(RenderPipeline) == alignof(WGPURenderPipeline), "alignof mismatch for RenderPipeline"); + + + + BindGroupLayout RenderPipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuRenderPipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); + } + void RenderPipeline::WGPUReference(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineReference(handle); + } + } + void RenderPipeline::WGPURelease(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineRelease(handle); + } + } + + + static_assert(sizeof(Sampler) == sizeof(WGPUSampler), "sizeof mismatch for Sampler"); + static_assert(alignof(Sampler) == alignof(WGPUSampler), "alignof mismatch for Sampler"); + + + + void Sampler::WGPUReference(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerReference(handle); + } + } + void Sampler::WGPURelease(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerRelease(handle); + } + } + + + static_assert(sizeof(ShaderModule) == sizeof(WGPUShaderModule), "sizeof mismatch for ShaderModule"); + static_assert(alignof(ShaderModule) == alignof(WGPUShaderModule), "alignof mismatch for ShaderModule"); + + + + void ShaderModule::WGPUReference(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleReference(handle); + } + } + void ShaderModule::WGPURelease(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleRelease(handle); + } + } + + + static_assert(sizeof(Surface) == sizeof(WGPUSurface), "sizeof mismatch for Surface"); + static_assert(alignof(Surface) == alignof(WGPUSurface), "alignof mismatch for Surface"); + + + + void Surface::WGPUReference(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceReference(handle); + } + } + void Surface::WGPURelease(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceRelease(handle); + } + } + + + static_assert(sizeof(SwapChain) == sizeof(WGPUSwapChain), "sizeof mismatch for SwapChain"); + static_assert(alignof(SwapChain) == alignof(WGPUSwapChain), "alignof mismatch for SwapChain"); + + + + void SwapChain::Configure(TextureFormat format, TextureUsage allowedUsage, uint32_t width, uint32_t height) const { + wgpuSwapChainConfigure(Get(), static_cast(format), static_cast(allowedUsage), width, height); + } + TextureView SwapChain::GetCurrentTextureView() const { + auto result = wgpuSwapChainGetCurrentTextureView(Get()); + return TextureView::Acquire(result); + } + void SwapChain::Present() const { + wgpuSwapChainPresent(Get()); + } + void SwapChain::WGPUReference(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainReference(handle); + } + } + void SwapChain::WGPURelease(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainRelease(handle); + } + } + + + static_assert(sizeof(Texture) == sizeof(WGPUTexture), "sizeof mismatch for Texture"); + static_assert(alignof(Texture) == alignof(WGPUTexture), "alignof mismatch for Texture"); + + + + TextureView Texture::CreateView(TextureViewDescriptor const * descriptor) const { + auto result = wgpuTextureCreateView(Get(), reinterpret_cast(descriptor)); + return TextureView::Acquire(result); + } + void Texture::Destroy() const { + wgpuTextureDestroy(Get()); + } + void Texture::WGPUReference(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureReference(handle); + } + } + void Texture::WGPURelease(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureRelease(handle); + } + } + + + static_assert(sizeof(TextureView) == sizeof(WGPUTextureView), "sizeof mismatch for TextureView"); + static_assert(alignof(TextureView) == alignof(WGPUTextureView), "alignof mismatch for TextureView"); + + + + void TextureView::WGPUReference(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewReference(handle); + } + } + void TextureView::WGPURelease(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewRelease(handle); + } + } + + + Instance CreateInstance(const InstanceDescriptor* descriptor) { + const WGPUInstanceDescriptor* cDescriptor = + reinterpret_cast(descriptor); + return Instance::Acquire(wgpuCreateInstance(cDescriptor)); + } + + Proc GetProcAddress(Device const& device, const char* procName) { + return reinterpret_cast(wgpuGetProcAddress(device.Get(), procName)); + } + +} diff --git a/modules/dnn/test/test_common.impl.hpp b/modules/dnn/test/test_common.impl.hpp index b33b8e40d9e7..9293e07f0ea6 100644 --- a/modules/dnn/test/test_common.impl.hpp +++ b/modules/dnn/test/test_common.impl.hpp @@ -25,6 +25,7 @@ void PrintTo(const cv::dnn::Backend& v, std::ostream* os) case DNN_BACKEND_HALIDE: *os << "HALIDE"; return; case DNN_BACKEND_INFERENCE_ENGINE: *os << "DLIE*"; return; case DNN_BACKEND_VKCOM: *os << "VKCOM"; return; + case DNN_BACKEND_WGPU: *os << "WGPU"; return; case DNN_BACKEND_OPENCV: *os << "OCV"; return; case DNN_BACKEND_CUDA: *os << "CUDA"; return; case DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019: *os << "DLIE"; return; @@ -41,6 +42,7 @@ void PrintTo(const cv::dnn::Target& v, std::ostream* os) case DNN_TARGET_OPENCL_FP16: *os << "OCL_FP16"; return; case DNN_TARGET_MYRIAD: *os << "MYRIAD"; return; case DNN_TARGET_VULKAN: *os << "VULKAN"; return; + case DNN_TARGET_WGPU: *os << "WGPU"; return; case DNN_TARGET_FPGA: *os << "FPGA"; return; case DNN_TARGET_CUDA: *os << "CUDA"; return; case DNN_TARGET_CUDA_FP16: *os << "CUDA_FP16"; return;