{-# language CPP #-}
module Vulkan.Extensions.VK_KHR_external_fence_fd  ( getFenceFdKHR
                                                   , importFenceFdKHR
                                                   , ImportFenceFdInfoKHR(..)
                                                   , FenceGetFdInfoKHR(..)
                                                   , KHR_EXTERNAL_FENCE_FD_SPEC_VERSION
                                                   , pattern KHR_EXTERNAL_FENCE_FD_SPEC_VERSION
                                                   , KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME
                                                   , pattern KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME
                                                   ) where

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 Foreign.C.Types (CInt(..))
import Control.Monad.IO.Class (MonadIO)
import Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.C.Types (CInt)
import Foreign.C.Types (CInt(CInt))
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 Data.Int (Int32)
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Vulkan.NamedType ((:::))
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Dynamic (DeviceCmds(pVkGetFenceFdKHR))
import Vulkan.Dynamic (DeviceCmds(pVkImportFenceFdKHR))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits (ExternalFenceHandleTypeFlagBits)
import Vulkan.Core10.Handles (Fence)
import Vulkan.Core11.Enums.FenceImportFlagBits (FenceImportFlags)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
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.Enums.StructureType (StructureType(STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkGetFenceFdKHR
  :: FunPtr (Ptr Device_T -> Ptr FenceGetFdInfoKHR -> Ptr CInt -> IO Result) -> Ptr Device_T -> Ptr FenceGetFdInfoKHR -> Ptr CInt -> IO Result

-- | vkGetFenceFdKHR - Get a POSIX file descriptor handle for a fence
--
-- = Description
--
-- Each call to 'getFenceFdKHR' /must/ create a new file descriptor and
-- transfer ownership of it to the application. To avoid leaking resources,
-- the application /must/ release ownership of the file descriptor when it
-- is no longer needed.
--
-- Note
--
-- Ownership can be released in many ways. For example, the application can
-- call @close@() on the file descriptor, or transfer ownership back to
-- Vulkan by using the file descriptor to import a fence payload.
--
-- If @pGetFdInfo->handleType@ is
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT'
-- and the fence is signaled at the time 'getFenceFdKHR' is called, @pFd@
-- /may/ return the value @-1@ instead of a valid file descriptor.
--
-- Where supported by the operating system, the implementation /must/ set
-- the file descriptor to be closed automatically when an @execve@ system
-- call is made.
--
-- Exporting a file descriptor from a fence /may/ have side effects
-- depending on the transference of the specified handle type, as described
-- in
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-fences-importing Importing Fence State>.
--
-- == 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_TOO_MANY_OBJECTS'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY'
--
-- = See Also
--
-- 'Vulkan.Core10.Handles.Device', 'FenceGetFdInfoKHR'
getFenceFdKHR :: forall io
               . (MonadIO io)
              => -- | @device@ is the logical device that created the fence being exported.
                 --
                 -- @device@ /must/ be a valid 'Vulkan.Core10.Handles.Device' handle
                 Device
              -> -- | @pGetFdInfo@ is a pointer to a 'FenceGetFdInfoKHR' structure containing
                 -- parameters of the export operation.
                 --
                 -- @pGetFdInfo@ /must/ be a valid pointer to a valid 'FenceGetFdInfoKHR'
                 -- structure
                 FenceGetFdInfoKHR
              -> io (("fd" ::: Int32))
getFenceFdKHR :: Device -> FenceGetFdInfoKHR -> io ("fd" ::: Int32)
getFenceFdKHR device :: Device
device getFdInfo :: FenceGetFdInfoKHR
getFdInfo = IO ("fd" ::: Int32) -> io ("fd" ::: Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("fd" ::: Int32) -> io ("fd" ::: Int32))
-> (ContT ("fd" ::: Int32) IO ("fd" ::: Int32)
    -> IO ("fd" ::: Int32))
-> ContT ("fd" ::: Int32) IO ("fd" ::: Int32)
-> io ("fd" ::: Int32)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("fd" ::: Int32) IO ("fd" ::: Int32) -> IO ("fd" ::: Int32)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("fd" ::: Int32) IO ("fd" ::: Int32) -> io ("fd" ::: Int32))
-> ContT ("fd" ::: Int32) IO ("fd" ::: Int32)
-> io ("fd" ::: Int32)
forall a b. (a -> b) -> a -> b
$ do
  let vkGetFenceFdKHRPtr :: FunPtr
  (Ptr Device_T
   -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
   -> ("pFd" ::: Ptr CInt)
   -> IO Result)
vkGetFenceFdKHRPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
      -> ("pFd" ::: Ptr CInt)
      -> IO Result)
pVkGetFenceFdKHR (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
  IO () -> ContT ("fd" ::: Int32) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("fd" ::: Int32) IO ())
-> IO () -> ContT ("fd" ::: Int32) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
   -> ("pFd" ::: Ptr CInt)
   -> IO Result)
vkGetFenceFdKHRPtr FunPtr
  (Ptr Device_T
   -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
   -> ("pFd" ::: Ptr CInt)
   -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
      -> ("pFd" ::: Ptr CInt)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
   -> ("pFd" ::: Ptr CInt)
   -> 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 vkGetFenceFdKHR is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkGetFenceFdKHR' :: Ptr Device_T
-> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> ("pFd" ::: Ptr CInt)
-> IO Result
vkGetFenceFdKHR' = FunPtr
  (Ptr Device_T
   -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
   -> ("pFd" ::: Ptr CInt)
   -> IO Result)
-> Ptr Device_T
-> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> ("pFd" ::: Ptr CInt)
-> IO Result
mkVkGetFenceFdKHR FunPtr
  (Ptr Device_T
   -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
   -> ("pFd" ::: Ptr CInt)
   -> IO Result)
vkGetFenceFdKHRPtr
  "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
pGetFdInfo <- ((("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO ("fd" ::: Int32))
 -> IO ("fd" ::: Int32))
-> ContT
     ("fd" ::: Int32) IO ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO ("fd" ::: Int32))
  -> IO ("fd" ::: Int32))
 -> ContT
      ("fd" ::: Int32) IO ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR))
-> ((("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
     -> IO ("fd" ::: Int32))
    -> IO ("fd" ::: Int32))
-> ContT
     ("fd" ::: Int32) IO ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
forall a b. (a -> b) -> a -> b
$ FenceGetFdInfoKHR
-> (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
    -> IO ("fd" ::: Int32))
-> IO ("fd" ::: Int32)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (FenceGetFdInfoKHR
getFdInfo)
  "pFd" ::: Ptr CInt
pPFd <- ((("pFd" ::: Ptr CInt) -> IO ("fd" ::: Int32))
 -> IO ("fd" ::: Int32))
-> ContT ("fd" ::: Int32) IO ("pFd" ::: Ptr CInt)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pFd" ::: Ptr CInt) -> IO ("fd" ::: Int32))
  -> IO ("fd" ::: Int32))
 -> ContT ("fd" ::: Int32) IO ("pFd" ::: Ptr CInt))
-> ((("pFd" ::: Ptr CInt) -> IO ("fd" ::: Int32))
    -> IO ("fd" ::: Int32))
-> ContT ("fd" ::: Int32) IO ("pFd" ::: Ptr CInt)
forall a b. (a -> b) -> a -> b
$ IO ("pFd" ::: Ptr CInt)
-> (("pFd" ::: Ptr CInt) -> IO ())
-> (("pFd" ::: Ptr CInt) -> IO ("fd" ::: Int32))
-> IO ("fd" ::: Int32)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pFd" ::: Ptr CInt)
forall a. Int -> IO (Ptr a)
callocBytes @CInt 4) ("pFd" ::: Ptr CInt) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT ("fd" ::: Int32) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("fd" ::: Int32) IO Result)
-> IO Result -> ContT ("fd" ::: Int32) IO Result
forall a b. (a -> b) -> a -> b
$ Ptr Device_T
-> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> ("pFd" ::: Ptr CInt)
-> IO Result
vkGetFenceFdKHR' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
pGetFdInfo ("pFd" ::: Ptr CInt
pPFd)
  IO () -> ContT ("fd" ::: Int32) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("fd" ::: Int32) IO ())
-> IO () -> ContT ("fd" ::: Int32) 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))
  CInt
pFd <- IO CInt -> ContT ("fd" ::: Int32) IO CInt
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO CInt -> ContT ("fd" ::: Int32) IO CInt)
-> IO CInt -> ContT ("fd" ::: Int32) IO CInt
forall a b. (a -> b) -> a -> b
$ ("pFd" ::: Ptr CInt) -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek @CInt "pFd" ::: Ptr CInt
pPFd
  ("fd" ::: Int32) -> ContT ("fd" ::: Int32) IO ("fd" ::: Int32)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("fd" ::: Int32) -> ContT ("fd" ::: Int32) IO ("fd" ::: Int32))
-> ("fd" ::: Int32) -> ContT ("fd" ::: Int32) IO ("fd" ::: Int32)
forall a b. (a -> b) -> a -> b
$ (((\(CInt a :: "fd" ::: Int32
a) -> "fd" ::: Int32
a) CInt
pFd))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkImportFenceFdKHR
  :: FunPtr (Ptr Device_T -> Ptr ImportFenceFdInfoKHR -> IO Result) -> Ptr Device_T -> Ptr ImportFenceFdInfoKHR -> IO Result

-- | vkImportFenceFdKHR - Import a fence from a POSIX file descriptor
--
-- = Description
--
-- Importing a fence payload from a file descriptor transfers ownership of
-- the file descriptor from the application to the Vulkan implementation.
-- The application /must/ not perform any operations on the file descriptor
-- after a successful import.
--
-- Applications /can/ import the same fence payload into multiple instances
-- of Vulkan, into the same instance from which it was exported, and
-- multiple times into a given Vulkan instance.
--
-- == 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_INVALID_EXTERNAL_HANDLE'
--
-- = See Also
--
-- 'Vulkan.Core10.Handles.Device', 'ImportFenceFdInfoKHR'
importFenceFdKHR :: forall io
                  . (MonadIO io)
                 => -- | @device@ is the logical device that created the fence.
                    --
                    -- @device@ /must/ be a valid 'Vulkan.Core10.Handles.Device' handle
                    Device
                 -> -- | @pImportFenceFdInfo@ is a pointer to a 'ImportFenceFdInfoKHR' structure
                    -- specifying the fence and import parameters.
                    --
                    -- @pImportFenceFdInfo@ /must/ be a valid pointer to a valid
                    -- 'ImportFenceFdInfoKHR' structure
                    ImportFenceFdInfoKHR
                 -> io ()
importFenceFdKHR :: Device -> ImportFenceFdInfoKHR -> io ()
importFenceFdKHR device :: Device
device importFenceFdInfo :: ImportFenceFdInfoKHR
importFenceFdInfo = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  let vkImportFenceFdKHRPtr :: FunPtr
  (Ptr Device_T
   -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
   -> IO Result)
vkImportFenceFdKHRPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
      -> IO Result)
pVkImportFenceFdKHR (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
   -> IO Result)
vkImportFenceFdKHRPtr FunPtr
  (Ptr Device_T
   -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
   -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
   -> 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 vkImportFenceFdKHR is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkImportFenceFdKHR' :: Ptr Device_T
-> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO Result
vkImportFenceFdKHR' = FunPtr
  (Ptr Device_T
   -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
   -> IO Result)
-> Ptr Device_T
-> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> IO Result
mkVkImportFenceFdKHR FunPtr
  (Ptr Device_T
   -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
   -> IO Result)
vkImportFenceFdKHRPtr
  "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
pImportFenceFdInfo <- ((("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO ())
 -> IO ())
-> ContT () IO ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO ())
  -> IO ())
 -> ContT () IO ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR))
-> ((("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO ())
    -> IO ())
-> ContT () IO ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
forall a b. (a -> b) -> a -> b
$ ImportFenceFdInfoKHR
-> (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO ())
-> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ImportFenceFdInfoKHR
importFenceFdInfo)
  Result
r <- IO Result -> ContT () IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT () IO Result)
-> IO Result -> ContT () IO Result
forall a b. (a -> b) -> a -> b
$ Ptr Device_T
-> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO Result
vkImportFenceFdKHR' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
pImportFenceFdInfo
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () 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))


-- | VkImportFenceFdInfoKHR - (None)
--
-- = Description
--
-- The handle types supported by @handleType@ are:
--
-- +------------------------------------------------------------------------------------------------+----------------------+-----------------------+
-- | Handle Type                                                                                    | Transference         | Permanence Supported  |
-- +================================================================================================+======================+=======================+
-- | 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT' | Reference            | Temporary,Permanent   |
-- +------------------------------------------------------------------------------------------------+----------------------+-----------------------+
-- | 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT'   | Copy                 | Temporary             |
-- +------------------------------------------------------------------------------------------------+----------------------+-----------------------+
--
-- Handle Types Supported by 'ImportFenceFdInfoKHR'
--
-- == Valid Usage
--
-- -   @handleType@ /must/ be a value included in the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-fence-handletypes-fd Handle Types Supported by >
--     table
--
-- -   @fd@ /must/ obey any requirements listed for @handleType@ in
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#external-fence-handle-types-compatibility external fence handle types compatibility>
--
-- If @handleType@ is
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT',
-- the special value @-1@ for @fd@ is treated like a valid sync file
-- descriptor referring to an object that has already signaled. The import
-- operation will succeed and the 'Vulkan.Core10.Handles.Fence' will have a
-- temporarily imported payload as if a valid file descriptor had been
-- provided.
--
-- Note
--
-- This special behavior for importing an invalid sync file descriptor
-- allows easier interoperability with other system APIs which use the
-- convention that an invalid sync file descriptor represents work that has
-- already completed and does not need to be waited for. It is consistent
-- with the option for implementations to return a @-1@ file descriptor
-- when exporting a
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT'
-- from a 'Vulkan.Core10.Handles.Fence' which is signaled.
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR'
--
-- -   @pNext@ /must/ be @NULL@
--
-- -   @fence@ /must/ be a valid 'Vulkan.Core10.Handles.Fence' handle
--
-- -   @flags@ /must/ be a valid combination of
--     'Vulkan.Core11.Enums.FenceImportFlagBits.FenceImportFlagBits' values
--
-- -   @handleType@ /must/ be a valid
--     'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits'
--     value
--
-- == Host Synchronization
--
-- -   Host access to @fence@ /must/ be externally synchronized
--
-- = See Also
--
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits',
-- 'Vulkan.Core10.Handles.Fence',
-- 'Vulkan.Core11.Enums.FenceImportFlagBits.FenceImportFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'importFenceFdKHR'
data ImportFenceFdInfoKHR = ImportFenceFdInfoKHR
  { -- | @fence@ is the fence into which the payload will be imported.
    ImportFenceFdInfoKHR -> Fence
fence :: Fence
  , -- | @flags@ is a bitmask of
    -- 'Vulkan.Core11.Enums.FenceImportFlagBits.FenceImportFlagBits' specifying
    -- additional parameters for the fence payload import operation.
    ImportFenceFdInfoKHR -> FenceImportFlags
flags :: FenceImportFlags
  , -- | @handleType@ specifies the type of @fd@.
    ImportFenceFdInfoKHR -> ExternalFenceHandleTypeFlagBits
handleType :: ExternalFenceHandleTypeFlagBits
  , -- | @fd@ is the external handle to import.
    ImportFenceFdInfoKHR -> "fd" ::: Int32
fd :: Int32
  }
  deriving (Typeable, ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool
(ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool)
-> (ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool)
-> Eq ImportFenceFdInfoKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool
$c/= :: ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool
== :: ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool
$c== :: ImportFenceFdInfoKHR -> ImportFenceFdInfoKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ImportFenceFdInfoKHR)
#endif
deriving instance Show ImportFenceFdInfoKHR

instance ToCStruct ImportFenceFdInfoKHR where
  withCStruct :: ImportFenceFdInfoKHR
-> (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b)
-> IO b
withCStruct x :: ImportFenceFdInfoKHR
x f :: ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b
f = Int
-> Int
-> (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 40 8 ((("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b)
 -> IO b)
-> (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b)
-> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p -> ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> ImportFenceFdInfoKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ImportFenceFdInfoKHR
x (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b
f "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p)
  pokeCStruct :: ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> ImportFenceFdInfoKHR -> IO b -> IO b
pokeCStruct p :: "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ImportFenceFdInfoKHR{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Fence -> Fence -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Fence)) (Fence
fence)
    Ptr FenceImportFlags -> FenceImportFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr FenceImportFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr FenceImportFlags)) (FenceImportFlags
flags)
    Ptr ExternalFenceHandleTypeFlagBits
-> ExternalFenceHandleTypeFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr ExternalFenceHandleTypeFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr ExternalFenceHandleTypeFlagBits)) (ExternalFenceHandleTypeFlagBits
handleType)
    ("pFd" ::: Ptr CInt) -> CInt -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> "pFd" ::: Ptr CInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr CInt)) (("fd" ::: Int32) -> CInt
CInt ("fd" ::: Int32
fd))
    IO b
f
  cStructSize :: Int
cStructSize = 40
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR) -> IO b -> IO b
pokeZeroCStruct p :: "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Fence -> Fence -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Fence)) (Fence
forall a. Zero a => a
zero)
    Ptr ExternalFenceHandleTypeFlagBits
-> ExternalFenceHandleTypeFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr ExternalFenceHandleTypeFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr ExternalFenceHandleTypeFlagBits)) (ExternalFenceHandleTypeFlagBits
forall a. Zero a => a
zero)
    ("pFd" ::: Ptr CInt) -> CInt -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> "pFd" ::: Ptr CInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr CInt)) (("fd" ::: Int32) -> CInt
CInt ("fd" ::: Int32
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct ImportFenceFdInfoKHR where
  peekCStruct :: ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> IO ImportFenceFdInfoKHR
peekCStruct p :: "pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p = do
    Fence
fence <- Ptr Fence -> IO Fence
forall a. Storable a => Ptr a -> IO a
peek @Fence (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Fence))
    FenceImportFlags
flags <- Ptr FenceImportFlags -> IO FenceImportFlags
forall a. Storable a => Ptr a -> IO a
peek @FenceImportFlags (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr FenceImportFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr FenceImportFlags))
    ExternalFenceHandleTypeFlagBits
handleType <- Ptr ExternalFenceHandleTypeFlagBits
-> IO ExternalFenceHandleTypeFlagBits
forall a. Storable a => Ptr a -> IO a
peek @ExternalFenceHandleTypeFlagBits (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> Ptr ExternalFenceHandleTypeFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr ExternalFenceHandleTypeFlagBits))
    CInt
fd <- ("pFd" ::: Ptr CInt) -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek @CInt (("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR
p ("pImportFenceFdInfo" ::: Ptr ImportFenceFdInfoKHR)
-> Int -> "pFd" ::: Ptr CInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr CInt))
    ImportFenceFdInfoKHR -> IO ImportFenceFdInfoKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ImportFenceFdInfoKHR -> IO ImportFenceFdInfoKHR)
-> ImportFenceFdInfoKHR -> IO ImportFenceFdInfoKHR
forall a b. (a -> b) -> a -> b
$ Fence
-> FenceImportFlags
-> ExternalFenceHandleTypeFlagBits
-> ("fd" ::: Int32)
-> ImportFenceFdInfoKHR
ImportFenceFdInfoKHR
             Fence
fence FenceImportFlags
flags ExternalFenceHandleTypeFlagBits
handleType ((\(CInt a :: "fd" ::: Int32
a) -> "fd" ::: Int32
a) CInt
fd)

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

instance Zero ImportFenceFdInfoKHR where
  zero :: ImportFenceFdInfoKHR
zero = Fence
-> FenceImportFlags
-> ExternalFenceHandleTypeFlagBits
-> ("fd" ::: Int32)
-> ImportFenceFdInfoKHR
ImportFenceFdInfoKHR
           Fence
forall a. Zero a => a
zero
           FenceImportFlags
forall a. Zero a => a
zero
           ExternalFenceHandleTypeFlagBits
forall a. Zero a => a
zero
           "fd" ::: Int32
forall a. Zero a => a
zero


-- | VkFenceGetFdInfoKHR - Structure describing a POSIX FD fence export
-- operation
--
-- = Description
--
-- The properties of the file descriptor returned depend on the value of
-- @handleType@. See
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits'
-- for a description of the properties of the defined external fence handle
-- types.
--
-- == Valid Usage
--
-- -   @handleType@ /must/ have been included in
--     'Vulkan.Core11.Promoted_From_VK_KHR_external_fence.ExportFenceCreateInfo'::@handleTypes@
--     when @fence@’s current payload was created
--
-- -   If @handleType@ refers to a handle type with copy payload
--     transference semantics, @fence@ /must/ be signaled, or have an
--     associated
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-fences-signaling fence signal operation>
--     pending execution
--
-- -   @fence@ /must/ not currently have its payload replaced by an
--     imported payload as described below in
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-fences-importing Importing Fence Payloads>
--     unless that imported payload’s handle type was included in
--     'Vulkan.Core11.Promoted_From_VK_KHR_external_fence_capabilities.ExternalFenceProperties'::@exportFromImportedHandleTypes@
--     for @handleType@
--
-- -   @handleType@ /must/ be defined as a POSIX file descriptor handle
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR'
--
-- -   @pNext@ /must/ be @NULL@
--
-- -   @fence@ /must/ be a valid 'Vulkan.Core10.Handles.Fence' handle
--
-- -   @handleType@ /must/ be a valid
--     'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits'
--     value
--
-- = See Also
--
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits',
-- 'Vulkan.Core10.Handles.Fence',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'getFenceFdKHR'
data FenceGetFdInfoKHR = FenceGetFdInfoKHR
  { -- | @fence@ is the fence from which state will be exported.
    FenceGetFdInfoKHR -> Fence
fence :: Fence
  , -- | @handleType@ is the type of handle requested.
    FenceGetFdInfoKHR -> ExternalFenceHandleTypeFlagBits
handleType :: ExternalFenceHandleTypeFlagBits
  }
  deriving (Typeable, FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool
(FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool)
-> (FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool)
-> Eq FenceGetFdInfoKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool
$c/= :: FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool
== :: FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool
$c== :: FenceGetFdInfoKHR -> FenceGetFdInfoKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (FenceGetFdInfoKHR)
#endif
deriving instance Show FenceGetFdInfoKHR

instance ToCStruct FenceGetFdInfoKHR where
  withCStruct :: FenceGetFdInfoKHR
-> (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b) -> IO b
withCStruct x :: FenceGetFdInfoKHR
x f :: ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b
f = Int
-> Int
-> (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b) -> IO b)
-> (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p -> ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> FenceGetFdInfoKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p FenceGetFdInfoKHR
x (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b
f "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p)
  pokeCStruct :: ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> FenceGetFdInfoKHR -> IO b -> IO b
pokeCStruct p :: "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p FenceGetFdInfoKHR{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Fence -> Fence -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> Int -> Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Fence)) (Fence
fence)
    Ptr ExternalFenceHandleTypeFlagBits
-> ExternalFenceHandleTypeFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> Int -> Ptr ExternalFenceHandleTypeFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr ExternalFenceHandleTypeFlagBits)) (ExternalFenceHandleTypeFlagBits
handleType)
    IO b
f
  cStructSize :: Int
cStructSize = 32
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO b -> IO b
pokeZeroCStruct p :: "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Fence -> Fence -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> Int -> Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Fence)) (Fence
forall a. Zero a => a
zero)
    Ptr ExternalFenceHandleTypeFlagBits
-> ExternalFenceHandleTypeFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> Int -> Ptr ExternalFenceHandleTypeFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr ExternalFenceHandleTypeFlagBits)) (ExternalFenceHandleTypeFlagBits
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct FenceGetFdInfoKHR where
  peekCStruct :: ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> IO FenceGetFdInfoKHR
peekCStruct p :: "pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p = do
    Fence
fence <- Ptr Fence -> IO Fence
forall a. Storable a => Ptr a -> IO a
peek @Fence (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR) -> Int -> Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Fence))
    ExternalFenceHandleTypeFlagBits
handleType <- Ptr ExternalFenceHandleTypeFlagBits
-> IO ExternalFenceHandleTypeFlagBits
forall a. Storable a => Ptr a -> IO a
peek @ExternalFenceHandleTypeFlagBits (("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR
p ("pGetFdInfo" ::: Ptr FenceGetFdInfoKHR)
-> Int -> Ptr ExternalFenceHandleTypeFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr ExternalFenceHandleTypeFlagBits))
    FenceGetFdInfoKHR -> IO FenceGetFdInfoKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FenceGetFdInfoKHR -> IO FenceGetFdInfoKHR)
-> FenceGetFdInfoKHR -> IO FenceGetFdInfoKHR
forall a b. (a -> b) -> a -> b
$ Fence -> ExternalFenceHandleTypeFlagBits -> FenceGetFdInfoKHR
FenceGetFdInfoKHR
             Fence
fence ExternalFenceHandleTypeFlagBits
handleType

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

instance Zero FenceGetFdInfoKHR where
  zero :: FenceGetFdInfoKHR
zero = Fence -> ExternalFenceHandleTypeFlagBits -> FenceGetFdInfoKHR
FenceGetFdInfoKHR
           Fence
forall a. Zero a => a
zero
           ExternalFenceHandleTypeFlagBits
forall a. Zero a => a
zero


type KHR_EXTERNAL_FENCE_FD_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_KHR_EXTERNAL_FENCE_FD_SPEC_VERSION"
pattern KHR_EXTERNAL_FENCE_FD_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_EXTERNAL_FENCE_FD_SPEC_VERSION :: a
$mKHR_EXTERNAL_FENCE_FD_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_EXTERNAL_FENCE_FD_SPEC_VERSION = 1


type KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME = "VK_KHR_external_fence_fd"

-- No documentation found for TopLevel "VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME"
pattern KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_EXTERNAL_FENCE_FD_EXTENSION_NAME :: a
$mKHR_EXTERNAL_FENCE_FD_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME = "VK_KHR_external_fence_fd"