{-# language CPP #-}
module Vulkan.Core11.Promoted_From_VK_KHR_device_group_creation  ( enumeratePhysicalDeviceGroups
                                                                 , PhysicalDeviceGroupProperties(..)
                                                                 , DeviceGroupDeviceCreateInfo(..)
                                                                 , StructureType(..)
                                                                 , MemoryHeapFlagBits(..)
                                                                 , MemoryHeapFlags
                                                                 , MAX_DEVICE_GROUP_SIZE
                                                                 , pattern MAX_DEVICE_GROUP_SIZE
                                                                 ) where

import Vulkan.CStruct.Utils (FixedArray)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import 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 Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.CStruct.Utils (lowerArrayPtr)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Core10.Handles (Instance)
import Vulkan.Core10.Handles (Instance(..))
import Vulkan.Dynamic (InstanceCmds(pVkEnumeratePhysicalDeviceGroups))
import Vulkan.Core10.Handles (Instance_T)
import Vulkan.Core10.APIConstants (MAX_DEVICE_GROUP_SIZE)
import Vulkan.Core10.Handles (PhysicalDevice_T)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Exception (VulkanException(..))
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.APIConstants (pattern MAX_DEVICE_GROUP_SIZE)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.APIConstants (MAX_DEVICE_GROUP_SIZE)
import Vulkan.Core10.Enums.MemoryHeapFlagBits (MemoryHeapFlagBits(..))
import Vulkan.Core10.Enums.MemoryHeapFlagBits (MemoryHeapFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
import Vulkan.Core10.APIConstants (pattern MAX_DEVICE_GROUP_SIZE)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkEnumeratePhysicalDeviceGroups
  :: FunPtr (Ptr Instance_T -> Ptr Word32 -> Ptr PhysicalDeviceGroupProperties -> IO Result) -> Ptr Instance_T -> Ptr Word32 -> Ptr PhysicalDeviceGroupProperties -> IO Result

-- | vkEnumeratePhysicalDeviceGroups - Enumerates groups of physical devices
-- that can be used to create a single logical device
--
-- = Description
--
-- If @pPhysicalDeviceGroupProperties@ is @NULL@, then the number of device
-- groups available is returned in @pPhysicalDeviceGroupCount@. Otherwise,
-- @pPhysicalDeviceGroupCount@ /must/ point to a variable set by the user
-- to the number of elements in the @pPhysicalDeviceGroupProperties@ array,
-- and on return the variable is overwritten with the number of structures
-- actually written to @pPhysicalDeviceGroupProperties@. If
-- @pPhysicalDeviceGroupCount@ is less than the number of device groups
-- available, at most @pPhysicalDeviceGroupCount@ structures will be
-- written. If @pPhysicalDeviceGroupCount@ is smaller than the number of
-- device groups available, 'Vulkan.Core10.Enums.Result.INCOMPLETE' will be
-- returned instead of 'Vulkan.Core10.Enums.Result.SUCCESS', to indicate
-- that not all the available device groups were returned.
--
-- Every physical device /must/ be in exactly one device group.
--
-- == Valid Usage (Implicit)
--
-- -   @instance@ /must/ be a valid 'Vulkan.Core10.Handles.Instance' handle
--
-- -   @pPhysicalDeviceGroupCount@ /must/ be a valid pointer to a
--     @uint32_t@ value
--
-- -   If the value referenced by @pPhysicalDeviceGroupCount@ is not @0@,
--     and @pPhysicalDeviceGroupProperties@ is not @NULL@,
--     @pPhysicalDeviceGroupProperties@ /must/ be a valid pointer to an
--     array of @pPhysicalDeviceGroupCount@ 'PhysicalDeviceGroupProperties'
--     structures
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
--     -   'Vulkan.Core10.Enums.Result.INCOMPLETE'
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>]
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_INITIALIZATION_FAILED'
--
-- = See Also
--
-- 'Vulkan.Core10.Handles.Instance', 'PhysicalDeviceGroupProperties'
enumeratePhysicalDeviceGroups :: forall io
                               . (MonadIO io)
                              => -- | @instance@ is a handle to a Vulkan instance previously created with
                                 -- 'Vulkan.Core10.DeviceInitialization.createInstance'.
                                 Instance
                              -> io (Result, ("physicalDeviceGroupProperties" ::: Vector PhysicalDeviceGroupProperties))
enumeratePhysicalDeviceGroups :: Instance
-> io
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
enumeratePhysicalDeviceGroups instance' :: Instance
instance' = IO
  (Result,
   "physicalDeviceGroupProperties"
   ::: Vector PhysicalDeviceGroupProperties)
-> io
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO
   (Result,
    "physicalDeviceGroupProperties"
    ::: Vector PhysicalDeviceGroupProperties)
 -> io
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> (ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
-> io
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Result,
   "physicalDeviceGroupProperties"
   ::: Vector PhysicalDeviceGroupProperties)
  IO
  (Result,
   "physicalDeviceGroupProperties"
   ::: Vector PhysicalDeviceGroupProperties)
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Result,
    "physicalDeviceGroupProperties"
    ::: Vector PhysicalDeviceGroupProperties)
   IO
   (Result,
    "physicalDeviceGroupProperties"
    ::: Vector PhysicalDeviceGroupProperties)
 -> io
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
-> io
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b. (a -> b) -> a -> b
$ do
  let vkEnumeratePhysicalDeviceGroupsPtr :: FunPtr
  (Ptr Instance_T
   -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties)
   -> IO Result)
vkEnumeratePhysicalDeviceGroupsPtr = InstanceCmds
-> FunPtr
     (Ptr Instance_T
      -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
      -> ("pPhysicalDeviceGroupProperties"
          ::: Ptr PhysicalDeviceGroupProperties)
      -> IO Result)
pVkEnumeratePhysicalDeviceGroups (Instance -> InstanceCmds
instanceCmds (Instance
instance' :: Instance))
  IO ()
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ())
-> IO ()
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Instance_T
   -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties)
   -> IO Result)
vkEnumeratePhysicalDeviceGroupsPtr FunPtr
  (Ptr Instance_T
   -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties)
   -> IO Result)
-> FunPtr
     (Ptr Instance_T
      -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
      -> ("pPhysicalDeviceGroupProperties"
          ::: Ptr PhysicalDeviceGroupProperties)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Instance_T
   -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties)
   -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for vkEnumeratePhysicalDeviceGroups is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkEnumeratePhysicalDeviceGroups' :: Ptr Instance_T
-> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
-> ("pPhysicalDeviceGroupProperties"
    ::: Ptr PhysicalDeviceGroupProperties)
-> IO Result
vkEnumeratePhysicalDeviceGroups' = FunPtr
  (Ptr Instance_T
   -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties)
   -> IO Result)
-> Ptr Instance_T
-> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
-> ("pPhysicalDeviceGroupProperties"
    ::: Ptr PhysicalDeviceGroupProperties)
-> IO Result
mkVkEnumeratePhysicalDeviceGroups FunPtr
  (Ptr Instance_T
   -> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties)
   -> IO Result)
vkEnumeratePhysicalDeviceGroupsPtr
  let instance'' :: Ptr Instance_T
instance'' = Instance -> Ptr Instance_T
instanceHandle (Instance
instance')
  "pPhysicalDeviceGroupCount" ::: Ptr Word32
pPPhysicalDeviceGroupCount <- ((("pPhysicalDeviceGroupCount" ::: Ptr Word32)
  -> IO
       (Result,
        "physicalDeviceGroupProperties"
        ::: Vector PhysicalDeviceGroupProperties))
 -> IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pPhysicalDeviceGroupCount" ::: Ptr Word32)
   -> IO
        (Result,
         "physicalDeviceGroupProperties"
         ::: Vector PhysicalDeviceGroupProperties))
  -> IO
       (Result,
        "physicalDeviceGroupProperties"
        ::: Vector PhysicalDeviceGroupProperties))
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ("pPhysicalDeviceGroupCount" ::: Ptr Word32))
-> ((("pPhysicalDeviceGroupCount" ::: Ptr Word32)
     -> IO
          (Result,
           "physicalDeviceGroupProperties"
           ::: Vector PhysicalDeviceGroupProperties))
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
forall a b. (a -> b) -> a -> b
$ IO ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
-> (("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> IO ())
-> (("pPhysicalDeviceGroupCount" ::: Ptr Word32)
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      Result)
-> IO Result
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Result
forall a b. (a -> b) -> a -> b
$ Ptr Instance_T
-> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
-> ("pPhysicalDeviceGroupProperties"
    ::: Ptr PhysicalDeviceGroupProperties)
-> IO Result
vkEnumeratePhysicalDeviceGroups' Ptr Instance_T
instance'' ("pPhysicalDeviceGroupCount" ::: Ptr Word32
pPPhysicalDeviceGroupCount) ("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
forall a. Ptr a
nullPtr)
  IO ()
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ())
-> IO ()
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Word32
pPhysicalDeviceGroupCount <- IO Word32
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      Word32)
-> IO Word32
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Word32
forall a b. (a -> b) -> a -> b
$ ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 "pPhysicalDeviceGroupCount" ::: Ptr Word32
pPPhysicalDeviceGroupCount
  "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
pPPhysicalDeviceGroupProperties <- ((("pPhysicalDeviceGroupProperties"
   ::: Ptr PhysicalDeviceGroupProperties)
  -> IO
       (Result,
        "physicalDeviceGroupProperties"
        ::: Vector PhysicalDeviceGroupProperties))
 -> IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ("pPhysicalDeviceGroupProperties"
      ::: Ptr PhysicalDeviceGroupProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pPhysicalDeviceGroupProperties"
    ::: Ptr PhysicalDeviceGroupProperties)
   -> IO
        (Result,
         "physicalDeviceGroupProperties"
         ::: Vector PhysicalDeviceGroupProperties))
  -> IO
       (Result,
        "physicalDeviceGroupProperties"
        ::: Vector PhysicalDeviceGroupProperties))
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ("pPhysicalDeviceGroupProperties"
       ::: Ptr PhysicalDeviceGroupProperties))
-> ((("pPhysicalDeviceGroupProperties"
      ::: Ptr PhysicalDeviceGroupProperties)
     -> IO
          (Result,
           "physicalDeviceGroupProperties"
           ::: Vector PhysicalDeviceGroupProperties))
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ("pPhysicalDeviceGroupProperties"
      ::: Ptr PhysicalDeviceGroupProperties)
forall a b. (a -> b) -> a -> b
$ IO
  ("pPhysicalDeviceGroupProperties"
   ::: Ptr PhysicalDeviceGroupProperties)
-> (("pPhysicalDeviceGroupProperties"
     ::: Ptr PhysicalDeviceGroupProperties)
    -> IO ())
-> (("pPhysicalDeviceGroupProperties"
     ::: Ptr PhysicalDeviceGroupProperties)
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
     ("pPhysicalDeviceGroupProperties"
      ::: Ptr PhysicalDeviceGroupProperties)
forall a. Int -> IO (Ptr a)
callocBytes @PhysicalDeviceGroupProperties ((Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPhysicalDeviceGroupCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 288)) ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO ()
forall a. Ptr a -> IO ()
free
  [()]
_ <- (Int
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ())
-> [Int]
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\i :: Int
i -> ((()
  -> IO
       (Result,
        "physicalDeviceGroupProperties"
        ::: Vector PhysicalDeviceGroupProperties))
 -> IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((()
   -> IO
        (Result,
         "physicalDeviceGroupProperties"
         ::: Vector PhysicalDeviceGroupProperties))
  -> IO
       (Result,
        "physicalDeviceGroupProperties"
        ::: Vector PhysicalDeviceGroupProperties))
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ())
-> ((()
     -> IO
          (Result,
           "physicalDeviceGroupProperties"
           ::: Vector PhysicalDeviceGroupProperties))
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct ("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
pPPhysicalDeviceGroupProperties ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int
-> "pPhysicalDeviceGroupProperties"
   ::: Ptr PhysicalDeviceGroupProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 288) :: Ptr PhysicalDeviceGroupProperties) (IO
   (Result,
    "physicalDeviceGroupProperties"
    ::: Vector PhysicalDeviceGroupProperties)
 -> IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> ((()
     -> IO
          (Result,
           "physicalDeviceGroupProperties"
           ::: Vector PhysicalDeviceGroupProperties))
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> (()
    -> IO
         (Result,
          "physicalDeviceGroupProperties"
          ::: Vector PhysicalDeviceGroupProperties))
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((()
 -> IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> ()
-> IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b. (a -> b) -> a -> b
$ ())) [0..(Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPhysicalDeviceGroupCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1]
  Result
r' <- IO Result
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      Result)
-> IO Result
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Result
forall a b. (a -> b) -> a -> b
$ Ptr Instance_T
-> ("pPhysicalDeviceGroupCount" ::: Ptr Word32)
-> ("pPhysicalDeviceGroupProperties"
    ::: Ptr PhysicalDeviceGroupProperties)
-> IO Result
vkEnumeratePhysicalDeviceGroups' Ptr Instance_T
instance'' ("pPhysicalDeviceGroupCount" ::: Ptr Word32
pPPhysicalDeviceGroupCount) (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
pPPhysicalDeviceGroupProperties))
  IO ()
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ())
-> IO ()
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r' Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r'))
  Word32
pPhysicalDeviceGroupCount' <- IO Word32
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      Word32)
-> IO Word32
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     Word32
forall a b. (a -> b) -> a -> b
$ ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 "pPhysicalDeviceGroupCount" ::: Ptr Word32
pPPhysicalDeviceGroupCount
  "physicalDeviceGroupProperties"
::: Vector PhysicalDeviceGroupProperties
pPhysicalDeviceGroupProperties' <- IO
  ("physicalDeviceGroupProperties"
   ::: Vector PhysicalDeviceGroupProperties)
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ("physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO
   ("physicalDeviceGroupProperties"
    ::: Vector PhysicalDeviceGroupProperties)
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      ("physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> IO
     ("physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     ("physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO PhysicalDeviceGroupProperties)
-> IO
     ("physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPhysicalDeviceGroupCount')) (\i :: Int
i -> ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO PhysicalDeviceGroupProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @PhysicalDeviceGroupProperties ((("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
pPPhysicalDeviceGroupProperties) ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int
-> "pPhysicalDeviceGroupProperties"
   ::: Ptr PhysicalDeviceGroupProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (288 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PhysicalDeviceGroupProperties)))
  (Result,
 "physicalDeviceGroupProperties"
 ::: Vector PhysicalDeviceGroupProperties)
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result,
  "physicalDeviceGroupProperties"
  ::: Vector PhysicalDeviceGroupProperties)
 -> ContT
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties)
      IO
      (Result,
       "physicalDeviceGroupProperties"
       ::: Vector PhysicalDeviceGroupProperties))
-> (Result,
    "physicalDeviceGroupProperties"
    ::: Vector PhysicalDeviceGroupProperties)
-> ContT
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
     IO
     (Result,
      "physicalDeviceGroupProperties"
      ::: Vector PhysicalDeviceGroupProperties)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "physicalDeviceGroupProperties"
::: Vector PhysicalDeviceGroupProperties
pPhysicalDeviceGroupProperties')


-- | VkPhysicalDeviceGroupProperties - Structure specifying physical device
-- group properties
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Handles.PhysicalDevice',
-- 'Vulkan.Core10.Enums.StructureType.StructureType',
-- 'enumeratePhysicalDeviceGroups',
-- 'Vulkan.Extensions.VK_KHR_device_group_creation.enumeratePhysicalDeviceGroupsKHR'
data PhysicalDeviceGroupProperties = PhysicalDeviceGroupProperties
  { -- | @physicalDeviceCount@ is the number of physical devices in the group.
    PhysicalDeviceGroupProperties -> Word32
physicalDeviceCount :: Word32
  , -- | @physicalDevices@ is an array of
    -- 'Vulkan.Core10.APIConstants.MAX_DEVICE_GROUP_SIZE'
    -- 'Vulkan.Core10.Handles.PhysicalDevice' handles representing all physical
    -- devices in the group. The first @physicalDeviceCount@ elements of the
    -- array will be valid.
    PhysicalDeviceGroupProperties -> Vector (Ptr PhysicalDevice_T)
physicalDevices :: Vector (Ptr PhysicalDevice_T)
  , -- | @subsetAllocation@ specifies whether logical devices created from the
    -- group support allocating device memory on a subset of devices, via the
    -- @deviceMask@ member of the
    -- 'Vulkan.Core11.Promoted_From_VK_KHR_device_group.MemoryAllocateFlagsInfo'.
    -- If this is 'Vulkan.Core10.FundamentalTypes.FALSE', then all device
    -- memory allocations are made across all physical devices in the group. If
    -- @physicalDeviceCount@ is @1@, then @subsetAllocation@ /must/ be
    -- 'Vulkan.Core10.FundamentalTypes.FALSE'.
    PhysicalDeviceGroupProperties -> Bool
subsetAllocation :: Bool
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceGroupProperties)
#endif
deriving instance Show PhysicalDeviceGroupProperties

instance ToCStruct PhysicalDeviceGroupProperties where
  withCStruct :: PhysicalDeviceGroupProperties
-> (("pPhysicalDeviceGroupProperties"
     ::: Ptr PhysicalDeviceGroupProperties)
    -> IO b)
-> IO b
withCStruct x :: PhysicalDeviceGroupProperties
x f :: ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO b
f = Int
-> Int
-> (("pPhysicalDeviceGroupProperties"
     ::: Ptr PhysicalDeviceGroupProperties)
    -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 288 8 ((("pPhysicalDeviceGroupProperties"
   ::: Ptr PhysicalDeviceGroupProperties)
  -> IO b)
 -> IO b)
-> (("pPhysicalDeviceGroupProperties"
     ::: Ptr PhysicalDeviceGroupProperties)
    -> IO b)
-> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p -> ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> PhysicalDeviceGroupProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p PhysicalDeviceGroupProperties
x (("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO b
f "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p)
  pokeCStruct :: ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> PhysicalDeviceGroupProperties -> IO b -> IO b
pokeCStruct p :: "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p PhysicalDeviceGroupProperties{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> "pPhysicalDeviceGroupCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
physicalDeviceCount)
    Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((Vector (Ptr PhysicalDevice_T) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector (Ptr PhysicalDevice_T) -> Int)
-> Vector (Ptr PhysicalDevice_T) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector (Ptr PhysicalDevice_T)
physicalDevices)) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
forall a. Integral a => a
MAX_DEVICE_GROUP_SIZE) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
      IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "physicalDevices is too long, a maximum of MAX_DEVICE_GROUP_SIZE elements are allowed" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
    (Int -> Ptr PhysicalDevice_T -> IO ())
-> Vector (Ptr PhysicalDevice_T) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Ptr PhysicalDevice_T
e -> Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))
-> Ptr (Ptr PhysicalDevice_T)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int
-> Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))))) Ptr (Ptr PhysicalDevice_T) -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr PhysicalDevice_T)) (Ptr PhysicalDevice_T
e)) (Vector (Ptr PhysicalDevice_T)
physicalDevices)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 280 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
subsetAllocation))
    IO b
f
  cStructSize :: Int
cStructSize = 288
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO b -> IO b
pokeZeroCStruct p :: "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> "pPhysicalDeviceGroupCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
    Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((Vector Any -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Any -> Int) -> Vector Any -> Int
forall a b. (a -> b) -> a -> b
$ (Vector Any
forall a. Monoid a => a
mempty)) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
forall a. Integral a => a
MAX_DEVICE_GROUP_SIZE) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
      IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "physicalDevices is too long, a maximum of MAX_DEVICE_GROUP_SIZE elements are allowed" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
    (Int -> Ptr PhysicalDevice_T -> IO ())
-> Vector (Ptr PhysicalDevice_T) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Ptr PhysicalDevice_T
e -> Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))
-> Ptr (Ptr PhysicalDevice_T)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int
-> Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))))) Ptr (Ptr PhysicalDevice_T) -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr PhysicalDevice_T)) (Ptr PhysicalDevice_T
e)) (Vector (Ptr PhysicalDevice_T)
forall a. Monoid a => a
mempty)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 280 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct PhysicalDeviceGroupProperties where
  peekCStruct :: ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> IO PhysicalDeviceGroupProperties
peekCStruct p :: "pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p = do
    Word32
physicalDeviceCount <- ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> "pPhysicalDeviceGroupCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32))
    Vector (Ptr PhysicalDevice_T)
physicalDevices <- Int
-> (Int -> IO (Ptr PhysicalDevice_T))
-> IO (Vector (Ptr PhysicalDevice_T))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Int
forall a. Integral a => a
MAX_DEVICE_GROUP_SIZE) (\i :: Int
i -> Ptr (Ptr PhysicalDevice_T) -> IO (Ptr PhysicalDevice_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PhysicalDevice_T) (((Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))
-> Ptr (Ptr PhysicalDevice_T)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr @(Ptr PhysicalDevice_T) (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int
-> Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (FixedArray MAX_DEVICE_GROUP_SIZE (Ptr PhysicalDevice_T))))) Ptr (Ptr PhysicalDevice_T) -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr PhysicalDevice_T))))
    Bool32
subsetAllocation <- Ptr Bool32 -> IO Bool32
forall a. Storable a => Ptr a -> IO a
peek @Bool32 (("pPhysicalDeviceGroupProperties"
::: Ptr PhysicalDeviceGroupProperties
p ("pPhysicalDeviceGroupProperties"
 ::: Ptr PhysicalDeviceGroupProperties)
-> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 280 :: Ptr Bool32))
    PhysicalDeviceGroupProperties -> IO PhysicalDeviceGroupProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PhysicalDeviceGroupProperties -> IO PhysicalDeviceGroupProperties)
-> PhysicalDeviceGroupProperties
-> IO PhysicalDeviceGroupProperties
forall a b. (a -> b) -> a -> b
$ Word32
-> Vector (Ptr PhysicalDevice_T)
-> Bool
-> PhysicalDeviceGroupProperties
PhysicalDeviceGroupProperties
             Word32
physicalDeviceCount Vector (Ptr PhysicalDevice_T)
physicalDevices (Bool32 -> Bool
bool32ToBool Bool32
subsetAllocation)

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

instance Zero PhysicalDeviceGroupProperties where
  zero :: PhysicalDeviceGroupProperties
zero = Word32
-> Vector (Ptr PhysicalDevice_T)
-> Bool
-> PhysicalDeviceGroupProperties
PhysicalDeviceGroupProperties
           Word32
forall a. Zero a => a
zero
           Vector (Ptr PhysicalDevice_T)
forall a. Monoid a => a
mempty
           Bool
forall a. Zero a => a
zero


-- | VkDeviceGroupDeviceCreateInfo - Create a logical device from multiple
-- physical devices
--
-- = Description
--
-- The elements of the @pPhysicalDevices@ array are an ordered list of the
-- physical devices that the logical device represents. These /must/ be a
-- subset of a single device group, and need not be in the same order as
-- they were enumerated. The order of the physical devices in the
-- @pPhysicalDevices@ array determines the /device index/ of each physical
-- device, with element i being assigned a device index of i. Certain
-- commands and structures refer to one or more physical devices by using
-- device indices or /device masks/ formed using device indices.
--
-- A logical device created without using 'DeviceGroupDeviceCreateInfo', or
-- with @physicalDeviceCount@ equal to zero, is equivalent to a
-- @physicalDeviceCount@ of one and @pPhysicalDevices@ pointing to the
-- @physicalDevice@ parameter to 'Vulkan.Core10.Device.createDevice'. In
-- particular, the device index of that physical device is zero.
--
-- == Valid Usage
--
-- -   Each element of @pPhysicalDevices@ /must/ be unique
--
-- -   All elements of @pPhysicalDevices@ /must/ be in the same device
--     group as enumerated by 'enumeratePhysicalDeviceGroups'
--
-- -   If @physicalDeviceCount@ is not @0@, the @physicalDevice@ parameter
--     of 'Vulkan.Core10.Device.createDevice' /must/ be an element of
--     @pPhysicalDevices@
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO'
--
-- -   If @physicalDeviceCount@ is not @0@, @pPhysicalDevices@ /must/ be a
--     valid pointer to an array of @physicalDeviceCount@ valid
--     'Vulkan.Core10.Handles.PhysicalDevice' handles
--
-- = See Also
--
-- 'Vulkan.Core10.Handles.PhysicalDevice',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data DeviceGroupDeviceCreateInfo = DeviceGroupDeviceCreateInfo
  { -- | @pPhysicalDevices@ is a pointer to an array of physical device handles
    -- belonging to the same device group.
    DeviceGroupDeviceCreateInfo -> Vector (Ptr PhysicalDevice_T)
physicalDevices :: Vector (Ptr PhysicalDevice_T) }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DeviceGroupDeviceCreateInfo)
#endif
deriving instance Show DeviceGroupDeviceCreateInfo

instance ToCStruct DeviceGroupDeviceCreateInfo where
  withCStruct :: DeviceGroupDeviceCreateInfo
-> (Ptr DeviceGroupDeviceCreateInfo -> IO b) -> IO b
withCStruct x :: DeviceGroupDeviceCreateInfo
x f :: Ptr DeviceGroupDeviceCreateInfo -> IO b
f = Int -> Int -> (Ptr DeviceGroupDeviceCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr DeviceGroupDeviceCreateInfo -> IO b) -> IO b)
-> (Ptr DeviceGroupDeviceCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr DeviceGroupDeviceCreateInfo
p -> Ptr DeviceGroupDeviceCreateInfo
-> DeviceGroupDeviceCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DeviceGroupDeviceCreateInfo
p DeviceGroupDeviceCreateInfo
x (Ptr DeviceGroupDeviceCreateInfo -> IO b
f Ptr DeviceGroupDeviceCreateInfo
p)
  pokeCStruct :: Ptr DeviceGroupDeviceCreateInfo
-> DeviceGroupDeviceCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr DeviceGroupDeviceCreateInfo
p DeviceGroupDeviceCreateInfo{..} f :: IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo
-> Int -> "pPhysicalDeviceGroupCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector (Ptr PhysicalDevice_T) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector (Ptr PhysicalDevice_T) -> Int)
-> Vector (Ptr PhysicalDevice_T) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector (Ptr PhysicalDevice_T)
physicalDevices)) :: Word32))
    Ptr (Ptr PhysicalDevice_T)
pPPhysicalDevices' <- ((Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b)
-> ContT b IO (Ptr (Ptr PhysicalDevice_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b)
 -> ContT b IO (Ptr (Ptr PhysicalDevice_T)))
-> ((Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b)
-> ContT b IO (Ptr (Ptr PhysicalDevice_T))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(Ptr PhysicalDevice_T) ((Vector (Ptr PhysicalDevice_T) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector (Ptr PhysicalDevice_T)
physicalDevices)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> Ptr PhysicalDevice_T -> IO ())
-> Vector (Ptr PhysicalDevice_T) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Ptr PhysicalDevice_T
e -> Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr (Ptr PhysicalDevice_T)
pPPhysicalDevices' Ptr (Ptr PhysicalDevice_T) -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr PhysicalDevice_T)) (Ptr PhysicalDevice_T
e)) (Vector (Ptr PhysicalDevice_T)
physicalDevices)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr (Ptr PhysicalDevice_T))
-> Ptr (Ptr PhysicalDevice_T) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo
-> Int -> Ptr (Ptr (Ptr PhysicalDevice_T))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr (Ptr PhysicalDevice_T)))) (Ptr (Ptr PhysicalDevice_T)
pPPhysicalDevices')
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = 32
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr DeviceGroupDeviceCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr DeviceGroupDeviceCreateInfo
p f :: IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr (Ptr PhysicalDevice_T)
pPPhysicalDevices' <- ((Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b)
-> ContT b IO (Ptr (Ptr PhysicalDevice_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b)
 -> ContT b IO (Ptr (Ptr PhysicalDevice_T)))
-> ((Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b)
-> ContT b IO (Ptr (Ptr PhysicalDevice_T))
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr (Ptr PhysicalDevice_T) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(Ptr PhysicalDevice_T) ((Vector Any -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Any
forall a. Monoid a => a
mempty)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> Ptr PhysicalDevice_T -> IO ())
-> Vector (Ptr PhysicalDevice_T) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Ptr PhysicalDevice_T
e -> Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr (Ptr PhysicalDevice_T)
pPPhysicalDevices' Ptr (Ptr PhysicalDevice_T) -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr PhysicalDevice_T)) (Ptr PhysicalDevice_T
e)) (Vector (Ptr PhysicalDevice_T)
forall a. Monoid a => a
mempty)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr (Ptr PhysicalDevice_T))
-> Ptr (Ptr PhysicalDevice_T) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo
-> Int -> Ptr (Ptr (Ptr PhysicalDevice_T))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr (Ptr PhysicalDevice_T)))) (Ptr (Ptr PhysicalDevice_T)
pPPhysicalDevices')
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f

instance FromCStruct DeviceGroupDeviceCreateInfo where
  peekCStruct :: Ptr DeviceGroupDeviceCreateInfo -> IO DeviceGroupDeviceCreateInfo
peekCStruct p :: Ptr DeviceGroupDeviceCreateInfo
p = do
    Word32
physicalDeviceCount <- ("pPhysicalDeviceGroupCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo
-> Int -> "pPhysicalDeviceGroupCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32))
    Ptr (Ptr PhysicalDevice_T)
pPhysicalDevices <- Ptr (Ptr (Ptr PhysicalDevice_T)) -> IO (Ptr (Ptr PhysicalDevice_T))
forall a. Storable a => Ptr a -> IO a
peek @(Ptr (Ptr PhysicalDevice_T)) ((Ptr DeviceGroupDeviceCreateInfo
p Ptr DeviceGroupDeviceCreateInfo
-> Int -> Ptr (Ptr (Ptr PhysicalDevice_T))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr (Ptr PhysicalDevice_T))))
    Vector (Ptr PhysicalDevice_T)
pPhysicalDevices' <- Int
-> (Int -> IO (Ptr PhysicalDevice_T))
-> IO (Vector (Ptr PhysicalDevice_T))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
physicalDeviceCount) (\i :: Int
i -> Ptr (Ptr PhysicalDevice_T) -> IO (Ptr PhysicalDevice_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PhysicalDevice_T) ((Ptr (Ptr PhysicalDevice_T)
pPhysicalDevices Ptr (Ptr PhysicalDevice_T) -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr PhysicalDevice_T))))
    DeviceGroupDeviceCreateInfo -> IO DeviceGroupDeviceCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceGroupDeviceCreateInfo -> IO DeviceGroupDeviceCreateInfo)
-> DeviceGroupDeviceCreateInfo -> IO DeviceGroupDeviceCreateInfo
forall a b. (a -> b) -> a -> b
$ Vector (Ptr PhysicalDevice_T) -> DeviceGroupDeviceCreateInfo
DeviceGroupDeviceCreateInfo
             Vector (Ptr PhysicalDevice_T)
pPhysicalDevices'

instance Zero DeviceGroupDeviceCreateInfo where
  zero :: DeviceGroupDeviceCreateInfo
zero = Vector (Ptr PhysicalDevice_T) -> DeviceGroupDeviceCreateInfo
DeviceGroupDeviceCreateInfo
           Vector (Ptr PhysicalDevice_T)
forall a. Monoid a => a
mempty