{-# language CPP #-}
module Vulkan.Core11.Promoted_From_VK_KHR_bind_memory2 ( bindBufferMemory2
, bindImageMemory2
, BindBufferMemoryInfo(..)
, BindImageMemoryInfo(..)
, StructureType(..)
, ImageCreateFlagBits(..)
, ImageCreateFlags
) where
import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
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.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Extends (pokeSomeCStruct)
import Vulkan.NamedType ((:::))
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_groupAndVK_KHR_bind_memory2 (BindBufferMemoryDeviceGroupInfo)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_groupAndVK_KHR_bind_memory2 (BindImageMemoryDeviceGroupInfo)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_swapchain (BindImageMemorySwapchainInfoKHR)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_sampler_ycbcr_conversion (BindImagePlaneMemoryInfo)
import Vulkan.Core10.Handles (Buffer)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Dynamic (DeviceCmds(pVkBindBufferMemory2))
import Vulkan.Dynamic (DeviceCmds(pVkBindImageMemory2))
import Vulkan.Core10.Handles (DeviceMemory)
import Vulkan.Core10.FundamentalTypes (DeviceSize)
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.Core10.Handles (Image)
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_BIND_BUFFER_MEMORY_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Enums.ImageCreateFlagBits (ImageCreateFlagBits(..))
import Vulkan.Core10.Enums.ImageCreateFlagBits (ImageCreateFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkBindBufferMemory2
:: FunPtr (Ptr Device_T -> Word32 -> Ptr (SomeStruct BindBufferMemoryInfo) -> IO Result) -> Ptr Device_T -> Word32 -> Ptr (SomeStruct BindBufferMemoryInfo) -> IO Result
bindBufferMemory2 :: forall io
. (MonadIO io)
=>
Device
->
("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo))
-> io ()
bindBufferMemory2 :: Device
-> ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo))
-> io ()
bindBufferMemory2 device :: Device
device bindInfos :: "bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos = 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 vkBindBufferMemory2Ptr :: FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
vkBindBufferMemory2Ptr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
pVkBindBufferMemory2 (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
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
vkBindBufferMemory2Ptr FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> 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 vkBindBufferMemory2 is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkBindBufferMemory2' :: Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result
vkBindBufferMemory2' = FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
-> Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result
mkVkBindBufferMemory2 FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
vkBindBufferMemory2Ptr
Ptr (BindBufferMemoryInfo Any)
pPBindInfos <- ((Ptr (BindBufferMemoryInfo Any) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindBufferMemoryInfo Any))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BindBufferMemoryInfo Any) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindBufferMemoryInfo Any)))
-> ((Ptr (BindBufferMemoryInfo Any) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindBufferMemoryInfo Any))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr (BindBufferMemoryInfo Any) -> IO ()) -> IO ()
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(BindBufferMemoryInfo _) ((("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 40) 8
(Int -> SomeStruct BindBufferMemoryInfo -> ContT () IO ())
-> ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo))
-> ContT () IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: SomeStruct BindBufferMemoryInfo
e -> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ()) -> IO ()) -> ContT () IO ())
-> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> SomeStruct BindBufferMemoryInfo -> IO () -> IO ()
forall (a :: [*] -> *) b.
(forall (es :: [*]).
(Extendss a es, PokeChain es) =>
ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (Ptr (BindBufferMemoryInfo Any)
-> "pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindBufferMemoryInfo Any)
pPBindInfos Ptr (BindBufferMemoryInfo Any)
-> Int -> Ptr (BindBufferMemoryInfo _)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (40 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (BindBufferMemoryInfo _))) (SomeStruct BindBufferMemoryInfo
e) (IO () -> IO ())
-> ((() -> IO ()) -> IO ()) -> (() -> IO ()) -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ())) ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos)
Result
r <- IO Result -> ContT () IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT () IO Result)
-> IO Result -> ContT () IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkBindBufferMemory2" (Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result
vkBindBufferMemory2' (Device -> Ptr Device_T
deviceHandle (Device
device)) ((Int -> "bindInfoCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)) -> Int
forall a. Vector a -> Int
Data.Vector.length (("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)) -> Int)
-> ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo))
-> Int
forall a b. (a -> b) -> a -> b
$ ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos)) :: Word32)) (Ptr (BindBufferMemoryInfo Any)
-> "pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindBufferMemoryInfo Any)
pPBindInfos)))
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 ()
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))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkBindImageMemory2
:: FunPtr (Ptr Device_T -> Word32 -> Ptr (SomeStruct BindImageMemoryInfo) -> IO Result) -> Ptr Device_T -> Word32 -> Ptr (SomeStruct BindImageMemoryInfo) -> IO Result
bindImageMemory2 :: forall io
. (MonadIO io)
=>
Device
->
("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo))
-> io ()
bindImageMemory2 :: Device
-> ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo))
-> io ()
bindImageMemory2 device :: Device
device bindInfos :: "bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos = 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 vkBindImageMemory2Ptr :: FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
vkBindImageMemory2Ptr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
pVkBindImageMemory2 (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
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
vkBindImageMemory2Ptr FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> 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 vkBindImageMemory2 is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkBindImageMemory2' :: Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result
vkBindImageMemory2' = FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
-> Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result
mkVkBindImageMemory2 FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
vkBindImageMemory2Ptr
Ptr (BindImageMemoryInfo Any)
pPBindInfos <- ((Ptr (BindImageMemoryInfo Any) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindImageMemoryInfo Any))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BindImageMemoryInfo Any) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindImageMemoryInfo Any)))
-> ((Ptr (BindImageMemoryInfo Any) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindImageMemoryInfo Any))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr (BindImageMemoryInfo Any) -> IO ()) -> IO ()
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(BindImageMemoryInfo _) ((("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 40) 8
(Int -> SomeStruct BindImageMemoryInfo -> ContT () IO ())
-> ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo))
-> ContT () IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: SomeStruct BindImageMemoryInfo
e -> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ()) -> IO ()) -> ContT () IO ())
-> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> SomeStruct BindImageMemoryInfo -> IO () -> IO ()
forall (a :: [*] -> *) b.
(forall (es :: [*]).
(Extendss a es, PokeChain es) =>
ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (Ptr (BindImageMemoryInfo Any)
-> "pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindImageMemoryInfo Any)
pPBindInfos Ptr (BindImageMemoryInfo Any) -> Int -> Ptr (BindImageMemoryInfo _)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (40 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (BindImageMemoryInfo _))) (SomeStruct BindImageMemoryInfo
e) (IO () -> IO ())
-> ((() -> IO ()) -> IO ()) -> (() -> IO ()) -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ())) ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos)
Result
r <- IO Result -> ContT () IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT () IO Result)
-> IO Result -> ContT () IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkBindImageMemory2" (Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result
vkBindImageMemory2' (Device -> Ptr Device_T
deviceHandle (Device
device)) ((Int -> "bindInfoCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)) -> Int
forall a. Vector a -> Int
Data.Vector.length (("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)) -> Int)
-> ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)) -> Int
forall a b. (a -> b) -> a -> b
$ ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos)) :: Word32)) (Ptr (BindImageMemoryInfo Any)
-> "pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindImageMemoryInfo Any)
pPBindInfos)))
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 ()
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))
data BindBufferMemoryInfo (es :: [Type]) = BindBufferMemoryInfo
{
BindBufferMemoryInfo es -> Chain es
next :: Chain es
,
BindBufferMemoryInfo es -> Buffer
buffer :: Buffer
,
BindBufferMemoryInfo es -> DeviceMemory
memory :: DeviceMemory
,
BindBufferMemoryInfo es -> DeviceSize
memoryOffset :: DeviceSize
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindBufferMemoryInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (BindBufferMemoryInfo es)
instance Extensible BindBufferMemoryInfo where
extensibleTypeName :: String
extensibleTypeName = "BindBufferMemoryInfo"
setNext :: BindBufferMemoryInfo ds -> Chain es -> BindBufferMemoryInfo es
setNext x :: BindBufferMemoryInfo ds
x next :: Chain es
next = BindBufferMemoryInfo ds
x{$sel:next:BindBufferMemoryInfo :: Chain es
next = Chain es
next}
getNext :: BindBufferMemoryInfo es -> Chain es
getNext BindBufferMemoryInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends BindBufferMemoryInfo e => b) -> Maybe b
extends :: proxy e -> (Extends BindBufferMemoryInfo e => b) -> Maybe b
extends _ f :: Extends BindBufferMemoryInfo e => b
f
| Just Refl <- (Typeable e, Typeable BindBufferMemoryDeviceGroupInfo) =>
Maybe (e :~: BindBufferMemoryDeviceGroupInfo)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindBufferMemoryDeviceGroupInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindBufferMemoryInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss BindBufferMemoryInfo es, PokeChain es) => ToCStruct (BindBufferMemoryInfo es) where
withCStruct :: BindBufferMemoryInfo es
-> (Ptr (BindBufferMemoryInfo es) -> IO b) -> IO b
withCStruct x :: BindBufferMemoryInfo es
x f :: Ptr (BindBufferMemoryInfo es) -> IO b
f = Int -> Int -> (Ptr (BindBufferMemoryInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 40 8 ((Ptr (BindBufferMemoryInfo es) -> IO b) -> IO b)
-> (Ptr (BindBufferMemoryInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (BindBufferMemoryInfo es)
p -> Ptr (BindBufferMemoryInfo es)
-> BindBufferMemoryInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (BindBufferMemoryInfo es)
p BindBufferMemoryInfo es
x (Ptr (BindBufferMemoryInfo es) -> IO b
f Ptr (BindBufferMemoryInfo es)
p)
pokeCStruct :: Ptr (BindBufferMemoryInfo es)
-> BindBufferMemoryInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (BindBufferMemoryInfo es)
p BindBufferMemoryInfo{..} f :: 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 (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 (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO)
Ptr ()
pNext'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
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
withChain (Chain es
next)
IO () -> ContT b IO ()
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 (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext''
IO () -> ContT b IO ()
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 Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Buffer)) (Buffer
buffer)
IO () -> ContT b IO ()
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 DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr DeviceMemory)) (DeviceMemory
memory)
IO () -> ContT b IO ()
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 DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DeviceSize)) (DeviceSize
memoryOffset)
IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = 40
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (BindBufferMemoryInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (BindBufferMemoryInfo es)
p f :: 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 (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 (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO)
Ptr ()
pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
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 a. PokeChain es => (Ptr (Chain es) -> IO a) -> IO a
forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
IO () -> ContT b IO ()
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 (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext'
IO () -> ContT b IO ()
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 Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Buffer)) (Buffer
forall a. Zero a => a
zero)
IO () -> ContT b IO ()
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 DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr DeviceMemory)) (DeviceMemory
forall a. Zero a => a
zero)
IO () -> ContT b IO ()
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 DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
instance (Extendss BindBufferMemoryInfo es, PeekChain es) => FromCStruct (BindBufferMemoryInfo es) where
peekCStruct :: Ptr (BindBufferMemoryInfo es) -> IO (BindBufferMemoryInfo es)
peekCStruct p :: Ptr (BindBufferMemoryInfo es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ())))
Chain es
next <- Ptr (Chain es) -> IO (Chain es)
forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (Ptr () -> Ptr (Chain es)
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
Buffer
buffer <- Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Buffer))
DeviceMemory
memory <- Ptr DeviceMemory -> IO DeviceMemory
forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr DeviceMemory))
DeviceSize
memoryOffset <- Ptr DeviceSize -> IO DeviceSize
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (BindBufferMemoryInfo es)
p Ptr (BindBufferMemoryInfo es) -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DeviceSize))
BindBufferMemoryInfo es -> IO (BindBufferMemoryInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BindBufferMemoryInfo es -> IO (BindBufferMemoryInfo es))
-> BindBufferMemoryInfo es -> IO (BindBufferMemoryInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> Buffer -> DeviceMemory -> DeviceSize -> BindBufferMemoryInfo es
forall (es :: [*]).
Chain es
-> Buffer -> DeviceMemory -> DeviceSize -> BindBufferMemoryInfo es
BindBufferMemoryInfo
Chain es
next Buffer
buffer DeviceMemory
memory DeviceSize
memoryOffset
instance es ~ '[] => Zero (BindBufferMemoryInfo es) where
zero :: BindBufferMemoryInfo es
zero = Chain es
-> Buffer -> DeviceMemory -> DeviceSize -> BindBufferMemoryInfo es
forall (es :: [*]).
Chain es
-> Buffer -> DeviceMemory -> DeviceSize -> BindBufferMemoryInfo es
BindBufferMemoryInfo
()
Buffer
forall a. Zero a => a
zero
DeviceMemory
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
data BindImageMemoryInfo (es :: [Type]) = BindImageMemoryInfo
{
BindImageMemoryInfo es -> Chain es
next :: Chain es
,
BindImageMemoryInfo es -> Image
image :: Image
,
BindImageMemoryInfo es -> DeviceMemory
memory :: DeviceMemory
,
BindImageMemoryInfo es -> DeviceSize
memoryOffset :: DeviceSize
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindImageMemoryInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (BindImageMemoryInfo es)
instance Extensible BindImageMemoryInfo where
extensibleTypeName :: String
extensibleTypeName = "BindImageMemoryInfo"
setNext :: BindImageMemoryInfo ds -> Chain es -> BindImageMemoryInfo es
setNext x :: BindImageMemoryInfo ds
x next :: Chain es
next = BindImageMemoryInfo ds
x{$sel:next:BindImageMemoryInfo :: Chain es
next = Chain es
next}
getNext :: BindImageMemoryInfo es -> Chain es
getNext BindImageMemoryInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends BindImageMemoryInfo e => b) -> Maybe b
extends :: proxy e -> (Extends BindImageMemoryInfo e => b) -> Maybe b
extends _ f :: Extends BindImageMemoryInfo e => b
f
| Just Refl <- (Typeable e, Typeable BindImagePlaneMemoryInfo) =>
Maybe (e :~: BindImagePlaneMemoryInfo)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindImagePlaneMemoryInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindImageMemoryInfo e => b
f
| Just Refl <- (Typeable e, Typeable BindImageMemorySwapchainInfoKHR) =>
Maybe (e :~: BindImageMemorySwapchainInfoKHR)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindImageMemorySwapchainInfoKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindImageMemoryInfo e => b
f
| Just Refl <- (Typeable e, Typeable BindImageMemoryDeviceGroupInfo) =>
Maybe (e :~: BindImageMemoryDeviceGroupInfo)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindImageMemoryDeviceGroupInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindImageMemoryInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss BindImageMemoryInfo es, PokeChain es) => ToCStruct (BindImageMemoryInfo es) where
withCStruct :: BindImageMemoryInfo es
-> (Ptr (BindImageMemoryInfo es) -> IO b) -> IO b
withCStruct x :: BindImageMemoryInfo es
x f :: Ptr (BindImageMemoryInfo es) -> IO b
f = Int -> Int -> (Ptr (BindImageMemoryInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 40 8 ((Ptr (BindImageMemoryInfo es) -> IO b) -> IO b)
-> (Ptr (BindImageMemoryInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (BindImageMemoryInfo es)
p -> Ptr (BindImageMemoryInfo es)
-> BindImageMemoryInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (BindImageMemoryInfo es)
p BindImageMemoryInfo es
x (Ptr (BindImageMemoryInfo es) -> IO b
f Ptr (BindImageMemoryInfo es)
p)
pokeCStruct :: Ptr (BindImageMemoryInfo es)
-> BindImageMemoryInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (BindImageMemoryInfo es)
p BindImageMemoryInfo{..} f :: 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 (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 (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO)
Ptr ()
pNext'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
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
withChain (Chain es
next)
IO () -> ContT b IO ()
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 (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext''
IO () -> ContT b IO ()
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 Image -> Image -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Image)) (Image
image)
IO () -> ContT b IO ()
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 DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr DeviceMemory)) (DeviceMemory
memory)
IO () -> ContT b IO ()
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 DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DeviceSize)) (DeviceSize
memoryOffset)
IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = 40
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (BindImageMemoryInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (BindImageMemoryInfo es)
p f :: 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 (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 (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO)
Ptr ()
pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
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 a. PokeChain es => (Ptr (Chain es) -> IO a) -> IO a
forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
IO () -> ContT b IO ()
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 (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext'
IO () -> ContT b IO ()
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 Image -> Image -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Image)) (Image
forall a. Zero a => a
zero)
IO () -> ContT b IO ()
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 DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr DeviceMemory)) (DeviceMemory
forall a. Zero a => a
zero)
IO () -> ContT b IO ()
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 DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
instance (Extendss BindImageMemoryInfo es, PeekChain es) => FromCStruct (BindImageMemoryInfo es) where
peekCStruct :: Ptr (BindImageMemoryInfo es) -> IO (BindImageMemoryInfo es)
peekCStruct p :: Ptr (BindImageMemoryInfo es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ())))
Chain es
next <- Ptr (Chain es) -> IO (Chain es)
forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (Ptr () -> Ptr (Chain es)
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
Image
image <- Ptr Image -> IO Image
forall a. Storable a => Ptr a -> IO a
peek @Image ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Image))
DeviceMemory
memory <- Ptr DeviceMemory -> IO DeviceMemory
forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr DeviceMemory))
DeviceSize
memoryOffset <- Ptr DeviceSize -> IO DeviceSize
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (BindImageMemoryInfo es)
p Ptr (BindImageMemoryInfo es) -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DeviceSize))
BindImageMemoryInfo es -> IO (BindImageMemoryInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BindImageMemoryInfo es -> IO (BindImageMemoryInfo es))
-> BindImageMemoryInfo es -> IO (BindImageMemoryInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> Image -> DeviceMemory -> DeviceSize -> BindImageMemoryInfo es
forall (es :: [*]).
Chain es
-> Image -> DeviceMemory -> DeviceSize -> BindImageMemoryInfo es
BindImageMemoryInfo
Chain es
next Image
image DeviceMemory
memory DeviceSize
memoryOffset
instance es ~ '[] => Zero (BindImageMemoryInfo es) where
zero :: BindImageMemoryInfo es
zero = Chain es
-> Image -> DeviceMemory -> DeviceSize -> BindImageMemoryInfo es
forall (es :: [*]).
Chain es
-> Image -> DeviceMemory -> DeviceSize -> BindImageMemoryInfo es
BindImageMemoryInfo
()
Image
forall a. Zero a => a
zero
DeviceMemory
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero