packages feed

mischief-render-0.1.0.0: src/Mischief/WGPU/Types/General.hsc

#include "webgpu.h"

module Mischief.WGPU.Types.General where 

import Foreign 
import Foreign.C.ConstPtr
import Foreign.C.Types
import Data.Void

import Mischief.WGPU.Callbacks
import Mischief.WGPU.Types.Enums


import Data.Data(Proxy(Proxy))
import Mischief.WGPU.Opaque


data WGPUSurface = WGPUSurface

data WGPUChainedStruct = WGPUChainedStruct
  { next :: Ptr WGPUChainedStruct,
    sType :: WGPUSType
  }
  

instance Storable WGPUChainedStruct where 
  alignment _ = #{alignment WGPUChainedStruct}
  sizeOf _ = #{size WGPUChainedStruct}
  peek ptr = do 
    next <- #{peek WGPUChainedStruct, next} ptr 
    sType <- #{peek WGPUChainedStruct, sType} ptr 
    return WGPUChainedStruct {next, sType}
  poke ptr WGPUChainedStruct {next, sType} = do 
    #{poke WGPUChainedStruct, next} ptr next
    #{poke WGPUChainedStruct, sType} ptr sType  


data WGPUSurfaceSourceXlibWindow = WGPUSurfaceSourceXlibWindow { 
  chain :: WGPUChainedStruct,
  display :: Ptr Void,
  window :: Int64
}

instance Storable WGPUSurfaceSourceXlibWindow where 
  alignment _ = #{alignment WGPUSurfaceSourceXlibWindow}
  sizeOf _ = #{size WGPUSurfaceSourceXlibWindow}
  peek ptr = do 
    chain <- #{peek WGPUSurfaceSourceXlibWindow, chain} ptr 
    display <- #{peek WGPUSurfaceSourceXlibWindow, display} ptr 
    window <- #{peek WGPUSurfaceSourceXlibWindow, window} ptr 
    return WGPUSurfaceSourceXlibWindow {chain, display, window}
  poke ptr WGPUSurfaceSourceXlibWindow {chain, display, window} = do 
    #{poke WGPUSurfaceSourceXlibWindow, chain} ptr chain
    #{poke WGPUSurfaceSourceXlibWindow, display} ptr display
    #{poke WGPUSurfaceSourceXlibWindow, window} ptr window

data WGPUSurfaceSourceWindowsHWND = WGPUSurfaceSourceWindowsHWND {
  chain :: WGPUChainedStruct, 
  hinstance :: Ptr Void,
  hwnd :: Ptr Void  
}

instance Storable WGPUSurfaceSourceWindowsHWND where
  alignment _ = #{alignment WGPUSurfaceSourceWindowsHWND}
  sizeOf _ = #{size WGPUSurfaceSourceWindowsHWND}
  peek ptr = do
    chain <- #{peek WGPUSurfaceSourceWindowsHWND, chain} ptr
    hinstance <- #{peek WGPUSurfaceSourceWindowsHWND, hinstance} ptr
    hwnd <- #{peek WGPUSurfaceSourceWindowsHWND, hwnd} ptr
    return WGPUSurfaceSourceWindowsHWND{chain, hinstance, hwnd}
  poke ptr WGPUSurfaceSourceWindowsHWND{chain, hinstance, hwnd} = do
    #{poke WGPUSurfaceSourceWindowsHWND, chain} ptr chain
    #{poke WGPUSurfaceSourceWindowsHWND, hinstance} ptr hinstance
    #{poke WGPUSurfaceSourceWindowsHWND, hwnd} ptr hwnd


data WGPUSurfaceSourceMetalLayer = WGPUSurfaceSourceMetalLayer {
  chain :: WGPUChainedStruct, 
  layer :: Ptr Void 
}

instance Storable WGPUSurfaceSourceMetalLayer where 
  alignment _ = #{alignment WGPUSurfaceSourceMetalLayer}
  sizeOf _ = #{size WGPUSurfaceSourceMetalLayer}
  peek ptr = do 
    chain <- #{peek WGPUSurfaceSourceMetalLayer, chain} ptr 
    layer <- #{peek WGPUSurfaceSourceMetalLayer, layer} ptr 
    return WGPUSurfaceSourceMetalLayer {chain, layer} 
  poke ptr WGPUSurfaceSourceMetalLayer {chain, layer} = do 
    #{poke WGPUSurfaceSourceMetalLayer, chain} ptr chain 
    #{poke WGPUSurfaceSourceMetalLayer, layer} ptr layer

data WGPUStringView = WGPUStringView {
  _data :: ConstPtr CChar, 
  length :: Int 
}

instance Storable WGPUStringView where 
  alignment _ = #{alignment WGPUStringView}
  sizeOf _ = #{size WGPUStringView}
  peek ptr = do 
    _data <- #{peek WGPUStringView, data} ptr 
    length <- #{peek WGPUStringView, length} ptr 
    return WGPUStringView {_data, length} 
  poke ptr WGPUStringView {_data, length} = do 
    #{poke WGPUStringView, data} ptr _data
    #{poke WGPUStringView, length} ptr length
  
data WGPUSurfaceDescriptor = WGPUSurfaceDescriptor {
  nextInChain :: Ptr WGPUChainedStruct,
  label :: WGPUStringView 
}

instance Storable WGPUSurfaceDescriptor where 
  alignment _ = #{alignment WGPUSurfaceDescriptor}
  sizeOf _ = #{size WGPUSurfaceDescriptor}
  peek ptr = do 
    nextInChain <- #{peek WGPUSurfaceDescriptor, nextInChain} ptr 
    label <- #{peek WGPUSurfaceDescriptor, label} ptr 
    return WGPUSurfaceDescriptor {nextInChain, label}
  poke ptr WGPUSurfaceDescriptor {nextInChain, label} = do
    #{poke WGPUSurfaceDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUSurfaceDescriptor, label} ptr label 


data WGPURequestAdapterOptions = WGPURequestAdapterOptions {
  nextInChain :: Ptr WGPUChainedStruct, 
  featureLevel :: WGPUFeatureLevel, 
  powerPreference :: WGPUPowerPreference, 
  forceFallbackAdapter :: WGPUBool,
  backendType :: WGPUBackendType, 
  compatibleSurface :: Ptr WGPUSurface 
}

instance Storable WGPURequestAdapterOptions where 
  alignment _ = #{alignment WGPURequestAdapterOptions}
  sizeOf _ = #{size WGPURequestAdapterOptions}
  peek ptr = do 
    nextInChain <- #{peek WGPURequestAdapterOptions, nextInChain} ptr 
    featureLevel <- #{peek WGPURequestAdapterOptions, featureLevel} ptr 
    powerPreference <- #{peek WGPURequestAdapterOptions, powerPreference} ptr 
    forceFallbackAdapter <- #{peek WGPURequestAdapterOptions, forceFallbackAdapter} ptr 
    backendType <- #{peek WGPURequestAdapterOptions, backendType} ptr 
    compatibleSurface <- #{peek WGPURequestAdapterOptions, compatibleSurface} ptr 
    return WGPURequestAdapterOptions {nextInChain, featureLevel, powerPreference, forceFallbackAdapter, backendType, compatibleSurface}
  poke ptr WGPURequestAdapterOptions {nextInChain, featureLevel, powerPreference, forceFallbackAdapter, backendType, compatibleSurface} = do
    #{poke WGPURequestAdapterOptions, nextInChain} ptr nextInChain 
    #{poke WGPURequestAdapterOptions, featureLevel} ptr featureLevel 
    #{poke WGPURequestAdapterOptions, powerPreference} ptr powerPreference 
    #{poke WGPURequestAdapterOptions, forceFallbackAdapter} ptr forceFallbackAdapter 
    #{poke WGPURequestAdapterOptions, backendType} ptr backendType 
    #{poke WGPURequestAdapterOptions, compatibleSurface} ptr compatibleSurface


data WGPURequestCallbackInfo f = WGPURequestCallbackInfo {
  nextInChain :: Ptr WGPUChainedStruct, 
  mode :: WGPUCallbackMode, 
  callback :: FunPtr f, 
  userdata1 :: Ptr (), 
  userdata2 :: Ptr ()
}

instance Storable (WGPURequestCallbackInfo WGPURequestAdapterCallback) where 
  alignment _ = #{alignment WGPURequestAdapterCallbackInfo}
  sizeOf _ = #{size WGPURequestAdapterCallbackInfo}
  peek ptr = do 
    nextInChain <- #{peek WGPURequestAdapterCallbackInfo, nextInChain} ptr 
    mode <- #{peek WGPURequestAdapterCallbackInfo, mode} ptr 
    callback <- #{peek WGPURequestAdapterCallbackInfo, callback} ptr 
    userdata1 <- #{peek WGPURequestAdapterCallbackInfo, userdata1} ptr 
    userdata2 <- #{peek WGPURequestAdapterCallbackInfo, userdata2} ptr 
    return WGPURequestCallbackInfo {nextInChain, mode, callback, userdata1, userdata2}
  poke ptr WGPURequestCallbackInfo {nextInChain, mode, callback, userdata1, userdata2} = do 
    #{poke WGPURequestAdapterCallbackInfo, nextInChain} ptr nextInChain
    #{poke WGPURequestAdapterCallbackInfo, mode} ptr mode  
    #{poke WGPURequestAdapterCallbackInfo, callback} ptr callback  
    #{poke WGPURequestAdapterCallbackInfo, userdata1} ptr userdata1  
    #{poke WGPURequestAdapterCallbackInfo, userdata2} ptr userdata2  


instance Storable (WGPURequestCallbackInfo WGPURequestDeviceCallback) where 
  alignment _ = #{alignment WGPURequestDeviceCallbackInfo}
  sizeOf _ = #{size WGPURequestDeviceCallbackInfo}
  peek ptr = do 
    nextInChain <- #{peek WGPURequestDeviceCallbackInfo, nextInChain} ptr 
    mode <- #{peek WGPURequestDeviceCallbackInfo, mode} ptr 
    callback <- #{peek WGPURequestDeviceCallbackInfo, callback} ptr 
    userdata1 <- #{peek WGPURequestDeviceCallbackInfo, userdata1} ptr 
    userdata2 <- #{peek WGPURequestDeviceCallbackInfo, userdata2} ptr 
    return WGPURequestCallbackInfo {nextInChain, mode, callback, userdata1, userdata2}
  poke ptr WGPURequestCallbackInfo {nextInChain, mode, callback, userdata1, userdata2} = do 
    #{poke WGPURequestDeviceCallbackInfo, nextInChain} ptr nextInChain
    #{poke WGPURequestDeviceCallbackInfo, mode} ptr mode  
    #{poke WGPURequestDeviceCallbackInfo, callback} ptr callback  
    #{poke WGPURequestDeviceCallbackInfo, userdata1} ptr userdata1  
    #{poke WGPURequestDeviceCallbackInfo, userdata2} ptr userdata2  

data WGPUShaderSourceWGSL = WGPUShaderSourceWGSL {
  chain :: WGPUChainedStruct, 
  code :: WGPUStringView
}

instance Storable WGPUShaderSourceWGSL where 
  alignment _ = #{alignment WGPUShaderSourceWGSL}
  sizeOf _ = #{size WGPUShaderSourceWGSL}
  peek ptr = do 
    chain <- #{peek WGPUShaderSourceWGSL, chain} ptr 
    code <- #{peek WGPUShaderSourceWGSL, code} ptr 
    return WGPUShaderSourceWGSL {chain, code}
  poke ptr WGPUShaderSourceWGSL {chain, code} = do 
    #{poke WGPUShaderSourceWGSL, chain} ptr chain 
    #{poke WGPUShaderSourceWGSL, code} ptr code 

data WGPUShaderModuleDescriptor = WGPUShaderModuleDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView
}

instance Storable WGPUShaderModuleDescriptor where 
  alignment _ = #{alignment WGPUShaderModuleDescriptor}
  sizeOf _ = #{size WGPUShaderModuleDescriptor}
  peek ptr = do 
    nextInChain <- #{peek WGPUShaderModuleDescriptor, nextInChain} ptr 
    label <- #{peek WGPUShaderModuleDescriptor, label} ptr 
    return WGPUShaderModuleDescriptor {nextInChain, label}
  poke ptr WGPUShaderModuleDescriptor {nextInChain, label} = do 
    #{poke WGPUShaderModuleDescriptor, nextInChain} ptr nextInChain 
    #{poke WGPUShaderModuleDescriptor, label} ptr label 

data WGPUSurfaceCapabilities = WGPUSurfaceCapabilities {
  nextInChain :: Ptr WGPUChainedStruct, 
  usages :: WGPUTextureUsage, 
  formatCount :: Int,
  formats :: ConstPtr WGPUTextureFormat, 
  presentModeCount :: Int, 
  presentModes :: ConstPtr WGPUPresentMode, 
  alphaModeCount :: Int, 
  alphaModes :: ConstPtr WGPUCompositeAlphaMode
}

instance Storable WGPUSurfaceCapabilities where 
  alignment _ = #{alignment WGPUSurfaceCapabilities}
  sizeOf _ = #{size WGPUSurfaceCapabilities}
  peek ptr = do 
    nextInChain <- #{peek WGPUSurfaceCapabilities, nextInChain} ptr
    usages <- #{peek WGPUSurfaceCapabilities, usages} ptr 
    formatCount <- #{peek WGPUSurfaceCapabilities, formatCount} ptr
    formats <- #{peek WGPUSurfaceCapabilities, formats} ptr 
    presentModeCount <- #{peek WGPUSurfaceCapabilities, presentModeCount} ptr 
    alphaModeCount <- #{peek WGPUSurfaceCapabilities, alphaModeCount} ptr 
    alphaModes <- #{peek WGPUSurfaceCapabilities, alphaModes} ptr 
    return WGPUSurfaceCapabilities {nextInChain, usages, formatCount, formats, presentModeCount, alphaModeCount, alphaModes}
  poke ptr WGPUSurfaceCapabilities {nextInChain, usages, formatCount, formats, presentModeCount, alphaModeCount, alphaModes} = do 
    #{poke WGPUSurfaceCapabilities, nextInChain} ptr nextInChain 
    #{poke WGPUSurfaceCapabilities, usages} ptr usages 
    #{poke WGPUSurfaceCapabilities, formatCount} ptr formatCount 
    #{poke WGPUSurfaceCapabilities, formats} ptr formats 
    #{poke WGPUSurfaceCapabilities, presentModeCount} ptr presentModeCount
    #{poke WGPUSurfaceCapabilities, alphaModeCount} ptr alphaModeCount
    #{poke WGPUSurfaceCapabilities, alphaModes} ptr alphaModes
  
data WGPUMultisampleState = WGPUMultisampleState {
  nextInChain :: Ptr WGPUChainedStruct, 
  count :: Word32, 
  mask :: Word32, 
  alphaToCoverageEnabled :: WGPUBool 
}

instance Storable WGPUMultisampleState where 
  alignment _ = #{alignment WGPUMultisampleState}
  sizeOf _ = #{size WGPUMultisampleState}
  peek ptr = do 
    nextInChain <- #{peek WGPUMultisampleState, nextInChain} ptr 
    count <- #{peek WGPUMultisampleState, count} ptr 
    mask <- #{peek WGPUMultisampleState, mask} ptr 
    alphaToCoverageEnabled <- #{peek WGPUMultisampleState, alphaToCoverageEnabled} ptr 
    return WGPUMultisampleState {nextInChain, count, mask, alphaToCoverageEnabled}
  poke ptr WGPUMultisampleState {nextInChain, count, mask, alphaToCoverageEnabled} = do 
    #{poke WGPUMultisampleState, nextInChain} ptr nextInChain
    #{poke WGPUMultisampleState, count} ptr count
    #{poke WGPUMultisampleState, mask} ptr mask
    #{poke WGPUMultisampleState, alphaToCoverageEnabled} ptr alphaToCoverageEnabled
    
data WGPUPrimitiveState = WGPUPrimitiveState {
  nextInChain :: Ptr WGPUChainedStruct, 
  topology :: WGPUPrimitiveTopology, 
  stripIndexFormat :: WGPUIndexFormat, 
  frontFace :: WGPUFrontFace, 
  cullMode :: WGPUCullMode, 
  unclippedDepth :: WGPUBool 
}

instance Storable WGPUPrimitiveState where
  alignment _ = #{alignment WGPUPrimitiveState}
  sizeOf _ = #{size WGPUPrimitiveState}
  peek ptr = do
    nextInChain <- #{peek WGPUPrimitiveState, nextInChain} ptr
    topology <- #{peek WGPUPrimitiveState, topology} ptr
    stripIndexFormat <- #{peek WGPUPrimitiveState, stripIndexFormat} ptr
    frontFace <- #{peek WGPUPrimitiveState, frontFace} ptr
    cullMode <- #{peek WGPUPrimitiveState, cullMode} ptr
    unclippedDepth <- #{peek WGPUPrimitiveState, unclippedDepth} ptr
    return WGPUPrimitiveState{nextInChain, topology, stripIndexFormat, frontFace, cullMode, unclippedDepth}
  poke ptr WGPUPrimitiveState{nextInChain, topology, stripIndexFormat, frontFace, cullMode, unclippedDepth} = do
    #{poke WGPUPrimitiveState, nextInChain} ptr nextInChain
    #{poke WGPUPrimitiveState, topology} ptr topology
    #{poke WGPUPrimitiveState, stripIndexFormat} ptr stripIndexFormat
    #{poke WGPUPrimitiveState, frontFace} ptr frontFace
    #{poke WGPUPrimitiveState, cullMode} ptr cullMode
    #{poke WGPUPrimitiveState, unclippedDepth} ptr unclippedDepth

data WGPUConstantEntry = WGPUConstantEntry {
  nextInChain :: Ptr WGPUChainedStruct, 
  key :: WGPUStringView, 
  value :: CDouble
}

instance Storable WGPUConstantEntry where 
  alignment _ = #{alignment WGPUConstantEntry}
  sizeOf _ = #{size WGPUConstantEntry}
  peek ptr = do 
    nextInChain <- #{peek WGPUConstantEntry, nextInChain} ptr 
    key <- #{peek WGPUConstantEntry, key} ptr 
    value <- #{peek WGPUConstantEntry, value} ptr 
    return WGPUConstantEntry {nextInChain, key, value}
  poke ptr WGPUConstantEntry {nextInChain, key, value} = do 
    #{poke WGPUConstantEntry, nextInChain} ptr nextInChain 
    #{poke WGPUConstantEntry, key} ptr key 
    #{poke WGPUConstantEntry, value} ptr value

data WGPUVertexAttribute = WGPUVertexAttribute {
  nextInChain :: Ptr WGPUChainedStruct,
  format :: WGPUVertexFormat, 
  offset :: Word64, 
  shaderLocation :: Word32
}

instance Storable WGPUVertexAttribute where
  alignment _ = #{alignment WGPUVertexAttribute}
  sizeOf _ = #{size WGPUVertexAttribute}
  peek ptr = do
    nextInChain <- #{peek WGPUVertexAttribute, nextInChain} ptr
    format <- #{peek WGPUVertexAttribute, format} ptr
    offset <- #{peek WGPUVertexAttribute, offset} ptr
    shaderLocation <- #{peek WGPUVertexAttribute, shaderLocation} ptr
    return WGPUVertexAttribute{nextInChain, format, offset, shaderLocation}
  poke ptr WGPUVertexAttribute{nextInChain, format, offset, shaderLocation} = do
    #{poke WGPUVertexAttribute, nextInChain} ptr nextInChain
    #{poke WGPUVertexAttribute, format} ptr format
    #{poke WGPUVertexAttribute, offset} ptr offset
    #{poke WGPUVertexAttribute, shaderLocation} ptr shaderLocation


data WGPUVertexBufferLayout = WGPUVertexBufferLayout {
  nextInChain :: Ptr WGPUChainedStruct, 
  stepMode :: WGPUVertexStepMode, 
  arrayStride :: Word64, 
  attributeCount :: Int,
  attributes :: ConstPtr WGPUVertexAttribute
}

instance Storable WGPUVertexBufferLayout where
  alignment _ = #{alignment WGPUVertexBufferLayout}
  sizeOf _ = #{size WGPUVertexBufferLayout}
  peek ptr = do
    nextInChain <- #{peek WGPUVertexBufferLayout, nextInChain} ptr
    stepMode <- #{peek WGPUVertexBufferLayout, stepMode} ptr
    arrayStride <- #{peek WGPUVertexBufferLayout, arrayStride} ptr
    attributeCount <- #{peek WGPUVertexBufferLayout, attributeCount} ptr
    attributes <- #{peek WGPUVertexBufferLayout, attributes} ptr
    return WGPUVertexBufferLayout{nextInChain, stepMode, arrayStride, attributeCount, attributes}
  poke ptr WGPUVertexBufferLayout{nextInChain, stepMode, arrayStride, attributeCount, attributes} = do
    #{poke WGPUVertexBufferLayout, nextInChain} ptr nextInChain
    #{poke WGPUVertexBufferLayout, stepMode} ptr stepMode
    #{poke WGPUVertexBufferLayout, arrayStride} ptr arrayStride
    #{poke WGPUVertexBufferLayout, attributeCount} ptr attributeCount
    #{poke WGPUVertexBufferLayout, attributes} ptr attributes

data WGPUVertexState = WGPUVertexState {
  nextInChain :: Ptr WGPUChainedStruct, 
  _module :: Ptr WGPUShaderModule, 
  entryPoint :: WGPUStringView, 
  constantCount :: Int, 
  constants :: ConstPtr WGPUConstantEntry, 
  bufferCount :: Int, 
  buffers :: ConstPtr WGPUVertexBufferLayout, 
  _WGPUVertexState :: Proxy ()
}

instance Storable WGPUVertexState where
  alignment _ = #{alignment WGPUVertexState}
  sizeOf _ = #{size WGPUVertexState}
  peek ptr = do
    nextInChain <- #{peek WGPUVertexState, nextInChain} ptr
    _module <- #{peek WGPUVertexState, module} ptr
    entryPoint <- #{peek WGPUVertexState, entryPoint} ptr
    constantCount <- #{peek WGPUVertexState, constantCount} ptr
    constants <- #{peek WGPUVertexState, constants} ptr
    bufferCount <- #{peek WGPUVertexState, bufferCount} ptr
    buffers <- #{peek WGPUVertexState, buffers} ptr
    return WGPUVertexState{nextInChain, _module, entryPoint, constantCount, constants, bufferCount, buffers, _WGPUVertexState = Proxy}
  poke ptr WGPUVertexState{nextInChain, _module, entryPoint, constantCount, constants, bufferCount, buffers} = do
    #{poke WGPUVertexState, nextInChain} ptr nextInChain
    #{poke WGPUVertexState, module} ptr _module
    #{poke WGPUVertexState, entryPoint} ptr entryPoint
    #{poke WGPUVertexState, constantCount} ptr constantCount
    #{poke WGPUVertexState, constants} ptr constants
    #{poke WGPUVertexState, bufferCount} ptr bufferCount
    #{poke WGPUVertexState, buffers} ptr buffers


data WGPUBufferBindingLayout = WGPUBufferBindingLayout {
  nextInChain :: Ptr WGPUChainedStruct, 
  _type :: WGPUBufferBindingType, 
  hasDynamicOffset :: WGPUBool, 
  minBindingSize :: Word64
}

instance Storable WGPUBufferBindingLayout where 
  alignment _ = #{alignment WGPUBufferBindingLayout}
  sizeOf _ = #{size WGPUBufferBindingLayout}
  peek ptr = do 
    nextInChain <- #{peek WGPUBufferBindingLayout, nextInChain} ptr 
    _type <- #{peek WGPUBufferBindingLayout, type} ptr
    hasDynamicOffset <- #{peek WGPUBufferBindingLayout, hasDynamicOffset} ptr 
    minBindingSize <- #{peek WGPUBufferBindingLayout, minBindingSize} ptr 
    return WGPUBufferBindingLayout {nextInChain, _type, hasDynamicOffset, minBindingSize} 
  poke ptr WGPUBufferBindingLayout {nextInChain, _type, hasDynamicOffset, minBindingSize} = do 
    #{poke WGPUBufferBindingLayout, nextInChain} ptr nextInChain 
    #{poke WGPUBufferBindingLayout, type} ptr _type
    #{poke WGPUBufferBindingLayout, hasDynamicOffset} ptr hasDynamicOffset
    #{poke WGPUBufferBindingLayout, minBindingSize} ptr minBindingSize

data WGPUSamplerBindingLayout = WGPUSamplerBindingLayout {
  nextInChain :: Ptr WGPUChainedStruct,
  _type :: WGPUSamplerBindingType
}

instance Storable WGPUSamplerBindingLayout where 
  alignment _ = #{alignment WGPUSamplerBindingLayout}
  sizeOf _ = #{size WGPUSamplerBindingLayout}
  peek ptr = do 
    nextInChain <- #{peek WGPUSamplerBindingLayout, nextInChain} ptr 
    _type <- #{peek WGPUSamplerBindingLayout, type} ptr 
    return WGPUSamplerBindingLayout {nextInChain, _type}
  poke ptr WGPUSamplerBindingLayout {nextInChain, _type} = do 
    #{poke WGPUSamplerBindingLayout, nextInChain} ptr nextInChain
    #{poke WGPUSamplerBindingLayout, type} ptr _type
  
data WGPUTextureBindingLayout = WGPUTextureBindingLayout {
  nextInChain :: Ptr WGPUChainedStruct, 
  sampleType :: WGPUTextureSampleType, 
  viewDimension :: WGPUTextureViewDimension, 
  multisampled :: WGPUBool
} 

instance Storable WGPUTextureBindingLayout where 
  alignment _ = #{alignment WGPUTextureBindingLayout}
  sizeOf _ = #{size WGPUTextureBindingLayout}
  peek ptr = do 
    nextInChain <- #{peek WGPUTextureBindingLayout, nextInChain} ptr 
    sampleType <- #{peek WGPUTextureBindingLayout, sampleType} ptr
    viewDimension <- #{peek WGPUTextureBindingLayout, viewDimension} ptr
    multisampled <- #{peek WGPUTextureBindingLayout, multisampled} ptr
    return WGPUTextureBindingLayout {nextInChain, sampleType, viewDimension, multisampled}
  poke ptr WGPUTextureBindingLayout {nextInChain, sampleType, viewDimension, multisampled} = do 
    #{poke WGPUTextureBindingLayout, nextInChain} ptr nextInChain
    #{poke WGPUTextureBindingLayout, sampleType} ptr sampleType 
    #{poke WGPUTextureBindingLayout, viewDimension} ptr viewDimension
    #{poke WGPUTextureBindingLayout, multisampled} ptr multisampled

data WGPUStorageTextureBindingLayout = WGPUStorageTextureBindingLayout {
  nextInChain :: Ptr WGPUChainedStruct, 
  access :: WGPUStorageTextureAccess, 
  format :: WGPUTextureFormat, 
  viewDimension :: WGPUTextureViewDimension
}

instance Storable WGPUStorageTextureBindingLayout where 
  alignment _ = #{alignment WGPUStorageTextureBindingLayout}
  sizeOf _ = #{size WGPUStorageTextureBindingLayout}
  peek ptr = do 
    nextInChain <- #{peek WGPUStorageTextureBindingLayout, nextInChain} ptr 
    access <- #{peek WGPUStorageTextureBindingLayout, access} ptr
    format <- #{peek WGPUStorageTextureBindingLayout, format} ptr
    viewDimension <- #{peek WGPUStorageTextureBindingLayout, viewDimension} ptr
    return WGPUStorageTextureBindingLayout {nextInChain, access, format, viewDimension}
  poke ptr WGPUStorageTextureBindingLayout {nextInChain, access, format, viewDimension} = do 
    #{poke WGPUStorageTextureBindingLayout, nextInChain} ptr nextInChain
    #{poke WGPUStorageTextureBindingLayout, access} ptr access 
    #{poke WGPUStorageTextureBindingLayout, format} ptr format
    #{poke WGPUStorageTextureBindingLayout, viewDimension} ptr viewDimension

data WGPUBindGroupLayoutEntry = WGPUBindGroupLayoutEntry {
  nextInChain :: Ptr WGPUChainedStruct, 
  binding :: Word32, 
  visibility :: WGPUShaderStage, 
  bindingArraySize :: Word32, 
  buffer :: WGPUBufferBindingLayout, 
  sampler :: WGPUSamplerBindingLayout, 
  texture :: WGPUTextureBindingLayout, 
  storageTexture :: WGPUStorageTextureBindingLayout
} 

instance Storable WGPUBindGroupLayoutEntry where 
  alignment _ = #{alignment WGPUBindGroupLayoutEntry}
  sizeOf _ = #{size WGPUBindGroupLayoutEntry}
  peek ptr = do 
    nextInChain <- #{peek WGPUBindGroupLayoutEntry, nextInChain} ptr 
    binding <- #{peek WGPUBindGroupLayoutEntry, binding} ptr
    visibility <- #{peek WGPUBindGroupLayoutEntry, visibility} ptr 
    bindingArraySize <- #{peek WGPUBindGroupLayoutEntry, bindingArraySize} ptr
    buffer <- #{peek WGPUBindGroupLayoutEntry, buffer} ptr
    sampler <- #{peek WGPUBindGroupLayoutEntry, sampler} ptr 
    texture <- #{peek WGPUBindGroupLayoutEntry, texture} ptr 
    storageTexture <- #{peek WGPUBindGroupLayoutEntry, storageTexture} ptr 
    return WGPUBindGroupLayoutEntry {nextInChain, binding, visibility, bindingArraySize, buffer, sampler, texture, storageTexture}
  poke ptr WGPUBindGroupLayoutEntry {nextInChain, binding, visibility, bindingArraySize, buffer, sampler, texture, storageTexture} = do
    #{poke WGPUBindGroupLayoutEntry, nextInChain} ptr nextInChain
    #{poke WGPUBindGroupLayoutEntry, binding} ptr binding
    #{poke WGPUBindGroupLayoutEntry, visibility} ptr visibility
    #{poke WGPUBindGroupLayoutEntry, bindingArraySize} ptr bindingArraySize
    #{poke WGPUBindGroupLayoutEntry, buffer} ptr buffer
    #{poke WGPUBindGroupLayoutEntry, sampler} ptr sampler
    #{poke WGPUBindGroupLayoutEntry, texture} ptr texture
    #{poke WGPUBindGroupLayoutEntry, storageTexture} ptr storageTexture
    
data WGPUPipelineLayoutDescriptor = WGPUPipelineLayoutDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  bindGroupLayoutCount :: CSize, 
  bindGroupLayouts :: ConstPtr (Ptr WGPUBindGroupLayout),
  immediateSize :: CUInt
}

instance Storable WGPUPipelineLayoutDescriptor where 
  alignment _ = #{alignment WGPUPipelineLayoutDescriptor}
  sizeOf _ = #{size WGPUPipelineLayoutDescriptor}
  peek ptr = do 
    nextInChain <- #{peek WGPUPipelineLayoutDescriptor, nextInChain} ptr
    label <- #{peek WGPUPipelineLayoutDescriptor, label} ptr
    bindGroupLayoutCount <- #{peek WGPUPipelineLayoutDescriptor, bindGroupLayoutCount} ptr
    bindGroupLayouts <- #{peek WGPUPipelineLayoutDescriptor, bindGroupLayouts} ptr
    immediateSize <- #{peek WGPUPipelineLayoutDescriptor, immediateSize} ptr
    return WGPUPipelineLayoutDescriptor {nextInChain, label, bindGroupLayoutCount, bindGroupLayouts, immediateSize}
  poke ptr WGPUPipelineLayoutDescriptor {nextInChain, label, bindGroupLayoutCount, bindGroupLayouts, immediateSize} = do 
    #{poke WGPUPipelineLayoutDescriptor, nextInChain} ptr nextInChain 
    #{poke WGPUPipelineLayoutDescriptor, label} ptr label 
    #{poke WGPUPipelineLayoutDescriptor, bindGroupLayoutCount} ptr bindGroupLayoutCount 
    #{poke WGPUPipelineLayoutDescriptor, bindGroupLayouts} ptr bindGroupLayouts 
    #{poke WGPUPipelineLayoutDescriptor, immediateSize} ptr immediateSize 

data WGPUBlendComponent = WGPUBlendComponent {
  operation :: WGPUBlendOperation, 
  srcFactor :: WGPUBlendFactor, 
  dstFactor :: WGPUBlendFactor
}

instance Storable WGPUBlendComponent where
  alignment _ = #{alignment WGPUBlendComponent}
  sizeOf _ = #{size WGPUBlendComponent}
  peek ptr = do
    operation <- #{peek WGPUBlendComponent, operation} ptr
    srcFactor <- #{peek WGPUBlendComponent, srcFactor} ptr
    dstFactor <- #{peek WGPUBlendComponent, dstFactor} ptr
    return WGPUBlendComponent{operation, srcFactor, dstFactor}
  poke ptr WGPUBlendComponent{operation, srcFactor, dstFactor} = do
    #{poke WGPUBlendComponent, operation} ptr operation
    #{poke WGPUBlendComponent, srcFactor} ptr srcFactor
    #{poke WGPUBlendComponent, dstFactor} ptr dstFactor

data WGPUBlendState = WGPUBlendState {
  color :: WGPUBlendComponent, 
  alpha :: WGPUBlendComponent
}

instance Storable WGPUBlendState where
  alignment _ = #{alignment WGPUBlendState}
  sizeOf _ = #{size WGPUBlendState}
  peek ptr = do
    color <- #{peek WGPUBlendState, color} ptr
    alpha <- #{peek WGPUBlendState, alpha} ptr
    return WGPUBlendState{color, alpha}
  poke ptr WGPUBlendState{color, alpha} = do
    #{poke WGPUBlendState, color} ptr color
    #{poke WGPUBlendState, alpha} ptr alpha

data WGPUColorTargetState = WGPUColorTargetState {
  nextInChain :: Ptr WGPUChainedStruct, 
  format :: WGPUTextureFormat, 
  blend :: ConstPtr WGPUBlendState, 
  writeMask :: WGPUColorWriteMask
}

instance Storable WGPUColorTargetState where
  alignment _ = #{alignment WGPUColorTargetState}
  sizeOf _ = #{size WGPUColorTargetState}
  peek ptr = do
    nextInChain <- #{peek WGPUColorTargetState, nextInChain} ptr
    format <- #{peek WGPUColorTargetState, format} ptr
    blend <- #{peek WGPUColorTargetState, blend} ptr
    writeMask <- #{peek WGPUColorTargetState, writeMask} ptr
    return WGPUColorTargetState{nextInChain, format, blend, writeMask}
  poke ptr WGPUColorTargetState{nextInChain, format, blend, writeMask} = do
    #{poke WGPUColorTargetState, nextInChain} ptr nextInChain
    #{poke WGPUColorTargetState, format} ptr format
    #{poke WGPUColorTargetState, blend} ptr blend
    #{poke WGPUColorTargetState, writeMask} ptr writeMask


data WGPUFragmentState = WGPUFragmentState {
  nextInChain :: Ptr WGPUChainedStruct, 
  _module :: Ptr WGPUShaderModule, 
  entryPoint :: WGPUStringView, 
  constantCount :: Int, 
  constants :: ConstPtr WGPUConstantEntry, 
  targetCount :: Int, 
  targets :: ConstPtr WGPUColorTargetState, 
  _WGPUFragmentState :: Proxy ()
}

instance Storable WGPUFragmentState where
  alignment _ = #{alignment WGPUFragmentState}
  sizeOf _ = #{size WGPUFragmentState}
  peek ptr = do
    nextInChain <- #{peek WGPUFragmentState, nextInChain} ptr
    _module <- #{peek WGPUFragmentState, module} ptr
    entryPoint <- #{peek WGPUFragmentState, entryPoint} ptr
    constantCount <- #{peek WGPUFragmentState, constantCount} ptr
    constants <- #{peek WGPUFragmentState, constants} ptr
    targetCount <- #{peek WGPUFragmentState, targetCount} ptr
    targets <- #{peek WGPUFragmentState, targets} ptr
    return WGPUFragmentState{nextInChain, _module, entryPoint, constantCount, constants, targetCount, targets, _WGPUFragmentState = Proxy}
  poke ptr WGPUFragmentState{nextInChain, _module, entryPoint, constantCount, constants, targetCount, targets} = do
    #{poke WGPUFragmentState, nextInChain} ptr nextInChain
    #{poke WGPUFragmentState, module} ptr _module
    #{poke WGPUFragmentState, entryPoint} ptr entryPoint
    #{poke WGPUFragmentState, constantCount} ptr constantCount
    #{poke WGPUFragmentState, constants} ptr constants
    #{poke WGPUFragmentState, targetCount} ptr targetCount
    #{poke WGPUFragmentState, targets} ptr targets

data WGPURenderPipelineDescriptor = WGPURenderPipelineDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  layout :: Ptr WGPUPipelineLayout, 
  vertex :: WGPUVertexState, 
  primitive :: WGPUPrimitiveState, 
  depthStencil :: ConstPtr (), 
  multisample :: WGPUMultisampleState, 
  fragment :: ConstPtr WGPUFragmentState
}

instance Storable WGPURenderPipelineDescriptor where
  alignment _ = #{alignment WGPURenderPipelineDescriptor}
  sizeOf _ = #{size WGPURenderPipelineDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPURenderPipelineDescriptor, nextInChain} ptr
    label <- #{peek WGPURenderPipelineDescriptor, label} ptr
    layout <- #{peek WGPURenderPipelineDescriptor, layout} ptr
    vertex <- #{peek WGPURenderPipelineDescriptor, vertex} ptr
    primitive <- #{peek WGPURenderPipelineDescriptor, primitive} ptr
    depthStencil <- #{peek WGPURenderPipelineDescriptor, depthStencil} ptr
    multisample <- #{peek WGPURenderPipelineDescriptor, multisample} ptr
    fragment <- #{peek WGPURenderPipelineDescriptor, fragment} ptr
    return WGPURenderPipelineDescriptor{nextInChain, label, layout, vertex, primitive, depthStencil, multisample, fragment}
  poke ptr WGPURenderPipelineDescriptor{nextInChain, label, layout, vertex, primitive, depthStencil, multisample, fragment} = do
    #{poke WGPURenderPipelineDescriptor, nextInChain} ptr nextInChain
    #{poke WGPURenderPipelineDescriptor, label} ptr label
    #{poke WGPURenderPipelineDescriptor, layout} ptr layout
    #{poke WGPURenderPipelineDescriptor, vertex} ptr vertex
    #{poke WGPURenderPipelineDescriptor, primitive} ptr primitive
    #{poke WGPURenderPipelineDescriptor, depthStencil} ptr depthStencil
    #{poke WGPURenderPipelineDescriptor, multisample} ptr multisample
    #{poke WGPURenderPipelineDescriptor, fragment} ptr fragment

data WGPUSurfaceConfiguration = WGPUSurfaceConfiguration {
  nextInChain :: Ptr WGPUChainedStruct, 
  device :: Ptr WGPUDevice, 
  format :: WGPUTextureFormat, 
  usage :: WGPUTextureUsage, 
  width :: CInt, 
  height :: CInt, 
  viewFormatCount :: Int, 
  viewFormats :: ConstPtr WGPUTextureFormat, 
  alphaMode :: WGPUCompositeAlphaMode, 
  presentMode :: WGPUPresentMode
}

instance Storable WGPUSurfaceConfiguration where
  alignment _ = #{alignment WGPUSurfaceConfiguration}
  sizeOf _ = #{size WGPUSurfaceConfiguration}
  peek ptr = do
    nextInChain <- #{peek WGPUSurfaceConfiguration, nextInChain} ptr
    device <- #{peek WGPUSurfaceConfiguration, device} ptr
    format <- #{peek WGPUSurfaceConfiguration, format} ptr
    usage <- #{peek WGPUSurfaceConfiguration, usage} ptr
    width <- #{peek WGPUSurfaceConfiguration, width} ptr
    height <- #{peek WGPUSurfaceConfiguration, height} ptr
    viewFormatCount <- #{peek WGPUSurfaceConfiguration, viewFormatCount} ptr
    viewFormats <- #{peek WGPUSurfaceConfiguration, viewFormats} ptr
    alphaMode <- #{peek WGPUSurfaceConfiguration, alphaMode} ptr
    presentMode <- #{peek WGPUSurfaceConfiguration, presentMode} ptr
    return WGPUSurfaceConfiguration{nextInChain, device, format, usage, width, height, viewFormatCount, viewFormats, alphaMode, presentMode}
  poke ptr WGPUSurfaceConfiguration{nextInChain, device, format, usage, width, height, viewFormatCount, viewFormats, alphaMode, presentMode} = do
    #{poke WGPUSurfaceConfiguration, nextInChain} ptr nextInChain
    #{poke WGPUSurfaceConfiguration, device} ptr device
    #{poke WGPUSurfaceConfiguration, format} ptr format
    #{poke WGPUSurfaceConfiguration, usage} ptr usage
    #{poke WGPUSurfaceConfiguration, width} ptr width
    #{poke WGPUSurfaceConfiguration, height} ptr height
    #{poke WGPUSurfaceConfiguration, viewFormatCount} ptr viewFormatCount
    #{poke WGPUSurfaceConfiguration, viewFormats} ptr viewFormats
    #{poke WGPUSurfaceConfiguration, alphaMode} ptr alphaMode
    #{poke WGPUSurfaceConfiguration, presentMode} ptr presentMode

data WGPUSurfaceTexture = WGPUSurfaceTexture {
  nextInChain :: Ptr WGPUChainedStruct, 
  texture :: Ptr WGPUTexture, 
  status :: WGPUSurfaceGetCurrentTextureStatus
}

instance Storable WGPUSurfaceTexture where
  alignment _ = #{alignment WGPUSurfaceTexture}
  sizeOf _ = #{size WGPUSurfaceTexture}
  peek ptr = do
    nextInChain <- #{peek WGPUSurfaceTexture, nextInChain} ptr
    texture <- #{peek WGPUSurfaceTexture, texture} ptr
    status <- #{peek WGPUSurfaceTexture, status} ptr
    return WGPUSurfaceTexture{nextInChain, texture, status}
  poke ptr WGPUSurfaceTexture{nextInChain, texture, status} = do
    #{poke WGPUSurfaceTexture, nextInChain} ptr nextInChain
    #{poke WGPUSurfaceTexture, texture} ptr texture
    #{poke WGPUSurfaceTexture, status} ptr status

data WGPUCommandEncoderDescriptor = WGPUCommandEncoderDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView
}

instance Storable WGPUCommandEncoderDescriptor where
  alignment _ = #{alignment WGPUCommandEncoderDescriptor}
  sizeOf _ = #{size WGPUCommandEncoderDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUCommandEncoderDescriptor, nextInChain} ptr
    label <- #{peek WGPUCommandEncoderDescriptor, label} ptr
    return WGPUCommandEncoderDescriptor{nextInChain, label}
  poke ptr WGPUCommandEncoderDescriptor{nextInChain, label} = do
    #{poke WGPUCommandEncoderDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUCommandEncoderDescriptor, label} ptr label

data WGPUColor = WGPUColor {
  wgpuColorR :: CDouble, 
  wgpuColorG :: CDouble, 
  wgpuColorB :: CDouble, 
  wgpuColorA :: CDouble
}

instance Storable WGPUColor where
  alignment _ = #{alignment WGPUColor}
  sizeOf _ = #{size WGPUColor}
  peek ptr = do
    wgpuColorR <- #{peek WGPUColor, r} ptr
    wgpuColorG <- #{peek WGPUColor, g} ptr
    wgpuColorB <- #{peek WGPUColor, b} ptr
    wgpuColorA <- #{peek WGPUColor, a} ptr
    return WGPUColor{wgpuColorR, wgpuColorG, wgpuColorB, wgpuColorA}
  poke ptr WGPUColor{wgpuColorR, wgpuColorG, wgpuColorB, wgpuColorA} = do
    #{poke WGPUColor, r} ptr wgpuColorR
    #{poke WGPUColor, g} ptr wgpuColorG
    #{poke WGPUColor, b} ptr wgpuColorB
    #{poke WGPUColor, a} ptr wgpuColorA

data WGPURenderPassColorAttachment = WGPURenderPassColorAttachment {
  nextInChain :: Ptr WGPUChainedStruct, 
  view :: Ptr WGPUTextureView, 
  depthSlice :: Word32, 
  resolveTarget :: Ptr WGPUTextureView, 
  loadOp :: WGPULoadOp,
  storeOp :: WGPUStoreOp,
  clearValue :: WGPUColor    
}

instance Storable WGPURenderPassColorAttachment where
  alignment _ = #{alignment WGPURenderPassColorAttachment}
  sizeOf _ = #{size WGPURenderPassColorAttachment}
  peek ptr = do
    nextInChain <- #{peek WGPURenderPassColorAttachment, nextInChain} ptr
    view <- #{peek WGPURenderPassColorAttachment, view} ptr
    depthSlice <- #{peek WGPURenderPassColorAttachment, depthSlice} ptr
    resolveTarget <- #{peek WGPURenderPassColorAttachment, resolveTarget} ptr
    loadOp <- #{peek WGPURenderPassColorAttachment, loadOp} ptr
    storeOp <- #{peek WGPURenderPassColorAttachment, storeOp} ptr
    clearValue <- #{peek WGPURenderPassColorAttachment, clearValue} ptr
    return WGPURenderPassColorAttachment{nextInChain, view, depthSlice, resolveTarget, loadOp, storeOp, clearValue}
  poke ptr WGPURenderPassColorAttachment{nextInChain, view, depthSlice, resolveTarget, loadOp, storeOp, clearValue} = do
    #{poke WGPURenderPassColorAttachment, nextInChain} ptr nextInChain
    #{poke WGPURenderPassColorAttachment, view} ptr view
    #{poke WGPURenderPassColorAttachment, depthSlice} ptr depthSlice
    #{poke WGPURenderPassColorAttachment, resolveTarget} ptr resolveTarget
    #{poke WGPURenderPassColorAttachment, loadOp} ptr loadOp
    #{poke WGPURenderPassColorAttachment, storeOp} ptr storeOp
    #{poke WGPURenderPassColorAttachment, clearValue} ptr clearValue

data WGPURenderPassDescriptor = WGPURenderPassDescriptor {
  nextInChain :: Ptr WGPUChainedStruct,
  label :: WGPUStringView, 
  colorAttachmentCount :: Int, 
  colorAttachments :: ConstPtr WGPURenderPassColorAttachment, 
  depthStencilAttachment :: ConstPtr (), 
  occlusionQuerySet :: Ptr WGPUQuerySet, 
  timestampWrites :: ConstPtr () 
}

instance Storable WGPURenderPassDescriptor where
  alignment _ = #{alignment WGPURenderPassDescriptor}
  sizeOf _ = #{size WGPURenderPassDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPURenderPassDescriptor, nextInChain} ptr
    label <- #{peek WGPURenderPassDescriptor, label} ptr
    colorAttachmentCount <- #{peek WGPURenderPassDescriptor, colorAttachmentCount} ptr
    colorAttachments <- #{peek WGPURenderPassDescriptor, colorAttachments} ptr
    depthStencilAttachment <- #{peek WGPURenderPassDescriptor, depthStencilAttachment} ptr
    occlusionQuerySet <- #{peek WGPURenderPassDescriptor, occlusionQuerySet} ptr
    timestampWrites <- #{peek WGPURenderPassDescriptor, timestampWrites} ptr
    return WGPURenderPassDescriptor{nextInChain, label, colorAttachmentCount, colorAttachments, depthStencilAttachment, occlusionQuerySet, timestampWrites}
  poke ptr WGPURenderPassDescriptor{nextInChain, label, colorAttachmentCount, colorAttachments, depthStencilAttachment, occlusionQuerySet, timestampWrites} = do
    #{poke WGPURenderPassDescriptor, nextInChain} ptr nextInChain
    #{poke WGPURenderPassDescriptor, label} ptr label
    #{poke WGPURenderPassDescriptor, colorAttachmentCount} ptr colorAttachmentCount
    #{poke WGPURenderPassDescriptor, colorAttachments} ptr colorAttachments
    #{poke WGPURenderPassDescriptor, depthStencilAttachment} ptr depthStencilAttachment
    #{poke WGPURenderPassDescriptor, occlusionQuerySet} ptr occlusionQuerySet
    #{poke WGPURenderPassDescriptor, timestampWrites} ptr timestampWrites

wGPU_DEPTH_SLICE_UNDEFINED :: Word32 
wGPU_DEPTH_SLICE_UNDEFINED = #const WGPU_DEPTH_SLICE_UNDEFINED

data WGPUCommandBufferDescriptor = WGPUCommandBufferDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView
}

instance Storable WGPUCommandBufferDescriptor where
  alignment _ = #{alignment WGPUCommandBufferDescriptor}
  sizeOf _ = #{size WGPUCommandBufferDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUCommandBufferDescriptor, nextInChain} ptr
    label <- #{peek WGPUCommandBufferDescriptor, label} ptr
    return WGPUCommandBufferDescriptor{nextInChain, label}
  poke ptr WGPUCommandBufferDescriptor{nextInChain, label} = do
    #{poke WGPUCommandBufferDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUCommandBufferDescriptor, label} ptr label

data WGPUExtent3D = WGPUExtent3D {
  width :: Word32, 
  height :: Word32, 
  depthOrArrayLayers :: Word32 
}

instance Storable WGPUExtent3D where
  alignment _ = #{alignment WGPUExtent3D}
  sizeOf _ = #{size WGPUExtent3D}
  peek ptr = do
    width <- #{peek WGPUExtent3D, width} ptr
    height <- #{peek WGPUExtent3D, height} ptr
    depthOrArrayLayers <- #{peek WGPUExtent3D, depthOrArrayLayers} ptr
    return WGPUExtent3D{width, height, depthOrArrayLayers}
  poke ptr WGPUExtent3D{width, height, depthOrArrayLayers} = do
    #{poke WGPUExtent3D, width} ptr width
    #{poke WGPUExtent3D, height} ptr height
    #{poke WGPUExtent3D, depthOrArrayLayers} ptr depthOrArrayLayers

data WGPUTextureDescriptor = WGPUTextureDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  usage :: WGPUTextureUsage, 
  dimension :: WGPUTextureDimension, 
  size :: WGPUExtent3D, 
  format :: WGPUTextureFormat, 
  mipLevelCount :: Word32, 
  sampleCount :: Word32, 
  viewFormatCount :: CSize, 
  viewFormats :: ConstPtr WGPUTextureFormat
}

instance Storable WGPUTextureDescriptor where
  alignment _ = #{alignment WGPUTextureDescriptor}
  sizeOf _ = #{size WGPUTextureDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUTextureDescriptor, nextInChain} ptr
    label <- #{peek WGPUTextureDescriptor, label} ptr
    usage <- #{peek WGPUTextureDescriptor, usage} ptr
    dimension <- #{peek WGPUTextureDescriptor, dimension} ptr
    size <- #{peek WGPUTextureDescriptor, size} ptr
    format <- #{peek WGPUTextureDescriptor, format} ptr
    mipLevelCount <- #{peek WGPUTextureDescriptor, mipLevelCount} ptr
    sampleCount <- #{peek WGPUTextureDescriptor, sampleCount} ptr
    viewFormatCount <- #{peek WGPUTextureDescriptor, viewFormatCount} ptr
    viewFormats <- #{peek WGPUTextureDescriptor, viewFormats} ptr
    return WGPUTextureDescriptor{nextInChain, label, usage, dimension, size, format, mipLevelCount, sampleCount, viewFormatCount, viewFormats}
  poke ptr WGPUTextureDescriptor{nextInChain, label, usage, dimension, size, format, mipLevelCount, sampleCount, viewFormatCount, viewFormats} = do
    #{poke WGPUTextureDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUTextureDescriptor, label} ptr label
    #{poke WGPUTextureDescriptor, usage} ptr usage
    #{poke WGPUTextureDescriptor, dimension} ptr dimension
    #{poke WGPUTextureDescriptor, size} ptr size
    #{poke WGPUTextureDescriptor, format} ptr format
    #{poke WGPUTextureDescriptor, mipLevelCount} ptr mipLevelCount
    #{poke WGPUTextureDescriptor, sampleCount} ptr sampleCount
    #{poke WGPUTextureDescriptor, viewFormatCount} ptr viewFormatCount
    #{poke WGPUTextureDescriptor, viewFormats} ptr viewFormats

data WGPUOrigin3D = WGPUOrigin3D {
  x :: Word32, 
  y :: Word32, 
  z :: Word32
}

instance Storable WGPUOrigin3D where
  alignment _ = #{alignment WGPUOrigin3D}
  sizeOf _ = #{size WGPUOrigin3D}
  peek ptr = do
    x <- #{peek WGPUOrigin3D, x} ptr
    y <- #{peek WGPUOrigin3D, y} ptr
    z <- #{peek WGPUOrigin3D, z} ptr
    return WGPUOrigin3D{x, y, z}
  poke ptr WGPUOrigin3D{x, y, z} = do
    #{poke WGPUOrigin3D, x} ptr x
    #{poke WGPUOrigin3D, y} ptr y
    #{poke WGPUOrigin3D, z} ptr z

data WGPUTexelCopyTextureInfo = WGPUTexelCopyTextureInfo {
  texture :: Ptr WGPUTexture, 
  mipLevel :: Word32, 
  origin :: WGPUOrigin3D, 
  aspect :: WGPUTextureAspect
}

instance Storable WGPUTexelCopyTextureInfo where
  alignment _ = #{alignment WGPUTexelCopyTextureInfo}
  sizeOf _ = #{size WGPUTexelCopyTextureInfo}
  peek ptr = do
    texture <- #{peek WGPUTexelCopyTextureInfo, texture} ptr
    mipLevel <- #{peek WGPUTexelCopyTextureInfo, mipLevel} ptr
    origin <- #{peek WGPUTexelCopyTextureInfo, origin} ptr
    aspect <- #{peek WGPUTexelCopyTextureInfo, aspect} ptr
    return WGPUTexelCopyTextureInfo{texture, mipLevel, origin, aspect}
  poke ptr WGPUTexelCopyTextureInfo{texture, mipLevel, origin, aspect} = do
    #{poke WGPUTexelCopyTextureInfo, texture} ptr texture
    #{poke WGPUTexelCopyTextureInfo, mipLevel} ptr mipLevel
    #{poke WGPUTexelCopyTextureInfo, origin} ptr origin
    #{poke WGPUTexelCopyTextureInfo, aspect} ptr aspect

data WGPUTexelCopyBufferLayout = WGPUTexelCopyBufferLayout {
  offset :: Word64, 
  bytesPerRow :: Word32, 
  rowsPerImage :: Word32
}

instance Storable WGPUTexelCopyBufferLayout where
  alignment _ = #{alignment WGPUTexelCopyBufferLayout}
  sizeOf _ = #{size WGPUTexelCopyBufferLayout}
  peek ptr = do
    offset <- #{peek WGPUTexelCopyBufferLayout, offset} ptr
    bytesPerRow <- #{peek WGPUTexelCopyBufferLayout, bytesPerRow} ptr
    rowsPerImage <- #{peek WGPUTexelCopyBufferLayout, rowsPerImage} ptr
    return WGPUTexelCopyBufferLayout{offset, bytesPerRow, rowsPerImage}
  poke ptr WGPUTexelCopyBufferLayout{offset, bytesPerRow, rowsPerImage} = do
    #{poke WGPUTexelCopyBufferLayout, offset} ptr offset
    #{poke WGPUTexelCopyBufferLayout, bytesPerRow} ptr bytesPerRow
    #{poke WGPUTexelCopyBufferLayout, rowsPerImage} ptr rowsPerImage


data WGPUSamplerDescriptor = WGPUSamplerDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  addressModeU :: WGPUAddressMode, 
  addressModeV :: WGPUAddressMode, 
  addressModeW :: WGPUAddressMode, 
  magFilter :: WGPUFilterMode, 
  minFilter :: WGPUFilterMode, 
  mipmapFilter :: WGPUMipmapFilterMode, 
  lodMinClamp :: Float, 
  lodMaxClamp :: Float, 
  compare :: WGPUCompareFunction, 
  maxAnisotropy :: Word16
}

instance Storable WGPUSamplerDescriptor where
  alignment _ = #{alignment WGPUSamplerDescriptor}
  sizeOf _ = #{size WGPUSamplerDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUSamplerDescriptor, nextInChain} ptr
    label <- #{peek WGPUSamplerDescriptor, label} ptr
    addressModeU <- #{peek WGPUSamplerDescriptor, addressModeU} ptr
    addressModeV <- #{peek WGPUSamplerDescriptor, addressModeV} ptr
    addressModeW <- #{peek WGPUSamplerDescriptor, addressModeW} ptr
    magFilter <- #{peek WGPUSamplerDescriptor, magFilter} ptr
    minFilter <- #{peek WGPUSamplerDescriptor, minFilter} ptr
    mipmapFilter <- #{peek WGPUSamplerDescriptor, mipmapFilter} ptr
    lodMinClamp <- #{peek WGPUSamplerDescriptor, lodMinClamp} ptr
    lodMaxClamp <- #{peek WGPUSamplerDescriptor, lodMaxClamp} ptr
    compare <- #{peek WGPUSamplerDescriptor, compare} ptr
    maxAnisotropy <- #{peek WGPUSamplerDescriptor, maxAnisotropy} ptr
    return WGPUSamplerDescriptor{nextInChain, label, addressModeU, addressModeV, addressModeW, magFilter, minFilter, mipmapFilter, lodMinClamp, lodMaxClamp, compare, maxAnisotropy}
  poke ptr WGPUSamplerDescriptor{nextInChain, label, addressModeU, addressModeV, addressModeW, magFilter, minFilter, mipmapFilter, lodMinClamp, lodMaxClamp, compare, maxAnisotropy} = do
    #{poke WGPUSamplerDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUSamplerDescriptor, label} ptr label
    #{poke WGPUSamplerDescriptor, addressModeU} ptr addressModeU
    #{poke WGPUSamplerDescriptor, addressModeV} ptr addressModeV
    #{poke WGPUSamplerDescriptor, addressModeW} ptr addressModeW
    #{poke WGPUSamplerDescriptor, magFilter} ptr magFilter
    #{poke WGPUSamplerDescriptor, minFilter} ptr minFilter
    #{poke WGPUSamplerDescriptor, mipmapFilter} ptr mipmapFilter
    #{poke WGPUSamplerDescriptor, lodMinClamp} ptr lodMinClamp
    #{poke WGPUSamplerDescriptor, lodMaxClamp} ptr lodMaxClamp
    #{poke WGPUSamplerDescriptor, compare} ptr compare
    #{poke WGPUSamplerDescriptor, maxAnisotropy} ptr maxAnisotropy

data WGPUBindGroupLayoutDescriptor = WGPUBindGroupLayoutDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  entryCount :: CSize, 
  entries :: ConstPtr WGPUBindGroupLayoutEntry
}

instance Storable WGPUBindGroupLayoutDescriptor where
  alignment _ = #{alignment WGPUBindGroupLayoutDescriptor}
  sizeOf _ = #{size WGPUBindGroupLayoutDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUBindGroupLayoutDescriptor, nextInChain} ptr
    label <- #{peek WGPUBindGroupLayoutDescriptor, label} ptr
    entryCount <- #{peek WGPUBindGroupLayoutDescriptor, entryCount} ptr
    entries <- #{peek WGPUBindGroupLayoutDescriptor, entries} ptr
    return WGPUBindGroupLayoutDescriptor{nextInChain, label, entryCount, entries}
  poke ptr WGPUBindGroupLayoutDescriptor{nextInChain, label, entryCount, entries} = do
    #{poke WGPUBindGroupLayoutDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUBindGroupLayoutDescriptor, label} ptr label
    #{poke WGPUBindGroupLayoutDescriptor, entryCount} ptr entryCount
    #{poke WGPUBindGroupLayoutDescriptor, entries} ptr entries

data WGPUBindGroupEntry = WGPUBindGroupEntry {
  nextInChain :: Ptr WGPUChainedStruct, 
  binding :: Word32, 
  buffer :: Ptr WGPUBuffer, 
  offset :: Word64, 
  size :: Word64, 
  sampler :: Ptr WGPUSampler, 
  textureView :: Ptr WGPUTextureView
}

instance Storable WGPUBindGroupEntry where
  alignment _ = #{alignment WGPUBindGroupEntry}
  sizeOf _ = #{size WGPUBindGroupEntry}
  peek ptr = do
    nextInChain <- #{peek WGPUBindGroupEntry, nextInChain} ptr
    binding <- #{peek WGPUBindGroupEntry, binding} ptr
    buffer <- #{peek WGPUBindGroupEntry, buffer} ptr
    offset <- #{peek WGPUBindGroupEntry, offset} ptr
    size <- #{peek WGPUBindGroupEntry, size} ptr
    sampler <- #{peek WGPUBindGroupEntry, sampler} ptr
    textureView <- #{peek WGPUBindGroupEntry, textureView} ptr
    return WGPUBindGroupEntry{nextInChain, binding, buffer, offset, size, sampler, textureView}
  poke ptr WGPUBindGroupEntry{nextInChain, binding, buffer, offset, size, sampler, textureView} = do
    #{poke WGPUBindGroupEntry, nextInChain} ptr nextInChain
    #{poke WGPUBindGroupEntry, binding} ptr binding
    #{poke WGPUBindGroupEntry, buffer} ptr buffer
    #{poke WGPUBindGroupEntry, offset} ptr offset
    #{poke WGPUBindGroupEntry, size} ptr size
    #{poke WGPUBindGroupEntry, sampler} ptr sampler
    #{poke WGPUBindGroupEntry, textureView} ptr textureView

data WGPUBindGroupDescriptor = WGPUBindGroupDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  layout :: Ptr WGPUBindGroupLayout, 
  entryCount :: CSize, 
  entries :: ConstPtr WGPUBindGroupEntry
}
 
instance Storable WGPUBindGroupDescriptor where
  alignment _ = #{alignment WGPUBindGroupDescriptor}
  sizeOf _ = #{size WGPUBindGroupDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUBindGroupDescriptor, nextInChain} ptr
    label <- #{peek WGPUBindGroupDescriptor, label} ptr
    layout <- #{peek WGPUBindGroupDescriptor, layout} ptr
    entryCount <- #{peek WGPUBindGroupDescriptor, entryCount} ptr
    entries <- #{peek WGPUBindGroupDescriptor, entries} ptr
    return WGPUBindGroupDescriptor{nextInChain, label, layout, entryCount, entries}
  poke ptr WGPUBindGroupDescriptor{nextInChain, label, layout, entryCount, entries} = do
    #{poke WGPUBindGroupDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUBindGroupDescriptor, label} ptr label
    #{poke WGPUBindGroupDescriptor, layout} ptr layout
    #{poke WGPUBindGroupDescriptor, entryCount} ptr entryCount
    #{poke WGPUBindGroupDescriptor, entries} ptr entries


data WGPUTextureViewDescriptor = WGPUTextureViewDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  format :: WGPUTextureFormat, 
  dimension :: WGPUTextureViewDimension, 
  baseMipLevel :: Word32, 
  mipLevelCount :: Word32, 
  baseArrayLayer :: Word32, 
  arrayLayerCount :: Word32, 
  aspect :: WGPUTextureAspect, 
  usage :: WGPUTextureUsage
}

instance Storable WGPUTextureViewDescriptor where
  alignment _ = #{alignment WGPUTextureViewDescriptor}
  sizeOf _ = #{size WGPUTextureViewDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUTextureViewDescriptor, nextInChain} ptr
    label <- #{peek WGPUTextureViewDescriptor, label} ptr
    format <- #{peek WGPUTextureViewDescriptor, format} ptr
    dimension <- #{peek WGPUTextureViewDescriptor, dimension} ptr
    baseMipLevel <- #{peek WGPUTextureViewDescriptor, baseMipLevel} ptr
    mipLevelCount <- #{peek WGPUTextureViewDescriptor, mipLevelCount} ptr
    baseArrayLayer <- #{peek WGPUTextureViewDescriptor, baseArrayLayer} ptr
    arrayLayerCount <- #{peek WGPUTextureViewDescriptor, arrayLayerCount} ptr
    aspect <- #{peek WGPUTextureViewDescriptor, aspect} ptr
    usage <- #{peek WGPUTextureViewDescriptor, usage} ptr
    return WGPUTextureViewDescriptor{nextInChain, label, format, dimension, baseMipLevel, mipLevelCount, baseArrayLayer, arrayLayerCount, aspect, usage}
  poke ptr WGPUTextureViewDescriptor{nextInChain, label, format, dimension, baseMipLevel, mipLevelCount, baseArrayLayer, arrayLayerCount, aspect, usage} = do
    #{poke WGPUTextureViewDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUTextureViewDescriptor, label} ptr label
    #{poke WGPUTextureViewDescriptor, format} ptr format
    #{poke WGPUTextureViewDescriptor, dimension} ptr dimension
    #{poke WGPUTextureViewDescriptor, baseMipLevel} ptr baseMipLevel
    #{poke WGPUTextureViewDescriptor, mipLevelCount} ptr mipLevelCount
    #{poke WGPUTextureViewDescriptor, baseArrayLayer} ptr baseArrayLayer
    #{poke WGPUTextureViewDescriptor, arrayLayerCount} ptr arrayLayerCount
    #{poke WGPUTextureViewDescriptor, aspect} ptr aspect
    #{poke WGPUTextureViewDescriptor, usage} ptr usage


data WGPUBufferDescriptor = WGPUBufferDescriptor {
  nextInChain :: Ptr WGPUChainedStruct, 
  label :: WGPUStringView, 
  usage :: WGPUBufferUsage, 
  size :: Word64, 
  mappedAtCreation :: WGPUBool
}

instance Storable WGPUBufferDescriptor where
  alignment _ = #{alignment WGPUBufferDescriptor}
  sizeOf _ = #{size WGPUBufferDescriptor}
  peek ptr = do
    nextInChain <- #{peek WGPUBufferDescriptor, nextInChain} ptr
    label <- #{peek WGPUBufferDescriptor, label} ptr
    usage <- #{peek WGPUBufferDescriptor, usage} ptr
    size <- #{peek WGPUBufferDescriptor, size} ptr
    mappedAtCreation <- #{peek WGPUBufferDescriptor, mappedAtCreation} ptr
    return WGPUBufferDescriptor{nextInChain, label, usage, size, mappedAtCreation}
  poke ptr WGPUBufferDescriptor{nextInChain, label, usage, size, mappedAtCreation} = do
    #{poke WGPUBufferDescriptor, nextInChain} ptr nextInChain
    #{poke WGPUBufferDescriptor, label} ptr label
    #{poke WGPUBufferDescriptor, usage} ptr usage
    #{poke WGPUBufferDescriptor, size} ptr size
    #{poke WGPUBufferDescriptor, mappedAtCreation} ptr mappedAtCreation