#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL)
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL)
#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL)
#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL)
#define WGPU_STRIDE_UNDEFINED (0xffffffffUL)
#define WGPU_WHOLE_MAP_SIZE SIZE_MAX
#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)

typedef uint32_t WGPUFlags;

typedef struct WGPUChainedStruct {
    struct WGPUChainedStruct const * next;
    WGPUSType sType;
} WGPUChainedStruct;

typedef struct WGPUChainedStructOut {
    struct WGPUChainedStructOut * next;
    WGPUSType sType;
} WGPUChainedStructOut;



// TODO: Dawn specific
typedef struct WGPUDawnCacheDeviceDescriptor {
    WGPUChainedStruct chain;
    char const * isolationKey;
} WGPUDawnCacheDeviceDescriptor;

// TODO: Dawn specific
typedef struct WGPUDawnEncoderInternalUsageDescriptor {
    WGPUChainedStruct chain;
    bool useInternalUsages;
} WGPUDawnEncoderInternalUsageDescriptor;

// TODO: Dawn specific
typedef struct WGPUDawnInstanceDescriptor {
    WGPUChainedStruct chain;
    uint32_t additionalRuntimeSearchPathsCount;
    const char* const * additionalRuntimeSearchPaths;
} WGPUDawnInstanceDescriptor;

// TODO: Dawn specific
typedef struct WGPUDawnTextureInternalUsageDescriptor {
    WGPUChainedStruct chain;
    WGPUTextureUsageFlags internalUsage;
} WGPUDawnTextureInternalUsageDescriptor;

// TODO: Dawn specific
typedef struct WGPUDawnTogglesDeviceDescriptor {
    WGPUChainedStruct chain;
    uint32_t forceEnabledTogglesCount;
    const char* const * forceEnabledToggles;
    uint32_t forceDisabledTogglesCount;
    const char* const * forceDisabledToggles;
} WGPUDawnTogglesDeviceDescriptor;







// TODO: Dawn-specific?
typedef struct WGPUCopyTextureForBrowserOptions {
    WGPUChainedStruct const * nextInChain;
    bool flipY;
    bool needsColorSpaceConversion;
    WGPUAlphaMode srcAlphaMode;
    float const * srcTransferFunctionParameters;
    float const * conversionMatrix;
    float const * dstTransferFunctionParameters;
    WGPUAlphaMode dstAlphaMode;
} WGPUCopyTextureForBrowserOptions;

typedef struct WGPUImageCopyBuffer {
    WGPUChainedStruct const * nextInChain;
    WGPUTextureDataLayout layout;
    WGPUBuffer buffer;
} WGPUImageCopyBuffer;

typedef struct WGPUImageCopyTexture {
    WGPUChainedStruct const * nextInChain;
    WGPUTexture texture;
    uint32_t mipLevel;
    WGPUOrigin3D origin;
    WGPUTextureAspect aspect;
} WGPUImageCopyTexture;

typedef struct WGPUSupportedLimits {
    WGPUChainedStructOut * nextInChain;
    WGPULimits limits;
} WGPUSupportedLimits;

typedef struct WGPUExternalTextureBindingEntry {
    WGPUChainedStruct chain;
    WGPUExternalTexture externalTexture;
} WGPUExternalTextureBindingEntry;

typedef struct WGPUExternalTextureBindingLayout {
    WGPUChainedStruct chain;
} WGPUExternalTextureBindingLayout;

typedef struct WGPUPrimitiveDepthClampingState {
    WGPUChainedStruct chain;
    bool clampDepth;
} WGPUPrimitiveDepthClampingState;





typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata);
typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, WGPUCompilationInfo const * compilationInfo, void * userdata);
typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata);
typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata);
typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata);
typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata);
typedef void (*WGPULoggingCallback)(WGPULoggingType type, char const * message, void * userdata);
typedef void (*WGPUProc)();

WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName);

typedef enum WGPUSType {
    // webgpu.h upstream:
    WGPUSType_Invalid = 0x00000000,
    WGPUSType_PrimitiveDepthClipControl = 0x00000007,
    WGPUSType_SurfaceDescriptorFromWaylandSurface = 0x00000008,
    WGPUSType_SurfaceDescriptorFromAndroidNativeWindow = 0x00000009,

    // webgpu.h dawn:
    WGPUSType_ExternalTextureBindingEntry = 0x00000009,
    WGPUSType_ExternalTextureBindingLayout = 0x0000000A,
    WGPUSType_DawnTextureInternalUsageDescriptor = 0x000003E8,
    WGPUSType_PrimitiveDepthClampingState = 0x000003E9,
    WGPUSType_DawnTogglesDeviceDescriptor = 0x000003EA,
    WGPUSType_DawnEncoderInternalUsageDescriptor = 0x000003EB,
    WGPUSType_DawnInstanceDescriptor = 0x000003EC,
    WGPUSType_DawnCacheDeviceDescriptor = 0x000003ED,
} WGPUSType;
