{-# language CPP #-}
module Vulkan.Core10.Memory ( allocateMemory
, withMemory
, freeMemory
, mapMemory
, withMappedMemory
, unmapMemory
, flushMappedMemoryRanges
, invalidateMappedMemoryRanges
, getDeviceMemoryCommitment
, MemoryAllocateInfo(..)
, MappedMemoryRange(..)
, MemoryMapFlags(..)
) 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 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.Extends (forgetExtensions)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.CStruct.Extends (Chain)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_dedicated_allocation (DedicatedAllocationMemoryAllocateInfoNV)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkAllocateMemory))
import Vulkan.Dynamic (DeviceCmds(pVkFlushMappedMemoryRanges))
import Vulkan.Dynamic (DeviceCmds(pVkFreeMemory))
import Vulkan.Dynamic (DeviceCmds(pVkGetDeviceMemoryCommitment))
import Vulkan.Dynamic (DeviceCmds(pVkInvalidateMappedMemoryRanges))
import Vulkan.Dynamic (DeviceCmds(pVkMapMemory))
import Vulkan.Dynamic (DeviceCmds(pVkUnmapMemory))
import Vulkan.Core10.Handles (DeviceMemory)
import Vulkan.Core10.Handles (DeviceMemory(..))
import Vulkan.Core10.FundamentalTypes (DeviceSize)
import Vulkan.Core10.Handles (Device_T)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_external_memory (ExportMemoryAllocateInfo)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_external_memory (ExportMemoryAllocateInfoNV)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_external_memory_win32 (ExportMemoryWin32HandleInfoKHR)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_external_memory_win32 (ExportMemoryWin32HandleInfoNV)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_metal_objects (ExportMetalObjectCreateInfoEXT)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer (ImportAndroidHardwareBufferInfoANDROID)
import {-# SOURCE #-} Vulkan.Extensions.VK_FUCHSIA_buffer_collection (ImportMemoryBufferCollectionFUCHSIA)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_external_memory_fd (ImportMemoryFdInfoKHR)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_external_memory_host (ImportMemoryHostPointerInfoEXT)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_external_memory_win32 (ImportMemoryWin32HandleInfoKHR)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_external_memory_win32 (ImportMemoryWin32HandleInfoNV)
import {-# SOURCE #-} Vulkan.Extensions.VK_FUCHSIA_external_memory (ImportMemoryZirconHandleInfoFUCHSIA)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_metal_objects (ImportMetalBufferInfoEXT)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_group (MemoryAllocateFlagsInfo)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation (MemoryDedicatedAllocateInfo)
import Vulkan.Core10.Enums.MemoryMapFlags (MemoryMapFlags)
import Vulkan.Core10.Enums.MemoryMapFlags (MemoryMapFlags(..))
import {-# SOURCE #-} Vulkan.Core12.Promoted_From_VK_KHR_buffer_device_address (MemoryOpaqueCaptureAddressAllocateInfo)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_memory_priority (MemoryPriorityAllocateInfoEXT)
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_MAPPED_MEMORY_RANGE))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Enums.MemoryMapFlags (MemoryMapFlags(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkAllocateMemory
:: FunPtr (Ptr Device_T -> Ptr (SomeStruct MemoryAllocateInfo) -> Ptr AllocationCallbacks -> Ptr DeviceMemory -> IO Result) -> Ptr Device_T -> Ptr (SomeStruct MemoryAllocateInfo) -> Ptr AllocationCallbacks -> Ptr DeviceMemory -> IO Result
allocateMemory :: forall a io
. (Extendss MemoryAllocateInfo a, PokeChain a, MonadIO io)
=>
Device
->
(MemoryAllocateInfo a)
->
("allocator" ::: Maybe AllocationCallbacks)
-> io (DeviceMemory)
allocateMemory :: forall (a :: [*]) (io :: * -> *).
(Extendss MemoryAllocateInfo a, PokeChain a, MonadIO io) =>
Device
-> MemoryAllocateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DeviceMemory
allocateMemory Device
device MemoryAllocateInfo a
allocateInfo "allocator" ::: Maybe AllocationCallbacks
allocator = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkAllocateMemoryPtr :: FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result)
vkAllocateMemoryPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result)
pVkAllocateMemory (case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result)
vkAllocateMemoryPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkAllocateMemory is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkAllocateMemory' :: Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result
vkAllocateMemory' = FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result)
-> Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result
mkVkAllocateMemory FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result)
vkAllocateMemoryPtr
Ptr (MemoryAllocateInfo a)
pAllocateInfo <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (MemoryAllocateInfo a
allocateInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
"allocator" ::: Maybe AllocationCallbacks
Nothing -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
Just AllocationCallbacks
j -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pMemory" ::: Ptr DeviceMemory
pPMemory <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @DeviceMemory Int
8) forall a. Ptr a -> IO ()
free
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkAllocateMemory" (Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pMemory" ::: Ptr DeviceMemory)
-> IO Result
vkAllocateMemory'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (MemoryAllocateInfo a)
pAllocateInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator
("pMemory" ::: Ptr DeviceMemory
pPMemory))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
DeviceMemory
pMemory <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory "pMemory" ::: Ptr DeviceMemory
pPMemory
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (DeviceMemory
pMemory)
withMemory :: forall a io r . (Extendss MemoryAllocateInfo a, PokeChain a, MonadIO io) => Device -> MemoryAllocateInfo a -> Maybe AllocationCallbacks -> (io DeviceMemory -> (DeviceMemory -> io ()) -> r) -> r
withMemory :: forall (a :: [*]) (io :: * -> *) r.
(Extendss MemoryAllocateInfo a, PokeChain a, MonadIO io) =>
Device
-> MemoryAllocateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io DeviceMemory -> (DeviceMemory -> io ()) -> r)
-> r
withMemory Device
device MemoryAllocateInfo a
pAllocateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator io DeviceMemory -> (DeviceMemory -> io ()) -> r
b =
io DeviceMemory -> (DeviceMemory -> io ()) -> r
b (forall (a :: [*]) (io :: * -> *).
(Extendss MemoryAllocateInfo a, PokeChain a, MonadIO io) =>
Device
-> MemoryAllocateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DeviceMemory
allocateMemory Device
device MemoryAllocateInfo a
pAllocateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
(\(DeviceMemory
o0) -> forall (io :: * -> *).
MonadIO io =>
Device
-> DeviceMemory
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
freeMemory Device
device DeviceMemory
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkFreeMemory
:: FunPtr (Ptr Device_T -> DeviceMemory -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> DeviceMemory -> Ptr AllocationCallbacks -> IO ()
freeMemory :: forall io
. (MonadIO io)
=>
Device
->
DeviceMemory
->
("allocator" ::: Maybe AllocationCallbacks)
-> io ()
freeMemory :: forall (io :: * -> *).
MonadIO io =>
Device
-> DeviceMemory
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
freeMemory Device
device DeviceMemory
memory "allocator" ::: Maybe AllocationCallbacks
allocator = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkFreeMemoryPtr :: FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkFreeMemoryPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
pVkFreeMemory (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkFreeMemoryPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkFreeMemory is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkFreeMemory' :: Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkFreeMemory' = FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
mkVkFreeMemory FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkFreeMemoryPtr
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
"allocator" ::: Maybe AllocationCallbacks
Nothing -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
Just AllocationCallbacks
j -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkFreeMemory" (Ptr Device_T
-> DeviceMemory
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkFreeMemory'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(DeviceMemory
memory)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator)
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ()
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkMapMemory
:: FunPtr (Ptr Device_T -> DeviceMemory -> DeviceSize -> DeviceSize -> MemoryMapFlags -> Ptr (Ptr ()) -> IO Result) -> Ptr Device_T -> DeviceMemory -> DeviceSize -> DeviceSize -> MemoryMapFlags -> Ptr (Ptr ()) -> IO Result
mapMemory :: forall io
. (MonadIO io)
=>
Device
->
DeviceMemory
->
("offset" ::: DeviceSize)
->
DeviceSize
->
MemoryMapFlags
-> io (("data" ::: Ptr ()))
mapMemory :: forall (io :: * -> *).
MonadIO io =>
Device
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> io ("data" ::: Ptr ())
mapMemory Device
device DeviceMemory
memory "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size MemoryMapFlags
flags = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkMapMemoryPtr :: FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result)
vkMapMemoryPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result)
pVkMapMemory (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result)
vkMapMemoryPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkMapMemory is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkMapMemory' :: Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result
vkMapMemory' = FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result)
-> Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result
mkVkMapMemory FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result)
vkMapMemoryPtr
"ppData" ::: Ptr ("data" ::: Ptr ())
pPpData <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @(Ptr ()) Int
8) forall a. Ptr a -> IO ()
free
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkMapMemory" (Ptr Device_T
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> ("ppData" ::: Ptr ("data" ::: Ptr ()))
-> IO Result
vkMapMemory'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(DeviceMemory
memory)
("offset" ::: DeviceSize
offset)
("offset" ::: DeviceSize
size)
(MemoryMapFlags
flags)
("ppData" ::: Ptr ("data" ::: Ptr ())
pPpData))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
"data" ::: Ptr ()
ppData <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) "ppData" ::: Ptr ("data" ::: Ptr ())
pPpData
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ("data" ::: Ptr ()
ppData)
withMappedMemory :: forall io r . MonadIO io => Device -> DeviceMemory -> DeviceSize -> DeviceSize -> MemoryMapFlags -> (io (Ptr ()) -> (Ptr () -> io ()) -> r) -> r
withMappedMemory :: forall (io :: * -> *) r.
MonadIO io =>
Device
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> (io ("data" ::: Ptr ()) -> (("data" ::: Ptr ()) -> io ()) -> r)
-> r
withMappedMemory Device
device DeviceMemory
memory "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size MemoryMapFlags
flags io ("data" ::: Ptr ()) -> (("data" ::: Ptr ()) -> io ()) -> r
b =
io ("data" ::: Ptr ()) -> (("data" ::: Ptr ()) -> io ()) -> r
b (forall (io :: * -> *).
MonadIO io =>
Device
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MemoryMapFlags
-> io ("data" ::: Ptr ())
mapMemory Device
device DeviceMemory
memory "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size MemoryMapFlags
flags)
(\("data" ::: Ptr ()
_) -> forall (io :: * -> *).
MonadIO io =>
Device -> DeviceMemory -> io ()
unmapMemory Device
device DeviceMemory
memory)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkUnmapMemory
:: FunPtr (Ptr Device_T -> DeviceMemory -> IO ()) -> Ptr Device_T -> DeviceMemory -> IO ()
unmapMemory :: forall io
. (MonadIO io)
=>
Device
->
DeviceMemory
-> io ()
unmapMemory :: forall (io :: * -> *).
MonadIO io =>
Device -> DeviceMemory -> io ()
unmapMemory Device
device DeviceMemory
memory = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
let vkUnmapMemoryPtr :: FunPtr (Ptr Device_T -> DeviceMemory -> IO ())
vkUnmapMemoryPtr = DeviceCmds -> FunPtr (Ptr Device_T -> DeviceMemory -> IO ())
pVkUnmapMemory (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Device_T -> DeviceMemory -> IO ())
vkUnmapMemoryPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkUnmapMemory is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkUnmapMemory' :: Ptr Device_T -> DeviceMemory -> IO ()
vkUnmapMemory' = FunPtr (Ptr Device_T -> DeviceMemory -> IO ())
-> Ptr Device_T -> DeviceMemory -> IO ()
mkVkUnmapMemory FunPtr (Ptr Device_T -> DeviceMemory -> IO ())
vkUnmapMemoryPtr
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkUnmapMemory" (Ptr Device_T -> DeviceMemory -> IO ()
vkUnmapMemory'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(DeviceMemory
memory))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ()
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkFlushMappedMemoryRanges
:: FunPtr (Ptr Device_T -> Word32 -> Ptr MappedMemoryRange -> IO Result) -> Ptr Device_T -> Word32 -> Ptr MappedMemoryRange -> IO Result
flushMappedMemoryRanges :: forall io
. (MonadIO io)
=>
Device
->
("memoryRanges" ::: Vector MappedMemoryRange)
-> io ()
flushMappedMemoryRanges :: forall (io :: * -> *).
MonadIO io =>
Device -> ("memoryRanges" ::: Vector MappedMemoryRange) -> io ()
flushMappedMemoryRanges Device
device "memoryRanges" ::: Vector MappedMemoryRange
memoryRanges = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkFlushMappedMemoryRangesPtr :: FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
vkFlushMappedMemoryRangesPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
pVkFlushMappedMemoryRanges (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
vkFlushMappedMemoryRangesPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkFlushMappedMemoryRanges is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkFlushMappedMemoryRanges' :: Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result
vkFlushMappedMemoryRanges' = FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
-> Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result
mkVkFlushMappedMemoryRanges FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
vkFlushMappedMemoryRangesPtr
"pMemoryRanges" ::: Ptr MappedMemoryRange
pPMemoryRanges <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @MappedMemoryRange ((forall a. Vector a -> Int
Data.Vector.length ("memoryRanges" ::: Vector MappedMemoryRange
memoryRanges)) forall a. Num a => a -> a -> a
* Int
40)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i MappedMemoryRange
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke ("pMemoryRanges" ::: Ptr MappedMemoryRange
pPMemoryRanges forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
40 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr MappedMemoryRange) (MappedMemoryRange
e)) ("memoryRanges" ::: Vector MappedMemoryRange
memoryRanges)
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkFlushMappedMemoryRanges" (Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result
vkFlushMappedMemoryRanges'
(Device -> Ptr Device_T
deviceHandle (Device
device))
((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ ("memoryRanges" ::: Vector MappedMemoryRange
memoryRanges)) :: Word32))
("pMemoryRanges" ::: Ptr MappedMemoryRange
pPMemoryRanges))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkInvalidateMappedMemoryRanges
:: FunPtr (Ptr Device_T -> Word32 -> Ptr MappedMemoryRange -> IO Result) -> Ptr Device_T -> Word32 -> Ptr MappedMemoryRange -> IO Result
invalidateMappedMemoryRanges :: forall io
. (MonadIO io)
=>
Device
->
("memoryRanges" ::: Vector MappedMemoryRange)
-> io ()
invalidateMappedMemoryRanges :: forall (io :: * -> *).
MonadIO io =>
Device -> ("memoryRanges" ::: Vector MappedMemoryRange) -> io ()
invalidateMappedMemoryRanges Device
device "memoryRanges" ::: Vector MappedMemoryRange
memoryRanges = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkInvalidateMappedMemoryRangesPtr :: FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
vkInvalidateMappedMemoryRangesPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
pVkInvalidateMappedMemoryRanges (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
vkInvalidateMappedMemoryRangesPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkInvalidateMappedMemoryRanges is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkInvalidateMappedMemoryRanges' :: Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result
vkInvalidateMappedMemoryRanges' = FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
-> Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result
mkVkInvalidateMappedMemoryRanges FunPtr
(Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result)
vkInvalidateMappedMemoryRangesPtr
"pMemoryRanges" ::: Ptr MappedMemoryRange
pPMemoryRanges <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @MappedMemoryRange ((forall a. Vector a -> Int
Data.Vector.length ("memoryRanges" ::: Vector MappedMemoryRange
memoryRanges)) forall a. Num a => a -> a -> a
* Int
40)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i MappedMemoryRange
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke ("pMemoryRanges" ::: Ptr MappedMemoryRange
pPMemoryRanges forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
40 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr MappedMemoryRange) (MappedMemoryRange
e)) ("memoryRanges" ::: Vector MappedMemoryRange
memoryRanges)
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkInvalidateMappedMemoryRanges" (Ptr Device_T
-> ("memoryRangeCount" ::: Word32)
-> ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> IO Result
vkInvalidateMappedMemoryRanges'
(Device -> Ptr Device_T
deviceHandle (Device
device))
((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ ("memoryRanges" ::: Vector MappedMemoryRange
memoryRanges)) :: Word32))
("pMemoryRanges" ::: Ptr MappedMemoryRange
pPMemoryRanges))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetDeviceMemoryCommitment
:: FunPtr (Ptr Device_T -> DeviceMemory -> Ptr DeviceSize -> IO ()) -> Ptr Device_T -> DeviceMemory -> Ptr DeviceSize -> IO ()
getDeviceMemoryCommitment :: forall io
. (MonadIO io)
=>
Device
->
DeviceMemory
-> io (("committedMemoryInBytes" ::: DeviceSize))
getDeviceMemoryCommitment :: forall (io :: * -> *).
MonadIO io =>
Device -> DeviceMemory -> io ("offset" ::: DeviceSize)
getDeviceMemoryCommitment Device
device DeviceMemory
memory = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkGetDeviceMemoryCommitmentPtr :: FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ())
vkGetDeviceMemoryCommitmentPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ())
pVkGetDeviceMemoryCommitment (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ())
vkGetDeviceMemoryCommitmentPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkGetDeviceMemoryCommitment is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkGetDeviceMemoryCommitment' :: Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ()
vkGetDeviceMemoryCommitment' = FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ())
-> Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ()
mkVkGetDeviceMemoryCommitment FunPtr
(Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ())
vkGetDeviceMemoryCommitmentPtr
"pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize)
pPCommittedMemoryInBytes <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @DeviceSize Int
8) forall a. Ptr a -> IO ()
free
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetDeviceMemoryCommitment" (Ptr Device_T
-> DeviceMemory
-> ("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize))
-> IO ()
vkGetDeviceMemoryCommitment'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(DeviceMemory
memory)
("pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize)
pPCommittedMemoryInBytes))
"offset" ::: DeviceSize
pCommittedMemoryInBytes <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @DeviceSize "pCommittedMemoryInBytes" ::: Ptr ("offset" ::: DeviceSize)
pPCommittedMemoryInBytes
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ("offset" ::: DeviceSize
pCommittedMemoryInBytes)
data MemoryAllocateInfo (es :: [Type]) = MemoryAllocateInfo
{
forall (es :: [*]). MemoryAllocateInfo es -> Chain es
next :: Chain es
,
forall (es :: [*]).
MemoryAllocateInfo es -> "offset" ::: DeviceSize
allocationSize :: DeviceSize
,
forall (es :: [*]).
MemoryAllocateInfo es -> "memoryRangeCount" ::: Word32
memoryTypeIndex :: Word32
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (MemoryAllocateInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (MemoryAllocateInfo es)
instance Extensible MemoryAllocateInfo where
extensibleTypeName :: String
extensibleTypeName = String
"MemoryAllocateInfo"
setNext :: forall (ds :: [*]) (es :: [*]).
MemoryAllocateInfo ds -> Chain es -> MemoryAllocateInfo es
setNext MemoryAllocateInfo{"memoryRangeCount" ::: Word32
"offset" ::: DeviceSize
Chain ds
memoryTypeIndex :: "memoryRangeCount" ::: Word32
allocationSize :: "offset" ::: DeviceSize
next :: Chain ds
$sel:memoryTypeIndex:MemoryAllocateInfo :: forall (es :: [*]).
MemoryAllocateInfo es -> "memoryRangeCount" ::: Word32
$sel:allocationSize:MemoryAllocateInfo :: forall (es :: [*]).
MemoryAllocateInfo es -> "offset" ::: DeviceSize
$sel:next:MemoryAllocateInfo :: forall (es :: [*]). MemoryAllocateInfo es -> Chain es
..} Chain es
next' = MemoryAllocateInfo{$sel:next:MemoryAllocateInfo :: Chain es
next = Chain es
next', "memoryRangeCount" ::: Word32
"offset" ::: DeviceSize
memoryTypeIndex :: "memoryRangeCount" ::: Word32
allocationSize :: "offset" ::: DeviceSize
$sel:memoryTypeIndex:MemoryAllocateInfo :: "memoryRangeCount" ::: Word32
$sel:allocationSize:MemoryAllocateInfo :: "offset" ::: DeviceSize
..}
getNext :: forall (es :: [*]). MemoryAllocateInfo es -> Chain es
getNext MemoryAllocateInfo{"memoryRangeCount" ::: Word32
"offset" ::: DeviceSize
Chain es
memoryTypeIndex :: "memoryRangeCount" ::: Word32
allocationSize :: "offset" ::: DeviceSize
next :: Chain es
$sel:memoryTypeIndex:MemoryAllocateInfo :: forall (es :: [*]).
MemoryAllocateInfo es -> "memoryRangeCount" ::: Word32
$sel:allocationSize:MemoryAllocateInfo :: forall (es :: [*]).
MemoryAllocateInfo es -> "offset" ::: DeviceSize
$sel:next:MemoryAllocateInfo :: forall (es :: [*]). MemoryAllocateInfo es -> Chain es
..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends MemoryAllocateInfo e => b) -> Maybe b
extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends MemoryAllocateInfo e => b) -> Maybe b
extends proxy e
_ Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMetalBufferInfoEXT
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMetalBufferInfoEXT = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ExportMetalObjectCreateInfoEXT
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportMetalObjectCreateInfoEXT = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMemoryBufferCollectionFUCHSIA
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMemoryBufferCollectionFUCHSIA = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: MemoryOpaqueCaptureAddressAllocateInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @MemoryOpaqueCaptureAddressAllocateInfo = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: MemoryPriorityAllocateInfoEXT
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @MemoryPriorityAllocateInfoEXT = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportAndroidHardwareBufferInfoANDROID
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportAndroidHardwareBufferInfoANDROID = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMemoryHostPointerInfoEXT
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMemoryHostPointerInfoEXT = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: MemoryDedicatedAllocateInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @MemoryDedicatedAllocateInfo = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: MemoryAllocateFlagsInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @MemoryAllocateFlagsInfo = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMemoryFdInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMemoryFdInfoKHR = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMemoryZirconHandleInfoFUCHSIA
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMemoryZirconHandleInfoFUCHSIA = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ExportMemoryWin32HandleInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportMemoryWin32HandleInfoKHR = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMemoryWin32HandleInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMemoryWin32HandleInfoKHR = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ExportMemoryAllocateInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportMemoryAllocateInfo = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ExportMemoryWin32HandleInfoNV
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportMemoryWin32HandleInfoNV = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ImportMemoryWin32HandleInfoNV
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ImportMemoryWin32HandleInfoNV = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: ExportMemoryAllocateInfoNV
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportMemoryAllocateInfoNV = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Just e :~: DedicatedAllocationMemoryAllocateInfoNV
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DedicatedAllocationMemoryAllocateInfoNV = forall a. a -> Maybe a
Just Extends MemoryAllocateInfo e => b
f
| Bool
otherwise = forall a. Maybe a
Nothing
instance ( Extendss MemoryAllocateInfo es
, PokeChain es ) => ToCStruct (MemoryAllocateInfo es) where
withCStruct :: forall b.
MemoryAllocateInfo es
-> (Ptr (MemoryAllocateInfo es) -> IO b) -> IO b
withCStruct MemoryAllocateInfo es
x Ptr (MemoryAllocateInfo es) -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 forall a b. (a -> b) -> a -> b
$ \Ptr (MemoryAllocateInfo es)
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (MemoryAllocateInfo es)
p MemoryAllocateInfo es
x (Ptr (MemoryAllocateInfo es) -> IO b
f Ptr (MemoryAllocateInfo es)
p)
pokeCStruct :: forall b.
Ptr (MemoryAllocateInfo es)
-> MemoryAllocateInfo es -> IO b -> IO b
pokeCStruct Ptr (MemoryAllocateInfo es)
p MemoryAllocateInfo{"memoryRangeCount" ::: Word32
"offset" ::: DeviceSize
Chain es
memoryTypeIndex :: "memoryRangeCount" ::: Word32
allocationSize :: "offset" ::: DeviceSize
next :: Chain es
$sel:memoryTypeIndex:MemoryAllocateInfo :: forall (es :: [*]).
MemoryAllocateInfo es -> "memoryRangeCount" ::: Word32
$sel:allocationSize:MemoryAllocateInfo :: forall (es :: [*]).
MemoryAllocateInfo es -> "offset" ::: DeviceSize
$sel:next:MemoryAllocateInfo :: forall (es :: [*]). MemoryAllocateInfo es -> Chain es
..} IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO)
"data" ::: Ptr ()
pNext'' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) "data" ::: Ptr ()
pNext''
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
allocationSize)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32)) ("memoryRangeCount" ::: Word32
memoryTypeIndex)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = Int
32
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr (MemoryAllocateInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (MemoryAllocateInfo es)
p IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO)
"data" ::: Ptr ()
pNext' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) "data" ::: Ptr ()
pNext'
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
instance ( Extendss MemoryAllocateInfo es
, PeekChain es ) => FromCStruct (MemoryAllocateInfo es) where
peekCStruct :: Ptr (MemoryAllocateInfo es) -> IO (MemoryAllocateInfo es)
peekCStruct Ptr (MemoryAllocateInfo es)
p = do
"data" ::: Ptr ()
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
Chain es
next <- forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (forall a b. Ptr a -> Ptr b
castPtr "data" ::: Ptr ()
pNext)
"offset" ::: DeviceSize
allocationSize <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize))
"memoryRangeCount" ::: Word32
memoryTypeIndex <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (MemoryAllocateInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (es :: [*]).
Chain es
-> ("offset" ::: DeviceSize)
-> ("memoryRangeCount" ::: Word32)
-> MemoryAllocateInfo es
MemoryAllocateInfo
Chain es
next "offset" ::: DeviceSize
allocationSize "memoryRangeCount" ::: Word32
memoryTypeIndex
instance es ~ '[] => Zero (MemoryAllocateInfo es) where
zero :: MemoryAllocateInfo es
zero = forall (es :: [*]).
Chain es
-> ("offset" ::: DeviceSize)
-> ("memoryRangeCount" ::: Word32)
-> MemoryAllocateInfo es
MemoryAllocateInfo
()
forall a. Zero a => a
zero
forall a. Zero a => a
zero
data MappedMemoryRange = MappedMemoryRange
{
MappedMemoryRange -> DeviceMemory
memory :: DeviceMemory
,
MappedMemoryRange -> "offset" ::: DeviceSize
offset :: DeviceSize
,
MappedMemoryRange -> "offset" ::: DeviceSize
size :: DeviceSize
}
deriving (Typeable, MappedMemoryRange -> MappedMemoryRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MappedMemoryRange -> MappedMemoryRange -> Bool
$c/= :: MappedMemoryRange -> MappedMemoryRange -> Bool
== :: MappedMemoryRange -> MappedMemoryRange -> Bool
$c== :: MappedMemoryRange -> MappedMemoryRange -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (MappedMemoryRange)
#endif
deriving instance Show MappedMemoryRange
instance ToCStruct MappedMemoryRange where
withCStruct :: forall b.
MappedMemoryRange
-> (("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO b) -> IO b
withCStruct MappedMemoryRange
x ("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 forall a b. (a -> b) -> a -> b
$ \"pMemoryRanges" ::: Ptr MappedMemoryRange
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pMemoryRanges" ::: Ptr MappedMemoryRange
p MappedMemoryRange
x (("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO b
f "pMemoryRanges" ::: Ptr MappedMemoryRange
p)
pokeCStruct :: forall b.
("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> MappedMemoryRange -> IO b -> IO b
pokeCStruct "pMemoryRanges" ::: Ptr MappedMemoryRange
p MappedMemoryRange{"offset" ::: DeviceSize
DeviceMemory
size :: "offset" ::: DeviceSize
offset :: "offset" ::: DeviceSize
memory :: DeviceMemory
$sel:size:MappedMemoryRange :: MappedMemoryRange -> "offset" ::: DeviceSize
$sel:offset:MappedMemoryRange :: MappedMemoryRange -> "offset" ::: DeviceSize
$sel:memory:MappedMemoryRange :: MappedMemoryRange -> DeviceMemory
..} IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_MAPPED_MEMORY_RANGE)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceMemory)) (DeviceMemory
memory)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
offset)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
size)
IO b
f
cStructSize :: Int
cStructSize = Int
40
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b.
("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO b -> IO b
pokeZeroCStruct "pMemoryRanges" ::: Ptr MappedMemoryRange
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_MAPPED_MEMORY_RANGE)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceMemory)) (forall a. Zero a => a
zero)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
IO b
f
instance FromCStruct MappedMemoryRange where
peekCStruct :: ("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO MappedMemoryRange
peekCStruct "pMemoryRanges" ::: Ptr MappedMemoryRange
p = do
DeviceMemory
memory <- forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceMemory))
"offset" ::: DeviceSize
offset <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize))
"offset" ::: DeviceSize
size <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize (("pMemoryRanges" ::: Ptr MappedMemoryRange
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MappedMemoryRange
MappedMemoryRange
DeviceMemory
memory "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size
instance Storable MappedMemoryRange where
sizeOf :: MappedMemoryRange -> Int
sizeOf ~MappedMemoryRange
_ = Int
40
alignment :: MappedMemoryRange -> Int
alignment ~MappedMemoryRange
_ = Int
8
peek :: ("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO MappedMemoryRange
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pMemoryRanges" ::: Ptr MappedMemoryRange)
-> MappedMemoryRange -> IO ()
poke "pMemoryRanges" ::: Ptr MappedMemoryRange
ptr MappedMemoryRange
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pMemoryRanges" ::: Ptr MappedMemoryRange
ptr MappedMemoryRange
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero MappedMemoryRange where
zero :: MappedMemoryRange
zero = DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> MappedMemoryRange
MappedMemoryRange
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero