{-# 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 Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
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.Typeable (Typeable)
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
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.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.Core10.Handles (Buffer)
import Vulkan.Core10.Handles (BufferView)
import Vulkan.Core10.Handles (BufferView(..))
import Vulkan.Core10.Enums.BufferViewCreateFlags (BufferViewCreateFlags)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Dynamic (DeviceCmds(pVkCreateBufferView))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyBufferView))
import Vulkan.Core10.FundamentalTypes (DeviceSize)
import Vulkan.Core10.Handles (Device_T)
import Vulkan.Core10.Enums.Format (Format)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
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 BufferViewCreateInfo -> Ptr AllocationCallbacks -> Ptr BufferView -> IO Result) -> Ptr Device_T -> Ptr BufferViewCreateInfo -> Ptr AllocationCallbacks -> Ptr BufferView -> IO Result
createBufferView :: forall io
. (MonadIO io)
=>
Device
->
BufferViewCreateInfo
->
("allocator" ::: Maybe AllocationCallbacks)
-> io (BufferView)
createBufferView :: Device
-> BufferViewCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io BufferView
createBufferView device :: Device
device createInfo :: BufferViewCreateInfo
createInfo allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = IO BufferView -> io BufferView
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
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
vkCreateBufferViewPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
pVkCreateBufferView (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT BufferView IO ()
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
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
vkCreateBufferViewPtr FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: 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. 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 "" "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
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result
vkCreateBufferView' = FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
-> Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result
mkVkCreateBufferView FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result)
vkCreateBufferViewPtr
"pCreateInfo" ::: Ptr BufferViewCreateInfo
pCreateInfo <- ((("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO BufferView)
-> IO BufferView)
-> ContT
BufferView IO ("pCreateInfo" ::: Ptr BufferViewCreateInfo))
-> ((("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
forall a b. (a -> b) -> a -> b
$ BufferViewCreateInfo
-> (("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO BufferView)
-> IO BufferView
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferViewCreateInfo
createInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT BufferView IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pAllocator" ::: Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
Just j :: AllocationCallbacks
j -> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pAllocator" ::: Ptr AllocationCallbacks) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks) -> IO BufferView)
-> IO BufferView
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pView" ::: Ptr BufferView
pPView <- ((("pView" ::: Ptr BufferView) -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO ("pView" ::: Ptr BufferView)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pView" ::: Ptr BufferView) -> IO BufferView) -> IO BufferView)
-> ContT BufferView IO ("pView" ::: Ptr BufferView))
-> ((("pView" ::: Ptr BufferView) -> IO BufferView)
-> IO BufferView)
-> ContT BufferView IO ("pView" ::: Ptr BufferView)
forall a b. (a -> b) -> a -> b
$ IO ("pView" ::: Ptr BufferView)
-> (("pView" ::: Ptr BufferView) -> IO ())
-> (("pView" ::: Ptr BufferView) -> IO BufferView)
-> IO BufferView
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pView" ::: Ptr BufferView)
forall a. Int -> IO (Ptr a)
callocBytes @BufferView 8) ("pView" ::: Ptr BufferView) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT BufferView IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT BufferView IO Result)
-> IO Result -> ContT BufferView IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkCreateBufferView" (Ptr Device_T
-> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pView" ::: Ptr BufferView)
-> IO Result
vkCreateBufferView' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pCreateInfo" ::: Ptr BufferViewCreateInfo
pCreateInfo "pAllocator" ::: Ptr AllocationCallbacks
pAllocator ("pView" ::: Ptr BufferView
pPView))
IO () -> ContT BufferView IO ()
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 ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
BufferView
pView <- IO BufferView -> ContT BufferView IO BufferView
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO BufferView -> ContT BufferView IO BufferView)
-> IO BufferView -> ContT BufferView IO BufferView
forall a b. (a -> b) -> a -> b
$ ("pView" ::: Ptr BufferView) -> IO BufferView
forall a. Storable a => Ptr a -> IO a
peek @BufferView "pView" ::: Ptr BufferView
pPView
BufferView -> ContT BufferView IO BufferView
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BufferView -> ContT BufferView IO BufferView)
-> BufferView -> ContT BufferView IO BufferView
forall a b. (a -> b) -> a -> b
$ (BufferView
pView)
withBufferView :: forall io r . MonadIO io => Device -> BufferViewCreateInfo -> Maybe AllocationCallbacks -> (io BufferView -> (BufferView -> io ()) -> r) -> r
withBufferView :: Device
-> BufferViewCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io BufferView -> (BufferView -> io ()) -> r)
-> r
withBufferView device :: Device
device pCreateInfo :: BufferViewCreateInfo
pCreateInfo pAllocator :: "allocator" ::: Maybe AllocationCallbacks
pAllocator b :: io BufferView -> (BufferView -> io ()) -> r
b =
io BufferView -> (BufferView -> io ()) -> r
b (Device
-> BufferViewCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io BufferView
forall (io :: * -> *).
MonadIO io =>
Device
-> BufferViewCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io BufferView
createBufferView Device
device BufferViewCreateInfo
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 :: Device
-> BufferView
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyBufferView device :: Device
device bufferView :: BufferView
bufferView allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = IO () -> io ()
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
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyBufferViewPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
pVkDestroyBufferView (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT () IO ()
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
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyBufferViewPtr FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
IOException -> IO ()
forall e a. 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 "" "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
-> ("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
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pAllocator" ::: Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
Just j :: AllocationCallbacks
j -> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ())
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ())
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ())
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
IO () -> ContT () IO ()
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
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent "vkDestroyBufferView" (Ptr Device_T
-> BufferView
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyBufferView' (Device -> Ptr Device_T
deviceHandle (Device
device)) (BufferView
bufferView) "pAllocator" ::: Ptr AllocationCallbacks
pAllocator)
() -> ContT () IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> ContT () IO ()) -> () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ()
data BufferViewCreateInfo = BufferViewCreateInfo
{
BufferViewCreateInfo -> BufferViewCreateFlags
flags :: BufferViewCreateFlags
,
BufferViewCreateInfo -> Buffer
buffer :: Buffer
,
BufferViewCreateInfo -> Format
format :: Format
,
BufferViewCreateInfo -> DeviceSize
offset :: DeviceSize
,
BufferViewCreateInfo -> DeviceSize
range :: DeviceSize
}
deriving (Typeable, BufferViewCreateInfo -> BufferViewCreateInfo -> Bool
(BufferViewCreateInfo -> BufferViewCreateInfo -> Bool)
-> (BufferViewCreateInfo -> BufferViewCreateInfo -> Bool)
-> Eq BufferViewCreateInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BufferViewCreateInfo -> BufferViewCreateInfo -> Bool
$c/= :: BufferViewCreateInfo -> BufferViewCreateInfo -> Bool
== :: BufferViewCreateInfo -> BufferViewCreateInfo -> Bool
$c== :: BufferViewCreateInfo -> BufferViewCreateInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BufferViewCreateInfo)
#endif
deriving instance Show BufferViewCreateInfo
instance ToCStruct BufferViewCreateInfo where
withCStruct :: BufferViewCreateInfo
-> (("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b) -> IO b
withCStruct x :: BufferViewCreateInfo
x f :: ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b
f = Int
-> Int
-> (("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 56 8 ((("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b) -> IO b)
-> (("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pCreateInfo" ::: Ptr BufferViewCreateInfo
p -> ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> BufferViewCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pCreateInfo" ::: Ptr BufferViewCreateInfo
p BufferViewCreateInfo
x (("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b
f "pCreateInfo" ::: Ptr BufferViewCreateInfo
p)
pokeCStruct :: ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> BufferViewCreateInfo -> IO b -> IO b
pokeCStruct p :: "pCreateInfo" ::: Ptr BufferViewCreateInfo
p BufferViewCreateInfo{..} f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr BufferViewCreateFlags -> BufferViewCreateFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr BufferViewCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr BufferViewCreateFlags)) (BufferViewCreateFlags
flags)
Ptr Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Buffer)) (Buffer
buffer)
Ptr Format -> Format -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr Format
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Format)) (Format
format)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr DeviceSize)) (DeviceSize
offset)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr DeviceSize)) (DeviceSize
range)
IO b
f
cStructSize :: Int
cStructSize = 56
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> IO b -> IO b
pokeZeroCStruct p :: "pCreateInfo" ::: Ptr BufferViewCreateInfo
p f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Buffer)) (Buffer
forall a. Zero a => a
zero)
Ptr Format -> Format -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr Format
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Format)) (Format
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct BufferViewCreateInfo where
peekCStruct :: ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> IO BufferViewCreateInfo
peekCStruct p :: "pCreateInfo" ::: Ptr BufferViewCreateInfo
p = do
BufferViewCreateFlags
flags <- Ptr BufferViewCreateFlags -> IO BufferViewCreateFlags
forall a. Storable a => Ptr a -> IO a
peek @BufferViewCreateFlags (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr BufferViewCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr BufferViewCreateFlags))
Buffer
buffer <- Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Buffer))
Format
format <- Ptr Format -> IO Format
forall a. Storable a => Ptr a -> IO a
peek @Format (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo) -> Int -> Ptr Format
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Format))
DeviceSize
offset <- Ptr DeviceSize -> IO DeviceSize
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr DeviceSize))
DeviceSize
range <- Ptr DeviceSize -> IO DeviceSize
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize (("pCreateInfo" ::: Ptr BufferViewCreateInfo
p ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr DeviceSize))
BufferViewCreateInfo -> IO BufferViewCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BufferViewCreateInfo -> IO BufferViewCreateInfo)
-> BufferViewCreateInfo -> IO BufferViewCreateInfo
forall a b. (a -> b) -> a -> b
$ BufferViewCreateFlags
-> Buffer
-> Format
-> DeviceSize
-> DeviceSize
-> BufferViewCreateInfo
BufferViewCreateInfo
BufferViewCreateFlags
flags Buffer
buffer Format
format DeviceSize
offset DeviceSize
range
instance Storable BufferViewCreateInfo where
sizeOf :: BufferViewCreateInfo -> Int
sizeOf ~BufferViewCreateInfo
_ = 56
alignment :: BufferViewCreateInfo -> Int
alignment ~BufferViewCreateInfo
_ = 8
peek :: ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> IO BufferViewCreateInfo
peek = ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> IO BufferViewCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> BufferViewCreateInfo -> IO ()
poke ptr :: "pCreateInfo" ::: Ptr BufferViewCreateInfo
ptr poked :: BufferViewCreateInfo
poked = ("pCreateInfo" ::: Ptr BufferViewCreateInfo)
-> BufferViewCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pCreateInfo" ::: Ptr BufferViewCreateInfo
ptr BufferViewCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero BufferViewCreateInfo where
zero :: BufferViewCreateInfo
zero = BufferViewCreateFlags
-> Buffer
-> Format
-> DeviceSize
-> DeviceSize
-> BufferViewCreateInfo
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