{-# language CPP #-}
module Vulkan.Core10.SparseResourceMemoryManagement ( getImageSparseMemoryRequirements
, getPhysicalDeviceSparseImageFormatProperties
, queueBindSparse
, SparseImageFormatProperties(..)
, SparseImageMemoryRequirements(..)
, ImageSubresource(..)
, SparseMemoryBind(..)
, SparseImageMemoryBind(..)
, SparseBufferMemoryBindInfo(..)
, SparseImageOpaqueMemoryBindInfo(..)
, SparseImageMemoryBindInfo(..)
, BindSparseInfo(..)
, ImageAspectFlagBits(..)
, ImageAspectFlags
, SparseImageFormatFlagBits(..)
, SparseImageFormatFlags
, SparseMemoryBindFlagBits(..)
, SparseMemoryBindFlags
) 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 Data.Vector (generateM)
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)
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.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Extends (pokeSomeCStruct)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.Handles (Buffer)
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(pVkGetImageSparseMemoryRequirements))
import Vulkan.Dynamic (DeviceCmds(pVkQueueBindSparse))
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_group (DeviceGroupBindSparseInfo)
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.FundamentalTypes (Extent3D)
import Vulkan.Core10.Handles (Fence)
import Vulkan.Core10.Handles (Fence(..))
import Vulkan.Core10.Enums.Format (Format)
import Vulkan.Core10.Enums.Format (Format(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_frame_boundary (FrameBoundaryEXT)
import {-# SOURCE #-} Vulkan.Extensions.VK_ARM_tensors (FrameBoundaryTensorsARM)
import Vulkan.Core10.Handles (Image)
import Vulkan.Core10.Handles (Image(..))
import Vulkan.Core10.Enums.ImageAspectFlagBits (ImageAspectFlags)
import Vulkan.Core10.Enums.ImageTiling (ImageTiling)
import Vulkan.Core10.Enums.ImageTiling (ImageTiling(..))
import Vulkan.Core10.Enums.ImageType (ImageType)
import Vulkan.Core10.Enums.ImageType (ImageType(..))
import Vulkan.Core10.Enums.ImageUsageFlagBits (ImageUsageFlagBits(..))
import Vulkan.Core10.Enums.ImageUsageFlagBits (ImageUsageFlags)
import Vulkan.Dynamic (InstanceCmds(pVkGetPhysicalDeviceSparseImageFormatProperties))
import Vulkan.Core10.FundamentalTypes (Offset3D)
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.Core10.Handles (PhysicalDevice)
import Vulkan.Core10.Handles (PhysicalDevice(..))
import Vulkan.Core10.Handles (PhysicalDevice(PhysicalDevice))
import Vulkan.Core10.Handles (PhysicalDevice_T)
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Handles (Queue)
import Vulkan.Core10.Handles (Queue(..))
import Vulkan.Core10.Handles (Queue(Queue))
import Vulkan.Core10.Handles (Queue_T)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.Core10.Enums.SampleCountFlagBits (SampleCountFlagBits)
import Vulkan.Core10.Enums.SampleCountFlagBits (SampleCountFlagBits(..))
import Vulkan.Core10.Handles (Semaphore)
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.SparseImageFormatFlagBits (SparseImageFormatFlags)
import Vulkan.Core10.Enums.SparseMemoryBindFlagBits (SparseMemoryBindFlags)
import Vulkan.Core10.Enums.StructureType (StructureType)
import {-# SOURCE #-} Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore (TimelineSemaphoreSubmitInfo)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BIND_SPARSE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Enums.ImageAspectFlagBits (ImageAspectFlagBits(..))
import Vulkan.Core10.Enums.ImageAspectFlagBits (ImageAspectFlags)
import Vulkan.Core10.Enums.SparseImageFormatFlagBits (SparseImageFormatFlagBits(..))
import Vulkan.Core10.Enums.SparseImageFormatFlagBits (SparseImageFormatFlags)
import Vulkan.Core10.Enums.SparseMemoryBindFlagBits (SparseMemoryBindFlagBits(..))
import Vulkan.Core10.Enums.SparseMemoryBindFlagBits (SparseMemoryBindFlags)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetImageSparseMemoryRequirements
:: FunPtr (Ptr Device_T -> Image -> Ptr Word32 -> Ptr SparseImageMemoryRequirements -> IO ()) -> Ptr Device_T -> Image -> Ptr Word32 -> Ptr SparseImageMemoryRequirements -> IO ()
getImageSparseMemoryRequirements :: forall io
. (MonadIO io)
=>
Device
->
Image
-> io (("sparseMemoryRequirements" ::: Vector SparseImageMemoryRequirements))
getImageSparseMemoryRequirements :: forall (io :: * -> *).
MonadIO io =>
Device
-> Image
-> io
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
getImageSparseMemoryRequirements Device
device Image
image = IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> io
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> io
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> (ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> io
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> io
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> io
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall a b. (a -> b) -> a -> b
$ do
let vkGetImageSparseMemoryRequirementsPtr :: FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
vkGetImageSparseMemoryRequirementsPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
pVkGetImageSparseMemoryRequirements (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
IO ()
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
()
forall (m :: * -> *) a.
Monad m =>
m a
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
m
a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
())
-> IO ()
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
vkGetImageSparseMemoryRequirementsPtr FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
-> FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> 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 vkGetImageSparseMemoryRequirements is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkGetImageSparseMemoryRequirements' :: Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ()
vkGetImageSparseMemoryRequirements' = FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
-> Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ()
mkVkGetImageSparseMemoryRequirements FunPtr
(Ptr Device_T
-> Image
-> Ptr Word32
-> Ptr SparseImageMemoryRequirements
-> IO ())
vkGetImageSparseMemoryRequirementsPtr
let device' :: Ptr Device_T
device' = Device -> Ptr Device_T
deviceHandle (Device
device)
pPSparseMemoryRequirementCount <- ((Ptr Word32
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
(Ptr Word32)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Word32
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
(Ptr Word32))
-> ((Ptr Word32
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
(Ptr Word32)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Word32)
-> (Ptr Word32 -> IO ())
-> (Ptr Word32
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @Word32 Int
4) Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
free
lift $ traceAroundEvent "vkGetImageSparseMemoryRequirements" (vkGetImageSparseMemoryRequirements'
device'
(image)
(pPSparseMemoryRequirementCount)
(nullPtr))
pSparseMemoryRequirementCount <- lift $ peek @Word32 pPSparseMemoryRequirementCount
pPSparseMemoryRequirements <- ContT $ bracket (callocBytes @SparseImageMemoryRequirements ((fromIntegral (pSparseMemoryRequirementCount)) * 48)) free
_ <- traverse (\Int
i -> ((()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
()
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
())
-> ((()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ContT
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
IO
()
forall a b. (a -> b) -> a -> b
$ Ptr SparseImageMemoryRequirements
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall b. Ptr SparseImageMemoryRequirements -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct (Ptr SparseImageMemoryRequirements
pPSparseMemoryRequirements Ptr SparseImageMemoryRequirements
-> Int -> Ptr SparseImageMemoryRequirements
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
48) :: Ptr SparseImageMemoryRequirements) (IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ((()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> (()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements))
-> ()
-> IO
("sparseMemoryRequirements"
::: Vector SparseImageMemoryRequirements)
forall a b. (a -> b) -> a -> b
$ ())) [0..(fromIntegral (pSparseMemoryRequirementCount)) - 1]
lift $ traceAroundEvent "vkGetImageSparseMemoryRequirements" (vkGetImageSparseMemoryRequirements'
device'
(image)
(pPSparseMemoryRequirementCount)
((pPSparseMemoryRequirements)))
pSparseMemoryRequirementCount' <- lift $ peek @Word32 pPSparseMemoryRequirementCount
pSparseMemoryRequirements' <- lift $ generateM (fromIntegral (pSparseMemoryRequirementCount')) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseImageMemoryRequirements (((Ptr SparseImageMemoryRequirements
pPSparseMemoryRequirements) Ptr SparseImageMemoryRequirements
-> Int -> Ptr SparseImageMemoryRequirements
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
48 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageMemoryRequirements)))
pure $ (pSparseMemoryRequirements')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetPhysicalDeviceSparseImageFormatProperties
:: FunPtr (Ptr PhysicalDevice_T -> Format -> ImageType -> SampleCountFlagBits -> ImageUsageFlags -> ImageTiling -> Ptr Word32 -> Ptr SparseImageFormatProperties -> IO ()) -> Ptr PhysicalDevice_T -> Format -> ImageType -> SampleCountFlagBits -> ImageUsageFlags -> ImageTiling -> Ptr Word32 -> Ptr SparseImageFormatProperties -> IO ()
getPhysicalDeviceSparseImageFormatProperties :: forall io
. (MonadIO io)
=>
PhysicalDevice
->
Format
->
ImageType
->
("samples" ::: SampleCountFlagBits)
->
ImageUsageFlags
->
ImageTiling
-> io (("properties" ::: Vector SparseImageFormatProperties))
getPhysicalDeviceSparseImageFormatProperties :: forall (io :: * -> *).
MonadIO io =>
PhysicalDevice
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> io ("properties" ::: Vector SparseImageFormatProperties)
getPhysicalDeviceSparseImageFormatProperties PhysicalDevice
physicalDevice
Format
format
ImageType
type'
"samples" ::: SampleCountFlagBits
samples
ImageUsageFlags
usage
ImageTiling
tiling = IO ("properties" ::: Vector SparseImageFormatProperties)
-> io ("properties" ::: Vector SparseImageFormatProperties)
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("properties" ::: Vector SparseImageFormatProperties)
-> io ("properties" ::: Vector SparseImageFormatProperties))
-> (ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
("properties" ::: Vector SparseImageFormatProperties)
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
("properties" ::: Vector SparseImageFormatProperties)
-> io ("properties" ::: Vector SparseImageFormatProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
("properties" ::: Vector SparseImageFormatProperties)
-> IO ("properties" ::: Vector SparseImageFormatProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
("properties" ::: Vector SparseImageFormatProperties)
-> io ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
("properties" ::: Vector SparseImageFormatProperties)
-> io ("properties" ::: Vector SparseImageFormatProperties)
forall a b. (a -> b) -> a -> b
$ do
let vkGetPhysicalDeviceSparseImageFormatPropertiesPtr :: FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
vkGetPhysicalDeviceSparseImageFormatPropertiesPtr = InstanceCmds
-> FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
pVkGetPhysicalDeviceSparseImageFormatProperties (case PhysicalDevice
physicalDevice of PhysicalDevice{InstanceCmds
instanceCmds :: InstanceCmds
instanceCmds :: PhysicalDevice -> InstanceCmds
instanceCmds} -> InstanceCmds
instanceCmds)
IO ()
-> ContT
("properties" ::: Vector SparseImageFormatProperties) IO ()
forall (m :: * -> *) a.
Monad m =>
m a
-> ContT ("properties" ::: Vector SparseImageFormatProperties) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
("properties" ::: Vector SparseImageFormatProperties) IO ())
-> IO ()
-> ContT
("properties" ::: Vector SparseImageFormatProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
vkGetPhysicalDeviceSparseImageFormatPropertiesPtr FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
-> FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> 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 vkGetPhysicalDeviceSparseImageFormatProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkGetPhysicalDeviceSparseImageFormatProperties' :: Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ()
vkGetPhysicalDeviceSparseImageFormatProperties' = FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
-> Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ()
mkVkGetPhysicalDeviceSparseImageFormatProperties FunPtr
(Ptr PhysicalDevice_T
-> Format
-> ImageType
-> ("samples" ::: SampleCountFlagBits)
-> ImageUsageFlags
-> ImageTiling
-> Ptr Word32
-> Ptr SparseImageFormatProperties
-> IO ())
vkGetPhysicalDeviceSparseImageFormatPropertiesPtr
let physicalDevice' :: Ptr PhysicalDevice_T
physicalDevice' = PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice)
pPPropertyCount <- ((Ptr Word32
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
(Ptr Word32)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Word32
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
(Ptr Word32))
-> ((Ptr Word32
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties)
IO
(Ptr Word32)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Word32)
-> (Ptr Word32 -> IO ())
-> (Ptr Word32
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @Word32 Int
4) Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
free
lift $ traceAroundEvent "vkGetPhysicalDeviceSparseImageFormatProperties" (vkGetPhysicalDeviceSparseImageFormatProperties'
physicalDevice'
(format)
(type')
(samples)
(usage)
(tiling)
(pPPropertyCount)
(nullPtr))
pPropertyCount <- lift $ peek @Word32 pPPropertyCount
pPProperties <- ContT $ bracket (callocBytes @SparseImageFormatProperties ((fromIntegral (pPropertyCount)) * 20)) free
_ <- traverse (\Int
i -> ((() -> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties) IO ()
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties) IO ())
-> ((()
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ContT
("properties" ::: Vector SparseImageFormatProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SparseImageFormatProperties
-> IO ("properties" ::: Vector SparseImageFormatProperties)
-> IO ("properties" ::: Vector SparseImageFormatProperties)
forall b. Ptr SparseImageFormatProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct (Ptr SparseImageFormatProperties
pPProperties Ptr SparseImageFormatProperties
-> Int -> Ptr SparseImageFormatProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
20) :: Ptr SparseImageFormatProperties) (IO ("properties" ::: Vector SparseImageFormatProperties)
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> ((()
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties))
-> (() -> IO ("properties" ::: Vector SparseImageFormatProperties))
-> IO ("properties" ::: Vector SparseImageFormatProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ("properties" ::: Vector SparseImageFormatProperties))
-> () -> IO ("properties" ::: Vector SparseImageFormatProperties)
forall a b. (a -> b) -> a -> b
$ ())) [0..(fromIntegral (pPropertyCount)) - 1]
lift $ traceAroundEvent "vkGetPhysicalDeviceSparseImageFormatProperties" (vkGetPhysicalDeviceSparseImageFormatProperties'
physicalDevice'
(format)
(type')
(samples)
(usage)
(tiling)
(pPPropertyCount)
((pPProperties)))
pPropertyCount' <- lift $ peek @Word32 pPPropertyCount
pProperties' <- lift $ generateM (fromIntegral (pPropertyCount')) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseImageFormatProperties (((Ptr SparseImageFormatProperties
pPProperties) Ptr SparseImageFormatProperties
-> Int -> Ptr SparseImageFormatProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
20 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageFormatProperties)))
pure $ (pProperties')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkQueueBindSparse
:: FunPtr (Ptr Queue_T -> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result) -> Ptr Queue_T -> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result
queueBindSparse :: forall io
. (MonadIO io)
=>
Queue
->
("bindInfo" ::: Vector (SomeStruct BindSparseInfo))
->
Fence
-> io ()
queueBindSparse :: forall (io :: * -> *).
MonadIO io =>
Queue
-> ("bindInfo" ::: Vector (SomeStruct BindSparseInfo))
-> Fence
-> io ()
queueBindSparse Queue
queue "bindInfo" ::: Vector (SomeStruct BindSparseInfo)
bindInfo Fence
fence = 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 vkQueueBindSparsePtr :: FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
vkQueueBindSparsePtr = DeviceCmds
-> FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
pVkQueueBindSparse (case Queue
queue of Queue{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Queue -> 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 Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
vkQueueBindSparsePtr FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
-> FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> 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 vkQueueBindSparse is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkQueueBindSparse' :: Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result
vkQueueBindSparse' = FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
-> Ptr Queue_T
-> Word32
-> Ptr (SomeStruct BindSparseInfo)
-> Fence
-> IO Result
mkVkQueueBindSparse FunPtr
(Ptr Queue_T
-> Word32 -> Ptr (SomeStruct BindSparseInfo) -> Fence -> IO Result)
vkQueueBindSparsePtr
pPBindInfo <- ((Ptr (BindSparseInfo (ZonkAny 0)) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindSparseInfo (ZonkAny 0)))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BindSparseInfo (ZonkAny 0)) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindSparseInfo (ZonkAny 0))))
-> ((Ptr (BindSparseInfo (ZonkAny 0)) -> IO ()) -> IO ())
-> ContT () IO (Ptr (BindSparseInfo (ZonkAny 0)))
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(BindSparseInfo _) ((("bindInfo" ::: Vector (SomeStruct BindSparseInfo)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("bindInfo" ::: Vector (SomeStruct BindSparseInfo)
bindInfo)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
96)
Data.Vector.imapM_ (\Int
i SomeStruct BindSparseInfo
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
$ Ptr (SomeStruct BindSparseInfo)
-> SomeStruct BindSparseInfo -> 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 (BindSparseInfo (ZonkAny 1)) -> Ptr (SomeStruct BindSparseInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindSparseInfo (ZonkAny 0))
pPBindInfo Ptr (BindSparseInfo (ZonkAny 0)) -> Int -> Ptr (BindSparseInfo w)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
96 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (BindSparseInfo _))) (SomeStruct BindSparseInfo
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
$ ())) (bindInfo)
r <- lift $ traceAroundEvent "vkQueueBindSparse" (vkQueueBindSparse'
(queueHandle (queue))
((fromIntegral (Data.Vector.length $ (bindInfo)) :: Word32))
(forgetExtensions (pPBindInfo))
(fence))
lift $ when (r < SUCCESS) (throwIO (VulkanException r))
data SparseImageFormatProperties = SparseImageFormatProperties
{
SparseImageFormatProperties -> ImageAspectFlags
aspectMask :: ImageAspectFlags
,
SparseImageFormatProperties -> Extent3D
imageGranularity :: Extent3D
,
SparseImageFormatProperties -> SparseImageFormatFlags
flags :: SparseImageFormatFlags
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseImageFormatProperties)
#endif
deriving instance Show SparseImageFormatProperties
instance ToCStruct SparseImageFormatProperties where
withCStruct :: forall b.
SparseImageFormatProperties
-> (Ptr SparseImageFormatProperties -> IO b) -> IO b
withCStruct SparseImageFormatProperties
x Ptr SparseImageFormatProperties -> IO b
f = Int -> (Ptr SparseImageFormatProperties -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
20 ((Ptr SparseImageFormatProperties -> IO b) -> IO b)
-> (Ptr SparseImageFormatProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseImageFormatProperties
p -> Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO b -> IO b
forall b.
Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageFormatProperties
p SparseImageFormatProperties
x (Ptr SparseImageFormatProperties -> IO b
f Ptr SparseImageFormatProperties
p)
pokeCStruct :: forall b.
Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO b -> IO b
pokeCStruct Ptr SparseImageFormatProperties
p SparseImageFormatProperties{Extent3D
SparseImageFormatFlags
ImageAspectFlags
aspectMask :: SparseImageFormatProperties -> ImageAspectFlags
imageGranularity :: SparseImageFormatProperties -> Extent3D
flags :: SparseImageFormatProperties -> SparseImageFormatFlags
aspectMask :: ImageAspectFlags
imageGranularity :: Extent3D
flags :: SparseImageFormatFlags
..} IO b
f = do
Ptr ImageAspectFlags -> ImageAspectFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageFormatProperties
p Ptr SparseImageFormatProperties -> Int -> Ptr ImageAspectFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageAspectFlags)) (ImageAspectFlags
aspectMask)
Ptr Extent3D -> Extent3D -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageFormatProperties
p Ptr SparseImageFormatProperties -> Int -> Ptr Extent3D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Extent3D)) (Extent3D
imageGranularity)
Ptr SparseImageFormatFlags -> SparseImageFormatFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageFormatProperties
p Ptr SparseImageFormatProperties
-> Int -> Ptr SparseImageFormatFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr SparseImageFormatFlags)) (SparseImageFormatFlags
flags)
IO b
f
cStructSize :: Int
cStructSize = Int
20
cStructAlignment :: Int
cStructAlignment = Int
4
pokeZeroCStruct :: forall b. Ptr SparseImageFormatProperties -> IO b -> IO b
pokeZeroCStruct Ptr SparseImageFormatProperties
p IO b
f = do
Ptr Extent3D -> Extent3D -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageFormatProperties
p Ptr SparseImageFormatProperties -> Int -> Ptr Extent3D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Extent3D)) (Extent3D
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseImageFormatProperties where
peekCStruct :: Ptr SparseImageFormatProperties -> IO SparseImageFormatProperties
peekCStruct Ptr SparseImageFormatProperties
p = do
aspectMask <- forall a. Storable a => Ptr a -> IO a
peek @ImageAspectFlags ((Ptr SparseImageFormatProperties
p Ptr SparseImageFormatProperties -> Int -> Ptr ImageAspectFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageAspectFlags))
imageGranularity <- peekCStruct @Extent3D ((p `plusPtr` 4 :: Ptr Extent3D))
flags <- peek @SparseImageFormatFlags ((p `plusPtr` 16 :: Ptr SparseImageFormatFlags))
pure $ SparseImageFormatProperties
aspectMask imageGranularity flags
instance Storable SparseImageFormatProperties where
sizeOf :: SparseImageFormatProperties -> Int
sizeOf ~SparseImageFormatProperties
_ = Int
20
alignment :: SparseImageFormatProperties -> Int
alignment ~SparseImageFormatProperties
_ = Int
4
peek :: Ptr SparseImageFormatProperties -> IO SparseImageFormatProperties
peek = Ptr SparseImageFormatProperties -> IO SparseImageFormatProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO ()
poke Ptr SparseImageFormatProperties
ptr SparseImageFormatProperties
poked = Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO () -> IO ()
forall b.
Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageFormatProperties
ptr SparseImageFormatProperties
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SparseImageFormatProperties where
zero :: SparseImageFormatProperties
zero = ImageAspectFlags
-> Extent3D
-> SparseImageFormatFlags
-> SparseImageFormatProperties
SparseImageFormatProperties
ImageAspectFlags
forall a. Zero a => a
zero
Extent3D
forall a. Zero a => a
zero
SparseImageFormatFlags
forall a. Zero a => a
zero
data SparseImageMemoryRequirements = SparseImageMemoryRequirements
{
SparseImageMemoryRequirements -> SparseImageFormatProperties
formatProperties :: SparseImageFormatProperties
,
SparseImageMemoryRequirements -> Word32
imageMipTailFirstLod :: Word32
,
SparseImageMemoryRequirements -> DeviceSize
imageMipTailSize :: DeviceSize
,
SparseImageMemoryRequirements -> DeviceSize
imageMipTailOffset :: DeviceSize
,
SparseImageMemoryRequirements -> DeviceSize
imageMipTailStride :: DeviceSize
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseImageMemoryRequirements)
#endif
deriving instance Show SparseImageMemoryRequirements
instance ToCStruct SparseImageMemoryRequirements where
withCStruct :: forall b.
SparseImageMemoryRequirements
-> (Ptr SparseImageMemoryRequirements -> IO b) -> IO b
withCStruct SparseImageMemoryRequirements
x Ptr SparseImageMemoryRequirements -> IO b
f = Int -> (Ptr SparseImageMemoryRequirements -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
48 ((Ptr SparseImageMemoryRequirements -> IO b) -> IO b)
-> (Ptr SparseImageMemoryRequirements -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseImageMemoryRequirements
p -> Ptr SparseImageMemoryRequirements
-> SparseImageMemoryRequirements -> IO b -> IO b
forall b.
Ptr SparseImageMemoryRequirements
-> SparseImageMemoryRequirements -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryRequirements
p SparseImageMemoryRequirements
x (Ptr SparseImageMemoryRequirements -> IO b
f Ptr SparseImageMemoryRequirements
p)
pokeCStruct :: forall b.
Ptr SparseImageMemoryRequirements
-> SparseImageMemoryRequirements -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryRequirements
p SparseImageMemoryRequirements{Word32
DeviceSize
SparseImageFormatProperties
formatProperties :: SparseImageMemoryRequirements -> SparseImageFormatProperties
imageMipTailFirstLod :: SparseImageMemoryRequirements -> Word32
imageMipTailSize :: SparseImageMemoryRequirements -> DeviceSize
imageMipTailOffset :: SparseImageMemoryRequirements -> DeviceSize
imageMipTailStride :: SparseImageMemoryRequirements -> DeviceSize
formatProperties :: SparseImageFormatProperties
imageMipTailFirstLod :: Word32
imageMipTailSize :: DeviceSize
imageMipTailOffset :: DeviceSize
imageMipTailStride :: DeviceSize
..} IO b
f = do
Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements
-> Int -> Ptr SparseImageFormatProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr SparseImageFormatProperties)) (SparseImageFormatProperties
formatProperties)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32)) (Word32
imageMipTailFirstLod)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (DeviceSize
imageMipTailSize)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (DeviceSize
imageMipTailOffset)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) (DeviceSize
imageMipTailStride)
IO b
f
cStructSize :: Int
cStructSize = Int
48
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SparseImageMemoryRequirements -> IO b -> IO b
pokeZeroCStruct Ptr SparseImageMemoryRequirements
p IO b
f = do
Ptr SparseImageFormatProperties
-> SparseImageFormatProperties -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements
-> Int -> Ptr SparseImageFormatProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr SparseImageFormatProperties)) (SparseImageFormatProperties
forall a. Zero a => a
zero)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseImageMemoryRequirements where
peekCStruct :: Ptr SparseImageMemoryRequirements
-> IO SparseImageMemoryRequirements
peekCStruct Ptr SparseImageMemoryRequirements
p = do
formatProperties <- forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseImageFormatProperties ((Ptr SparseImageMemoryRequirements
p Ptr SparseImageMemoryRequirements
-> Int -> Ptr SparseImageFormatProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr SparseImageFormatProperties))
imageMipTailFirstLod <- peek @Word32 ((p `plusPtr` 20 :: Ptr Word32))
imageMipTailSize <- peek @DeviceSize ((p `plusPtr` 24 :: Ptr DeviceSize))
imageMipTailOffset <- peek @DeviceSize ((p `plusPtr` 32 :: Ptr DeviceSize))
imageMipTailStride <- peek @DeviceSize ((p `plusPtr` 40 :: Ptr DeviceSize))
pure $ SparseImageMemoryRequirements
formatProperties
imageMipTailFirstLod
imageMipTailSize
imageMipTailOffset
imageMipTailStride
instance Storable SparseImageMemoryRequirements where
sizeOf :: SparseImageMemoryRequirements -> Int
sizeOf ~SparseImageMemoryRequirements
_ = Int
48
alignment :: SparseImageMemoryRequirements -> Int
alignment ~SparseImageMemoryRequirements
_ = Int
8
peek :: Ptr SparseImageMemoryRequirements
-> IO SparseImageMemoryRequirements
peek = Ptr SparseImageMemoryRequirements
-> IO SparseImageMemoryRequirements
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr SparseImageMemoryRequirements
-> SparseImageMemoryRequirements -> IO ()
poke Ptr SparseImageMemoryRequirements
ptr SparseImageMemoryRequirements
poked = Ptr SparseImageMemoryRequirements
-> SparseImageMemoryRequirements -> IO () -> IO ()
forall b.
Ptr SparseImageMemoryRequirements
-> SparseImageMemoryRequirements -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryRequirements
ptr SparseImageMemoryRequirements
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SparseImageMemoryRequirements where
zero :: SparseImageMemoryRequirements
zero = SparseImageFormatProperties
-> Word32
-> DeviceSize
-> DeviceSize
-> DeviceSize
-> SparseImageMemoryRequirements
SparseImageMemoryRequirements
SparseImageFormatProperties
forall a. Zero a => a
zero
Word32
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
data ImageSubresource = ImageSubresource
{
ImageSubresource -> ImageAspectFlags
aspectMask :: ImageAspectFlags
,
ImageSubresource -> Word32
mipLevel :: Word32
,
ImageSubresource -> Word32
arrayLayer :: Word32
}
deriving (Typeable, ImageSubresource -> ImageSubresource -> Bool
(ImageSubresource -> ImageSubresource -> Bool)
-> (ImageSubresource -> ImageSubresource -> Bool)
-> Eq ImageSubresource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ImageSubresource -> ImageSubresource -> Bool
== :: ImageSubresource -> ImageSubresource -> Bool
$c/= :: ImageSubresource -> ImageSubresource -> Bool
/= :: ImageSubresource -> ImageSubresource -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ImageSubresource)
#endif
deriving instance Show ImageSubresource
instance ToCStruct ImageSubresource where
withCStruct :: forall b.
ImageSubresource -> (Ptr ImageSubresource -> IO b) -> IO b
withCStruct ImageSubresource
x Ptr ImageSubresource -> IO b
f = Int -> (Ptr ImageSubresource -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
12 ((Ptr ImageSubresource -> IO b) -> IO b)
-> (Ptr ImageSubresource -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr ImageSubresource
p -> Ptr ImageSubresource -> ImageSubresource -> IO b -> IO b
forall b. Ptr ImageSubresource -> ImageSubresource -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ImageSubresource
p ImageSubresource
x (Ptr ImageSubresource -> IO b
f Ptr ImageSubresource
p)
pokeCStruct :: forall b. Ptr ImageSubresource -> ImageSubresource -> IO b -> IO b
pokeCStruct Ptr ImageSubresource
p ImageSubresource{Word32
ImageAspectFlags
aspectMask :: ImageSubresource -> ImageAspectFlags
mipLevel :: ImageSubresource -> Word32
arrayLayer :: ImageSubresource -> Word32
aspectMask :: ImageAspectFlags
mipLevel :: Word32
arrayLayer :: Word32
..} IO b
f = do
Ptr ImageAspectFlags -> ImageAspectFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr ImageAspectFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageAspectFlags)) (ImageAspectFlags
aspectMask)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Word32)) (Word32
mipLevel)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Word32)) (Word32
arrayLayer)
IO b
f
cStructSize :: Int
cStructSize = Int
12
cStructAlignment :: Int
cStructAlignment = Int
4
pokeZeroCStruct :: forall b. Ptr ImageSubresource -> IO b -> IO b
pokeZeroCStruct Ptr ImageSubresource
p IO b
f = do
Ptr ImageAspectFlags -> ImageAspectFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr ImageAspectFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageAspectFlags)) (ImageAspectFlags
forall a. Zero a => a
zero)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ImageSubresource where
peekCStruct :: Ptr ImageSubresource -> IO ImageSubresource
peekCStruct Ptr ImageSubresource
p = do
aspectMask <- forall a. Storable a => Ptr a -> IO a
peek @ImageAspectFlags ((Ptr ImageSubresource
p Ptr ImageSubresource -> Int -> Ptr ImageAspectFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageAspectFlags))
mipLevel <- peek @Word32 ((p `plusPtr` 4 :: Ptr Word32))
arrayLayer <- peek @Word32 ((p `plusPtr` 8 :: Ptr Word32))
pure $ ImageSubresource
aspectMask mipLevel arrayLayer
instance Storable ImageSubresource where
sizeOf :: ImageSubresource -> Int
sizeOf ~ImageSubresource
_ = Int
12
alignment :: ImageSubresource -> Int
alignment ~ImageSubresource
_ = Int
4
peek :: Ptr ImageSubresource -> IO ImageSubresource
peek = Ptr ImageSubresource -> IO ImageSubresource
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ImageSubresource -> ImageSubresource -> IO ()
poke Ptr ImageSubresource
ptr ImageSubresource
poked = Ptr ImageSubresource -> ImageSubresource -> IO () -> IO ()
forall b. Ptr ImageSubresource -> ImageSubresource -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ImageSubresource
ptr ImageSubresource
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ImageSubresource where
zero :: ImageSubresource
zero = ImageAspectFlags -> Word32 -> Word32 -> ImageSubresource
ImageSubresource
ImageAspectFlags
forall a. Zero a => a
zero
Word32
forall a. Zero a => a
zero
Word32
forall a. Zero a => a
zero
data SparseMemoryBind = SparseMemoryBind
{
SparseMemoryBind -> DeviceSize
resourceOffset :: DeviceSize
,
SparseMemoryBind -> DeviceSize
size :: DeviceSize
,
SparseMemoryBind -> DeviceMemory
memory :: DeviceMemory
,
SparseMemoryBind -> DeviceSize
memoryOffset :: DeviceSize
,
SparseMemoryBind -> SparseMemoryBindFlags
flags :: SparseMemoryBindFlags
}
deriving (Typeable, SparseMemoryBind -> SparseMemoryBind -> Bool
(SparseMemoryBind -> SparseMemoryBind -> Bool)
-> (SparseMemoryBind -> SparseMemoryBind -> Bool)
-> Eq SparseMemoryBind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SparseMemoryBind -> SparseMemoryBind -> Bool
== :: SparseMemoryBind -> SparseMemoryBind -> Bool
$c/= :: SparseMemoryBind -> SparseMemoryBind -> Bool
/= :: SparseMemoryBind -> SparseMemoryBind -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseMemoryBind)
#endif
deriving instance Show SparseMemoryBind
instance ToCStruct SparseMemoryBind where
withCStruct :: forall b.
SparseMemoryBind -> (Ptr SparseMemoryBind -> IO b) -> IO b
withCStruct SparseMemoryBind
x Ptr SparseMemoryBind -> IO b
f = Int -> (Ptr SparseMemoryBind -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 ((Ptr SparseMemoryBind -> IO b) -> IO b)
-> (Ptr SparseMemoryBind -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseMemoryBind
p -> Ptr SparseMemoryBind -> SparseMemoryBind -> IO b -> IO b
forall b. Ptr SparseMemoryBind -> SparseMemoryBind -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseMemoryBind
p SparseMemoryBind
x (Ptr SparseMemoryBind -> IO b
f Ptr SparseMemoryBind
p)
pokeCStruct :: forall b. Ptr SparseMemoryBind -> SparseMemoryBind -> IO b -> IO b
pokeCStruct Ptr SparseMemoryBind
p SparseMemoryBind{DeviceSize
SparseMemoryBindFlags
DeviceMemory
resourceOffset :: SparseMemoryBind -> DeviceSize
size :: SparseMemoryBind -> DeviceSize
memory :: SparseMemoryBind -> DeviceMemory
memoryOffset :: SparseMemoryBind -> DeviceSize
flags :: SparseMemoryBind -> SparseMemoryBindFlags
resourceOffset :: DeviceSize
size :: DeviceSize
memory :: DeviceMemory
memoryOffset :: DeviceSize
flags :: SparseMemoryBindFlags
..} IO b
f = do
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) (DeviceSize
resourceOffset)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) (DeviceSize
size)
Ptr DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceMemory)) (DeviceMemory
memory)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (DeviceSize
memoryOffset)
Ptr SparseMemoryBindFlags -> SparseMemoryBindFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr SparseMemoryBindFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr SparseMemoryBindFlags)) (SparseMemoryBindFlags
flags)
IO b
f
cStructSize :: Int
cStructSize = Int
40
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SparseMemoryBind -> IO b -> IO b
pokeZeroCStruct Ptr SparseMemoryBind
p IO b
f = do
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseMemoryBind where
peekCStruct :: Ptr SparseMemoryBind -> IO SparseMemoryBind
peekCStruct Ptr SparseMemoryBind
p = do
resourceOffset <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr SparseMemoryBind
p Ptr SparseMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize))
size <- peek @DeviceSize ((p `plusPtr` 8 :: Ptr DeviceSize))
memory <- peek @DeviceMemory ((p `plusPtr` 16 :: Ptr DeviceMemory))
memoryOffset <- peek @DeviceSize ((p `plusPtr` 24 :: Ptr DeviceSize))
flags <- peek @SparseMemoryBindFlags ((p `plusPtr` 32 :: Ptr SparseMemoryBindFlags))
pure $ SparseMemoryBind
resourceOffset size memory memoryOffset flags
instance Storable SparseMemoryBind where
sizeOf :: SparseMemoryBind -> Int
sizeOf ~SparseMemoryBind
_ = Int
40
alignment :: SparseMemoryBind -> Int
alignment ~SparseMemoryBind
_ = Int
8
peek :: Ptr SparseMemoryBind -> IO SparseMemoryBind
peek = Ptr SparseMemoryBind -> IO SparseMemoryBind
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr SparseMemoryBind -> SparseMemoryBind -> IO ()
poke Ptr SparseMemoryBind
ptr SparseMemoryBind
poked = Ptr SparseMemoryBind -> SparseMemoryBind -> IO () -> IO ()
forall b. Ptr SparseMemoryBind -> SparseMemoryBind -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseMemoryBind
ptr SparseMemoryBind
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SparseMemoryBind where
zero :: SparseMemoryBind
zero = DeviceSize
-> DeviceSize
-> DeviceMemory
-> DeviceSize
-> SparseMemoryBindFlags
-> SparseMemoryBind
SparseMemoryBind
DeviceSize
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
DeviceMemory
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
SparseMemoryBindFlags
forall a. Zero a => a
zero
data SparseImageMemoryBind = SparseImageMemoryBind
{
SparseImageMemoryBind -> ImageSubresource
subresource :: ImageSubresource
,
SparseImageMemoryBind -> Offset3D
offset :: Offset3D
,
SparseImageMemoryBind -> Extent3D
extent :: Extent3D
,
SparseImageMemoryBind -> DeviceMemory
memory :: DeviceMemory
,
SparseImageMemoryBind -> DeviceSize
memoryOffset :: DeviceSize
,
SparseImageMemoryBind -> SparseMemoryBindFlags
flags :: SparseMemoryBindFlags
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseImageMemoryBind)
#endif
deriving instance Show SparseImageMemoryBind
instance ToCStruct SparseImageMemoryBind where
withCStruct :: forall b.
SparseImageMemoryBind
-> (Ptr SparseImageMemoryBind -> IO b) -> IO b
withCStruct SparseImageMemoryBind
x Ptr SparseImageMemoryBind -> IO b
f = Int -> (Ptr SparseImageMemoryBind -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
64 ((Ptr SparseImageMemoryBind -> IO b) -> IO b)
-> (Ptr SparseImageMemoryBind -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseImageMemoryBind
p -> Ptr SparseImageMemoryBind -> SparseImageMemoryBind -> IO b -> IO b
forall b.
Ptr SparseImageMemoryBind -> SparseImageMemoryBind -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryBind
p SparseImageMemoryBind
x (Ptr SparseImageMemoryBind -> IO b
f Ptr SparseImageMemoryBind
p)
pokeCStruct :: forall b.
Ptr SparseImageMemoryBind -> SparseImageMemoryBind -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryBind
p SparseImageMemoryBind{DeviceSize
Offset3D
Extent3D
SparseMemoryBindFlags
DeviceMemory
ImageSubresource
subresource :: SparseImageMemoryBind -> ImageSubresource
offset :: SparseImageMemoryBind -> Offset3D
extent :: SparseImageMemoryBind -> Extent3D
memory :: SparseImageMemoryBind -> DeviceMemory
memoryOffset :: SparseImageMemoryBind -> DeviceSize
flags :: SparseImageMemoryBind -> SparseMemoryBindFlags
subresource :: ImageSubresource
offset :: Offset3D
extent :: Extent3D
memory :: DeviceMemory
memoryOffset :: DeviceSize
flags :: SparseMemoryBindFlags
..} IO b
f = do
Ptr ImageSubresource -> ImageSubresource -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr ImageSubresource
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageSubresource)) (ImageSubresource
subresource)
Ptr Offset3D -> Offset3D -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr Offset3D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12 :: Ptr Offset3D)) (Offset3D
offset)
Ptr Extent3D -> Extent3D -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr Extent3D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Extent3D)) (Extent3D
extent)
Ptr DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceMemory)) (DeviceMemory
memory)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize)) (DeviceSize
memoryOffset)
Ptr SparseMemoryBindFlags -> SparseMemoryBindFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr SparseMemoryBindFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr SparseMemoryBindFlags)) (SparseMemoryBindFlags
flags)
IO b
f
cStructSize :: Int
cStructSize = Int
64
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SparseImageMemoryBind -> IO b -> IO b
pokeZeroCStruct Ptr SparseImageMemoryBind
p IO b
f = do
Ptr ImageSubresource -> ImageSubresource -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr ImageSubresource
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageSubresource)) (ImageSubresource
forall a. Zero a => a
zero)
Ptr Offset3D -> Offset3D -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr Offset3D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12 :: Ptr Offset3D)) (Offset3D
forall a. Zero a => a
zero)
Ptr Extent3D -> Extent3D -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr Extent3D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Extent3D)) (Extent3D
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseImageMemoryBind where
peekCStruct :: Ptr SparseImageMemoryBind -> IO SparseImageMemoryBind
peekCStruct Ptr SparseImageMemoryBind
p = do
subresource <- forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @ImageSubresource ((Ptr SparseImageMemoryBind
p Ptr SparseImageMemoryBind -> Int -> Ptr ImageSubresource
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr ImageSubresource))
offset <- peekCStruct @Offset3D ((p `plusPtr` 12 :: Ptr Offset3D))
extent <- peekCStruct @Extent3D ((p `plusPtr` 24 :: Ptr Extent3D))
memory <- peek @DeviceMemory ((p `plusPtr` 40 :: Ptr DeviceMemory))
memoryOffset <- peek @DeviceSize ((p `plusPtr` 48 :: Ptr DeviceSize))
flags <- peek @SparseMemoryBindFlags ((p `plusPtr` 56 :: Ptr SparseMemoryBindFlags))
pure $ SparseImageMemoryBind
subresource offset extent memory memoryOffset flags
instance Storable SparseImageMemoryBind where
sizeOf :: SparseImageMemoryBind -> Int
sizeOf ~SparseImageMemoryBind
_ = Int
64
alignment :: SparseImageMemoryBind -> Int
alignment ~SparseImageMemoryBind
_ = Int
8
peek :: Ptr SparseImageMemoryBind -> IO SparseImageMemoryBind
peek = Ptr SparseImageMemoryBind -> IO SparseImageMemoryBind
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr SparseImageMemoryBind -> SparseImageMemoryBind -> IO ()
poke Ptr SparseImageMemoryBind
ptr SparseImageMemoryBind
poked = Ptr SparseImageMemoryBind
-> SparseImageMemoryBind -> IO () -> IO ()
forall b.
Ptr SparseImageMemoryBind -> SparseImageMemoryBind -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryBind
ptr SparseImageMemoryBind
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SparseImageMemoryBind where
zero :: SparseImageMemoryBind
zero = ImageSubresource
-> Offset3D
-> Extent3D
-> DeviceMemory
-> DeviceSize
-> SparseMemoryBindFlags
-> SparseImageMemoryBind
SparseImageMemoryBind
ImageSubresource
forall a. Zero a => a
zero
Offset3D
forall a. Zero a => a
zero
Extent3D
forall a. Zero a => a
zero
DeviceMemory
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
SparseMemoryBindFlags
forall a. Zero a => a
zero
data SparseBufferMemoryBindInfo = SparseBufferMemoryBindInfo
{
SparseBufferMemoryBindInfo -> Buffer
buffer :: Buffer
,
SparseBufferMemoryBindInfo -> Vector SparseMemoryBind
binds :: Vector SparseMemoryBind
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseBufferMemoryBindInfo)
#endif
deriving instance Show SparseBufferMemoryBindInfo
instance ToCStruct SparseBufferMemoryBindInfo where
withCStruct :: forall b.
SparseBufferMemoryBindInfo
-> (Ptr SparseBufferMemoryBindInfo -> IO b) -> IO b
withCStruct SparseBufferMemoryBindInfo
x Ptr SparseBufferMemoryBindInfo -> IO b
f = Int -> (Ptr SparseBufferMemoryBindInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr SparseBufferMemoryBindInfo -> IO b) -> IO b)
-> (Ptr SparseBufferMemoryBindInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseBufferMemoryBindInfo
p -> Ptr SparseBufferMemoryBindInfo
-> SparseBufferMemoryBindInfo -> IO b -> IO b
forall b.
Ptr SparseBufferMemoryBindInfo
-> SparseBufferMemoryBindInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseBufferMemoryBindInfo
p SparseBufferMemoryBindInfo
x (Ptr SparseBufferMemoryBindInfo -> IO b
f Ptr SparseBufferMemoryBindInfo
p)
pokeCStruct :: forall b.
Ptr SparseBufferMemoryBindInfo
-> SparseBufferMemoryBindInfo -> IO b -> IO b
pokeCStruct Ptr SparseBufferMemoryBindInfo
p SparseBufferMemoryBindInfo{Vector SparseMemoryBind
Buffer
buffer :: SparseBufferMemoryBindInfo -> Buffer
binds :: SparseBufferMemoryBindInfo -> Vector SparseMemoryBind
buffer :: Buffer
binds :: Vector SparseMemoryBind
..} 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 Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseBufferMemoryBindInfo
p Ptr SparseBufferMemoryBindInfo -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Buffer)) (Buffer
buffer)
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseBufferMemoryBindInfo
p Ptr SparseBufferMemoryBindInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector SparseMemoryBind -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SparseMemoryBind -> Int) -> Vector SparseMemoryBind -> Int
forall a b. (a -> b) -> a -> b
$ (Vector SparseMemoryBind
binds)) :: Word32))
pPBinds' <- ((Ptr SparseMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseMemoryBind)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr SparseMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseMemoryBind))
-> ((Ptr SparseMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseMemoryBind)
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @SparseMemoryBind ((Vector SparseMemoryBind -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SparseMemoryBind
binds)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
40)
lift $ Data.Vector.imapM_ (\Int
i SparseMemoryBind
e -> Ptr SparseMemoryBind -> SparseMemoryBind -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SparseMemoryBind
pPBinds' Ptr SparseMemoryBind -> Int -> Ptr SparseMemoryBind
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
40 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseMemoryBind) (SparseMemoryBind
e)) (binds)
lift $ poke ((p `plusPtr` 16 :: Ptr (Ptr SparseMemoryBind))) (pPBinds')
lift $ f
cStructSize :: Int
cStructSize = Int
24
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SparseBufferMemoryBindInfo -> IO b -> IO b
pokeZeroCStruct Ptr SparseBufferMemoryBindInfo
p IO b
f = do
Ptr Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseBufferMemoryBindInfo
p Ptr SparseBufferMemoryBindInfo -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Buffer)) (Buffer
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseBufferMemoryBindInfo where
peekCStruct :: Ptr SparseBufferMemoryBindInfo -> IO SparseBufferMemoryBindInfo
peekCStruct Ptr SparseBufferMemoryBindInfo
p = do
buffer <- forall a. Storable a => Ptr a -> IO a
peek @Buffer ((Ptr SparseBufferMemoryBindInfo
p Ptr SparseBufferMemoryBindInfo -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Buffer))
bindCount <- peek @Word32 ((p `plusPtr` 8 :: Ptr Word32))
pBinds <- peek @(Ptr SparseMemoryBind) ((p `plusPtr` 16 :: Ptr (Ptr SparseMemoryBind)))
pBinds' <- generateM (fromIntegral bindCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseMemoryBind ((Ptr SparseMemoryBind
pBinds Ptr SparseMemoryBind -> Int -> Ptr SparseMemoryBind
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
40 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseMemoryBind)))
pure $ SparseBufferMemoryBindInfo
buffer pBinds'
instance Zero SparseBufferMemoryBindInfo where
zero :: SparseBufferMemoryBindInfo
zero = Buffer -> Vector SparseMemoryBind -> SparseBufferMemoryBindInfo
SparseBufferMemoryBindInfo
Buffer
forall a. Zero a => a
zero
Vector SparseMemoryBind
forall a. Monoid a => a
mempty
data SparseImageOpaqueMemoryBindInfo = SparseImageOpaqueMemoryBindInfo
{
SparseImageOpaqueMemoryBindInfo -> Image
image :: Image
,
SparseImageOpaqueMemoryBindInfo -> Vector SparseMemoryBind
binds :: Vector SparseMemoryBind
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseImageOpaqueMemoryBindInfo)
#endif
deriving instance Show SparseImageOpaqueMemoryBindInfo
instance ToCStruct SparseImageOpaqueMemoryBindInfo where
withCStruct :: forall b.
SparseImageOpaqueMemoryBindInfo
-> (Ptr SparseImageOpaqueMemoryBindInfo -> IO b) -> IO b
withCStruct SparseImageOpaqueMemoryBindInfo
x Ptr SparseImageOpaqueMemoryBindInfo -> IO b
f = Int -> (Ptr SparseImageOpaqueMemoryBindInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr SparseImageOpaqueMemoryBindInfo -> IO b) -> IO b)
-> (Ptr SparseImageOpaqueMemoryBindInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseImageOpaqueMemoryBindInfo
p -> Ptr SparseImageOpaqueMemoryBindInfo
-> SparseImageOpaqueMemoryBindInfo -> IO b -> IO b
forall b.
Ptr SparseImageOpaqueMemoryBindInfo
-> SparseImageOpaqueMemoryBindInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageOpaqueMemoryBindInfo
p SparseImageOpaqueMemoryBindInfo
x (Ptr SparseImageOpaqueMemoryBindInfo -> IO b
f Ptr SparseImageOpaqueMemoryBindInfo
p)
pokeCStruct :: forall b.
Ptr SparseImageOpaqueMemoryBindInfo
-> SparseImageOpaqueMemoryBindInfo -> IO b -> IO b
pokeCStruct Ptr SparseImageOpaqueMemoryBindInfo
p SparseImageOpaqueMemoryBindInfo{Vector SparseMemoryBind
Image
image :: SparseImageOpaqueMemoryBindInfo -> Image
binds :: SparseImageOpaqueMemoryBindInfo -> Vector SparseMemoryBind
image :: Image
binds :: Vector SparseMemoryBind
..} 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 Image -> Image -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageOpaqueMemoryBindInfo
p Ptr SparseImageOpaqueMemoryBindInfo -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Image)) (Image
image)
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageOpaqueMemoryBindInfo
p Ptr SparseImageOpaqueMemoryBindInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector SparseMemoryBind -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SparseMemoryBind -> Int) -> Vector SparseMemoryBind -> Int
forall a b. (a -> b) -> a -> b
$ (Vector SparseMemoryBind
binds)) :: Word32))
pPBinds' <- ((Ptr SparseMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseMemoryBind)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr SparseMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseMemoryBind))
-> ((Ptr SparseMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseMemoryBind)
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @SparseMemoryBind ((Vector SparseMemoryBind -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SparseMemoryBind
binds)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
40)
lift $ Data.Vector.imapM_ (\Int
i SparseMemoryBind
e -> Ptr SparseMemoryBind -> SparseMemoryBind -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SparseMemoryBind
pPBinds' Ptr SparseMemoryBind -> Int -> Ptr SparseMemoryBind
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
40 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseMemoryBind) (SparseMemoryBind
e)) (binds)
lift $ poke ((p `plusPtr` 16 :: Ptr (Ptr SparseMemoryBind))) (pPBinds')
lift $ f
cStructSize :: Int
cStructSize = Int
24
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SparseImageOpaqueMemoryBindInfo -> IO b -> IO b
pokeZeroCStruct Ptr SparseImageOpaqueMemoryBindInfo
p IO b
f = do
Ptr Image -> Image -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageOpaqueMemoryBindInfo
p Ptr SparseImageOpaqueMemoryBindInfo -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Image)) (Image
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseImageOpaqueMemoryBindInfo where
peekCStruct :: Ptr SparseImageOpaqueMemoryBindInfo
-> IO SparseImageOpaqueMemoryBindInfo
peekCStruct Ptr SparseImageOpaqueMemoryBindInfo
p = do
image <- forall a. Storable a => Ptr a -> IO a
peek @Image ((Ptr SparseImageOpaqueMemoryBindInfo
p Ptr SparseImageOpaqueMemoryBindInfo -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Image))
bindCount <- peek @Word32 ((p `plusPtr` 8 :: Ptr Word32))
pBinds <- peek @(Ptr SparseMemoryBind) ((p `plusPtr` 16 :: Ptr (Ptr SparseMemoryBind)))
pBinds' <- generateM (fromIntegral bindCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseMemoryBind ((Ptr SparseMemoryBind
pBinds Ptr SparseMemoryBind -> Int -> Ptr SparseMemoryBind
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
40 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseMemoryBind)))
pure $ SparseImageOpaqueMemoryBindInfo
image pBinds'
instance Zero SparseImageOpaqueMemoryBindInfo where
zero :: SparseImageOpaqueMemoryBindInfo
zero = Image -> Vector SparseMemoryBind -> SparseImageOpaqueMemoryBindInfo
SparseImageOpaqueMemoryBindInfo
Image
forall a. Zero a => a
zero
Vector SparseMemoryBind
forall a. Monoid a => a
mempty
data SparseImageMemoryBindInfo = SparseImageMemoryBindInfo
{
SparseImageMemoryBindInfo -> Image
image :: Image
,
SparseImageMemoryBindInfo -> Vector SparseImageMemoryBind
binds :: Vector SparseImageMemoryBind
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SparseImageMemoryBindInfo)
#endif
deriving instance Show SparseImageMemoryBindInfo
instance ToCStruct SparseImageMemoryBindInfo where
withCStruct :: forall b.
SparseImageMemoryBindInfo
-> (Ptr SparseImageMemoryBindInfo -> IO b) -> IO b
withCStruct SparseImageMemoryBindInfo
x Ptr SparseImageMemoryBindInfo -> IO b
f = Int -> (Ptr SparseImageMemoryBindInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr SparseImageMemoryBindInfo -> IO b) -> IO b)
-> (Ptr SparseImageMemoryBindInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SparseImageMemoryBindInfo
p -> Ptr SparseImageMemoryBindInfo
-> SparseImageMemoryBindInfo -> IO b -> IO b
forall b.
Ptr SparseImageMemoryBindInfo
-> SparseImageMemoryBindInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryBindInfo
p SparseImageMemoryBindInfo
x (Ptr SparseImageMemoryBindInfo -> IO b
f Ptr SparseImageMemoryBindInfo
p)
pokeCStruct :: forall b.
Ptr SparseImageMemoryBindInfo
-> SparseImageMemoryBindInfo -> IO b -> IO b
pokeCStruct Ptr SparseImageMemoryBindInfo
p SparseImageMemoryBindInfo{Vector SparseImageMemoryBind
Image
image :: SparseImageMemoryBindInfo -> Image
binds :: SparseImageMemoryBindInfo -> Vector SparseImageMemoryBind
image :: Image
binds :: Vector SparseImageMemoryBind
..} 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 Image -> Image -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBindInfo
p Ptr SparseImageMemoryBindInfo -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Image)) (Image
image)
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBindInfo
p Ptr SparseImageMemoryBindInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector SparseImageMemoryBind -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SparseImageMemoryBind -> Int)
-> Vector SparseImageMemoryBind -> Int
forall a b. (a -> b) -> a -> b
$ (Vector SparseImageMemoryBind
binds)) :: Word32))
pPBinds' <- ((Ptr SparseImageMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseImageMemoryBind)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr SparseImageMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseImageMemoryBind))
-> ((Ptr SparseImageMemoryBind -> IO b) -> IO b)
-> ContT b IO (Ptr SparseImageMemoryBind)
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @SparseImageMemoryBind ((Vector SparseImageMemoryBind -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SparseImageMemoryBind
binds)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
64)
lift $ Data.Vector.imapM_ (\Int
i SparseImageMemoryBind
e -> Ptr SparseImageMemoryBind -> SparseImageMemoryBind -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SparseImageMemoryBind
pPBinds' Ptr SparseImageMemoryBind -> Int -> Ptr SparseImageMemoryBind
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageMemoryBind) (SparseImageMemoryBind
e)) (binds)
lift $ poke ((p `plusPtr` 16 :: Ptr (Ptr SparseImageMemoryBind))) (pPBinds')
lift $ f
cStructSize :: Int
cStructSize = Int
24
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SparseImageMemoryBindInfo -> IO b -> IO b
pokeZeroCStruct Ptr SparseImageMemoryBindInfo
p IO b
f = do
Ptr Image -> Image -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SparseImageMemoryBindInfo
p Ptr SparseImageMemoryBindInfo -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Image)) (Image
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SparseImageMemoryBindInfo where
peekCStruct :: Ptr SparseImageMemoryBindInfo -> IO SparseImageMemoryBindInfo
peekCStruct Ptr SparseImageMemoryBindInfo
p = do
image <- forall a. Storable a => Ptr a -> IO a
peek @Image ((Ptr SparseImageMemoryBindInfo
p Ptr SparseImageMemoryBindInfo -> Int -> Ptr Image
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Image))
bindCount <- peek @Word32 ((p `plusPtr` 8 :: Ptr Word32))
pBinds <- peek @(Ptr SparseImageMemoryBind) ((p `plusPtr` 16 :: Ptr (Ptr SparseImageMemoryBind)))
pBinds' <- generateM (fromIntegral bindCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseImageMemoryBind ((Ptr SparseImageMemoryBind
pBinds Ptr SparseImageMemoryBind -> Int -> Ptr SparseImageMemoryBind
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageMemoryBind)))
pure $ SparseImageMemoryBindInfo
image pBinds'
instance Zero SparseImageMemoryBindInfo where
zero :: SparseImageMemoryBindInfo
zero = Image -> Vector SparseImageMemoryBind -> SparseImageMemoryBindInfo
SparseImageMemoryBindInfo
Image
forall a. Zero a => a
zero
Vector SparseImageMemoryBind
forall a. Monoid a => a
mempty
data BindSparseInfo (es :: [Type]) = BindSparseInfo
{
forall (es :: [*]). BindSparseInfo es -> Chain es
next :: Chain es
,
forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
waitSemaphores :: Vector Semaphore
,
forall (es :: [*]).
BindSparseInfo es -> Vector SparseBufferMemoryBindInfo
bufferBinds :: Vector SparseBufferMemoryBindInfo
,
forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageOpaqueMemoryBindInfo
imageOpaqueBinds :: Vector SparseImageOpaqueMemoryBindInfo
,
forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageMemoryBindInfo
imageBinds :: Vector SparseImageMemoryBindInfo
,
forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
signalSemaphores :: Vector Semaphore
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindSparseInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (BindSparseInfo es)
instance Extensible BindSparseInfo where
extensibleTypeName :: String
extensibleTypeName = String
"BindSparseInfo"
setNext :: forall (ds :: [*]) (es :: [*]).
BindSparseInfo ds -> Chain es -> BindSparseInfo es
setNext BindSparseInfo{Vector Semaphore
Vector SparseImageOpaqueMemoryBindInfo
Vector SparseImageMemoryBindInfo
Vector SparseBufferMemoryBindInfo
Chain ds
next :: forall (es :: [*]). BindSparseInfo es -> Chain es
waitSemaphores :: forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
bufferBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageMemoryBindInfo
signalSemaphores :: forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
next :: Chain ds
waitSemaphores :: Vector Semaphore
bufferBinds :: Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: Vector SparseImageMemoryBindInfo
signalSemaphores :: Vector Semaphore
..} Chain es
next' = BindSparseInfo{next :: Chain es
next = Chain es
next', Vector Semaphore
Vector SparseImageOpaqueMemoryBindInfo
Vector SparseImageMemoryBindInfo
Vector SparseBufferMemoryBindInfo
waitSemaphores :: Vector Semaphore
bufferBinds :: Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: Vector SparseImageMemoryBindInfo
signalSemaphores :: Vector Semaphore
waitSemaphores :: Vector Semaphore
bufferBinds :: Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: Vector SparseImageMemoryBindInfo
signalSemaphores :: Vector Semaphore
..}
getNext :: forall (es :: [*]). BindSparseInfo es -> Chain es
getNext BindSparseInfo{Vector Semaphore
Vector SparseImageOpaqueMemoryBindInfo
Vector SparseImageMemoryBindInfo
Vector SparseBufferMemoryBindInfo
Chain es
next :: forall (es :: [*]). BindSparseInfo es -> Chain es
waitSemaphores :: forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
bufferBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageMemoryBindInfo
signalSemaphores :: forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
next :: Chain es
waitSemaphores :: Vector Semaphore
bufferBinds :: Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: Vector SparseImageMemoryBindInfo
signalSemaphores :: Vector Semaphore
..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends BindSparseInfo e => b) -> Maybe b
extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends BindSparseInfo e => b) -> Maybe b
extends proxy e
_ Extends BindSparseInfo e => b
f
| Just e :~: FrameBoundaryTensorsARM
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 @FrameBoundaryTensorsARM = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindSparseInfo e => b
f
| Just e :~: FrameBoundaryEXT
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 @FrameBoundaryEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindSparseInfo e => b
f
| Just e :~: TimelineSemaphoreSubmitInfo
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 @TimelineSemaphoreSubmitInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindSparseInfo e => b
f
| Just e :~: DeviceGroupBindSparseInfo
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 @DeviceGroupBindSparseInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends BindSparseInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance ( Extendss BindSparseInfo es
, PokeChain es ) => ToCStruct (BindSparseInfo es) where
withCStruct :: forall b.
BindSparseInfo es -> (Ptr (BindSparseInfo es) -> IO b) -> IO b
withCStruct BindSparseInfo es
x Ptr (BindSparseInfo es) -> IO b
f = Int -> (Ptr (BindSparseInfo es) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
96 ((Ptr (BindSparseInfo es) -> IO b) -> IO b)
-> (Ptr (BindSparseInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr (BindSparseInfo es)
p -> Ptr (BindSparseInfo es) -> BindSparseInfo es -> IO b -> IO b
forall b.
Ptr (BindSparseInfo es) -> BindSparseInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (BindSparseInfo es)
p BindSparseInfo es
x (Ptr (BindSparseInfo es) -> IO b
f Ptr (BindSparseInfo es)
p)
pokeCStruct :: forall b.
Ptr (BindSparseInfo es) -> BindSparseInfo es -> IO b -> IO b
pokeCStruct Ptr (BindSparseInfo es)
p BindSparseInfo{Vector Semaphore
Vector SparseImageOpaqueMemoryBindInfo
Vector SparseImageMemoryBindInfo
Vector SparseBufferMemoryBindInfo
Chain es
next :: forall (es :: [*]). BindSparseInfo es -> Chain es
waitSemaphores :: forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
bufferBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: forall (es :: [*]).
BindSparseInfo es -> Vector SparseImageMemoryBindInfo
signalSemaphores :: forall (es :: [*]). BindSparseInfo es -> Vector Semaphore
next :: Chain es
waitSemaphores :: Vector Semaphore
bufferBinds :: Vector SparseBufferMemoryBindInfo
imageOpaqueBinds :: Vector SparseImageOpaqueMemoryBindInfo
imageBinds :: Vector SparseImageMemoryBindInfo
signalSemaphores :: Vector Semaphore
..} 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 (BindSparseInfo es)
p Ptr (BindSparseInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_SPARSE_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 Word32)) ((fromIntegral (Data.Vector.length $ (waitSemaphores)) :: Word32))
pPWaitSemaphores' <- ContT $ allocaBytes @Semaphore ((Data.Vector.length (waitSemaphores)) * 8)
lift $ Data.Vector.imapM_ (\Int
i Semaphore
e -> Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPWaitSemaphores' Ptr Semaphore -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (waitSemaphores)
lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr Semaphore))) (pPWaitSemaphores')
lift $ poke ((p `plusPtr` 32 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (bufferBinds)) :: Word32))
pPBufferBinds' <- ContT $ allocaBytes @SparseBufferMemoryBindInfo ((Data.Vector.length (bufferBinds)) * 24)
Data.Vector.imapM_ (\Int
i SparseBufferMemoryBindInfo
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SparseBufferMemoryBindInfo
-> SparseBufferMemoryBindInfo -> IO b -> IO b
forall b.
Ptr SparseBufferMemoryBindInfo
-> SparseBufferMemoryBindInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr SparseBufferMemoryBindInfo
pPBufferBinds' Ptr SparseBufferMemoryBindInfo
-> Int -> Ptr SparseBufferMemoryBindInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseBufferMemoryBindInfo) (SparseBufferMemoryBindInfo
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (bufferBinds)
lift $ poke ((p `plusPtr` 40 :: Ptr (Ptr SparseBufferMemoryBindInfo))) (pPBufferBinds')
lift $ poke ((p `plusPtr` 48 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (imageOpaqueBinds)) :: Word32))
pPImageOpaqueBinds' <- ContT $ allocaBytes @SparseImageOpaqueMemoryBindInfo ((Data.Vector.length (imageOpaqueBinds)) * 24)
Data.Vector.imapM_ (\Int
i SparseImageOpaqueMemoryBindInfo
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SparseImageOpaqueMemoryBindInfo
-> SparseImageOpaqueMemoryBindInfo -> IO b -> IO b
forall b.
Ptr SparseImageOpaqueMemoryBindInfo
-> SparseImageOpaqueMemoryBindInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr SparseImageOpaqueMemoryBindInfo
pPImageOpaqueBinds' Ptr SparseImageOpaqueMemoryBindInfo
-> Int -> Ptr SparseImageOpaqueMemoryBindInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageOpaqueMemoryBindInfo) (SparseImageOpaqueMemoryBindInfo
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (imageOpaqueBinds)
lift $ poke ((p `plusPtr` 56 :: Ptr (Ptr SparseImageOpaqueMemoryBindInfo))) (pPImageOpaqueBinds')
lift $ poke ((p `plusPtr` 64 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (imageBinds)) :: Word32))
pPImageBinds' <- ContT $ allocaBytes @SparseImageMemoryBindInfo ((Data.Vector.length (imageBinds)) * 24)
Data.Vector.imapM_ (\Int
i SparseImageMemoryBindInfo
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SparseImageMemoryBindInfo
-> SparseImageMemoryBindInfo -> IO b -> IO b
forall b.
Ptr SparseImageMemoryBindInfo
-> SparseImageMemoryBindInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr SparseImageMemoryBindInfo
pPImageBinds' Ptr SparseImageMemoryBindInfo
-> Int -> Ptr SparseImageMemoryBindInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageMemoryBindInfo) (SparseImageMemoryBindInfo
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (imageBinds)
lift $ poke ((p `plusPtr` 72 :: Ptr (Ptr SparseImageMemoryBindInfo))) (pPImageBinds')
lift $ poke ((p `plusPtr` 80 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (signalSemaphores)) :: Word32))
pPSignalSemaphores' <- ContT $ allocaBytes @Semaphore ((Data.Vector.length (signalSemaphores)) * 8)
lift $ Data.Vector.imapM_ (\Int
i Semaphore
e -> Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPSignalSemaphores' Ptr Semaphore -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (signalSemaphores)
lift $ poke ((p `plusPtr` 88 :: Ptr (Ptr Semaphore))) (pPSignalSemaphores')
lift $ f
cStructSize :: Int
cStructSize = Int
96
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr (BindSparseInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (BindSparseInfo 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 (BindSparseInfo es)
p Ptr (BindSparseInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_SPARSE_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 $ f
instance ( Extendss BindSparseInfo es
, PeekChain es ) => FromCStruct (BindSparseInfo es) where
peekCStruct :: Ptr (BindSparseInfo es) -> IO (BindSparseInfo es)
peekCStruct Ptr (BindSparseInfo es)
p = do
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BindSparseInfo es)
p Ptr (BindSparseInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
next <- peekChain (castPtr pNext)
waitSemaphoreCount <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
pWaitSemaphores <- peek @(Ptr Semaphore) ((p `plusPtr` 24 :: Ptr (Ptr Semaphore)))
pWaitSemaphores' <- generateM (fromIntegral waitSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pWaitSemaphores Ptr Semaphore -> Int -> Ptr Semaphore
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
bufferBindCount <- peek @Word32 ((p `plusPtr` 32 :: Ptr Word32))
pBufferBinds <- peek @(Ptr SparseBufferMemoryBindInfo) ((p `plusPtr` 40 :: Ptr (Ptr SparseBufferMemoryBindInfo)))
pBufferBinds' <- generateM (fromIntegral bufferBindCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseBufferMemoryBindInfo ((Ptr SparseBufferMemoryBindInfo
pBufferBinds Ptr SparseBufferMemoryBindInfo
-> Int -> Ptr SparseBufferMemoryBindInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseBufferMemoryBindInfo)))
imageOpaqueBindCount <- peek @Word32 ((p `plusPtr` 48 :: Ptr Word32))
pImageOpaqueBinds <- peek @(Ptr SparseImageOpaqueMemoryBindInfo) ((p `plusPtr` 56 :: Ptr (Ptr SparseImageOpaqueMemoryBindInfo)))
pImageOpaqueBinds' <- generateM (fromIntegral imageOpaqueBindCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseImageOpaqueMemoryBindInfo ((Ptr SparseImageOpaqueMemoryBindInfo
pImageOpaqueBinds Ptr SparseImageOpaqueMemoryBindInfo
-> Int -> Ptr SparseImageOpaqueMemoryBindInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageOpaqueMemoryBindInfo)))
imageBindCount <- peek @Word32 ((p `plusPtr` 64 :: Ptr Word32))
pImageBinds <- peek @(Ptr SparseImageMemoryBindInfo) ((p `plusPtr` 72 :: Ptr (Ptr SparseImageMemoryBindInfo)))
pImageBinds' <- generateM (fromIntegral imageBindCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @SparseImageMemoryBindInfo ((Ptr SparseImageMemoryBindInfo
pImageBinds Ptr SparseImageMemoryBindInfo
-> Int -> Ptr SparseImageMemoryBindInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SparseImageMemoryBindInfo)))
signalSemaphoreCount <- peek @Word32 ((p `plusPtr` 80 :: Ptr Word32))
pSignalSemaphores <- peek @(Ptr Semaphore) ((p `plusPtr` 88 :: Ptr (Ptr Semaphore)))
pSignalSemaphores' <- generateM (fromIntegral signalSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pSignalSemaphores Ptr Semaphore -> Int -> Ptr Semaphore
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
pure $ BindSparseInfo
next
pWaitSemaphores'
pBufferBinds'
pImageOpaqueBinds'
pImageBinds'
pSignalSemaphores'
instance es ~ '[] => Zero (BindSparseInfo es) where
zero :: BindSparseInfo es
zero = Chain es
-> Vector Semaphore
-> Vector SparseBufferMemoryBindInfo
-> Vector SparseImageOpaqueMemoryBindInfo
-> Vector SparseImageMemoryBindInfo
-> Vector Semaphore
-> BindSparseInfo es
forall (es :: [*]).
Chain es
-> Vector Semaphore
-> Vector SparseBufferMemoryBindInfo
-> Vector SparseImageOpaqueMemoryBindInfo
-> Vector SparseImageMemoryBindInfo
-> Vector Semaphore
-> BindSparseInfo es
BindSparseInfo
()
Vector Semaphore
forall a. Monoid a => a
mempty
Vector SparseBufferMemoryBindInfo
forall a. Monoid a => a
mempty
Vector SparseImageOpaqueMemoryBindInfo
forall a. Monoid a => a
mempty
Vector SparseImageMemoryBindInfo
forall a. Monoid a => a
mempty
Vector Semaphore
forall a. Monoid a => a
mempty