{-# language CPP #-} -- | = Name -- -- XR_KHR_win32_convert_performance_counter_time - instance extension -- -- = Specification -- -- See -- -- in the main specification for complete information. -- -- = Registered Extension Number -- -- 36 -- -- = Revision -- -- 1 -- -- = Extension and Version Dependencies -- -- - Requires OpenXR 1.0 -- -- = See Also -- -- 'convertTimeToWin32PerformanceCounterKHR', -- 'convertWin32PerformanceCounterToTimeKHR' -- -- = Document Notes -- -- For more information, see the -- -- -- This page is a generated document. Fixes and changes should be made to -- the generator scripts, not directly. module OpenXR.Extensions.XR_KHR_win32_convert_performance_counter_time ( convertTimeToWin32PerformanceCounterKHR , convertWin32PerformanceCounterToTimeKHR , KHR_win32_convert_performance_counter_time_SPEC_VERSION , pattern KHR_win32_convert_performance_counter_time_SPEC_VERSION , KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME , pattern KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME , LARGE_INTEGER ) where import OpenXR.Internal.Utils (traceAroundEvent) import Control.Exception.Base (bracket) import Control.Monad (unless) import Control.Monad.IO.Class (liftIO) import Foreign.Marshal.Alloc (callocBytes) import Foreign.Marshal.Alloc (free) import Foreign.Marshal.Utils (with) import GHC.Base (when) import GHC.IO (throwIO) import GHC.Ptr (nullFunPtr) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Cont (evalContT) import Control.Monad.IO.Class (MonadIO) import Data.String (IsString) import Foreign.Storable (Storable(peek)) import GHC.IO.Exception (IOErrorType(..)) import GHC.IO.Exception (IOException(..)) import Foreign.Ptr (FunPtr) import Foreign.Ptr (Ptr) import Data.Word (Word64) import Control.Monad.Trans.Cont (ContT(..)) import OpenXR.NamedType ((:::)) import OpenXR.Core10.Handles (Instance) import OpenXR.Core10.Handles (Instance(..)) import OpenXR.Dynamic (InstanceCmds(pXrConvertTimeToWin32PerformanceCounterKHR)) import OpenXR.Dynamic (InstanceCmds(pXrConvertWin32PerformanceCounterToTimeKHR)) import OpenXR.Core10.Handles (Instance_T) import OpenXR.Exception (OpenXrException(..)) import OpenXR.Core10.Enums.Result (Result) import OpenXR.Core10.Enums.Result (Result(..)) import OpenXR.Core10.FundamentalTypes (Time) import OpenXR.Core10.Enums.Result (Result(SUCCESS)) foreign import ccall #if !defined(SAFE_FOREIGN_CALLS) unsafe #endif "dynamic" mkXrConvertTimeToWin32PerformanceCounterKHR :: FunPtr (Ptr Instance_T -> Time -> Ptr LARGE_INTEGER -> IO Result) -> Ptr Instance_T -> Time -> Ptr LARGE_INTEGER -> IO Result -- | xrConvertTimeToWin32PerformanceCounterKHR - Convert XrTime to Win32 -- @QueryPerformanceCounter@ time -- -- == Parameter Descriptions -- -- = Description -- -- The 'convertTimeToWin32PerformanceCounterKHR' function converts an -- -- to time as if generated by the @QueryPerformanceCounter@ Windows -- function. -- -- If the output @performanceCounter@ cannot represent the input @time@, -- the runtime /must/ return -- 'OpenXR.Core10.Enums.Result.ERROR_TIME_INVALID'. -- -- == Valid Usage (Implicit) -- -- - #VUID-xrConvertTimeToWin32PerformanceCounterKHR-extension-notenabled# -- The @@ extension /must/ be enabled prior to calling -- 'convertTimeToWin32PerformanceCounterKHR' -- -- - #VUID-xrConvertTimeToWin32PerformanceCounterKHR-instance-parameter# -- @instance@ /must/ be a valid 'OpenXR.Core10.Handles.Instance' handle -- -- - #VUID-xrConvertTimeToWin32PerformanceCounterKHR-performanceCounter-parameter# -- @performanceCounter@ /must/ be a pointer to a 'LARGE_INTEGER' value -- -- == Return Codes -- -- [] -- -- - 'OpenXR.Core10.Enums.Result.SUCCESS' -- -- [] -- -- - 'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_TIME_INVALID' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED' -- -- = See Also -- -- 'OpenXR.Core10.Handles.Instance', -- convertTimeToWin32PerformanceCounterKHR :: forall io . (MonadIO io) => -- | @instance@ is an 'OpenXR.Core10.Handles.Instance' handle previously -- created with 'OpenXR.Core10.Instance.createInstance'. Instance -> -- | @time@ is an -- . Time -> io (("performanceCounter" ::: LARGE_INTEGER)) convertTimeToWin32PerformanceCounterKHR instance' time = liftIO . evalContT $ do let xrConvertTimeToWin32PerformanceCounterKHRPtr = pXrConvertTimeToWin32PerformanceCounterKHR (instanceCmds (instance' :: Instance)) lift $ unless (xrConvertTimeToWin32PerformanceCounterKHRPtr /= nullFunPtr) $ throwIO $ IOError Nothing InvalidArgument "" "The function pointer for xrConvertTimeToWin32PerformanceCounterKHR is null" Nothing Nothing let xrConvertTimeToWin32PerformanceCounterKHR' = mkXrConvertTimeToWin32PerformanceCounterKHR xrConvertTimeToWin32PerformanceCounterKHRPtr pPerformanceCounter <- ContT $ bracket (callocBytes @LARGE_INTEGER 8) free r <- lift $ traceAroundEvent "xrConvertTimeToWin32PerformanceCounterKHR" (xrConvertTimeToWin32PerformanceCounterKHR' (instanceHandle (instance')) (time) (pPerformanceCounter)) lift $ when (r < SUCCESS) (throwIO (OpenXrException r)) performanceCounter <- lift $ peek @LARGE_INTEGER pPerformanceCounter pure $ (performanceCounter) foreign import ccall #if !defined(SAFE_FOREIGN_CALLS) unsafe #endif "dynamic" mkXrConvertWin32PerformanceCounterToTimeKHR :: FunPtr (Ptr Instance_T -> Ptr LARGE_INTEGER -> Ptr Time -> IO Result) -> Ptr Instance_T -> Ptr LARGE_INTEGER -> Ptr Time -> IO Result -- | xrConvertWin32PerformanceCounterToTimeKHR - Convert Win32 -- @QueryPerformanceCounter@ time to XrTime -- -- == Parameter Descriptions -- -- = Description -- -- The 'convertWin32PerformanceCounterToTimeKHR' function converts a time -- stamp obtained by the @QueryPerformanceCounter@ Windows function to the -- equivalent -- . -- -- If the output @time@ cannot represent the input @performanceCounter@, -- the runtime /must/ return -- 'OpenXR.Core10.Enums.Result.ERROR_TIME_INVALID'. -- -- == Valid Usage (Implicit) -- -- - #VUID-xrConvertWin32PerformanceCounterToTimeKHR-extension-notenabled# -- The @@ extension /must/ be enabled prior to calling -- 'convertWin32PerformanceCounterToTimeKHR' -- -- - #VUID-xrConvertWin32PerformanceCounterToTimeKHR-instance-parameter# -- @instance@ /must/ be a valid 'OpenXR.Core10.Handles.Instance' handle -- -- - #VUID-xrConvertWin32PerformanceCounterToTimeKHR-performanceCounter-parameter# -- @performanceCounter@ /must/ be a pointer to a valid 'LARGE_INTEGER' -- value -- -- - #VUID-xrConvertWin32PerformanceCounterToTimeKHR-time-parameter# -- @time@ /must/ be a pointer to an -- -- value -- -- == Return Codes -- -- [] -- -- - 'OpenXR.Core10.Enums.Result.SUCCESS' -- -- [] -- -- - 'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_TIME_INVALID' -- -- - 'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED' -- -- = See Also -- -- 'OpenXR.Core10.Handles.Instance', -- convertWin32PerformanceCounterToTimeKHR :: forall io . (MonadIO io) => -- | @instance@ is an 'OpenXR.Core10.Handles.Instance' handle previously -- created with 'OpenXR.Core10.Instance.createInstance'. Instance -> -- | @performanceCounter@ is a time returned by @QueryPerformanceCounter@. ("performanceCounter" ::: LARGE_INTEGER) -> io (Time) convertWin32PerformanceCounterToTimeKHR instance' performanceCounter = liftIO . evalContT $ do let xrConvertWin32PerformanceCounterToTimeKHRPtr = pXrConvertWin32PerformanceCounterToTimeKHR (instanceCmds (instance' :: Instance)) lift $ unless (xrConvertWin32PerformanceCounterToTimeKHRPtr /= nullFunPtr) $ throwIO $ IOError Nothing InvalidArgument "" "The function pointer for xrConvertWin32PerformanceCounterToTimeKHR is null" Nothing Nothing let xrConvertWin32PerformanceCounterToTimeKHR' = mkXrConvertWin32PerformanceCounterToTimeKHR xrConvertWin32PerformanceCounterToTimeKHRPtr performanceCounter' <- ContT $ with (performanceCounter) pTime <- ContT $ bracket (callocBytes @Time 8) free r <- lift $ traceAroundEvent "xrConvertWin32PerformanceCounterToTimeKHR" (xrConvertWin32PerformanceCounterToTimeKHR' (instanceHandle (instance')) performanceCounter' (pTime)) lift $ when (r < SUCCESS) (throwIO (OpenXrException r)) time <- lift $ peek @Time pTime pure $ (time) type KHR_win32_convert_performance_counter_time_SPEC_VERSION = 1 -- No documentation found for TopLevel "XR_KHR_win32_convert_performance_counter_time_SPEC_VERSION" pattern KHR_win32_convert_performance_counter_time_SPEC_VERSION :: forall a . Integral a => a pattern KHR_win32_convert_performance_counter_time_SPEC_VERSION = 1 type KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME = "XR_KHR_win32_convert_performance_counter_time" -- No documentation found for TopLevel "XR_KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME" pattern KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a pattern KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME = "XR_KHR_win32_convert_performance_counter_time" type LARGE_INTEGER = Word64