{-# language CPP #-}
-- | = Name
--
-- VK_EXT_memory_priority - device extension
--
-- == VK_EXT_memory_priority
--
-- [__Name String__]
--     @VK_EXT_memory_priority@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     239
--
-- [__Revision__]
--     1
--
-- [__Ratification Status__]
--     Not ratified
--
-- [__Extension and Version Dependencies__]
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_get_physical_device_properties2 VK_KHR_get_physical_device_properties2>
--
-- [__Contact__]
--
--     -   Jeff Bolz
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?body=[VK_EXT_memory_priority] @jeffbolznv%0A*Here describe the issue or question you have about the VK_EXT_memory_priority extension* >
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2018-10-08
--
-- [__Contributors__]
--
--     -   Jeff Bolz, NVIDIA
--
--     -   Jeff Juliano, NVIDIA
--
-- == Description
--
-- This extension adds a @priority@ value specified at memory allocation
-- time. On some systems with both device-local and non-device-local memory
-- heaps, the implementation may transparently move memory from one heap to
-- another when a heap becomes full (for example, when the total memory
-- used across all processes exceeds the size of the heap). In such a case,
-- this priority value may be used to determine which allocations are more
-- likely to remain in device-local memory.
--
-- == New Structures
--
-- -   Extending 'Vulkan.Core10.Memory.MemoryAllocateInfo':
--
--     -   'MemoryPriorityAllocateInfoEXT'
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDeviceMemoryPriorityFeaturesEXT'
--
-- == New Enum Constants
--
-- -   'EXT_MEMORY_PRIORITY_EXTENSION_NAME'
--
-- -   'EXT_MEMORY_PRIORITY_SPEC_VERSION'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT'
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT'
--
-- == Version History
--
-- -   Revision 1, 2018-10-08 (Jeff Bolz)
--
--     -   Initial revision
--
-- == See Also
--
-- 'MemoryPriorityAllocateInfoEXT',
-- 'PhysicalDeviceMemoryPriorityFeaturesEXT'
--
-- == Document Notes
--
-- For more information, see the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VK_EXT_memory_priority Vulkan Specification>
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module Vulkan.Extensions.VK_EXT_memory_priority  ( PhysicalDeviceMemoryPriorityFeaturesEXT(..)
                                                 , MemoryPriorityAllocateInfoEXT(..)
                                                 , EXT_MEMORY_PRIORITY_SPEC_VERSION
                                                 , pattern EXT_MEMORY_PRIORITY_SPEC_VERSION
                                                 , EXT_MEMORY_PRIORITY_EXTENSION_NAME
                                                 , pattern EXT_MEMORY_PRIORITY_EXTENSION_NAME
                                                 ) where

import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.Coerce (coerce)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.C.Types (CFloat)
import Foreign.C.Types (CFloat(..))
import Foreign.C.Types (CFloat(CFloat))
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import Foreign.Ptr (Ptr)
import Data.Kind (Type)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT))
-- | VkPhysicalDeviceMemoryPriorityFeaturesEXT - Structure describing memory
-- priority features that can be supported by an implementation
--
-- = Members
--
-- This structure describes the following feature:
--
-- = Description
--
-- If the 'PhysicalDeviceMemoryPriorityFeaturesEXT' structure is included
-- in the @pNext@ chain of the
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2'
-- structure passed to
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceFeatures2',
-- it is filled in to indicate whether each corresponding feature is
-- supported. 'PhysicalDeviceMemoryPriorityFeaturesEXT' /can/ also be used
-- in the @pNext@ chain of 'Vulkan.Core10.Device.DeviceCreateInfo' to
-- selectively enable these features.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_memory_priority VK_EXT_memory_priority>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceMemoryPriorityFeaturesEXT = PhysicalDeviceMemoryPriorityFeaturesEXT
  { -- | #features-memoryPriority# @memoryPriority@ indicates that the
    -- implementation supports memory priorities specified at memory allocation
    -- time via 'MemoryPriorityAllocateInfoEXT'.
    PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
memoryPriority :: Bool }
  deriving (Typeable, PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
$c/= :: PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
== :: PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
$c== :: PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceMemoryPriorityFeaturesEXT)
#endif
deriving instance Show PhysicalDeviceMemoryPriorityFeaturesEXT

instance ToCStruct PhysicalDeviceMemoryPriorityFeaturesEXT where
  withCStruct :: forall b.
PhysicalDeviceMemoryPriorityFeaturesEXT
-> (Ptr PhysicalDeviceMemoryPriorityFeaturesEXT -> IO b) -> IO b
withCStruct PhysicalDeviceMemoryPriorityFeaturesEXT
x Ptr PhysicalDeviceMemoryPriorityFeaturesEXT -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p PhysicalDeviceMemoryPriorityFeaturesEXT
x (Ptr PhysicalDeviceMemoryPriorityFeaturesEXT -> IO b
f Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p)
  pokeCStruct :: forall b.
Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p PhysicalDeviceMemoryPriorityFeaturesEXT{Bool
memoryPriority :: Bool
$sel:memoryPriority:PhysicalDeviceMemoryPriorityFeaturesEXT :: PhysicalDeviceMemoryPriorityFeaturesEXT -> Bool
..} IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
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 ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
memoryPriority))
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b.
Ptr PhysicalDeviceMemoryPriorityFeaturesEXT -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
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 ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct PhysicalDeviceMemoryPriorityFeaturesEXT where
  peekCStruct :: Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
-> IO PhysicalDeviceMemoryPriorityFeaturesEXT
peekCStruct Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p = do
    Bool32
memoryPriority <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Bool -> PhysicalDeviceMemoryPriorityFeaturesEXT
PhysicalDeviceMemoryPriorityFeaturesEXT
             (Bool32 -> Bool
bool32ToBool Bool32
memoryPriority)

instance Storable PhysicalDeviceMemoryPriorityFeaturesEXT where
  sizeOf :: PhysicalDeviceMemoryPriorityFeaturesEXT -> Int
sizeOf ~PhysicalDeviceMemoryPriorityFeaturesEXT
_ = Int
24
  alignment :: PhysicalDeviceMemoryPriorityFeaturesEXT -> Int
alignment ~PhysicalDeviceMemoryPriorityFeaturesEXT
_ = Int
8
  peek :: Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
-> IO PhysicalDeviceMemoryPriorityFeaturesEXT
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
-> PhysicalDeviceMemoryPriorityFeaturesEXT -> IO ()
poke Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
ptr PhysicalDeviceMemoryPriorityFeaturesEXT
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceMemoryPriorityFeaturesEXT
ptr PhysicalDeviceMemoryPriorityFeaturesEXT
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero PhysicalDeviceMemoryPriorityFeaturesEXT where
  zero :: PhysicalDeviceMemoryPriorityFeaturesEXT
zero = Bool -> PhysicalDeviceMemoryPriorityFeaturesEXT
PhysicalDeviceMemoryPriorityFeaturesEXT
           forall a. Zero a => a
zero


-- | VkMemoryPriorityAllocateInfoEXT - Specify a memory allocation priority
--
-- = Description
--
-- Memory allocations with higher priority /may/ be more likely to stay in
-- device-local memory when the system is under memory pressure.
--
-- If this structure is not included, it is as if the @priority@ value were
-- @0.5@.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_memory_priority VK_EXT_memory_priority>,
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data MemoryPriorityAllocateInfoEXT = MemoryPriorityAllocateInfoEXT
  { -- | @priority@ is a floating-point value between @0@ and @1@, indicating the
    -- priority of the allocation relative to other memory allocations. Larger
    -- values are higher priority. The granularity of the priorities is
    -- implementation-dependent.
    --
    -- #VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602# @priority@ /must/
    -- be between @0@ and @1@, inclusive
    MemoryPriorityAllocateInfoEXT -> Float
priority :: Float }
  deriving (Typeable, MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> Bool
$c/= :: MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> Bool
== :: MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> Bool
$c== :: MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (MemoryPriorityAllocateInfoEXT)
#endif
deriving instance Show MemoryPriorityAllocateInfoEXT

instance ToCStruct MemoryPriorityAllocateInfoEXT where
  withCStruct :: forall b.
MemoryPriorityAllocateInfoEXT
-> (Ptr MemoryPriorityAllocateInfoEXT -> IO b) -> IO b
withCStruct MemoryPriorityAllocateInfoEXT
x Ptr MemoryPriorityAllocateInfoEXT -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr MemoryPriorityAllocateInfoEXT
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr MemoryPriorityAllocateInfoEXT
p MemoryPriorityAllocateInfoEXT
x (Ptr MemoryPriorityAllocateInfoEXT -> IO b
f Ptr MemoryPriorityAllocateInfoEXT
p)
  pokeCStruct :: forall b.
Ptr MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> IO b -> IO b
pokeCStruct Ptr MemoryPriorityAllocateInfoEXT
p MemoryPriorityAllocateInfoEXT{Float
priority :: Float
$sel:priority:MemoryPriorityAllocateInfoEXT :: MemoryPriorityAllocateInfoEXT -> Float
..} IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr MemoryPriorityAllocateInfoEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr MemoryPriorityAllocateInfoEXT
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 ((Ptr MemoryPriorityAllocateInfoEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
priority))
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr MemoryPriorityAllocateInfoEXT -> IO b -> IO b
pokeZeroCStruct Ptr MemoryPriorityAllocateInfoEXT
p IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr MemoryPriorityAllocateInfoEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr MemoryPriorityAllocateInfoEXT
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 ((Ptr MemoryPriorityAllocateInfoEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CFloat)) (Float -> CFloat
CFloat (forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct MemoryPriorityAllocateInfoEXT where
  peekCStruct :: Ptr MemoryPriorityAllocateInfoEXT
-> IO MemoryPriorityAllocateInfoEXT
peekCStruct Ptr MemoryPriorityAllocateInfoEXT
p = do
    CFloat
priority <- forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr MemoryPriorityAllocateInfoEXT
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CFloat))
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Float -> MemoryPriorityAllocateInfoEXT
MemoryPriorityAllocateInfoEXT
             (coerce :: forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
priority)

instance Storable MemoryPriorityAllocateInfoEXT where
  sizeOf :: MemoryPriorityAllocateInfoEXT -> Int
sizeOf ~MemoryPriorityAllocateInfoEXT
_ = Int
24
  alignment :: MemoryPriorityAllocateInfoEXT -> Int
alignment ~MemoryPriorityAllocateInfoEXT
_ = Int
8
  peek :: Ptr MemoryPriorityAllocateInfoEXT
-> IO MemoryPriorityAllocateInfoEXT
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr MemoryPriorityAllocateInfoEXT
-> MemoryPriorityAllocateInfoEXT -> IO ()
poke Ptr MemoryPriorityAllocateInfoEXT
ptr MemoryPriorityAllocateInfoEXT
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr MemoryPriorityAllocateInfoEXT
ptr MemoryPriorityAllocateInfoEXT
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero MemoryPriorityAllocateInfoEXT where
  zero :: MemoryPriorityAllocateInfoEXT
zero = Float -> MemoryPriorityAllocateInfoEXT
MemoryPriorityAllocateInfoEXT
           forall a. Zero a => a
zero


type EXT_MEMORY_PRIORITY_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_EXT_MEMORY_PRIORITY_SPEC_VERSION"
pattern EXT_MEMORY_PRIORITY_SPEC_VERSION :: forall a . Integral a => a
pattern $bEXT_MEMORY_PRIORITY_SPEC_VERSION :: forall a. Integral a => a
$mEXT_MEMORY_PRIORITY_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
EXT_MEMORY_PRIORITY_SPEC_VERSION = 1


type EXT_MEMORY_PRIORITY_EXTENSION_NAME = "VK_EXT_memory_priority"

-- No documentation found for TopLevel "VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME"
pattern EXT_MEMORY_PRIORITY_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bEXT_MEMORY_PRIORITY_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
$mEXT_MEMORY_PRIORITY_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
EXT_MEMORY_PRIORITY_EXTENSION_NAME = "VK_EXT_memory_priority"