{-# language CPP #-}
module Vulkan.Core10.BufferView ( createBufferView
, withBufferView
, destroyBufferView
, BufferViewCreateInfo(..)
, BufferView(..)
, BufferViewCreateFlags(..)
) where
import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Control.Monad.IO.Class (MonadIO)
import Data.Type.Equality ((:~:)(Refl))
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.Core10.Handles (Buffer)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_maintenance5 (BufferUsageFlags2CreateInfoKHR)
import Vulkan.Core10.Handles (BufferView)
import Vulkan.Core10.Handles (BufferView(..))
import Vulkan.Core10.Enums.BufferViewCreateFlags (BufferViewCreateFlags)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkCreateBufferView))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyBufferView))
import Vulkan.Core10.FundamentalTypes (DeviceSize)
import Vulkan.Core10.Handles (Device_T)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_metal_objects (ExportMetalObjectCreateInfoEXT)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.Core10.Enums.Format (Format)
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Handles (BufferView(..))
import Vulkan.Core10.Enums.BufferViewCreateFlags (BufferViewCreateFlags(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkCreateBufferView
:: FunPtr (Ptr Device_T -> Ptr (SomeStruct BufferViewCreateInfo) -> Ptr AllocationCallbacks -> Ptr BufferView -> IO Result) -> Ptr Device_T -> Ptr (SomeStruct BufferViewCreateInfo) -> Ptr AllocationCallbacks -> Ptr BufferView -> IO Result
createBufferView :: forall a io
. (Extendss BufferViewCreateInfo a, PokeChain a, MonadIO io)
=>
Device
->
(BufferViewCreateInfo a)
->
("allocator" ::: Maybe AllocationCallbacks)
-> io (BufferView)
createBufferView :: forall (a :: [*]) (io :: * -> *).
(Extendss BufferViewCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> BufferViewCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io BufferView
createBufferView Device
device BufferViewCreateInfo a
createInfo "allocator" ::: Maybe AllocationCallbacks
allocator = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkCreateBufferViewPtr :: FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
vkCreateBufferViewPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
pVkCreateBufferView (case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
vkCreateBufferViewPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkCreateBufferView is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkCreateBufferView' :: Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result
vkCreateBufferView' = FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
-> Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result
mkVkCreateBufferView FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
vkCreateBufferViewPtr
Ptr (BufferViewCreateInfo a)
pCreateInfo <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferViewCreateInfo a
createInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
"allocator" ::: Maybe AllocationCallbacks
Nothing -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
Just AllocationCallbacks
j -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pView" ::: Ptr BufferView
pPView <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @BufferView Int
8) forall a. Ptr a -> IO ()
free
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkCreateBufferView" (Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct BufferViewCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result
vkCreateBufferView'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (BufferViewCreateInfo a)
pCreateInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator
("pView" ::: Ptr BufferView
pPView))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
BufferView
pView <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @BufferView "pView" ::: Ptr BufferView
pPView
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (BufferView
pView)
withBufferView :: forall a io r . (Extendss BufferViewCreateInfo a, PokeChain a, MonadIO io) => Device -> BufferViewCreateInfo a -> Maybe AllocationCallbacks -> (io BufferView -> (BufferView -> io ()) -> r) -> r
withBufferView :: forall (a :: [*]) (io :: * -> *) r.
(Extendss BufferViewCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> BufferViewCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io BufferView -> (BufferView -> io ()) -> r)
-> r
withBufferView Device
device BufferViewCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator io BufferView -> (BufferView -> io ()) -> r
b =
io BufferView -> (BufferView -> io ()) -> r
b (forall (a :: [*]) (io :: * -> *).
(Extendss BufferViewCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> BufferViewCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io BufferView
createBufferView Device
device BufferViewCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
(\(BufferView
o0) -> forall (io :: * -> *).
MonadIO io =>
Device
-> BufferView
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyBufferView Device
device BufferView
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkDestroyBufferView
:: FunPtr (Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ()
destroyBufferView :: forall io
. (MonadIO io)
=>
Device
->
BufferView
->
("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyBufferView :: forall (io :: * -> *).
MonadIO io =>
Device
-> BufferView
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyBufferView Device
device BufferView
bufferView "allocator" ::: Maybe AllocationCallbacks
allocator = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkDestroyBufferViewPtr :: FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyBufferViewPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
pVkDestroyBufferView (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyBufferViewPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkDestroyBufferView is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkDestroyBufferView' :: Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyBufferView' = FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
mkVkDestroyBufferView FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyBufferViewPtr
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
"allocator" ::: Maybe AllocationCallbacks
Nothing -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
Just AllocationCallbacks
j -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkDestroyBufferView" (Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyBufferView'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(BufferView
bufferView)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator)
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ()
data BufferViewCreateInfo (es :: [Type]) = BufferViewCreateInfo
{
forall (es :: [*]). BufferViewCreateInfo es -> Chain es
next :: Chain es
,
forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
flags :: BufferViewCreateFlags
,
forall (es :: [*]). BufferViewCreateInfo es -> Buffer
buffer :: Buffer
,
forall (es :: [*]). BufferViewCreateInfo es -> Format
format :: Format
,
forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
offset :: DeviceSize
,
forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
range :: DeviceSize
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BufferViewCreateInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (BufferViewCreateInfo es)
instance Extensible BufferViewCreateInfo where
extensibleTypeName :: String
extensibleTypeName = String
"BufferViewCreateInfo"
setNext :: forall (ds :: [*]) (es :: [*]).
BufferViewCreateInfo ds -> Chain es -> BufferViewCreateInfo es
setNext BufferViewCreateInfo{DeviceSize
Chain ds
Format
Buffer
BufferViewCreateFlags
range :: DeviceSize
offset :: DeviceSize
format :: Format
buffer :: Buffer
flags :: BufferViewCreateFlags
next :: Chain ds
$sel:range:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
$sel:offset:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
$sel:format:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Format
$sel:buffer:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Buffer
$sel:flags:BufferViewCreateInfo :: forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
$sel:next:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
..} Chain es
next' = BufferViewCreateInfo{$sel:next:BufferViewCreateInfo :: Chain es
next = Chain es
next', DeviceSize
Format
Buffer
BufferViewCreateFlags
range :: DeviceSize
offset :: DeviceSize
format :: Format
buffer :: Buffer
flags :: BufferViewCreateFlags
$sel:range:BufferViewCreateInfo :: DeviceSize
$sel:offset:BufferViewCreateInfo :: DeviceSize
$sel:format:BufferViewCreateInfo :: Format
$sel:buffer:BufferViewCreateInfo :: Buffer
$sel:flags:BufferViewCreateInfo :: BufferViewCreateFlags
..}
getNext :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
getNext BufferViewCreateInfo{DeviceSize
Chain es
Format
Buffer
BufferViewCreateFlags
range :: DeviceSize
offset :: DeviceSize
format :: Format
buffer :: Buffer
flags :: BufferViewCreateFlags
next :: Chain es
$sel:range:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
$sel:offset:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
$sel:format:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Format
$sel:buffer:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Buffer
$sel:flags:BufferViewCreateInfo :: forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
$sel:next:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends BufferViewCreateInfo e => b) -> Maybe b
extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends BufferViewCreateInfo e => b) -> Maybe b
extends proxy e
_ Extends BufferViewCreateInfo e => b
f
| Just e :~: ExportMetalObjectCreateInfoEXT
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportMetalObjectCreateInfoEXT = forall a. a -> Maybe a
Just Extends BufferViewCreateInfo e => b
f
| Just e :~: BufferUsageFlags2CreateInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BufferUsageFlags2CreateInfoKHR = forall a. a -> Maybe a
Just Extends BufferViewCreateInfo e => b
f
| Bool
otherwise = forall a. Maybe a
Nothing
instance ( Extendss BufferViewCreateInfo es
, PokeChain es ) => ToCStruct (BufferViewCreateInfo es) where
withCStruct :: forall b.
BufferViewCreateInfo es
-> (Ptr (BufferViewCreateInfo es) -> IO b) -> IO b
withCStruct BufferViewCreateInfo es
x Ptr (BufferViewCreateInfo es) -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
56 forall a b. (a -> b) -> a -> b
$ \Ptr (BufferViewCreateInfo es)
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (BufferViewCreateInfo es)
p BufferViewCreateInfo es
x (Ptr (BufferViewCreateInfo es) -> IO b
f Ptr (BufferViewCreateInfo es)
p)
pokeCStruct :: forall b.
Ptr (BufferViewCreateInfo es)
-> BufferViewCreateInfo es -> IO b -> IO b
pokeCStruct Ptr (BufferViewCreateInfo es)
p BufferViewCreateInfo{DeviceSize
Chain es
Format
Buffer
BufferViewCreateFlags
range :: DeviceSize
offset :: DeviceSize
format :: Format
buffer :: Buffer
flags :: BufferViewCreateFlags
next :: Chain es
$sel:range:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
$sel:offset:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
$sel:format:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Format
$sel:buffer:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Buffer
$sel:flags:BufferViewCreateInfo :: forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
$sel:next:BufferViewCreateInfo :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
..} IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
Ptr ()
pNext'' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext''
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr BufferViewCreateFlags)) (BufferViewCreateFlags
flags)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Buffer)) (Buffer
buffer)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Format)) (Format
format)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) (DeviceSize
offset)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize)) (DeviceSize
range)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = Int
56
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr (BufferViewCreateInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (BufferViewCreateInfo es)
p IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
Ptr ()
pNext' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext'
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Buffer)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Format)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
instance ( Extendss BufferViewCreateInfo es
, PeekChain es ) => FromCStruct (BufferViewCreateInfo es) where
peekCStruct :: Ptr (BufferViewCreateInfo es) -> IO (BufferViewCreateInfo es)
peekCStruct Ptr (BufferViewCreateInfo es)
p = do
Ptr ()
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
Chain es
next <- forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
BufferViewCreateFlags
flags <- forall a. Storable a => Ptr a -> IO a
peek @BufferViewCreateFlags ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr BufferViewCreateFlags))
Buffer
buffer <- forall a. Storable a => Ptr a -> IO a
peek @Buffer ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Buffer))
Format
format <- forall a. Storable a => Ptr a -> IO a
peek @Format ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Format))
DeviceSize
offset <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize))
DeviceSize
range <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (BufferViewCreateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (es :: [*]).
Chain es
-> BufferViewCreateFlags
-> Buffer
-> Format
-> DeviceSize
-> DeviceSize
-> BufferViewCreateInfo es
BufferViewCreateInfo
Chain es
next BufferViewCreateFlags
flags Buffer
buffer Format
format DeviceSize
offset DeviceSize
range
instance es ~ '[] => Zero (BufferViewCreateInfo es) where
zero :: BufferViewCreateInfo es
zero = forall (es :: [*]).
Chain es
-> BufferViewCreateFlags
-> Buffer
-> Format
-> DeviceSize
-> DeviceSize
-> BufferViewCreateInfo es
BufferViewCreateInfo
()
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero