{-# language CPP #-}
module Vulkan.Extensions.VK_KHR_external_semaphore_win32 ( getSemaphoreWin32HandleKHR
, importSemaphoreWin32HandleKHR
, ImportSemaphoreWin32HandleInfoKHR(..)
, ExportSemaphoreWin32HandleInfoKHR(..)
, D3D12FenceSubmitInfoKHR(..)
, SemaphoreGetWin32HandleInfoKHR(..)
, KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION
, pattern KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION
, KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME
, pattern KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME
, HANDLE
, DWORD
, LPCWSTR
, SECURITY_ATTRIBUTES
) 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 (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 qualified Data.Vector (null)
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.String (IsString)
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.Word (Word64)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Extensions.VK_NV_external_memory_win32 (DWORD)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkGetSemaphoreWin32HandleKHR))
import Vulkan.Dynamic (DeviceCmds(pVkImportSemaphoreWin32HandleKHR))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.Core11.Enums.ExternalSemaphoreHandleTypeFlagBits (ExternalSemaphoreHandleTypeFlagBits)
import Vulkan.Extensions.VK_NV_external_memory_win32 (HANDLE)
import Vulkan.Extensions.VK_KHR_external_memory_win32 (LPCWSTR)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.Extensions.VK_NV_external_memory_win32 (SECURITY_ATTRIBUTES)
import Vulkan.Core10.Handles (Semaphore)
import Vulkan.Core11.Enums.SemaphoreImportFlagBits (SemaphoreImportFlags)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Extensions.VK_NV_external_memory_win32 (DWORD)
import Vulkan.Extensions.VK_NV_external_memory_win32 (HANDLE)
import Vulkan.Extensions.VK_KHR_external_memory_win32 (LPCWSTR)
import Vulkan.Extensions.VK_NV_external_memory_win32 (SECURITY_ATTRIBUTES)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetSemaphoreWin32HandleKHR
:: FunPtr (Ptr Device_T -> Ptr SemaphoreGetWin32HandleInfoKHR -> Ptr HANDLE -> IO Result) -> Ptr Device_T -> Ptr SemaphoreGetWin32HandleInfoKHR -> Ptr HANDLE -> IO Result
getSemaphoreWin32HandleKHR :: forall io
. (MonadIO io)
=>
Device
->
SemaphoreGetWin32HandleInfoKHR
-> io (HANDLE)
getSemaphoreWin32HandleKHR :: forall (io :: * -> *).
MonadIO io =>
Device -> SemaphoreGetWin32HandleInfoKHR -> io HANDLE
getSemaphoreWin32HandleKHR Device
device SemaphoreGetWin32HandleInfoKHR
getWin32HandleInfo = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkGetSemaphoreWin32HandleKHRPtr :: FunPtr
(Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result)
vkGetSemaphoreWin32HandleKHRPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result)
pVkGetSemaphoreWin32HandleKHR (case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result)
vkGetSemaphoreWin32HandleKHRPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkGetSemaphoreWin32HandleKHR is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkGetSemaphoreWin32HandleKHR' :: Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result
vkGetSemaphoreWin32HandleKHR' = FunPtr
(Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result)
-> Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result
mkVkGetSemaphoreWin32HandleKHR FunPtr
(Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result)
vkGetSemaphoreWin32HandleKHRPtr
"pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
pGetWin32HandleInfo <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (SemaphoreGetWin32HandleInfoKHR
getWin32HandleInfo)
"pHandle" ::: Ptr HANDLE
pPHandle <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @HANDLE Int
8) forall a. Ptr a -> IO ()
free
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetSemaphoreWin32HandleKHR" (Ptr Device_T
-> ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> ("pHandle" ::: Ptr HANDLE)
-> IO Result
vkGetSemaphoreWin32HandleKHR'
(Device -> Ptr Device_T
deviceHandle (Device
device))
"pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
pGetWin32HandleInfo
("pHandle" ::: Ptr HANDLE
pPHandle))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
HANDLE
pHandle <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @HANDLE "pHandle" ::: Ptr HANDLE
pPHandle
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (HANDLE
pHandle)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkImportSemaphoreWin32HandleKHR
:: FunPtr (Ptr Device_T -> Ptr ImportSemaphoreWin32HandleInfoKHR -> IO Result) -> Ptr Device_T -> Ptr ImportSemaphoreWin32HandleInfoKHR -> IO Result
importSemaphoreWin32HandleKHR :: forall io
. (MonadIO io)
=>
Device
->
ImportSemaphoreWin32HandleInfoKHR
-> io ()
importSemaphoreWin32HandleKHR :: forall (io :: * -> *).
MonadIO io =>
Device -> ImportSemaphoreWin32HandleInfoKHR -> io ()
importSemaphoreWin32HandleKHR Device
device
ImportSemaphoreWin32HandleInfoKHR
importSemaphoreWin32HandleInfo = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkImportSemaphoreWin32HandleKHRPtr :: FunPtr
(Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result)
vkImportSemaphoreWin32HandleKHRPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result)
pVkImportSemaphoreWin32HandleKHR (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result)
vkImportSemaphoreWin32HandleKHRPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkImportSemaphoreWin32HandleKHR is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkImportSemaphoreWin32HandleKHR' :: Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result
vkImportSemaphoreWin32HandleKHR' = FunPtr
(Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result)
-> Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result
mkVkImportSemaphoreWin32HandleKHR FunPtr
(Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result)
vkImportSemaphoreWin32HandleKHRPtr
"pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
pImportSemaphoreWin32HandleInfo <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ImportSemaphoreWin32HandleInfoKHR
importSemaphoreWin32HandleInfo)
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkImportSemaphoreWin32HandleKHR" (Ptr Device_T
-> ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO Result
vkImportSemaphoreWin32HandleKHR'
(Device -> Ptr Device_T
deviceHandle (Device
device))
"pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
pImportSemaphoreWin32HandleInfo)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
data ImportSemaphoreWin32HandleInfoKHR = ImportSemaphoreWin32HandleInfoKHR
{
ImportSemaphoreWin32HandleInfoKHR -> Semaphore
semaphore :: Semaphore
,
ImportSemaphoreWin32HandleInfoKHR -> SemaphoreImportFlags
flags :: SemaphoreImportFlags
,
ImportSemaphoreWin32HandleInfoKHR
-> ExternalSemaphoreHandleTypeFlagBits
handleType :: ExternalSemaphoreHandleTypeFlagBits
,
ImportSemaphoreWin32HandleInfoKHR -> HANDLE
handle :: HANDLE
,
ImportSemaphoreWin32HandleInfoKHR -> LPCWSTR
name :: LPCWSTR
}
deriving (Typeable, ImportSemaphoreWin32HandleInfoKHR
-> ImportSemaphoreWin32HandleInfoKHR -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportSemaphoreWin32HandleInfoKHR
-> ImportSemaphoreWin32HandleInfoKHR -> Bool
$c/= :: ImportSemaphoreWin32HandleInfoKHR
-> ImportSemaphoreWin32HandleInfoKHR -> Bool
== :: ImportSemaphoreWin32HandleInfoKHR
-> ImportSemaphoreWin32HandleInfoKHR -> Bool
$c== :: ImportSemaphoreWin32HandleInfoKHR
-> ImportSemaphoreWin32HandleInfoKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ImportSemaphoreWin32HandleInfoKHR)
#endif
deriving instance Show ImportSemaphoreWin32HandleInfoKHR
instance ToCStruct ImportSemaphoreWin32HandleInfoKHR where
withCStruct :: forall b.
ImportSemaphoreWin32HandleInfoKHR
-> (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO b)
-> IO b
withCStruct ImportSemaphoreWin32HandleInfoKHR
x ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
48 forall a b. (a -> b) -> a -> b
$ \"pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p ImportSemaphoreWin32HandleInfoKHR
x (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO b
f "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p)
pokeCStruct :: forall b.
("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> ImportSemaphoreWin32HandleInfoKHR -> IO b -> IO b
pokeCStruct "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p ImportSemaphoreWin32HandleInfoKHR{HANDLE
LPCWSTR
Semaphore
SemaphoreImportFlags
ExternalSemaphoreHandleTypeFlagBits
name :: LPCWSTR
handle :: HANDLE
handleType :: ExternalSemaphoreHandleTypeFlagBits
flags :: SemaphoreImportFlags
semaphore :: Semaphore
$sel:name:ImportSemaphoreWin32HandleInfoKHR :: ImportSemaphoreWin32HandleInfoKHR -> LPCWSTR
$sel:handle:ImportSemaphoreWin32HandleInfoKHR :: ImportSemaphoreWin32HandleInfoKHR -> HANDLE
$sel:handleType:ImportSemaphoreWin32HandleInfoKHR :: ImportSemaphoreWin32HandleInfoKHR
-> ExternalSemaphoreHandleTypeFlagBits
$sel:flags:ImportSemaphoreWin32HandleInfoKHR :: ImportSemaphoreWin32HandleInfoKHR -> SemaphoreImportFlags
$sel:semaphore:ImportSemaphoreWin32HandleInfoKHR :: ImportSemaphoreWin32HandleInfoKHR -> Semaphore
..} IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore)) (Semaphore
semaphore)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr SemaphoreImportFlags)) (SemaphoreImportFlags
flags)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
28 :: Ptr ExternalSemaphoreHandleTypeFlagBits)) (ExternalSemaphoreHandleTypeFlagBits
handleType)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr HANDLE)) (HANDLE
handle)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr LPCWSTR)) (LPCWSTR
name)
IO b
f
cStructSize :: Int
cStructSize = Int
48
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b.
("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO b -> IO b
pokeZeroCStruct "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore)) (forall a. Zero a => a
zero)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
28 :: Ptr ExternalSemaphoreHandleTypeFlagBits)) (forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ImportSemaphoreWin32HandleInfoKHR where
peekCStruct :: ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO ImportSemaphoreWin32HandleInfoKHR
peekCStruct "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p = do
Semaphore
semaphore <- forall a. Storable a => Ptr a -> IO a
peek @Semaphore (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore))
SemaphoreImportFlags
flags <- forall a. Storable a => Ptr a -> IO a
peek @SemaphoreImportFlags (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr SemaphoreImportFlags))
ExternalSemaphoreHandleTypeFlagBits
handleType <- forall a. Storable a => Ptr a -> IO a
peek @ExternalSemaphoreHandleTypeFlagBits (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
28 :: Ptr ExternalSemaphoreHandleTypeFlagBits))
HANDLE
handle <- forall a. Storable a => Ptr a -> IO a
peek @HANDLE (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr HANDLE))
LPCWSTR
name <- forall a. Storable a => Ptr a -> IO a
peek @LPCWSTR (("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr LPCWSTR))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Semaphore
-> SemaphoreImportFlags
-> ExternalSemaphoreHandleTypeFlagBits
-> HANDLE
-> LPCWSTR
-> ImportSemaphoreWin32HandleInfoKHR
ImportSemaphoreWin32HandleInfoKHR
Semaphore
semaphore SemaphoreImportFlags
flags ExternalSemaphoreHandleTypeFlagBits
handleType HANDLE
handle LPCWSTR
name
instance Storable ImportSemaphoreWin32HandleInfoKHR where
sizeOf :: ImportSemaphoreWin32HandleInfoKHR -> Int
sizeOf ~ImportSemaphoreWin32HandleInfoKHR
_ = Int
48
alignment :: ImportSemaphoreWin32HandleInfoKHR -> Int
alignment ~ImportSemaphoreWin32HandleInfoKHR
_ = Int
8
peek :: ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> IO ImportSemaphoreWin32HandleInfoKHR
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR)
-> ImportSemaphoreWin32HandleInfoKHR -> IO ()
poke "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
ptr ImportSemaphoreWin32HandleInfoKHR
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pImportSemaphoreWin32HandleInfo"
::: Ptr ImportSemaphoreWin32HandleInfoKHR
ptr ImportSemaphoreWin32HandleInfoKHR
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ImportSemaphoreWin32HandleInfoKHR where
zero :: ImportSemaphoreWin32HandleInfoKHR
zero = Semaphore
-> SemaphoreImportFlags
-> ExternalSemaphoreHandleTypeFlagBits
-> HANDLE
-> LPCWSTR
-> ImportSemaphoreWin32HandleInfoKHR
ImportSemaphoreWin32HandleInfoKHR
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
data ExportSemaphoreWin32HandleInfoKHR = ExportSemaphoreWin32HandleInfoKHR
{
ExportSemaphoreWin32HandleInfoKHR -> Ptr SECURITY_ATTRIBUTES
attributes :: Ptr SECURITY_ATTRIBUTES
,
ExportSemaphoreWin32HandleInfoKHR -> DWORD
dwAccess :: DWORD
,
ExportSemaphoreWin32HandleInfoKHR -> LPCWSTR
name :: LPCWSTR
}
deriving (Typeable, ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> Bool
$c/= :: ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> Bool
== :: ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> Bool
$c== :: ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ExportSemaphoreWin32HandleInfoKHR)
#endif
deriving instance Show ExportSemaphoreWin32HandleInfoKHR
instance ToCStruct ExportSemaphoreWin32HandleInfoKHR where
withCStruct :: forall b.
ExportSemaphoreWin32HandleInfoKHR
-> (Ptr ExportSemaphoreWin32HandleInfoKHR -> IO b) -> IO b
withCStruct ExportSemaphoreWin32HandleInfoKHR
x Ptr ExportSemaphoreWin32HandleInfoKHR -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 forall a b. (a -> b) -> a -> b
$ \Ptr ExportSemaphoreWin32HandleInfoKHR
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ExportSemaphoreWin32HandleInfoKHR
p ExportSemaphoreWin32HandleInfoKHR
x (Ptr ExportSemaphoreWin32HandleInfoKHR -> IO b
f Ptr ExportSemaphoreWin32HandleInfoKHR
p)
pokeCStruct :: forall b.
Ptr ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> IO b -> IO b
pokeCStruct Ptr ExportSemaphoreWin32HandleInfoKHR
p ExportSemaphoreWin32HandleInfoKHR{DWORD
LPCWSTR
Ptr SECURITY_ATTRIBUTES
name :: LPCWSTR
dwAccess :: DWORD
attributes :: Ptr SECURITY_ATTRIBUTES
$sel:name:ExportSemaphoreWin32HandleInfoKHR :: ExportSemaphoreWin32HandleInfoKHR -> LPCWSTR
$sel:dwAccess:ExportSemaphoreWin32HandleInfoKHR :: ExportSemaphoreWin32HandleInfoKHR -> DWORD
$sel:attributes:ExportSemaphoreWin32HandleInfoKHR :: ExportSemaphoreWin32HandleInfoKHR -> Ptr SECURITY_ATTRIBUTES
..} IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr SECURITY_ATTRIBUTES))) (Ptr SECURITY_ATTRIBUTES
attributes)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DWORD)) (DWORD
dwAccess)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr LPCWSTR)) (LPCWSTR
name)
IO b
f
cStructSize :: Int
cStructSize = Int
40
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr ExportSemaphoreWin32HandleInfoKHR -> IO b -> IO b
pokeZeroCStruct Ptr ExportSemaphoreWin32HandleInfoKHR
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DWORD)) (forall a. Zero a => a
zero)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr LPCWSTR)) (forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ExportSemaphoreWin32HandleInfoKHR where
peekCStruct :: Ptr ExportSemaphoreWin32HandleInfoKHR
-> IO ExportSemaphoreWin32HandleInfoKHR
peekCStruct Ptr ExportSemaphoreWin32HandleInfoKHR
p = do
Ptr SECURITY_ATTRIBUTES
pAttributes <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr SECURITY_ATTRIBUTES) ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr SECURITY_ATTRIBUTES)))
DWORD
dwAccess <- forall a. Storable a => Ptr a -> IO a
peek @DWORD ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DWORD))
LPCWSTR
name <- forall a. Storable a => Ptr a -> IO a
peek @LPCWSTR ((Ptr ExportSemaphoreWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr LPCWSTR))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Ptr SECURITY_ATTRIBUTES
-> DWORD -> LPCWSTR -> ExportSemaphoreWin32HandleInfoKHR
ExportSemaphoreWin32HandleInfoKHR
Ptr SECURITY_ATTRIBUTES
pAttributes DWORD
dwAccess LPCWSTR
name
instance Storable ExportSemaphoreWin32HandleInfoKHR where
sizeOf :: ExportSemaphoreWin32HandleInfoKHR -> Int
sizeOf ~ExportSemaphoreWin32HandleInfoKHR
_ = Int
40
alignment :: ExportSemaphoreWin32HandleInfoKHR -> Int
alignment ~ExportSemaphoreWin32HandleInfoKHR
_ = Int
8
peek :: Ptr ExportSemaphoreWin32HandleInfoKHR
-> IO ExportSemaphoreWin32HandleInfoKHR
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr ExportSemaphoreWin32HandleInfoKHR
-> ExportSemaphoreWin32HandleInfoKHR -> IO ()
poke Ptr ExportSemaphoreWin32HandleInfoKHR
ptr ExportSemaphoreWin32HandleInfoKHR
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ExportSemaphoreWin32HandleInfoKHR
ptr ExportSemaphoreWin32HandleInfoKHR
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ExportSemaphoreWin32HandleInfoKHR where
zero :: ExportSemaphoreWin32HandleInfoKHR
zero = Ptr SECURITY_ATTRIBUTES
-> DWORD -> LPCWSTR -> ExportSemaphoreWin32HandleInfoKHR
ExportSemaphoreWin32HandleInfoKHR
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
data D3D12FenceSubmitInfoKHR = D3D12FenceSubmitInfoKHR
{
D3D12FenceSubmitInfoKHR -> DWORD
waitSemaphoreValuesCount :: Word32
,
D3D12FenceSubmitInfoKHR -> Vector Word64
waitSemaphoreValues :: Vector Word64
,
D3D12FenceSubmitInfoKHR -> DWORD
signalSemaphoreValuesCount :: Word32
,
D3D12FenceSubmitInfoKHR -> Vector Word64
signalSemaphoreValues :: Vector Word64
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (D3D12FenceSubmitInfoKHR)
#endif
deriving instance Show D3D12FenceSubmitInfoKHR
instance ToCStruct D3D12FenceSubmitInfoKHR where
withCStruct :: forall b.
D3D12FenceSubmitInfoKHR
-> (Ptr D3D12FenceSubmitInfoKHR -> IO b) -> IO b
withCStruct D3D12FenceSubmitInfoKHR
x Ptr D3D12FenceSubmitInfoKHR -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
48 forall a b. (a -> b) -> a -> b
$ \Ptr D3D12FenceSubmitInfoKHR
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr D3D12FenceSubmitInfoKHR
p D3D12FenceSubmitInfoKHR
x (Ptr D3D12FenceSubmitInfoKHR -> IO b
f Ptr D3D12FenceSubmitInfoKHR
p)
pokeCStruct :: forall b.
Ptr D3D12FenceSubmitInfoKHR
-> D3D12FenceSubmitInfoKHR -> IO b -> IO b
pokeCStruct Ptr D3D12FenceSubmitInfoKHR
p D3D12FenceSubmitInfoKHR{DWORD
Vector Word64
signalSemaphoreValues :: Vector Word64
signalSemaphoreValuesCount :: DWORD
waitSemaphoreValues :: Vector Word64
waitSemaphoreValuesCount :: DWORD
$sel:signalSemaphoreValues:D3D12FenceSubmitInfoKHR :: D3D12FenceSubmitInfoKHR -> Vector Word64
$sel:signalSemaphoreValuesCount:D3D12FenceSubmitInfoKHR :: D3D12FenceSubmitInfoKHR -> DWORD
$sel:waitSemaphoreValues:D3D12FenceSubmitInfoKHR :: D3D12FenceSubmitInfoKHR -> Vector Word64
$sel:waitSemaphoreValuesCount:D3D12FenceSubmitInfoKHR :: D3D12FenceSubmitInfoKHR -> DWORD
..} IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
let pWaitSemaphoreValuesLength :: Int
pWaitSemaphoreValuesLength = forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ (Vector Word64
waitSemaphoreValues)
DWORD
waitSemaphoreValuesCount'' <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ if (DWORD
waitSemaphoreValuesCount) forall a. Eq a => a -> a -> Bool
== DWORD
0
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pWaitSemaphoreValuesLength
else do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pWaitSemaphoreValuesLength forall a. Eq a => a -> a -> Bool
== (DWORD
waitSemaphoreValuesCount) Bool -> Bool -> Bool
|| Int
pWaitSemaphoreValuesLength forall a. Eq a => a -> a -> Bool
== Int
0) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pWaitSemaphoreValues must be empty or have 'waitSemaphoreValuesCount' elements" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DWORD
waitSemaphoreValuesCount)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) (DWORD
waitSemaphoreValuesCount'')
Ptr Word64
pWaitSemaphoreValues'' <- if forall a. Vector a -> Bool
Data.Vector.null (Vector Word64
waitSemaphoreValues)
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
else do
Ptr Word64
pPWaitSemaphoreValues <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Word64 (((forall a. Vector a -> Int
Data.Vector.length (Vector Word64
waitSemaphoreValues))) forall a. Num a => a -> a -> a
* Int
8)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Word64
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Word64
pPWaitSemaphoreValues forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) (Word64
e)) ((Vector Word64
waitSemaphoreValues))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Ptr Word64
pPWaitSemaphoreValues
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word64))) Ptr Word64
pWaitSemaphoreValues''
let pSignalSemaphoreValuesLength :: Int
pSignalSemaphoreValuesLength = forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ (Vector Word64
signalSemaphoreValues)
DWORD
signalSemaphoreValuesCount'' <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ if (DWORD
signalSemaphoreValuesCount) forall a. Eq a => a -> a -> Bool
== DWORD
0
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pSignalSemaphoreValuesLength
else do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pSignalSemaphoreValuesLength forall a. Eq a => a -> a -> Bool
== (DWORD
signalSemaphoreValuesCount) Bool -> Bool -> Bool
|| Int
pSignalSemaphoreValuesLength forall a. Eq a => a -> a -> Bool
== Int
0) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pSignalSemaphoreValues must be empty or have 'signalSemaphoreValuesCount' elements" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DWORD
signalSemaphoreValuesCount)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Word32)) (DWORD
signalSemaphoreValuesCount'')
Ptr Word64
pSignalSemaphoreValues'' <- if forall a. Vector a -> Bool
Data.Vector.null (Vector Word64
signalSemaphoreValues)
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
else do
Ptr Word64
pPSignalSemaphoreValues <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Word64 (((forall a. Vector a -> Int
Data.Vector.length (Vector Word64
signalSemaphoreValues))) forall a. Num a => a -> a -> a
* Int
8)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Word64
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Word64
pPSignalSemaphoreValues forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) (Word64
e)) ((Vector Word64
signalSemaphoreValues))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Ptr Word64
pPSignalSemaphoreValues
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr Word64))) Ptr Word64
pSignalSemaphoreValues''
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = Int
48
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr D3D12FenceSubmitInfoKHR -> IO b -> IO b
pokeZeroCStruct Ptr D3D12FenceSubmitInfoKHR
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
IO b
f
instance FromCStruct D3D12FenceSubmitInfoKHR where
peekCStruct :: Ptr D3D12FenceSubmitInfoKHR -> IO D3D12FenceSubmitInfoKHR
peekCStruct Ptr D3D12FenceSubmitInfoKHR
p = do
DWORD
waitSemaphoreValuesCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
Ptr Word64
pWaitSemaphoreValues <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word64) ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word64)))
let pWaitSemaphoreValuesLength :: Int
pWaitSemaphoreValuesLength = if Ptr Word64
pWaitSemaphoreValues forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr then Int
0 else (forall a b. (Integral a, Num b) => a -> b
fromIntegral DWORD
waitSemaphoreValuesCount)
Vector Word64
pWaitSemaphoreValues' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pWaitSemaphoreValuesLength (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word64 ((Ptr Word64
pWaitSemaphoreValues forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
DWORD
signalSemaphoreValuesCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Word32))
Ptr Word64
pSignalSemaphoreValues <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word64) ((Ptr D3D12FenceSubmitInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr Word64)))
let pSignalSemaphoreValuesLength :: Int
pSignalSemaphoreValuesLength = if Ptr Word64
pSignalSemaphoreValues forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr then Int
0 else (forall a b. (Integral a, Num b) => a -> b
fromIntegral DWORD
signalSemaphoreValuesCount)
Vector Word64
pSignalSemaphoreValues' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pSignalSemaphoreValuesLength (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word64 ((Ptr Word64
pSignalSemaphoreValues forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ DWORD
-> Vector Word64
-> DWORD
-> Vector Word64
-> D3D12FenceSubmitInfoKHR
D3D12FenceSubmitInfoKHR
DWORD
waitSemaphoreValuesCount
Vector Word64
pWaitSemaphoreValues'
DWORD
signalSemaphoreValuesCount
Vector Word64
pSignalSemaphoreValues'
instance Zero D3D12FenceSubmitInfoKHR where
zero :: D3D12FenceSubmitInfoKHR
zero = DWORD
-> Vector Word64
-> DWORD
-> Vector Word64
-> D3D12FenceSubmitInfoKHR
D3D12FenceSubmitInfoKHR
forall a. Zero a => a
zero
forall a. Monoid a => a
mempty
forall a. Zero a => a
zero
forall a. Monoid a => a
mempty
data SemaphoreGetWin32HandleInfoKHR = SemaphoreGetWin32HandleInfoKHR
{
SemaphoreGetWin32HandleInfoKHR -> Semaphore
semaphore :: Semaphore
,
SemaphoreGetWin32HandleInfoKHR
-> ExternalSemaphoreHandleTypeFlagBits
handleType :: ExternalSemaphoreHandleTypeFlagBits
}
deriving (Typeable, SemaphoreGetWin32HandleInfoKHR
-> SemaphoreGetWin32HandleInfoKHR -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SemaphoreGetWin32HandleInfoKHR
-> SemaphoreGetWin32HandleInfoKHR -> Bool
$c/= :: SemaphoreGetWin32HandleInfoKHR
-> SemaphoreGetWin32HandleInfoKHR -> Bool
== :: SemaphoreGetWin32HandleInfoKHR
-> SemaphoreGetWin32HandleInfoKHR -> Bool
$c== :: SemaphoreGetWin32HandleInfoKHR
-> SemaphoreGetWin32HandleInfoKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SemaphoreGetWin32HandleInfoKHR)
#endif
deriving instance Show SemaphoreGetWin32HandleInfoKHR
instance ToCStruct SemaphoreGetWin32HandleInfoKHR where
withCStruct :: forall b.
SemaphoreGetWin32HandleInfoKHR
-> (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> IO b)
-> IO b
withCStruct SemaphoreGetWin32HandleInfoKHR
x ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 forall a b. (a -> b) -> a -> b
$ \"pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p SemaphoreGetWin32HandleInfoKHR
x (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> IO b
f "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p)
pokeCStruct :: forall b.
("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> SemaphoreGetWin32HandleInfoKHR -> IO b -> IO b
pokeCStruct "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p SemaphoreGetWin32HandleInfoKHR{Semaphore
ExternalSemaphoreHandleTypeFlagBits
handleType :: ExternalSemaphoreHandleTypeFlagBits
semaphore :: Semaphore
$sel:handleType:SemaphoreGetWin32HandleInfoKHR :: SemaphoreGetWin32HandleInfoKHR
-> ExternalSemaphoreHandleTypeFlagBits
$sel:semaphore:SemaphoreGetWin32HandleInfoKHR :: SemaphoreGetWin32HandleInfoKHR -> Semaphore
..} IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore)) (Semaphore
semaphore)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr ExternalSemaphoreHandleTypeFlagBits)) (ExternalSemaphoreHandleTypeFlagBits
handleType)
IO b
f
cStructSize :: Int
cStructSize = Int
32
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b.
("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> IO b -> IO b
pokeZeroCStruct "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore)) (forall a. Zero a => a
zero)
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr ExternalSemaphoreHandleTypeFlagBits)) (forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SemaphoreGetWin32HandleInfoKHR where
peekCStruct :: ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> IO SemaphoreGetWin32HandleInfoKHR
peekCStruct "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p = do
Semaphore
semaphore <- forall a. Storable a => Ptr a -> IO a
peek @Semaphore (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore))
ExternalSemaphoreHandleTypeFlagBits
handleType <- forall a. Storable a => Ptr a -> IO a
peek @ExternalSemaphoreHandleTypeFlagBits (("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr ExternalSemaphoreHandleTypeFlagBits))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Semaphore
-> ExternalSemaphoreHandleTypeFlagBits
-> SemaphoreGetWin32HandleInfoKHR
SemaphoreGetWin32HandleInfoKHR
Semaphore
semaphore ExternalSemaphoreHandleTypeFlagBits
handleType
instance Storable SemaphoreGetWin32HandleInfoKHR where
sizeOf :: SemaphoreGetWin32HandleInfoKHR -> Int
sizeOf ~SemaphoreGetWin32HandleInfoKHR
_ = Int
32
alignment :: SemaphoreGetWin32HandleInfoKHR -> Int
alignment ~SemaphoreGetWin32HandleInfoKHR
_ = Int
8
peek :: ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> IO SemaphoreGetWin32HandleInfoKHR
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR)
-> SemaphoreGetWin32HandleInfoKHR -> IO ()
poke "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
ptr SemaphoreGetWin32HandleInfoKHR
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pGetWin32HandleInfo" ::: Ptr SemaphoreGetWin32HandleInfoKHR
ptr SemaphoreGetWin32HandleInfoKHR
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SemaphoreGetWin32HandleInfoKHR where
zero :: SemaphoreGetWin32HandleInfoKHR
zero = Semaphore
-> ExternalSemaphoreHandleTypeFlagBits
-> SemaphoreGetWin32HandleInfoKHR
SemaphoreGetWin32HandleInfoKHR
forall a. Zero a => a
zero
forall a. Zero a => a
zero
type KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION = 1
pattern KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION :: forall a. Integral a => a
$mKHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION = 1
type KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME = "VK_KHR_external_semaphore_win32"
pattern KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
$mKHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME = "VK_KHR_external_semaphore_win32"