{-# language CPP #-} -- No documentation found for Chapter "MemoryManagement" module Vulkan.Core10.MemoryManagement ( getBufferMemoryRequirements , bindBufferMemory , getImageMemoryRequirements , bindImageMemory , MemoryRequirements(..) , DeviceMemory(..) ) where import Vulkan.Internal.Utils (traceAroundEvent) import Control.Monad (unless) import Control.Monad.IO.Class (liftIO) import Foreign.Marshal.Alloc (allocaBytes) import GHC.Base (when) import GHC.IO (throwIO) import GHC.Ptr (nullFunPtr) import Foreign.Ptr (plusPtr) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Cont (evalContT) import Vulkan.CStruct (FromCStruct) import Vulkan.CStruct (FromCStruct(..)) import Vulkan.CStruct (ToCStruct) import Vulkan.CStruct (ToCStruct(..)) import Vulkan.Zero (Zero(..)) import Control.Monad.IO.Class (MonadIO) import Data.Typeable (Typeable) import Foreign.Storable (Storable) import Foreign.Storable (Storable(peek)) import Foreign.Storable (Storable(poke)) import qualified Foreign.Storable (Storable(..)) import GHC.Generics (Generic) import GHC.IO.Exception (IOErrorType(..)) import GHC.IO.Exception (IOException(..)) import Foreign.Ptr (FunPtr) import Foreign.Ptr (Ptr) import Data.Word (Word32) import Data.Kind (Type) import Control.Monad.Trans.Cont (ContT(..)) import Vulkan.NamedType ((:::)) import Vulkan.Core10.Handles (Buffer) import Vulkan.Core10.Handles (Buffer(..)) import Vulkan.Core10.Handles (Device) import Vulkan.Core10.Handles (Device(..)) import Vulkan.Core10.Handles (Device(Device)) import Vulkan.Dynamic (DeviceCmds(pVkBindBufferMemory)) import Vulkan.Dynamic (DeviceCmds(pVkBindImageMemory)) import Vulkan.Dynamic (DeviceCmds(pVkGetBufferMemoryRequirements)) import Vulkan.Dynamic (DeviceCmds(pVkGetImageMemoryRequirements)) import Vulkan.Core10.Handles (DeviceMemory) import Vulkan.Core10.Handles (DeviceMemory(..)) import Vulkan.Core10.FundamentalTypes (DeviceSize) import Vulkan.Core10.Handles (Device_T) import Vulkan.Core10.Handles (Image) import Vulkan.Core10.Handles (Image(..)) import Vulkan.Core10.Enums.Result (Result) import Vulkan.Core10.Enums.Result (Result(..)) import Vulkan.Exception (VulkanException(..)) import Vulkan.Core10.Enums.Result (Result(SUCCESS)) import Vulkan.Core10.Handles (DeviceMemory(..)) foreign import ccall #if !defined(SAFE_FOREIGN_CALLS) unsafe #endif "dynamic" mkVkGetBufferMemoryRequirements :: FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) -> Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO () -- | vkGetBufferMemoryRequirements - Returns the memory requirements for -- specified Vulkan object -- -- == Valid Usage (Implicit) -- -- = See Also -- -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>, -- 'Vulkan.Core10.Handles.Buffer', 'Vulkan.Core10.Handles.Device', -- 'MemoryRequirements' getBufferMemoryRequirements :: forall io . (MonadIO io) => -- | @device@ is the logical device that owns the buffer. -- -- #VUID-vkGetBufferMemoryRequirements-device-parameter# @device@ /must/ be -- a valid 'Vulkan.Core10.Handles.Device' handle Device -> -- | @buffer@ is the buffer to query. -- -- #VUID-vkGetBufferMemoryRequirements-buffer-parameter# @buffer@ /must/ be -- a valid 'Vulkan.Core10.Handles.Buffer' handle -- -- #VUID-vkGetBufferMemoryRequirements-buffer-parent# @buffer@ /must/ have -- been created, allocated, or retrieved from @device@ Buffer -> io (MemoryRequirements) getBufferMemoryRequirements :: forall (io :: * -> *). MonadIO io => Device -> Buffer -> io MemoryRequirements getBufferMemoryRequirements Device device Buffer buffer = IO MemoryRequirements -> io MemoryRequirements forall a. IO a -> io a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MemoryRequirements -> io MemoryRequirements) -> (ContT MemoryRequirements IO MemoryRequirements -> IO MemoryRequirements) -> ContT MemoryRequirements IO MemoryRequirements -> io MemoryRequirements forall b c a. (b -> c) -> (a -> b) -> a -> c . ContT MemoryRequirements IO MemoryRequirements -> IO MemoryRequirements forall (m :: * -> *) r. Monad m => ContT r m r -> m r evalContT (ContT MemoryRequirements IO MemoryRequirements -> io MemoryRequirements) -> ContT MemoryRequirements IO MemoryRequirements -> io MemoryRequirements forall a b. (a -> b) -> a -> b $ do let vkGetBufferMemoryRequirementsPtr :: FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) vkGetBufferMemoryRequirementsPtr = DeviceCmds -> FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) pVkGetBufferMemoryRequirements (case Device device of Device{DeviceCmds deviceCmds :: DeviceCmds deviceCmds :: Device -> DeviceCmds deviceCmds} -> DeviceCmds deviceCmds) IO () -> ContT MemoryRequirements IO () forall (m :: * -> *) a. Monad m => m a -> ContT MemoryRequirements m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. (MonadTrans t, Monad m) => m a -> t m a lift (IO () -> ContT MemoryRequirements IO ()) -> IO () -> ContT MemoryRequirements IO () forall a b. (a -> b) -> a -> b $ Bool -> IO () -> IO () forall (f :: * -> *). Applicative f => Bool -> f () -> f () unless (FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) vkGetBufferMemoryRequirementsPtr FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) -> FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) -> Bool forall a. Eq a => a -> a -> Bool /= FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> 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 vkGetBufferMemoryRequirements is null" Maybe CInt forall a. Maybe a Nothing Maybe String forall a. Maybe a Nothing let vkGetBufferMemoryRequirements' :: Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO () vkGetBufferMemoryRequirements' = FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) -> Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO () mkVkGetBufferMemoryRequirements FunPtr (Ptr Device_T -> Buffer -> Ptr MemoryRequirements -> IO ()) vkGetBufferMemoryRequirementsPtr pPMemoryRequirements <- ((Ptr MemoryRequirements -> IO MemoryRequirements) -> IO MemoryRequirements) -> ContT MemoryRequirements IO (Ptr MemoryRequirements) forall {k} (r :: k) (m :: k -> *) a. ((a -> m r) -> m r) -> ContT r m a ContT (forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b withZeroCStruct @MemoryRequirements) lift $ traceAroundEvent "vkGetBufferMemoryRequirements" (vkGetBufferMemoryRequirements' (deviceHandle (device)) (buffer) (pPMemoryRequirements)) pMemoryRequirements <- lift $ peekCStruct @MemoryRequirements pPMemoryRequirements pure $ (pMemoryRequirements) foreign import ccall #if !defined(SAFE_FOREIGN_CALLS) unsafe #endif "dynamic" mkVkBindBufferMemory :: FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> DeviceSize -> IO Result) -> Ptr Device_T -> Buffer -> DeviceMemory -> DeviceSize -> IO Result -- | vkBindBufferMemory - Bind device memory to a buffer object -- -- = Description -- -- 'bindBufferMemory' is equivalent to passing the same parameters through -- 'Vulkan.Core11.Promoted_From_VK_KHR_bind_memory2.BindBufferMemoryInfo' -- to 'Vulkan.Core11.Promoted_From_VK_KHR_bind_memory2.bindBufferMemory2'. -- -- == Valid Usage -- -- - #VUID-vkBindBufferMemory-buffer-07459# @buffer@ /must/ not have been -- bound to a memory object -- -- - #VUID-vkBindBufferMemory-buffer-01030# @buffer@ /must/ not have been -- created with any sparse memory binding flags -- -- - #VUID-vkBindBufferMemory-memoryOffset-01031# @memoryOffset@ /must/ -- be less than the size of @memory@ -- -- - #VUID-vkBindBufferMemory-memory-01035# @memory@ /must/ have been -- allocated using one of the memory types allowed in the -- @memoryTypeBits@ member of the 'MemoryRequirements' structure -- returned from a call to 'getBufferMemoryRequirements' with @buffer@ -- -- - #VUID-vkBindBufferMemory-None-10739# If @memory@ was not allocated -- from a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @memoryOffset@ /must/ be an integer multiple of the -- @alignment@ member of the 'MemoryRequirements' structure returned -- from a call to 'getBufferMemoryRequirements' with @buffer@ -- -- - #VUID-vkBindBufferMemory-memory-10740# If @memory@ was allocated -- from a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @memoryOffset@ /must/ be an integer multiple of the -- @alignment@ member of the -- 'Vulkan.Extensions.VK_QCOM_tile_memory_heap.TileMemoryRequirementsQCOM' -- structure returned from a call to 'getBufferMemoryRequirements' with -- @buffer@ -- -- - #VUID-vkBindBufferMemory-None-10741# If @memory@ was not allocated -- from a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @size@ member of the 'MemoryRequirements' structure -- returned from a call to 'getBufferMemoryRequirements' with @buffer@ -- /must/ be less than or equal to the size of @memory@ minus -- @memoryOffset@ -- -- - #VUID-vkBindBufferMemory-memory-10742# If @memory@ was allocated -- from a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @size@ member of the -- 'Vulkan.Extensions.VK_QCOM_tile_memory_heap.TileMemoryRequirementsQCOM' -- structure returned from a call to 'getBufferMemoryRequirements' with -- @buffer@ /must/ be less than or equal to the size of @memory@ minus -- @memoryOffset@ -- -- - #VUID-vkBindBufferMemory-buffer-01444# If @buffer@ requires a -- dedicated allocation (as reported by -- 'Vulkan.Core11.Promoted_From_VK_KHR_get_memory_requirements2.getBufferMemoryRequirements2' -- in -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedRequirements'::@requiresDedicatedAllocation@ -- for @buffer@), @memory@ /must/ have been allocated with -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@buffer@ -- equal to @buffer@ -- -- - #VUID-vkBindBufferMemory-memory-01508# If the -- 'Vulkan.Core10.Memory.MemoryAllocateInfo' provided when @memory@ was -- allocated included a -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo' -- structure in its @pNext@ chain, and -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@buffer@ -- was not 'Vulkan.Core10.APIConstants.NULL_HANDLE', then @buffer@ -- /must/ equal -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@buffer@, -- and @memoryOffset@ /must/ be zero -- -- - #VUID-vkBindBufferMemory-memory-10925# If the -- 'Vulkan.Core10.Memory.MemoryAllocateInfo' provided when @memory@ was -- allocated included a -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo' -- structure in its @pNext@ chain, -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@image@ -- /must/ have been 'Vulkan.Core10.APIConstants.NULL_HANDLE' -- -- - #VUID-vkBindBufferMemory-None-01898# If @buffer@ was created with -- the -- 'Vulkan.Core10.Enums.BufferCreateFlagBits.BUFFER_CREATE_PROTECTED_BIT' -- bit set, the buffer /must/ be bound to a memory object allocated -- with a memory type that reports -- 'Vulkan.Core10.Enums.MemoryPropertyFlagBits.MEMORY_PROPERTY_PROTECTED_BIT' -- -- - #VUID-vkBindBufferMemory-None-01899# If @buffer@ was created with -- the -- 'Vulkan.Core10.Enums.BufferCreateFlagBits.BUFFER_CREATE_PROTECTED_BIT' -- bit not set, the buffer /must/ not be bound to a memory object -- allocated with a memory type that reports -- 'Vulkan.Core10.Enums.MemoryPropertyFlagBits.MEMORY_PROPERTY_PROTECTED_BIT' -- -- - #VUID-vkBindBufferMemory-buffer-01038# If @buffer@ was created with -- 'Vulkan.Extensions.VK_NV_dedicated_allocation.DedicatedAllocationBufferCreateInfoNV'::@dedicatedAllocation@ -- equal to 'Vulkan.Core10.FundamentalTypes.TRUE', @memory@ /must/ have -- been allocated with -- 'Vulkan.Extensions.VK_NV_dedicated_allocation.DedicatedAllocationMemoryAllocateInfoNV'::@buffer@ -- equal to a buffer handle created with identical creation parameters -- to @buffer@ and @memoryOffset@ /must/ be zero -- -- - #VUID-vkBindBufferMemory-apiVersion-07920# If the -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_dedicated_allocation VK_KHR_dedicated_allocation> -- extension is not enabled, -- 'Vulkan.Core10.DeviceInitialization.PhysicalDeviceProperties'::@apiVersion@ -- is less than Vulkan 1.1, and @buffer@ was not created with -- 'Vulkan.Extensions.VK_NV_dedicated_allocation.DedicatedAllocationBufferCreateInfoNV'::@dedicatedAllocation@ -- equal to 'Vulkan.Core10.FundamentalTypes.TRUE', @memory@ /must/ not -- have been allocated dedicated for a specific buffer or image -- -- - #VUID-vkBindBufferMemory-memory-02726# If the value of -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExportMemoryAllocateInfo'::@handleTypes@ -- used to allocate @memory@ is not @0@, it /must/ include at least one -- of the handles set in -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExternalMemoryBufferCreateInfo'::@handleTypes@ -- when @buffer@ was created -- -- - #VUID-vkBindBufferMemory-memory-02985# If @memory@ was allocated by -- a memory import operation, that is not -- 'Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer.ImportAndroidHardwareBufferInfoANDROID' -- with a non-@NULL@ @buffer@ value, the external handle type of the -- imported memory /must/ also have been set in -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExternalMemoryBufferCreateInfo'::@handleTypes@ -- when @buffer@ was created -- -- - #VUID-vkBindBufferMemory-memory-02986# If @memory@ was allocated -- with the -- 'Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer.ImportAndroidHardwareBufferInfoANDROID' -- memory import operation with a non-@NULL@ @buffer@ value, -- 'Vulkan.Core11.Enums.ExternalMemoryHandleTypeFlagBits.EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID' -- /must/ also have been set in -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExternalMemoryBufferCreateInfo'::@handleTypes@ -- when @buffer@ was created -- -- - #VUID-vkBindBufferMemory-bufferDeviceAddress-03339# If the -- 'Vulkan.Core12.Promoted_From_VK_KHR_buffer_device_address.PhysicalDeviceBufferDeviceAddressFeatures'::@bufferDeviceAddress@ -- feature is enabled and @buffer@ was created with the -- 'Vulkan.Core10.Enums.BufferUsageFlagBits.BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT' -- usage flag set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT' -- bit set -- -- - #VUID-vkBindBufferMemory-bufferDeviceAddressCaptureReplay-09200# If -- the -- 'Vulkan.Core12.Promoted_From_VK_KHR_buffer_device_address.PhysicalDeviceBufferDeviceAddressFeatures'::@bufferDeviceAddressCaptureReplay@ -- feature is enabled and @buffer@ was created with the -- 'Vulkan.Core10.Enums.BufferCreateFlagBits.BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT' -- bit set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT' -- bit set -- -- - #VUID-vkBindBufferMemory-buffer-06408# If @buffer@ was created with -- 'Vulkan.Extensions.VK_FUCHSIA_buffer_collection.BufferCollectionBufferCreateInfoFUCHSIA' -- chained to 'Vulkan.Core10.Buffer.BufferCreateInfo'::@pNext@, -- @memory@ /must/ be allocated with a -- 'Vulkan.Extensions.VK_FUCHSIA_buffer_collection.ImportMemoryBufferCollectionFUCHSIA' -- chained to 'Vulkan.Core10.Memory.MemoryAllocateInfo'::@pNext@ -- -- - #VUID-vkBindBufferMemory-descriptorBufferCaptureReplay-08112# If the -- @buffer@ was created with the -- 'Vulkan.Core10.Enums.BufferCreateFlagBits.BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT' -- bit set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT' -- bit set -- -- - #VUID-vkBindBufferMemory-buffer-09201# If the @buffer@ was created -- with the -- 'Vulkan.Core10.Enums.BufferCreateFlagBits.BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT' -- bit set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT' -- bit set -- -- - #VUID-vkBindBufferMemory-buffer-11408# If the @buffer@ was created -- with the -- 'Vulkan.Core10.Enums.BufferUsageFlagBits.BUFFER_USAGE_DESCRIPTOR_HEAP_BIT_EXT' -- or -- 'Vulkan.Core14.Enums.BufferUsageFlags2.BUFFER_USAGE_2_DESCRIPTOR_HEAP_BIT_EXT' -- bit set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT' -- bit set -- -- == Valid Usage (Implicit) -- -- - #VUID-vkBindBufferMemory-device-parameter# @device@ /must/ be a -- valid 'Vulkan.Core10.Handles.Device' handle -- -- - #VUID-vkBindBufferMemory-buffer-parameter# @buffer@ /must/ be a -- valid 'Vulkan.Core10.Handles.Buffer' handle -- -- - #VUID-vkBindBufferMemory-memory-parameter# @memory@ /must/ be a -- valid 'Vulkan.Core10.Handles.DeviceMemory' handle -- -- - #VUID-vkBindBufferMemory-buffer-parent# @buffer@ /must/ have been -- created, allocated, or retrieved from @device@ -- -- - #VUID-vkBindBufferMemory-memory-parent# @memory@ /must/ have been -- created, allocated, or retrieved from @device@ -- -- == Host Synchronization -- -- - Host access to @buffer@ /must/ be externally synchronized -- -- == Return Codes -- -- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>] -- -- - 'Vulkan.Core10.Enums.Result.SUCCESS' -- -- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>] -- -- - 'Vulkan.Extensions.VK_KHR_buffer_device_address.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_UNKNOWN' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_VALIDATION_FAILED' -- -- = See Also -- -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>, -- 'Vulkan.Core10.Handles.Buffer', 'Vulkan.Core10.Handles.Device', -- 'Vulkan.Core10.Handles.DeviceMemory', -- 'Vulkan.Core10.FundamentalTypes.DeviceSize' bindBufferMemory :: forall io . (MonadIO io) => -- | @device@ is the logical device that owns the buffer and memory. Device -> -- | @buffer@ is the buffer to be attached to memory. Buffer -> -- | @memory@ is a 'Vulkan.Core10.Handles.DeviceMemory' object describing the -- device memory to attach. DeviceMemory -> -- | @memoryOffset@ is the start offset of the region of @memory@ which is to -- be bound to the buffer. The number of bytes returned in the -- 'MemoryRequirements'::@size@ member in @memory@, starting from -- @memoryOffset@ bytes, will be bound to the specified buffer. ("memoryOffset" ::: DeviceSize) -> io () bindBufferMemory :: forall (io :: * -> *). MonadIO io => Device -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> io () bindBufferMemory Device device Buffer buffer DeviceMemory memory "memoryOffset" ::: DeviceSize memoryOffset = IO () -> io () forall a. IO a -> io a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> io ()) -> IO () -> io () forall a b. (a -> b) -> a -> b $ do let vkBindBufferMemoryPtr :: FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) vkBindBufferMemoryPtr = DeviceCmds -> FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) pVkBindBufferMemory (case Device device of Device{DeviceCmds deviceCmds :: Device -> DeviceCmds deviceCmds :: DeviceCmds deviceCmds} -> DeviceCmds deviceCmds) Bool -> IO () -> IO () forall (f :: * -> *). Applicative f => Bool -> f () -> f () unless (FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) vkBindBufferMemoryPtr FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) -> FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) -> Bool forall a. Eq a => a -> a -> Bool /= FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> 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 vkBindBufferMemory is null" Maybe CInt forall a. Maybe a Nothing Maybe String forall a. Maybe a Nothing let vkBindBufferMemory' :: Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result vkBindBufferMemory' = FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) -> Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result mkVkBindBufferMemory FunPtr (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) vkBindBufferMemoryPtr r <- String -> IO Result -> IO Result forall a. String -> IO a -> IO a traceAroundEvent String "vkBindBufferMemory" (Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result vkBindBufferMemory' (Device -> Ptr Device_T deviceHandle (Device device)) (Buffer buffer) (DeviceMemory memory) ("memoryOffset" ::: DeviceSize memoryOffset)) when (r < SUCCESS) (throwIO (VulkanException r)) foreign import ccall #if !defined(SAFE_FOREIGN_CALLS) unsafe #endif "dynamic" mkVkGetImageMemoryRequirements :: FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) -> Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO () -- | vkGetImageMemoryRequirements - Returns the memory requirements for -- specified Vulkan object -- -- == Valid Usage -- -- - #VUID-vkGetImageMemoryRequirements-image-01588# @image@ /must/ not -- have been created with the -- 'Vulkan.Core10.Enums.ImageCreateFlagBits.IMAGE_CREATE_DISJOINT_BIT' -- flag set -- -- - #VUID-vkGetImageMemoryRequirements-image-04004# If @image@ was -- created with the -- 'Vulkan.Core11.Enums.ExternalMemoryHandleTypeFlagBits.EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID' -- external memory handle type, then @image@ /must/ be bound to memory -- -- - #VUID-vkGetImageMemoryRequirements-image-08960# If @image@ was -- created with the -- 'Vulkan.Core11.Enums.ExternalMemoryHandleTypeFlagBits.EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX' -- external memory handle type, then @image@ /must/ be bound to memory -- -- == Valid Usage (Implicit) -- -- - #VUID-vkGetImageMemoryRequirements-device-parameter# @device@ /must/ -- be a valid 'Vulkan.Core10.Handles.Device' handle -- -- - #VUID-vkGetImageMemoryRequirements-image-parameter# @image@ /must/ -- be a valid 'Vulkan.Core10.Handles.Image' handle -- -- - #VUID-vkGetImageMemoryRequirements-pMemoryRequirements-parameter# -- @pMemoryRequirements@ /must/ be a valid pointer to a -- 'MemoryRequirements' structure -- -- - #VUID-vkGetImageMemoryRequirements-image-parent# @image@ /must/ have -- been created, allocated, or retrieved from @device@ -- -- = See Also -- -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>, -- 'Vulkan.Core10.Handles.Device', 'Vulkan.Core10.Handles.Image', -- 'MemoryRequirements' getImageMemoryRequirements :: forall io . (MonadIO io) => -- | @device@ is the logical device that owns the image. Device -> -- | @image@ is the image to query. Image -> io (MemoryRequirements) getImageMemoryRequirements :: forall (io :: * -> *). MonadIO io => Device -> Image -> io MemoryRequirements getImageMemoryRequirements Device device Image image = IO MemoryRequirements -> io MemoryRequirements forall a. IO a -> io a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MemoryRequirements -> io MemoryRequirements) -> (ContT MemoryRequirements IO MemoryRequirements -> IO MemoryRequirements) -> ContT MemoryRequirements IO MemoryRequirements -> io MemoryRequirements forall b c a. (b -> c) -> (a -> b) -> a -> c . ContT MemoryRequirements IO MemoryRequirements -> IO MemoryRequirements forall (m :: * -> *) r. Monad m => ContT r m r -> m r evalContT (ContT MemoryRequirements IO MemoryRequirements -> io MemoryRequirements) -> ContT MemoryRequirements IO MemoryRequirements -> io MemoryRequirements forall a b. (a -> b) -> a -> b $ do let vkGetImageMemoryRequirementsPtr :: FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) vkGetImageMemoryRequirementsPtr = DeviceCmds -> FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) pVkGetImageMemoryRequirements (case Device device of Device{DeviceCmds deviceCmds :: Device -> DeviceCmds deviceCmds :: DeviceCmds deviceCmds} -> DeviceCmds deviceCmds) IO () -> ContT MemoryRequirements IO () forall (m :: * -> *) a. Monad m => m a -> ContT MemoryRequirements m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. (MonadTrans t, Monad m) => m a -> t m a lift (IO () -> ContT MemoryRequirements IO ()) -> IO () -> ContT MemoryRequirements 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 MemoryRequirements -> IO ()) vkGetImageMemoryRequirementsPtr FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) -> FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) -> Bool forall a. Eq a => a -> a -> Bool /= FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> 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 vkGetImageMemoryRequirements is null" Maybe CInt forall a. Maybe a Nothing Maybe String forall a. Maybe a Nothing let vkGetImageMemoryRequirements' :: Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO () vkGetImageMemoryRequirements' = FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) -> Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO () mkVkGetImageMemoryRequirements FunPtr (Ptr Device_T -> Image -> Ptr MemoryRequirements -> IO ()) vkGetImageMemoryRequirementsPtr pPMemoryRequirements <- ((Ptr MemoryRequirements -> IO MemoryRequirements) -> IO MemoryRequirements) -> ContT MemoryRequirements IO (Ptr MemoryRequirements) forall {k} (r :: k) (m :: k -> *) a. ((a -> m r) -> m r) -> ContT r m a ContT (forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b withZeroCStruct @MemoryRequirements) lift $ traceAroundEvent "vkGetImageMemoryRequirements" (vkGetImageMemoryRequirements' (deviceHandle (device)) (image) (pPMemoryRequirements)) pMemoryRequirements <- lift $ peekCStruct @MemoryRequirements pPMemoryRequirements pure $ (pMemoryRequirements) foreign import ccall #if !defined(SAFE_FOREIGN_CALLS) unsafe #endif "dynamic" mkVkBindImageMemory :: FunPtr (Ptr Device_T -> Image -> DeviceMemory -> DeviceSize -> IO Result) -> Ptr Device_T -> Image -> DeviceMemory -> DeviceSize -> IO Result -- | vkBindImageMemory - Bind device memory to an image object -- -- = Description -- -- 'bindImageMemory' is equivalent to passing the same parameters through -- 'Vulkan.Core11.Promoted_From_VK_KHR_bind_memory2.BindImageMemoryInfo' to -- 'Vulkan.Core11.Promoted_From_VK_KHR_bind_memory2.bindImageMemory2'. -- -- == Valid Usage -- -- - #VUID-vkBindImageMemory-image-07460# @image@ /must/ not have been -- bound to a memory object -- -- - #VUID-vkBindImageMemory-image-01045# @image@ /must/ not have been -- created with any sparse memory binding flags -- -- - #VUID-vkBindImageMemory-memoryOffset-01046# @memoryOffset@ /must/ be -- less than the size of @memory@ -- -- - #VUID-vkBindImageMemory-image-01445# If @image@ requires a dedicated -- allocation (as reported by -- 'Vulkan.Core11.Promoted_From_VK_KHR_get_memory_requirements2.getImageMemoryRequirements2' -- in -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedRequirements'::@requiresDedicatedAllocation@ -- for @image@), @memory@ /must/ have been created with -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@image@ -- equal to @image@ -- -- - #VUID-vkBindImageMemory-memory-02628# If the -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-dedicatedAllocationImageAliasing dedicatedAllocationImageAliasing> -- feature is not enabled, and the -- 'Vulkan.Core10.Memory.MemoryAllocateInfo' provided when @memory@ was -- allocated included a -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo' -- structure in its @pNext@ chain, and -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@image@ -- was not 'Vulkan.Core10.APIConstants.NULL_HANDLE', then @image@ -- /must/ equal -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@image@ -- and @memoryOffset@ /must/ be zero -- -- - #VUID-vkBindImageMemory-memory-02629# If the -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-dedicatedAllocationImageAliasing dedicatedAllocationImageAliasing> -- feature is enabled, and the -- 'Vulkan.Core10.Memory.MemoryAllocateInfo' provided when @memory@ was -- allocated included a -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo' -- structure in its @pNext@ chain, and -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@image@ -- was not 'Vulkan.Core10.APIConstants.NULL_HANDLE', then -- @memoryOffset@ /must/ be zero, and @image@ /must/ be either equal to -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@image@ -- or an image that was created using the same parameters in -- 'Vulkan.Core10.Image.ImageCreateInfo', with the exception that -- @extent@ and @arrayLayers@ /may/ differ subject to the following -- restrictions: every dimension in the @extent@ parameter of the image -- being bound /must/ be equal to or smaller than the original image -- for which the allocation was created; and the @arrayLayers@ -- parameter of the image being bound /must/ be equal to or smaller -- than the original image for which the allocation was created -- -- - #VUID-vkBindImageMemory-memory-10926# If the -- 'Vulkan.Core10.Memory.MemoryAllocateInfo' provided when @memory@ was -- allocated included a -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo' -- structure in its @pNext@ chain, -- 'Vulkan.Core11.Promoted_From_VK_KHR_dedicated_allocation.MemoryDedicatedAllocateInfo'::@buffer@ -- /must/ have been 'Vulkan.Core10.APIConstants.NULL_HANDLE' -- -- - #VUID-vkBindImageMemory-None-01901# If image was created with the -- 'Vulkan.Core10.Enums.ImageCreateFlagBits.IMAGE_CREATE_PROTECTED_BIT' -- bit set, the image /must/ be bound to a memory object allocated with -- a memory type that reports -- 'Vulkan.Core10.Enums.MemoryPropertyFlagBits.MEMORY_PROPERTY_PROTECTED_BIT' -- -- - #VUID-vkBindImageMemory-None-01902# If image was created with the -- 'Vulkan.Core10.Enums.ImageCreateFlagBits.IMAGE_CREATE_PROTECTED_BIT' -- bit not set, the image /must/ not be bound to a memory object -- created with a memory type that reports -- 'Vulkan.Core10.Enums.MemoryPropertyFlagBits.MEMORY_PROPERTY_PROTECTED_BIT' -- -- - #VUID-vkBindImageMemory-image-01050# If @image@ was created with -- 'Vulkan.Extensions.VK_NV_dedicated_allocation.DedicatedAllocationImageCreateInfoNV'::@dedicatedAllocation@ -- equal to 'Vulkan.Core10.FundamentalTypes.TRUE', @memory@ /must/ have -- been created with -- 'Vulkan.Extensions.VK_NV_dedicated_allocation.DedicatedAllocationMemoryAllocateInfoNV'::@image@ -- equal to an image handle created with identical creation parameters -- to @image@ and @memoryOffset@ /must/ be zero -- -- - #VUID-vkBindImageMemory-apiVersion-07921# If the -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_dedicated_allocation VK_KHR_dedicated_allocation> -- extension is not enabled, -- 'Vulkan.Core10.DeviceInitialization.PhysicalDeviceProperties'::@apiVersion@ -- is less than Vulkan 1.1, and @image@ was not created with -- 'Vulkan.Extensions.VK_NV_dedicated_allocation.DedicatedAllocationImageCreateInfoNV'::@dedicatedAllocation@ -- equal to 'Vulkan.Core10.FundamentalTypes.TRUE', @memory@ /must/ not -- have been allocated dedicated for a specific buffer or image -- -- - #VUID-vkBindImageMemory-memory-02728# If the value of -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExportMemoryAllocateInfo'::@handleTypes@ -- used to allocate @memory@ is not @0@, it /must/ include at least one -- of the handles set in -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExternalMemoryImageCreateInfo'::@handleTypes@ -- when @image@ was created -- -- - #VUID-vkBindImageMemory-memory-02989# If @memory@ was created by a -- memory import operation, that is not -- 'Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer.ImportAndroidHardwareBufferInfoANDROID' -- with a non-@NULL@ @buffer@ value, the external handle type of the -- imported memory /must/ also have been set in -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExternalMemoryImageCreateInfo'::@handleTypes@ -- when @image@ was created -- -- - #VUID-vkBindImageMemory-memory-02990# If @memory@ was created with -- the -- 'Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer.ImportAndroidHardwareBufferInfoANDROID' -- memory import operation with a non-@NULL@ @buffer@ value, -- 'Vulkan.Core11.Enums.ExternalMemoryHandleTypeFlagBits.EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID' -- /must/ also have been set in -- 'Vulkan.Core11.Promoted_From_VK_KHR_external_memory.ExternalMemoryImageCreateInfo'::@handleTypes@ -- when @image@ was created -- -- - #VUID-vkBindImageMemory-image-08113# If the @image@ was created with -- the -- 'Vulkan.Core10.Enums.ImageCreateFlagBits.IMAGE_CREATE_DESCRIPTOR_HEAP_CAPTURE_REPLAY_BIT_EXT' -- bit set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT' -- bit set -- -- - #VUID-vkBindImageMemory-image-09202# If the @image@ was created with -- the -- 'Vulkan.Core10.Enums.ImageCreateFlagBits.IMAGE_CREATE_DESCRIPTOR_HEAP_CAPTURE_REPLAY_BIT_EXT' -- bit set, @memory@ /must/ have been allocated with the -- 'Vulkan.Core11.Enums.MemoryAllocateFlagBits.MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT' -- bit set -- -- - #VUID-vkBindImageMemory-image-01608# @image@ /must/ not have been -- created with the -- 'Vulkan.Core10.Enums.ImageCreateFlagBits.IMAGE_CREATE_DISJOINT_BIT' -- set -- -- - #VUID-vkBindImageMemory-memory-01047# @memory@ /must/ have been -- allocated using one of the memory types allowed in the -- @memoryTypeBits@ member of the 'MemoryRequirements' structure -- returned from a call to 'getImageMemoryRequirements' with @image@ -- -- - #VUID-vkBindImageMemory-None-10735# If @memory@ was not allocated -- from a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @memoryOffset@ /must/ be an integer multiple of the -- @alignment@ member of the 'MemoryRequirements' structure returned -- from a call to 'getImageMemoryRequirements' with @image@ -- -- - #VUID-vkBindImageMemory-memory-10736# If @memory@ was allocated from -- a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @memoryOffset@ /must/ be an integer multiple of the -- @alignment@ member of the -- 'Vulkan.Extensions.VK_QCOM_tile_memory_heap.TileMemoryRequirementsQCOM' -- structure returned from a call to -- 'Vulkan.Core11.Promoted_From_VK_KHR_get_memory_requirements2.getImageMemoryRequirements2' -- with @image@ -- -- - #VUID-vkBindImageMemory-None-10737# If @memory@ was not allocated -- from a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @size@ member of the 'MemoryRequirements' structure -- returned from a call to 'getImageMemoryRequirements' with @image@ -- /must/ be less than or equal to the size of @memory@ minus -- @memoryOffset@ -- -- - #VUID-vkBindImageMemory-memory-10738# If @memory@ was allocated from -- a memory heap with the -- 'Vulkan.Core10.Enums.MemoryHeapFlagBits.MEMORY_HEAP_TILE_MEMORY_BIT_QCOM' -- property set, @size@ member of the -- 'Vulkan.Extensions.VK_QCOM_tile_memory_heap.TileMemoryRequirementsQCOM' -- structure returned from a call to -- 'Vulkan.Core11.Promoted_From_VK_KHR_get_memory_requirements2.getImageMemoryRequirements2' -- with @image@ /must/ be less than or equal to the size of @memory@ -- minus @memoryOffset@ -- -- - #VUID-vkBindImageMemory-image-06392# If @image@ was created with -- 'Vulkan.Extensions.VK_FUCHSIA_buffer_collection.BufferCollectionImageCreateInfoFUCHSIA' -- chained to 'Vulkan.Core10.Image.ImageCreateInfo'::@pNext@, @memory@ -- /must/ be allocated with a -- 'Vulkan.Extensions.VK_FUCHSIA_buffer_collection.ImportMemoryBufferCollectionFUCHSIA' -- chained to 'Vulkan.Core10.Memory.MemoryAllocateInfo'::@pNext@ -- -- == Valid Usage (Implicit) -- -- - #VUID-vkBindImageMemory-device-parameter# @device@ /must/ be a valid -- 'Vulkan.Core10.Handles.Device' handle -- -- - #VUID-vkBindImageMemory-image-parameter# @image@ /must/ be a valid -- 'Vulkan.Core10.Handles.Image' handle -- -- - #VUID-vkBindImageMemory-memory-parameter# @memory@ /must/ be a valid -- 'Vulkan.Core10.Handles.DeviceMemory' handle -- -- - #VUID-vkBindImageMemory-image-parent# @image@ /must/ have been -- created, allocated, or retrieved from @device@ -- -- - #VUID-vkBindImageMemory-memory-parent# @memory@ /must/ have been -- created, allocated, or retrieved from @device@ -- -- == Host Synchronization -- -- - Host access to @image@ /must/ be externally synchronized -- -- == Return Codes -- -- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>] -- -- - 'Vulkan.Core10.Enums.Result.SUCCESS' -- -- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>] -- -- - 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_UNKNOWN' -- -- - 'Vulkan.Core10.Enums.Result.ERROR_VALIDATION_FAILED' -- -- = See Also -- -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>, -- 'Vulkan.Core10.Handles.Device', 'Vulkan.Core10.Handles.DeviceMemory', -- 'Vulkan.Core10.FundamentalTypes.DeviceSize', -- 'Vulkan.Core10.Handles.Image' bindImageMemory :: forall io . (MonadIO io) => -- | @device@ is the logical device that owns the image and memory. Device -> -- | @image@ is the image. Image -> -- | @memory@ is the 'Vulkan.Core10.Handles.DeviceMemory' object describing -- the device memory to attach. DeviceMemory -> -- | @memoryOffset@ is the start offset of the region of @memory@ which is to -- be bound to the image. The number of bytes returned in the -- 'MemoryRequirements'::@size@ member in @memory@, starting from -- @memoryOffset@ bytes, will be bound to the specified image. ("memoryOffset" ::: DeviceSize) -> io () bindImageMemory :: forall (io :: * -> *). MonadIO io => Device -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> io () bindImageMemory Device device Image image DeviceMemory memory "memoryOffset" ::: DeviceSize memoryOffset = IO () -> io () forall a. IO a -> io a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> io ()) -> IO () -> io () forall a b. (a -> b) -> a -> b $ do let vkBindImageMemoryPtr :: FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) vkBindImageMemoryPtr = DeviceCmds -> FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) pVkBindImageMemory (case Device device of Device{DeviceCmds deviceCmds :: Device -> DeviceCmds deviceCmds :: DeviceCmds deviceCmds} -> DeviceCmds deviceCmds) Bool -> IO () -> IO () forall (f :: * -> *). Applicative f => Bool -> f () -> f () unless (FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) vkBindImageMemoryPtr FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) -> FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) -> Bool forall a. Eq a => a -> a -> Bool /= FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> 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 vkBindImageMemory is null" Maybe CInt forall a. Maybe a Nothing Maybe String forall a. Maybe a Nothing let vkBindImageMemory' :: Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result vkBindImageMemory' = FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) -> Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result mkVkBindImageMemory FunPtr (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result) vkBindImageMemoryPtr r <- String -> IO Result -> IO Result forall a. String -> IO a -> IO a traceAroundEvent String "vkBindImageMemory" (Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result vkBindImageMemory' (Device -> Ptr Device_T deviceHandle (Device device)) (Image image) (DeviceMemory memory) ("memoryOffset" ::: DeviceSize memoryOffset)) when (r < SUCCESS) (throwIO (VulkanException r)) -- | VkMemoryRequirements - Structure specifying memory requirements -- -- = See Also -- -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>, -- 'Vulkan.Core10.FundamentalTypes.DeviceSize', -- 'Vulkan.Core11.Promoted_From_VK_KHR_get_memory_requirements2.MemoryRequirements2', -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkVideoSessionMemoryRequirementsKHR VkVideoSessionMemoryRequirementsKHR>, -- 'getBufferMemoryRequirements', 'getImageMemoryRequirements' data MemoryRequirements = MemoryRequirements { -- | @size@ is the size, in bytes, of the memory allocation /required/ for -- the resource. MemoryRequirements -> "memoryOffset" ::: DeviceSize size :: DeviceSize , -- | @alignment@ is the alignment, in bytes, of the offset within the -- allocation /required/ for the resource. MemoryRequirements -> "memoryOffset" ::: DeviceSize alignment :: DeviceSize , -- | @memoryTypeBits@ is a bitmask and contains one bit set for every -- supported memory type for the resource. Bit @i@ is set if and only if -- the memory type @i@ in the -- 'Vulkan.Core10.DeviceInitialization.PhysicalDeviceMemoryProperties' -- structure for the physical device is supported for the resource. MemoryRequirements -> Word32 memoryTypeBits :: Word32 } deriving (Typeable, MemoryRequirements -> MemoryRequirements -> Bool (MemoryRequirements -> MemoryRequirements -> Bool) -> (MemoryRequirements -> MemoryRequirements -> Bool) -> Eq MemoryRequirements forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: MemoryRequirements -> MemoryRequirements -> Bool == :: MemoryRequirements -> MemoryRequirements -> Bool $c/= :: MemoryRequirements -> MemoryRequirements -> Bool /= :: MemoryRequirements -> MemoryRequirements -> Bool Eq) #if defined(GENERIC_INSTANCES) deriving instance Generic (MemoryRequirements) #endif deriving instance Show MemoryRequirements instance ToCStruct MemoryRequirements where withCStruct :: forall b. MemoryRequirements -> (Ptr MemoryRequirements -> IO b) -> IO b withCStruct MemoryRequirements x Ptr MemoryRequirements -> IO b f = Int -> (Ptr MemoryRequirements -> IO b) -> IO b forall a b. Int -> (Ptr a -> IO b) -> IO b allocaBytes Int 24 ((Ptr MemoryRequirements -> IO b) -> IO b) -> (Ptr MemoryRequirements -> IO b) -> IO b forall a b. (a -> b) -> a -> b $ \Ptr MemoryRequirements p -> Ptr MemoryRequirements -> MemoryRequirements -> IO b -> IO b forall b. Ptr MemoryRequirements -> MemoryRequirements -> IO b -> IO b forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b pokeCStruct Ptr MemoryRequirements p MemoryRequirements x (Ptr MemoryRequirements -> IO b f Ptr MemoryRequirements p) pokeCStruct :: forall b. Ptr MemoryRequirements -> MemoryRequirements -> IO b -> IO b pokeCStruct Ptr MemoryRequirements p MemoryRequirements{Word32 "memoryOffset" ::: DeviceSize size :: MemoryRequirements -> "memoryOffset" ::: DeviceSize alignment :: MemoryRequirements -> "memoryOffset" ::: DeviceSize memoryTypeBits :: MemoryRequirements -> Word32 size :: "memoryOffset" ::: DeviceSize alignment :: "memoryOffset" ::: DeviceSize memoryTypeBits :: Word32 ..} IO b f = do Ptr ("memoryOffset" ::: DeviceSize) -> ("memoryOffset" ::: DeviceSize) -> IO () forall a. Storable a => Ptr a -> a -> IO () poke ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr ("memoryOffset" ::: DeviceSize) forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 0 :: Ptr DeviceSize)) ("memoryOffset" ::: DeviceSize size) Ptr ("memoryOffset" ::: DeviceSize) -> ("memoryOffset" ::: DeviceSize) -> IO () forall a. Storable a => Ptr a -> a -> IO () poke ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr ("memoryOffset" ::: DeviceSize) forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 8 :: Ptr DeviceSize)) ("memoryOffset" ::: DeviceSize alignment) Ptr Word32 -> Word32 -> IO () forall a. Storable a => Ptr a -> a -> IO () poke ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr Word32 forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 16 :: Ptr Word32)) (Word32 memoryTypeBits) IO b f cStructSize :: Int cStructSize = Int 24 cStructAlignment :: Int cStructAlignment = Int 8 pokeZeroCStruct :: forall b. Ptr MemoryRequirements -> IO b -> IO b pokeZeroCStruct Ptr MemoryRequirements p IO b f = do Ptr ("memoryOffset" ::: DeviceSize) -> ("memoryOffset" ::: DeviceSize) -> IO () forall a. Storable a => Ptr a -> a -> IO () poke ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr ("memoryOffset" ::: DeviceSize) forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 0 :: Ptr DeviceSize)) ("memoryOffset" ::: DeviceSize forall a. Zero a => a zero) Ptr ("memoryOffset" ::: DeviceSize) -> ("memoryOffset" ::: DeviceSize) -> IO () forall a. Storable a => Ptr a -> a -> IO () poke ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr ("memoryOffset" ::: DeviceSize) forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 8 :: Ptr DeviceSize)) ("memoryOffset" ::: DeviceSize forall a. Zero a => a zero) Ptr Word32 -> Word32 -> IO () forall a. Storable a => Ptr a -> a -> IO () poke ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr Word32 forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 16 :: Ptr Word32)) (Word32 forall a. Zero a => a zero) IO b f instance FromCStruct MemoryRequirements where peekCStruct :: Ptr MemoryRequirements -> IO MemoryRequirements peekCStruct Ptr MemoryRequirements p = do size <- forall a. Storable a => Ptr a -> IO a peek @DeviceSize ((Ptr MemoryRequirements p Ptr MemoryRequirements -> Int -> Ptr ("memoryOffset" ::: DeviceSize) forall a b. Ptr a -> Int -> Ptr b `plusPtr` Int 0 :: Ptr DeviceSize)) alignment <- peek @DeviceSize ((p `plusPtr` 8 :: Ptr DeviceSize)) memoryTypeBits <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32)) pure $ MemoryRequirements size alignment memoryTypeBits instance Storable MemoryRequirements where sizeOf :: MemoryRequirements -> Int sizeOf ~MemoryRequirements _ = Int 24 alignment :: MemoryRequirements -> Int alignment ~MemoryRequirements _ = Int 8 peek :: Ptr MemoryRequirements -> IO MemoryRequirements peek = Ptr MemoryRequirements -> IO MemoryRequirements forall a. FromCStruct a => Ptr a -> IO a peekCStruct poke :: Ptr MemoryRequirements -> MemoryRequirements -> IO () poke Ptr MemoryRequirements ptr MemoryRequirements poked = Ptr MemoryRequirements -> MemoryRequirements -> IO () -> IO () forall b. Ptr MemoryRequirements -> MemoryRequirements -> IO b -> IO b forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b pokeCStruct Ptr MemoryRequirements ptr MemoryRequirements poked (() -> IO () forall a. a -> IO a forall (f :: * -> *) a. Applicative f => a -> f a pure ()) instance Zero MemoryRequirements where zero :: MemoryRequirements zero = ("memoryOffset" ::: DeviceSize) -> ("memoryOffset" ::: DeviceSize) -> Word32 -> MemoryRequirements MemoryRequirements "memoryOffset" ::: DeviceSize forall a. Zero a => a zero "memoryOffset" ::: DeviceSize forall a. Zero a => a zero Word32 forall a. Zero a => a zero