{-# 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.Core14.Promoted_From_VK_KHR_maintenance5Roadmap (BufferUsageFlags2CreateInfo)
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 = IO BufferView -> io BufferView
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO BufferView -> io BufferView)
-> (ContT BufferView IO BufferView -> IO BufferView)
-> ContT BufferView IO BufferView
-> io BufferView
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT BufferView IO BufferView -> IO BufferView
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT BufferView IO BufferView -> io BufferView)
-> ContT BufferView IO BufferView -> io BufferView
forall a b. (a -> b) -> a -> b
$ do
let vkCreateBufferViewPtr :: FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
vkCreateBufferViewPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
pVkCreateBufferView (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
IO () -> ContT BufferView IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT BufferView m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT BufferView IO ())
-> IO () -> ContT BufferView IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
vkCreateBufferViewPtr FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
-> FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. (HasCallStack, Exception e) => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkCreateBufferView is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkCreateBufferView' :: Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result
vkCreateBufferView' = 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
mkVkCreateBufferView FunPtr
(Ptr Device_T
-> Ptr (SomeStruct BufferViewCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr BufferView
-> IO Result)
vkCreateBufferViewPtr
pCreateInfo <- ((Ptr (BufferViewCreateInfo a) -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO (Ptr (BufferViewCreateInfo a))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BufferViewCreateInfo a) -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO (Ptr (BufferViewCreateInfo a)))
-> ((Ptr (BufferViewCreateInfo a) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO (Ptr (BufferViewCreateInfo a))
forall a b. (a -> b) -> a -> b
$ BufferViewCreateInfo a
-> (Ptr (BufferViewCreateInfo a) -> IO BufferView) -> IO BufferView
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
BufferViewCreateInfo a
-> (Ptr (BufferViewCreateInfo a) -> IO b) -> IO b
withCStruct (BufferViewCreateInfo a
createInfo)
pAllocator <- case (allocator) of
"allocator" ::: Maybe AllocationCallbacks
Nothing -> Ptr AllocationCallbacks
-> ContT BufferView IO (Ptr AllocationCallbacks)
forall a. a -> ContT BufferView IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
Just AllocationCallbacks
j -> ((Ptr AllocationCallbacks -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO (Ptr AllocationCallbacks)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCallbacks -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO (Ptr AllocationCallbacks))
-> ((Ptr AllocationCallbacks -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO (Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (Ptr AllocationCallbacks -> IO BufferView) -> IO BufferView
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
AllocationCallbacks -> (Ptr AllocationCallbacks -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
pPView <- ContT $ bracket (callocBytes @BufferView 8) free
r <- lift $ traceAroundEvent "vkCreateBufferView" (vkCreateBufferView'
(deviceHandle (device))
(forgetExtensions pCreateInfo)
pAllocator
(pPView))
lift $ when (r < SUCCESS) (throwIO (VulkanException r))
pView <- lift $ peek @BufferView pPView
pure $ (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 (Device
-> BufferViewCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io BufferView
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) -> Device
-> BufferView
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
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 = IO () -> io ()
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
let vkDestroyBufferViewPtr :: FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
vkDestroyBufferViewPtr = DeviceCmds
-> FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
pVkDestroyBufferView (case Device
device of Device{DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
IO () -> ContT () IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT () m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
vkDestroyBufferViewPtr FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
-> FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. (HasCallStack, Exception e) => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkDestroyBufferView is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkDestroyBufferView' :: Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ()
vkDestroyBufferView' = FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
-> Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ()
mkVkDestroyBufferView FunPtr
(Ptr Device_T -> BufferView -> Ptr AllocationCallbacks -> IO ())
vkDestroyBufferViewPtr
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
"allocator" ::: Maybe AllocationCallbacks
Nothing -> Ptr AllocationCallbacks -> ContT () IO (Ptr AllocationCallbacks)
forall a. a -> ContT () IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
Just AllocationCallbacks
j -> ((Ptr AllocationCallbacks -> IO ()) -> IO ())
-> ContT () IO (Ptr AllocationCallbacks)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCallbacks -> IO ()) -> IO ())
-> ContT () IO (Ptr AllocationCallbacks))
-> ((Ptr AllocationCallbacks -> IO ()) -> IO ())
-> ContT () IO (Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks -> (Ptr AllocationCallbacks -> IO ()) -> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
AllocationCallbacks -> (Ptr AllocationCallbacks -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
lift $ traceAroundEvent "vkDestroyBufferView" (vkDestroyBufferView'
(deviceHandle (device))
(bufferView)
pAllocator)
pure $ ()
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
Format
BufferViewCreateFlags
Buffer
Chain ds
next :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
flags :: forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
buffer :: forall (es :: [*]). BufferViewCreateInfo es -> Buffer
format :: forall (es :: [*]). BufferViewCreateInfo es -> Format
offset :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
range :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
next :: Chain ds
flags :: BufferViewCreateFlags
buffer :: Buffer
format :: Format
offset :: DeviceSize
range :: DeviceSize
..} Chain es
next' = BufferViewCreateInfo{next :: Chain es
next = Chain es
next', DeviceSize
Format
BufferViewCreateFlags
Buffer
flags :: BufferViewCreateFlags
buffer :: Buffer
format :: Format
offset :: DeviceSize
range :: DeviceSize
flags :: BufferViewCreateFlags
buffer :: Buffer
format :: Format
offset :: DeviceSize
range :: DeviceSize
..}
getNext :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
getNext BufferViewCreateInfo{DeviceSize
Format
BufferViewCreateFlags
Buffer
Chain es
next :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
flags :: forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
buffer :: forall (es :: [*]). BufferViewCreateInfo es -> Buffer
format :: forall (es :: [*]). BufferViewCreateInfo es -> Format
offset :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
range :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
next :: Chain es
flags :: BufferViewCreateFlags
buffer :: Buffer
format :: Format
offset :: DeviceSize
range :: DeviceSize
..} = 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)
forall a b. (Typeable a, Typeable b) => Maybe (a :~: b)
eqT @e @ExportMetalObjectCreateInfoEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BufferViewCreateInfo e => b
f
| Just e :~: BufferUsageFlags2CreateInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
forall a b. (Typeable a, Typeable b) => Maybe (a :~: b)
eqT @e @BufferUsageFlags2CreateInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BufferViewCreateInfo e => b
f
| Bool
otherwise = Maybe b
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 = Int -> (Ptr (BufferViewCreateInfo es) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
56 ((Ptr (BufferViewCreateInfo es) -> IO b) -> IO b)
-> (Ptr (BufferViewCreateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr (BufferViewCreateInfo es)
p -> Ptr (BufferViewCreateInfo es)
-> BufferViewCreateInfo es -> IO b -> IO b
forall b.
Ptr (BufferViewCreateInfo es)
-> BufferViewCreateInfo es -> IO b -> IO b
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
Format
BufferViewCreateFlags
Buffer
Chain es
next :: forall (es :: [*]). BufferViewCreateInfo es -> Chain es
flags :: forall (es :: [*]).
BufferViewCreateInfo es -> BufferViewCreateFlags
buffer :: forall (es :: [*]). BufferViewCreateInfo es -> Buffer
format :: forall (es :: [*]). BufferViewCreateInfo es -> Format
offset :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
range :: forall (es :: [*]). BufferViewCreateInfo es -> DeviceSize
next :: Chain es
flags :: BufferViewCreateFlags
buffer :: Buffer
format :: Format
offset :: DeviceSize
range :: DeviceSize
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p Ptr (BufferViewCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
pNext'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> ContT b IO a -> ContT b IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ Chain es -> (Ptr (Chain es) -> IO b) -> IO b
forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
forall a. Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) pNext''
lift $ poke ((p `plusPtr` 16 :: Ptr BufferViewCreateFlags)) (flags)
lift $ poke ((p `plusPtr` 24 :: Ptr Buffer)) (buffer)
lift $ poke ((p `plusPtr` 32 :: Ptr Format)) (format)
lift $ poke ((p `plusPtr` 40 :: Ptr DeviceSize)) (offset)
lift $ poke ((p `plusPtr` 48 :: Ptr DeviceSize)) (range)
lift $ 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 = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BufferViewCreateInfo es)
p Ptr (BufferViewCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> ContT b IO a -> ContT b IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) pNext'
lift $ poke ((p `plusPtr` 24 :: Ptr Buffer)) (zero)
lift $ poke ((p `plusPtr` 32 :: Ptr Format)) (zero)
lift $ poke ((p `plusPtr` 40 :: Ptr DeviceSize)) (zero)
lift $ poke ((p `plusPtr` 48 :: Ptr DeviceSize)) (zero)
lift $ f
instance ( Extendss BufferViewCreateInfo es
, PeekChain es ) => FromCStruct (BufferViewCreateInfo es) where
peekCStruct :: Ptr (BufferViewCreateInfo es) -> IO (BufferViewCreateInfo es)
peekCStruct Ptr (BufferViewCreateInfo es)
p = do
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BufferViewCreateInfo es)
p Ptr (BufferViewCreateInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
next <- peekChain (castPtr pNext)
flags <- peek @BufferViewCreateFlags ((p `plusPtr` 16 :: Ptr BufferViewCreateFlags))
buffer <- peek @Buffer ((p `plusPtr` 24 :: Ptr Buffer))
format <- peek @Format ((p `plusPtr` 32 :: Ptr Format))
offset <- peek @DeviceSize ((p `plusPtr` 40 :: Ptr DeviceSize))
range <- peek @DeviceSize ((p `plusPtr` 48 :: Ptr DeviceSize))
pure $ BufferViewCreateInfo
next flags buffer format offset range
instance es ~ '[] => Zero (BufferViewCreateInfo es) where
zero :: BufferViewCreateInfo es
zero = Chain es
-> BufferViewCreateFlags
-> Buffer
-> Format
-> DeviceSize
-> DeviceSize
-> BufferViewCreateInfo es
forall (es :: [*]).
Chain es
-> BufferViewCreateFlags
-> Buffer
-> Format
-> DeviceSize
-> DeviceSize
-> BufferViewCreateInfo es
BufferViewCreateInfo
()
BufferViewCreateFlags
forall a. Zero a => a
zero
Buffer
forall a. Zero a => a
zero
Format
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero