content: {-# language CPP #-}
  -- No documentation found for Chapter "PipelineCache"
  module Vulkan.Core10.PipelineCache  ( createPipelineCache
                                      , withPipelineCache
                                      , destroyPipelineCache
                                      , getPipelineCacheData
                                      , mergePipelineCaches
                                      , PipelineCacheCreateInfo(..)
                                      , PipelineCache(..)
                                      , PipelineCacheCreateFlagBits(..)
                                      , PipelineCacheCreateFlags
                                      ) where
  
  import Vulkan.Internal.Utils (traceAroundEvent)
  import Control.Exception.Base (bracket)
  import Control.Monad (unless)
  import Control.Monad.IO.Class (liftIO)
  import Foreign.Marshal.Alloc (allocaBytes)
  import Foreign.Marshal.Alloc (callocBytes)
  import Foreign.Marshal.Alloc (free)
  import GHC.Base (when)
  import GHC.IO (throwIO)
  import GHC.Ptr (castPtr)
  import GHC.Ptr (nullFunPtr)
  import Foreign.Ptr (nullPtr)
  import Foreign.Ptr (plusPtr)
  import Data.ByteString (packCStringLen)
  import Data.Coerce (coerce)
  import Control.Monad.Trans.Class (lift)
  import Control.Monad.Trans.Cont (evalContT)
  import qualified Data.Vector (imapM_)
  import qualified Data.Vector (length)
  import Foreign.C.Types (CSize(..))
  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.C.Types (CChar)
  import Foreign.C.Types (CSize)
  import Foreign.C.Types (CSize(..))
  import Foreign.C.Types (CSize(CSize))
  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.Word (Word64)
  import Data.ByteString (ByteString)
  import Data.Kind (Type)
  import Control.Monad.Trans.Cont (ContT(..))
  import Data.Vector (Vector)
  import Vulkan.NamedType ((:::))
  import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
  import Vulkan.Core10.Handles (Device)
  import Vulkan.Core10.Handles (Device(..))
  import Vulkan.Core10.Handles (Device(Device))
  import Vulkan.Dynamic (DeviceCmds(pVkCreatePipelineCache))
  import Vulkan.Dynamic (DeviceCmds(pVkDestroyPipelineCache))
  import Vulkan.Dynamic (DeviceCmds(pVkGetPipelineCacheData))
  import Vulkan.Dynamic (DeviceCmds(pVkMergePipelineCaches))
  import Vulkan.Core10.Handles (Device_T)
  import Vulkan.Core10.Handles (PipelineCache)
  import Vulkan.Core10.Handles (PipelineCache(..))
  import Vulkan.Core10.Enums.PipelineCacheCreateFlagBits (PipelineCacheCreateFlags)
  import Vulkan.Core10.Enums.Result (Result)
  import Vulkan.Core10.Enums.Result (Result(..))
  import Vulkan.Core10.Enums.StructureType (StructureType)
  import Vulkan.Exception (VulkanException(..))
  import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO))
  import Vulkan.Core10.Enums.Result (Result(SUCCESS))
  import Vulkan.Core10.Handles (PipelineCache(..))
  import Vulkan.Core10.Enums.PipelineCacheCreateFlagBits (PipelineCacheCreateFlagBits(..))
  import Vulkan.Core10.Enums.PipelineCacheCreateFlagBits (PipelineCacheCreateFlags)
  foreign import ccall
  #if !defined(SAFE_FOREIGN_CALLS)
    unsafe
  #endif
    "dynamic" mkVkCreatePipelineCache
    :: FunPtr (Ptr Device_T -> Ptr PipelineCacheCreateInfo -> Ptr AllocationCallbacks -> Ptr PipelineCache -> IO Result) -> Ptr Device_T -> Ptr PipelineCacheCreateInfo -> Ptr AllocationCallbacks -> Ptr PipelineCache -> IO Result
  
  -- | vkCreatePipelineCache - Creates a new pipeline cache
  --
  -- = Description
  --
  -- Note
  --
  -- Applications /can/ track and manage the total host memory size of a
  -- pipeline cache object using the @pAllocator@. Applications /can/ limit
  -- the amount of data retrieved from a pipeline cache object in
  -- 'getPipelineCacheData'. Implementations /should/ not internally limit
  -- the total number of entries added to a pipeline cache object or the
  -- total host memory consumed.
  --
  -- Once created, a pipeline cache /can/ be passed to the
  -- 'Vulkan.Core10.Pipeline.createGraphicsPipelines'
  -- 'Vulkan.Extensions.VK_KHR_ray_tracing_pipeline.createRayTracingPipelinesKHR',
  -- 'Vulkan.Extensions.VK_NV_ray_tracing.createRayTracingPipelinesNV', and
  -- 'Vulkan.Core10.Pipeline.createComputePipelines' commands. If the
  -- pipeline cache passed into these commands is not
  -- 'Vulkan.Core10.APIConstants.NULL_HANDLE', the implementation will query
  -- it for possible reuse opportunities and update it with new content. The
  -- use of the pipeline cache object in these commands is internally
  -- synchronized, and the same pipeline cache object /can/ be used in
  -- multiple threads simultaneously.
  --
  -- If @flags@ of @pCreateInfo@ includes
  -- 'Vulkan.Core10.Enums.PipelineCacheCreateFlagBits.PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT',
  -- all commands that modify the returned pipeline cache object /must/ be
  -- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#fundamentals-threadingbehavior externally synchronized>.
  --
  -- Note
  --
  -- Implementations /should/ make every effort to limit any critical
  -- sections to the actual accesses to the cache, which is expected to be
  -- significantly shorter than the duration of the @vkCreate*Pipelines@
  -- commands.
  --
  -- == Valid Usage (Implicit)
  --
  -- -   #VUID-vkCreatePipelineCache-device-parameter# @device@ /must/ be a
  --     valid 'Vulkan.Core10.Handles.Device' handle
  --
  -- -   #VUID-vkCreatePipelineCache-pCreateInfo-parameter# @pCreateInfo@
  --     /must/ be a valid pointer to a valid 'PipelineCacheCreateInfo'
  --     structure
  --
  -- -   #VUID-vkCreatePipelineCache-pAllocator-parameter# If @pAllocator@ is
  --     not @NULL@, @pAllocator@ /must/ be a valid pointer to a valid
  --     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' structure
  --
  -- -   #VUID-vkCreatePipelineCache-pPipelineCache-parameter#
  --     @pPipelineCache@ /must/ be a valid pointer to a
  --     'Vulkan.Core10.Handles.PipelineCache' handle
  --
  -- == 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_HOST_MEMORY'
  --
  --     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
  --
  -- = 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.AllocationCallbacks.AllocationCallbacks',
  -- 'Vulkan.Core10.Handles.Device', 'Vulkan.Core10.Handles.PipelineCache',
  -- 'PipelineCacheCreateInfo'
  createPipelineCache :: forall io
                       . (MonadIO io)
                      => -- | @device@ is the logical device that creates the pipeline cache object.
                         Device
                      -> -- | @pCreateInfo@ is a pointer to a 'PipelineCacheCreateInfo' structure
                         -- containing initial parameters for the pipeline cache object.
                         PipelineCacheCreateInfo
                      -> -- | @pAllocator@ controls host memory allocation as described in the
                         -- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#memory-allocation Memory Allocation>
                         -- chapter.
                         ("allocator" ::: Maybe AllocationCallbacks)
                      -> io (PipelineCache)
  createPipelineCache device createInfo allocator = liftIO . evalContT $ do
    let vkCreatePipelineCachePtr = pVkCreatePipelineCache (case device of Device{deviceCmds} -> deviceCmds)
    lift $ unless (vkCreatePipelineCachePtr /= nullFunPtr) $
      throwIO $ IOError Nothing InvalidArgument "" "The function pointer for vkCreatePipelineCache is null" Nothing Nothing
    let vkCreatePipelineCache' = mkVkCreatePipelineCache vkCreatePipelineCachePtr
    pCreateInfo <- ContT $ withCStruct (createInfo)
    pAllocator <- case (allocator) of
      Nothing -> pure nullPtr
      Just j -> ContT $ withCStruct (j)
    pPPipelineCache <- ContT $ bracket (callocBytes @PipelineCache 8) free
    r <- lift $ traceAroundEvent "vkCreatePipelineCache" (vkCreatePipelineCache'
                                                            (deviceHandle (device))
                                                            pCreateInfo
                                                            pAllocator
                                                            (pPPipelineCache))
    lift $ when (r < SUCCESS) (throwIO (VulkanException r))
    pPipelineCache <- lift $ peek @PipelineCache pPPipelineCache
    pure $ (pPipelineCache)
  
  -- | A convenience wrapper to make a compatible pair of calls to
  -- 'createPipelineCache' and 'destroyPipelineCache'
  --
  -- To ensure that 'destroyPipelineCache' is always called: pass
  -- 'Control.Exception.bracket' (or the allocate function from your
  -- favourite resource management library) as the last argument.
  -- To just extract the pair pass '(,)' as the last argument.
  --
  withPipelineCache :: forall io r . MonadIO io => Device -> PipelineCacheCreateInfo -> Maybe AllocationCallbacks -> (io PipelineCache -> (PipelineCache -> io ()) -> r) -> r
  withPipelineCache device pCreateInfo pAllocator b =
    b (createPipelineCache device pCreateInfo pAllocator)
      (\(o0) -> destroyPipelineCache device o0 pAllocator)
  
  
  foreign import ccall
  #if !defined(SAFE_FOREIGN_CALLS)
    unsafe
  #endif
    "dynamic" mkVkDestroyPipelineCache
    :: FunPtr (Ptr Device_T -> PipelineCache -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> PipelineCache -> Ptr AllocationCallbacks -> IO ()
  
  -- | vkDestroyPipelineCache - Destroy a pipeline cache object
  --
  -- == Valid Usage
  --
  -- -   #VUID-vkDestroyPipelineCache-pipelineCache-00771# If
  --     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' were
  --     provided when @pipelineCache@ was created, a compatible set of
  --     callbacks /must/ be provided here
  --
  -- -   #VUID-vkDestroyPipelineCache-pipelineCache-00772# If no
  --     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' were
  --     provided when @pipelineCache@ was created, @pAllocator@ /must/ be
  --     @NULL@
  --
  -- == Valid Usage (Implicit)
  --
  -- -   #VUID-vkDestroyPipelineCache-device-parameter# @device@ /must/ be a
  --     valid 'Vulkan.Core10.Handles.Device' handle
  --
  -- -   #VUID-vkDestroyPipelineCache-pipelineCache-parameter# If
  --     @pipelineCache@ is not 'Vulkan.Core10.APIConstants.NULL_HANDLE',
  --     @pipelineCache@ /must/ be a valid
  --     'Vulkan.Core10.Handles.PipelineCache' handle
  --
  -- -   #VUID-vkDestroyPipelineCache-pAllocator-parameter# If @pAllocator@
  --     is not @NULL@, @pAllocator@ /must/ be a valid pointer to a valid
  --     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' structure
  --
  -- -   #VUID-vkDestroyPipelineCache-pipelineCache-parent# If
  --     @pipelineCache@ is a valid handle, it /must/ have been created,
  --     allocated, or retrieved from @device@
  --
  -- == Host Synchronization
  --
  -- -   Host access to @pipelineCache@ /must/ be externally synchronized
  --
  -- = 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.AllocationCallbacks.AllocationCallbacks',
  -- 'Vulkan.Core10.Handles.Device', 'Vulkan.Core10.Handles.PipelineCache'
  destroyPipelineCache :: forall io
                        . (MonadIO io)
                       => -- | @device@ is the logical device that destroys the pipeline cache object.
                          Device
                       -> -- | @pipelineCache@ is the handle of the pipeline cache to destroy.
                          PipelineCache
                       -> -- | @pAllocator@ controls host memory allocation as described in the
                          -- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#memory-allocation Memory Allocation>
                          -- chapter.
                          ("allocator" ::: Maybe AllocationCallbacks)
                       -> io ()
  destroyPipelineCache device pipelineCache allocator = liftIO . evalContT $ do
    let vkDestroyPipelineCachePtr = pVkDestroyPipelineCache (case device of Device{deviceCmds} -> deviceCmds)
    lift $ unless (vkDestroyPipelineCachePtr /= nullFunPtr) $
      throwIO $ IOError Nothing InvalidArgument "" "The function pointer for vkDestroyPipelineCache is null" Nothing Nothing
    let vkDestroyPipelineCache' = mkVkDestroyPipelineCache vkDestroyPipelineCachePtr
    pAllocator <- case (allocator) of
      Nothing -> pure nullPtr
      Just j -> ContT $ withCStruct (j)
    lift $ traceAroundEvent "vkDestroyPipelineCache" (vkDestroyPipelineCache'
                                                        (deviceHandle (device))
                                                        (pipelineCache)
                                                        pAllocator)
    pure $ ()
  
  
  foreign import ccall
  #if !defined(SAFE_FOREIGN_CALLS)
    unsafe
  #endif
    "dynamic" mkVkGetPipelineCacheData
    :: FunPtr (Ptr Device_T -> PipelineCache -> Ptr CSize -> Ptr () -> IO Result) -> Ptr Device_T -> PipelineCache -> Ptr CSize -> Ptr () -> IO Result
  
  -- | vkGetPipelineCacheData - Get the data store from a pipeline cache
  --
  -- = Description
  --
  -- If @pData@ is @NULL@, then the maximum size of the data that /can/ be
  -- retrieved from the pipeline cache, in bytes, is returned in @pDataSize@.
  -- Otherwise, @pDataSize@ /must/ point to a variable set by the user to the
  -- size of the buffer, in bytes, pointed to by @pData@, and on return the
  -- variable is overwritten with the amount of data actually written to
  -- @pData@. If @pDataSize@ is less than the maximum size that /can/ be
  -- retrieved by the pipeline cache, at most @pDataSize@ bytes will be
  -- written to @pData@, and 'Vulkan.Core10.Enums.Result.INCOMPLETE' will be
  -- returned instead of 'Vulkan.Core10.Enums.Result.SUCCESS', to indicate
  -- that not all of the pipeline cache was returned.
  --
  -- Any data written to @pData@ is valid and /can/ be provided as the
  -- @pInitialData@ member of the 'PipelineCacheCreateInfo' structure passed
  -- to 'createPipelineCache'.
  --
  -- Two calls to 'getPipelineCacheData' with the same parameters /must/
  -- retrieve the same data unless a command that modifies the contents of
  -- the cache is called between them.
  --
  -- The initial bytes written to @pData@ /must/ be a header as described in
  -- the
  -- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#pipelines-cache-header Pipeline Cache Header>
  -- section.
  --
  -- If @pDataSize@ is less than what is necessary to store this header,
  -- nothing will be written to @pData@ and zero will be written to
  -- @pDataSize@.
  --
  -- == Valid Usage (Implicit)
  --
  -- -   #VUID-vkGetPipelineCacheData-device-parameter# @device@ /must/ be a
  --     valid 'Vulkan.Core10.Handles.Device' handle
  --
  -- -   #VUID-vkGetPipelineCacheData-pipelineCache-parameter#
  --     @pipelineCache@ /must/ be a valid
  --     'Vulkan.Core10.Handles.PipelineCache' handle
  --
  -- -   #VUID-vkGetPipelineCacheData-pDataSize-parameter# @pDataSize@ /must/
  --     be a valid pointer to a @size_t@ value
  --
  -- -   #VUID-vkGetPipelineCacheData-pData-parameter# If the value
  --     referenced by @pDataSize@ is not @0@, and @pData@ is not @NULL@,
  --     @pData@ /must/ be a valid pointer to an array of @pDataSize@ bytes
  --
  -- -   #VUID-vkGetPipelineCacheData-pipelineCache-parent# @pipelineCache@
  --     /must/ have been created, allocated, or retrieved from @device@
  --
  -- == 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'
  --
  -- = 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.PipelineCache'
  getPipelineCacheData :: forall io
                        . (MonadIO io)
                       => -- | @device@ is the logical device that owns the pipeline cache.
                          Device
                       -> -- | @pipelineCache@ is the pipeline cache to retrieve data from.
                          PipelineCache
                       -> io (Result, ("data" ::: ByteString))
  getPipelineCacheData device pipelineCache = liftIO . evalContT $ do
    let vkGetPipelineCacheDataPtr = pVkGetPipelineCacheData (case device of Device{deviceCmds} -> deviceCmds)
    lift $ unless (vkGetPipelineCacheDataPtr /= nullFunPtr) $
      throwIO $ IOError Nothing InvalidArgument "" "The function pointer for vkGetPipelineCacheData is null" Nothing Nothing
    let vkGetPipelineCacheData' = mkVkGetPipelineCacheData vkGetPipelineCacheDataPtr
    let device' = deviceHandle (device)
    pPDataSize <- ContT $ bracket (callocBytes @CSize 8) free
    r <- lift $ traceAroundEvent "vkGetPipelineCacheData" (vkGetPipelineCacheData'
                                                             device'
                                                             (pipelineCache)
                                                             (pPDataSize)
                                                             (nullPtr))
    lift $ when (r < SUCCESS) (throwIO (VulkanException r))
    pDataSize <- lift $ peek @CSize pPDataSize
    pPData <- ContT $ bracket (callocBytes @(()) (fromIntegral ((coerce @CSize @Word64 pDataSize)))) free
    r' <- lift $ traceAroundEvent "vkGetPipelineCacheData" (vkGetPipelineCacheData'
                                                              device'
                                                              (pipelineCache)
                                                              (pPDataSize)
                                                              (pPData))
    lift $ when (r' < SUCCESS) (throwIO (VulkanException r'))
    pDataSize'' <- lift $ peek @CSize pPDataSize
    pData' <- lift $ packCStringLen  ( castPtr @() @CChar pPData
                                     , (fromIntegral ((coerce @CSize @Word64 pDataSize''))) )
    pure $ ((r'), pData')
  
  
  foreign import ccall
  #if !defined(SAFE_FOREIGN_CALLS)
    unsafe
  #endif
    "dynamic" mkVkMergePipelineCaches
    :: FunPtr (Ptr Device_T -> PipelineCache -> Word32 -> Ptr PipelineCache -> IO Result) -> Ptr Device_T -> PipelineCache -> Word32 -> Ptr PipelineCache -> IO Result
  
  -- | vkMergePipelineCaches - Combine the data stores of pipeline caches
  --
  -- = Description
  --
  -- Note
  --
  -- The details of the merge operation are implementation-dependent, but
  -- implementations /should/ merge the contents of the specified pipelines
  -- and prune duplicate entries.
  --
  -- == Valid Usage
  --
  -- -   #VUID-vkMergePipelineCaches-dstCache-00770# @dstCache@ /must/ not
  --     appear in the list of source caches
  --
  -- == Valid Usage (Implicit)
  --
  -- -   #VUID-vkMergePipelineCaches-device-parameter# @device@ /must/ be a
  --     valid 'Vulkan.Core10.Handles.Device' handle
  --
  -- -   #VUID-vkMergePipelineCaches-dstCache-parameter# @dstCache@ /must/ be
  --     a valid 'Vulkan.Core10.Handles.PipelineCache' handle
  --
  -- -   #VUID-vkMergePipelineCaches-pSrcCaches-parameter# @pSrcCaches@
  --     /must/ be a valid pointer to an array of @srcCacheCount@ valid
  --     'Vulkan.Core10.Handles.PipelineCache' handles
  --
  -- -   #VUID-vkMergePipelineCaches-srcCacheCount-arraylength#
  --     @srcCacheCount@ /must/ be greater than @0@
  --
  -- -   #VUID-vkMergePipelineCaches-dstCache-parent# @dstCache@ /must/ have
  --     been created, allocated, or retrieved from @device@
  --
  -- -   #VUID-vkMergePipelineCaches-pSrcCaches-parent# Each element of
  --     @pSrcCaches@ /must/ have been created, allocated, or retrieved from
  --     @device@
  --
  -- == Host Synchronization
  --
  -- -   Host access to @dstCache@ /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_HOST_MEMORY'
  --
  --     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
  --
  -- = 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.PipelineCache'
  mergePipelineCaches :: forall io
                       . (MonadIO io)
                      => -- | @device@ is the logical device that owns the pipeline cache objects.
                         Device
                      -> -- | @dstCache@ is the handle of the pipeline cache to merge results into.
                         ("dstCache" ::: PipelineCache)
                      -> -- | @pSrcCaches@ is a pointer to an array of pipeline cache handles, which
                         -- will be merged into @dstCache@. The previous contents of @dstCache@ are
                         -- included after the merge.
                         ("srcCaches" ::: Vector PipelineCache)
                      -> io ()
  mergePipelineCaches device dstCache srcCaches = liftIO . evalContT $ do
    let vkMergePipelineCachesPtr = pVkMergePipelineCaches (case device of Device{deviceCmds} -> deviceCmds)
    lift $ unless (vkMergePipelineCachesPtr /= nullFunPtr) $
      throwIO $ IOError Nothing InvalidArgument "" "The function pointer for vkMergePipelineCaches is null" Nothing Nothing
    let vkMergePipelineCaches' = mkVkMergePipelineCaches vkMergePipelineCachesPtr
    pPSrcCaches <- ContT $ allocaBytes @PipelineCache ((Data.Vector.length (srcCaches)) * 8)
    lift $ Data.Vector.imapM_ (\i e -> poke (pPSrcCaches `plusPtr` (8 * (i)) :: Ptr PipelineCache) (e)) (srcCaches)
    r <- lift $ traceAroundEvent "vkMergePipelineCaches" (vkMergePipelineCaches'
                                                            (deviceHandle (device))
                                                            (dstCache)
                                                            ((fromIntegral (Data.Vector.length $ (srcCaches)) :: Word32))
                                                            (pPSrcCaches))
    lift $ when (r < SUCCESS) (throwIO (VulkanException r))
  
  
  -- | VkPipelineCacheCreateInfo - Structure specifying parameters of a newly
  -- created pipeline cache
  --
  -- == Valid Usage
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-initialDataSize-00768# If
  --     @initialDataSize@ is not @0@, it /must/ be equal to the size of
  --     @pInitialData@, as returned by 'getPipelineCacheData' when
  --     @pInitialData@ was originally retrieved
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-initialDataSize-00769# If
  --     @initialDataSize@ is not @0@, @pInitialData@ /must/ have been
  --     retrieved from a previous call to 'getPipelineCacheData'
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-pipelineCreationCacheControl-02892#
  --     If the
  --     <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#features-pipelineCreationCacheControl pipelineCreationCacheControl>
  --     feature is not enabled, @flags@ /must/ not include
  --     'Vulkan.Core10.Enums.PipelineCacheCreateFlagBits.PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT'
  --
  -- == Valid Usage (Implicit)
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-sType-sType# @sType@ /must/ be
  --     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO'
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-pNext-pNext# @pNext@ /must/ be
  --     @NULL@
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-flags-parameter# @flags@ /must/ be a
  --     valid combination of
  --     'Vulkan.Core10.Enums.PipelineCacheCreateFlagBits.PipelineCacheCreateFlagBits'
  --     values
  --
  -- -   #VUID-VkPipelineCacheCreateInfo-pInitialData-parameter# If
  --     @initialDataSize@ is not @0@, @pInitialData@ /must/ be a valid
  --     pointer to an array of @initialDataSize@ bytes
  --
  -- = 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.Enums.PipelineCacheCreateFlagBits.PipelineCacheCreateFlags',
  -- 'Vulkan.Core10.Enums.StructureType.StructureType', 'createPipelineCache'
  data PipelineCacheCreateInfo = PipelineCacheCreateInfo
    { -- | @flags@ is a bitmask of
      -- 'Vulkan.Core10.Enums.PipelineCacheCreateFlagBits.PipelineCacheCreateFlagBits'
      -- specifying the behavior of the pipeline cache.
      flags :: PipelineCacheCreateFlags
    , -- | @initialDataSize@ is the number of bytes in @pInitialData@. If
      -- @initialDataSize@ is zero, the pipeline cache will initially be empty.
      initialDataSize :: Word64
    , -- | @pInitialData@ is a pointer to previously retrieved pipeline cache data.
      -- If the pipeline cache data is incompatible (as defined below) with the
      -- device, the pipeline cache will be initially empty. If @initialDataSize@
      -- is zero, @pInitialData@ is ignored.
      initialData :: Ptr ()
    }
    deriving (Typeable)
  #if defined(GENERIC_INSTANCES)
  deriving instance Generic (PipelineCacheCreateInfo)
  #endif
  deriving instance Show PipelineCacheCreateInfo
  
  instance ToCStruct PipelineCacheCreateInfo where
    withCStruct x f = allocaBytes 40 $ \p -> pokeCStruct p x (f p)
    pokeCStruct p PipelineCacheCreateInfo{..} f = do
      poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO)
      poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
      poke ((p `plusPtr` 16 :: Ptr PipelineCacheCreateFlags)) (flags)
      poke ((p `plusPtr` 24 :: Ptr CSize)) (CSize (initialDataSize))
      poke ((p `plusPtr` 32 :: Ptr (Ptr ()))) (initialData)
      f
    cStructSize = 40
    cStructAlignment = 8
    pokeZeroCStruct p f = do
      poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO)
      poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
      poke ((p `plusPtr` 32 :: Ptr (Ptr ()))) (zero)
      f
  
  instance FromCStruct PipelineCacheCreateInfo where
    peekCStruct p = do
      flags <- peek @PipelineCacheCreateFlags ((p `plusPtr` 16 :: Ptr PipelineCacheCreateFlags))
      initialDataSize <- peek @CSize ((p `plusPtr` 24 :: Ptr CSize))
      pInitialData <- peek @(Ptr ()) ((p `plusPtr` 32 :: Ptr (Ptr ())))
      pure $ PipelineCacheCreateInfo
               flags (coerce @CSize @Word64 initialDataSize) pInitialData
  
  instance Storable PipelineCacheCreateInfo where
    sizeOf ~_ = 40
    alignment ~_ = 8
    peek = peekCStruct
    poke ptr poked = pokeCStruct ptr poked (pure ())
  
  instance Zero PipelineCacheCreateInfo where
    zero = PipelineCacheCreateInfo
             zero
             zero
             zero
  
  