module Graphics.Vulkan.Types.Struct.LayerProperties
(VkLayerProperties(..)) where
import Foreign.Storable (Storable (..))
import GHC.Base (Addr#, ByteArray#, Proxy#,
byteArrayContents#,
plusAddr#, proxy#)
import GHC.TypeLits (KnownNat, natVal')
import Graphics.Vulkan.Constants (VK_MAX_DESCRIPTION_SIZE, pattern VK_MAX_DESCRIPTION_SIZE,
VK_MAX_EXTENSION_NAME_SIZE,
pattern VK_MAX_EXTENSION_NAME_SIZE)
import Graphics.Vulkan.Marshal
import Graphics.Vulkan.Marshal.Internal
import System.IO.Unsafe (unsafeDupablePerformIO)
data VkLayerProperties = VkLayerProperties# Addr# ByteArray#
instance Eq VkLayerProperties where
(VkLayerProperties# a _) == x@(VkLayerProperties# b _)
= EQ == cmpBytes# (sizeOf x) a b
instance Ord VkLayerProperties where
(VkLayerProperties# a _) `compare` x@(VkLayerProperties# b _)
= cmpBytes# (sizeOf x) a b
instance Storable VkLayerProperties where
sizeOf ~_ = (520)
alignment ~_ = (4)
peek = peekVkData#
poke = pokeVkData#
instance VulkanMarshalPrim VkLayerProperties where
unsafeAddr (VkLayerProperties# a _) = a
unsafeByteArray (VkLayerProperties# _ b) = b
unsafeFromByteArrayOffset off b
= VkLayerProperties# (plusAddr# (byteArrayContents# b) off) b
instance VulkanMarshal VkLayerProperties where
type StructFields VkLayerProperties =
'["layerName", "specVersion", "implementationVersion",
"description"]
type CUnionType VkLayerProperties = 'False
type ReturnedOnly VkLayerProperties = 'True
type StructExtends VkLayerProperties = '[]
instance HasField "layerName" VkLayerProperties
where
type FieldType "layerName" VkLayerProperties = CChar
type FieldOptional "layerName" VkLayerProperties = 'False
type FieldOffset "layerName" VkLayerProperties =
(0)
type FieldIsArray "layerName" VkLayerProperties = 'True
fieldOptional = False
fieldOffset = (0)
instance
(KnownNat idx, IndexInBounds "layerName" idx VkLayerProperties) =>
CanReadFieldArray "layerName" idx VkLayerProperties
where
type FieldArrayLength "layerName" VkLayerProperties =
VK_MAX_EXTENSION_NAME_SIZE
fieldArrayLength = VK_MAX_EXTENSION_NAME_SIZE
getFieldArray = f
where
f x = unsafeDupablePerformIO (peekByteOff (unsafePtr x) off)
off
= (0) +
sizeOf (undefined :: CChar) *
fromInteger (natVal' (proxy# :: Proxy# idx))
readFieldArray p
= peekByteOff p
((0) +
sizeOf (undefined :: CChar) *
fromInteger (natVal' (proxy# :: Proxy# idx)))
instance
(KnownNat idx, IndexInBounds "layerName" idx VkLayerProperties) =>
CanWriteFieldArray "layerName" idx VkLayerProperties
where
writeFieldArray p
= pokeByteOff p
((0) +
sizeOf (undefined :: CChar) *
fromInteger (natVal' (proxy# :: Proxy# idx)))
instance
HasField "specVersion" VkLayerProperties where
type FieldType "specVersion" VkLayerProperties = Word32
type FieldOptional "specVersion" VkLayerProperties = 'False
type FieldOffset "specVersion" VkLayerProperties =
(256)
type FieldIsArray "specVersion" VkLayerProperties = 'False
fieldOptional = False
fieldOffset = (256)
instance
CanReadField "specVersion" VkLayerProperties where
getField x
= unsafeDupablePerformIO
(peekByteOff (unsafePtr x) (256))
readField p
= peekByteOff p (256)
instance
CanWriteField "specVersion" VkLayerProperties where
writeField p
= pokeByteOff p (256)
instance
HasField "implementationVersion" VkLayerProperties where
type FieldType "implementationVersion" VkLayerProperties = Word32
type FieldOptional "implementationVersion" VkLayerProperties =
'False
type FieldOffset "implementationVersion" VkLayerProperties =
(260)
type FieldIsArray "implementationVersion" VkLayerProperties =
'False
fieldOptional = False
fieldOffset
= (260)
instance
CanReadField "implementationVersion" VkLayerProperties where
getField x
= unsafeDupablePerformIO
(peekByteOff (unsafePtr x) (260))
readField p
= peekByteOff p (260)
instance
CanWriteField "implementationVersion" VkLayerProperties where
writeField p
= pokeByteOff p (260)
instance
HasField "description" VkLayerProperties where
type FieldType "description" VkLayerProperties = CChar
type FieldOptional "description" VkLayerProperties = 'False
type FieldOffset "description" VkLayerProperties =
(264)
type FieldIsArray "description" VkLayerProperties = 'True
fieldOptional = False
fieldOffset = (264)
instance
(KnownNat idx,
IndexInBounds "description" idx VkLayerProperties) =>
CanReadFieldArray "description" idx VkLayerProperties
where
type FieldArrayLength "description" VkLayerProperties =
VK_MAX_DESCRIPTION_SIZE
fieldArrayLength = VK_MAX_DESCRIPTION_SIZE
getFieldArray = f
where
f x = unsafeDupablePerformIO (peekByteOff (unsafePtr x) off)
off
= (264) +
sizeOf (undefined :: CChar) *
fromInteger (natVal' (proxy# :: Proxy# idx))
readFieldArray p
= peekByteOff p
((264) +
sizeOf (undefined :: CChar) *
fromInteger (natVal' (proxy# :: Proxy# idx)))
instance
(KnownNat idx,
IndexInBounds "description" idx VkLayerProperties) =>
CanWriteFieldArray "description" idx VkLayerProperties
where
writeFieldArray p
= pokeByteOff p
((264) +
sizeOf (undefined :: CChar) *
fromInteger (natVal' (proxy# :: Proxy# idx)))
instance Show VkLayerProperties where
showsPrec d x
= showString "VkLayerProperties {" .
(showString "layerName = [" .
showsPrec d
(let s = sizeOf
(undefined :: FieldType "layerName" VkLayerProperties)
o = fieldOffset @"layerName" @VkLayerProperties
f i
= peekByteOff (unsafePtr x) i ::
IO (FieldType "layerName" VkLayerProperties)
in
unsafeDupablePerformIO . mapM f $
map (\ i -> o + i * s) [0 .. VK_MAX_EXTENSION_NAME_SIZE 1])
. showChar ']')
.
showString ", " .
showString "specVersion = " .
showsPrec d (getField @"specVersion" x) .
showString ", " .
showString "implementationVersion = " .
showsPrec d (getField @"implementationVersion" x) .
showString ", " .
(showString "description = [" .
showsPrec d
(let s = sizeOf
(undefined ::
FieldType "description" VkLayerProperties)
o = fieldOffset @"description" @VkLayerProperties
f i
= peekByteOff (unsafePtr x) i ::
IO (FieldType "description" VkLayerProperties)
in
unsafeDupablePerformIO . mapM f $
map (\ i -> o + i * s) [0 .. VK_MAX_DESCRIPTION_SIZE 1])
. showChar ']')
. showChar '}'