|
| 1 | +module Web.GPU.GPUTexture |
| 2 | + ( TextureViewDescriptor |
| 3 | + , createView |
| 4 | + , destroy |
| 5 | + , width |
| 6 | + , height |
| 7 | + , depthOrArrayLayers |
| 8 | + , mipLevelCount |
| 9 | + , sampleCount |
| 10 | + , dimension |
| 11 | + , format |
| 12 | + , usage |
| 13 | + ) where |
| 14 | + |
| 15 | +import Prelude |
| 16 | + |
| 17 | +import Effect (Effect) |
| 18 | +import Web.GPU.GPUTextureAspect (GPUTextureAspect) |
| 19 | +import Web.GPU.GPUTextureDimension (GPUTextureDimension) |
| 20 | +import Web.GPU.GPUTextureFormat (GPUTextureFormat) |
| 21 | +import Web.GPU.GPUTextureUsage (GPUTextureUsage) |
| 22 | +import Web.GPU.GPUTextureViewDimension (GPUTextureViewDimension) |
| 23 | +import Web.GPU.Internal.ConvertibleOptions (class ConvertOption, class ConvertOptionsWithDefaults, convertOptionsWithDefaults) |
| 24 | +import Web.GPU.Internal.Types (GPUTexture, GPUTextureView) |
| 25 | +import Web.GPU.Internal.Undefinable (Undefinable, defined, undefined) |
| 26 | +import Web.GPU.Internal.Unsigned (GPUIntegerCoordinate, GPUSize32) |
| 27 | + |
| 28 | +type GPUTextureViewDescriptorOptional = |
| 29 | + ( aspect :: Undefinable GPUTextureAspect |
| 30 | + , baseMipLevel :: Undefinable GPUIntegerCoordinate |
| 31 | + , baseArrayLayer :: Undefinable GPUIntegerCoordinate |
| 32 | + ) |
| 33 | + |
| 34 | +type GPUTextureViewDescriptor = |
| 35 | + ( format :: GPUTextureFormat |
| 36 | + , dimension :: GPUTextureViewDimension |
| 37 | + , mipLevelCount :: GPUIntegerCoordinate |
| 38 | + , arrayLayerCount :: GPUIntegerCoordinate |
| 39 | + | GPUTextureViewDescriptorOptional |
| 40 | + ) |
| 41 | + |
| 42 | +defaultGPUTextureViewDescriptorOptions :: { | GPUTextureViewDescriptorOptional } |
| 43 | +defaultGPUTextureViewDescriptorOptions = |
| 44 | + { aspect: undefined |
| 45 | + , baseMipLevel: undefined |
| 46 | + , baseArrayLayer: undefined |
| 47 | + } |
| 48 | + |
| 49 | +data TextureViewDescriptor = TextureViewDescriptor |
| 50 | + |
| 51 | +instance ConvertOption TextureViewDescriptor "aspect" GPUTextureAspect (Undefinable GPUTextureAspect) where |
| 52 | + convertOption _ _ = defined |
| 53 | + |
| 54 | +instance ConvertOption TextureViewDescriptor "baseMipLevel" GPUIntegerCoordinate (Undefinable GPUIntegerCoordinate) where |
| 55 | + convertOption _ _ = defined |
| 56 | + |
| 57 | +instance ConvertOption TextureViewDescriptor "baseArrayLayer" GPUIntegerCoordinate (Undefinable GPUIntegerCoordinate) where |
| 58 | + convertOption _ _ = defined |
| 59 | + |
| 60 | +foreign import createViewImpl :: GPUTexture -> { | GPUTextureViewDescriptor } -> Effect GPUTextureView |
| 61 | + |
| 62 | +createView |
| 63 | + :: forall provided |
| 64 | + . ConvertOptionsWithDefaults TextureViewDescriptor { | GPUTextureViewDescriptorOptional } { | provided } { | GPUTextureViewDescriptor } |
| 65 | + => GPUTexture |
| 66 | + -> { | provided } |
| 67 | + -> Effect GPUTextureView |
| 68 | +createView gpuDevice provided = createViewImpl gpuDevice all |
| 69 | + where |
| 70 | + all :: { | GPUTextureViewDescriptor } |
| 71 | + all = convertOptionsWithDefaults TextureViewDescriptor defaultGPUTextureViewDescriptorOptions provided |
| 72 | + |
| 73 | +foreign import destroyImpl :: GPUTexture -> Effect Unit |
| 74 | + |
| 75 | +destroy :: GPUTexture -> Effect Unit |
| 76 | +destroy = destroyImpl |
| 77 | + |
| 78 | +foreign import widthImpl :: GPUTexture -> Effect GPUIntegerCoordinate |
| 79 | + |
| 80 | +width :: GPUTexture -> Effect GPUIntegerCoordinate |
| 81 | +width = widthImpl |
| 82 | + |
| 83 | +foreign import heightImpl :: GPUTexture -> Effect GPUIntegerCoordinate |
| 84 | + |
| 85 | +height :: GPUTexture -> Effect GPUIntegerCoordinate |
| 86 | +height = heightImpl |
| 87 | + |
| 88 | +foreign import depthOrArrayLayersImpl :: GPUTexture -> Effect GPUIntegerCoordinate |
| 89 | + |
| 90 | +depthOrArrayLayers :: GPUTexture -> Effect GPUIntegerCoordinate |
| 91 | +depthOrArrayLayers = depthOrArrayLayersImpl |
| 92 | + |
| 93 | +foreign import mipLevelCountImpl :: GPUTexture -> Effect GPUIntegerCoordinate |
| 94 | + |
| 95 | +mipLevelCount :: GPUTexture -> Effect GPUIntegerCoordinate |
| 96 | +mipLevelCount = mipLevelCountImpl |
| 97 | + |
| 98 | +foreign import sampleCountImpl :: GPUTexture -> Effect GPUSize32 |
| 99 | + |
| 100 | +sampleCount :: GPUTexture -> Effect GPUSize32 |
| 101 | +sampleCount = sampleCountImpl |
| 102 | + |
| 103 | +foreign import dimensionImpl :: GPUTexture -> Effect GPUTextureDimension |
| 104 | + |
| 105 | +dimension :: GPUTexture -> Effect GPUTextureDimension |
| 106 | +dimension = dimensionImpl |
| 107 | + |
| 108 | +foreign import formatImpl :: GPUTexture -> Effect GPUTextureFormat |
| 109 | + |
| 110 | +format :: GPUTexture -> Effect GPUTextureFormat |
| 111 | +format = formatImpl |
| 112 | + |
| 113 | +foreign import usageImpl :: GPUTexture -> Effect GPUTextureUsage |
| 114 | + |
| 115 | +usage :: GPUTexture -> Effect GPUTextureUsage |
| 116 | +usage = usageImpl |
0 commit comments