// Copyright (c) 2017-2024, The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

include::{generated}/meta/XR_KHR_win32_convert_performance_counter_time.adoc[]

*Last Modified Date*::
   2019-01-24
*IP Status*::
    No known IP claims.
*Contributors*::
    Paul Pedriana, Oculus +
    Bryce Hutchings, Microsoft

*Overview*

This extension provides two functions for converting between the Windows
performance counter (QPC) time stamps and basetype:XrTime.
The flink:xrConvertWin32PerformanceCounterToTimeKHR function converts from
Windows performance counter time stamps to basetype:XrTime, while the
flink:xrConvertTimeToWin32PerformanceCounterKHR function converts
basetype:XrTime to Windows performance counter time stamps.
The primary use case for this functionality is to be able to synchronize
events between the local system and the OpenXR system.

*New Object Types*

*New Flag Types*

*New Enum Constants*

*New Enums*

*New Structures*

*New Functions*

[open,refpage='xrConvertWin32PerformanceCounterToTimeKHR',type='protos',desc='Convert Win32 code:QueryPerformanceCounter time to XrTime',xrefs='XrTime']
--
To convert from a Windows performance counter time stamp to basetype:XrTime,
call:

include::{generated}/api/protos/xrConvertWin32PerformanceCounterToTimeKHR.adoc[]

.Parameter Descriptions
****
* pname:instance is an slink:XrInstance handle previously created with
  flink:xrCreateInstance.
* pname:performanceCounter is a time returned by
  code:QueryPerformanceCounter.
* pname:time is the resulting basetype:XrTime that is equivalent to the
  pname:performanceCounter.
****

The flink:xrConvertWin32PerformanceCounterToTimeKHR function converts a time
stamp obtained by the code:QueryPerformanceCounter Windows function to the
equivalent basetype:XrTime.

If the output pname:time cannot represent the input
pname:performanceCounter, the runtime must: return
ename:XR_ERROR_TIME_INVALID.

include::{generated}/validity/protos/xrConvertWin32PerformanceCounterToTimeKHR.adoc[]
--

[open,refpage='xrConvertTimeToWin32PerformanceCounterKHR',type='protos',desc='Convert XrTime to Win32 code:QueryPerformanceCounter time',xrefs='XrTime']
--
To convert from basetype:XrTime to a Windows performance counter time stamp,
call:

include::{generated}/api/protos/xrConvertTimeToWin32PerformanceCounterKHR.adoc[]

.Parameter Descriptions
****
* pname:instance is an slink:XrInstance handle previously created with
  flink:xrCreateInstance.
* pname:time is an basetype:XrTime.
* pname:performanceCounter is the resulting Windows performance counter time
  stamp that is equivalent to the pname:time.
****

The flink:xrConvertTimeToWin32PerformanceCounterKHR function converts an
basetype:XrTime to time as if generated by the code:QueryPerformanceCounter
Windows function.

If the output pname:performanceCounter cannot represent the input
pname:time, the runtime must: return ename:XR_ERROR_TIME_INVALID.

include::{generated}/validity/protos/xrConvertTimeToWin32PerformanceCounterKHR.adoc[]
--

*Issues*

*Version History*

* Revision 1, 2019-01-24 (Paul Pedriana)
** Initial draft

