mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
st/oxr: Implement XR_KHR_win32_convert_performance_counter_time
This commit is contained in:
parent
1debb2e015
commit
32fd49d52b
|
@ -26,6 +26,7 @@ EXTENSIONS = (
|
|||
['XR_KHR_swapchain_usage_input_attachment_bit'],
|
||||
['XR_KHR_vulkan_enable', 'XR_USE_GRAPHICS_API_VULKAN'],
|
||||
['XR_KHR_vulkan_enable2', 'XR_USE_GRAPHICS_API_VULKAN'],
|
||||
['XR_KHR_win32_convert_performance_counter_time', 'XR_USE_PLATFORM_WIN32'],
|
||||
['XR_EXT_debug_utils', 'XRT_FEATURE_OPENXR_DEBUG_UTILS'],
|
||||
['XR_EXT_dpad_binding'],
|
||||
['XR_EXT_hand_tracking'],
|
||||
|
|
|
@ -86,6 +86,10 @@ if(ANDROID)
|
|||
target_link_libraries(st_oxr PRIVATE aux_android)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(st_oxr PRIVATE XR_USE_PLATFORM_WIN32)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
st_oxr
|
||||
PRIVATE
|
||||
|
|
|
@ -104,6 +104,18 @@ oxr_xrConvertTimespecTimeToTimeKHR(XrInstance instance, const struct timespec *t
|
|||
XRAPI_ATTR XrResult XRAPI_CALL
|
||||
oxr_xrConvertTimeToTimespecTimeKHR(XrInstance instance, XrTime time, struct timespec *timespecTime);
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
//! OpenXR API function @ep{xrConvertWin32PerformanceCounterToTimeKHR}
|
||||
XRAPI_ATTR XrResult XRAPI_CALL
|
||||
oxr_xrConvertWin32PerformanceCounterToTimeKHR(XrInstance instance,
|
||||
const LARGE_INTEGER *performanceCounter,
|
||||
XrTime *time);
|
||||
|
||||
//! OpenXR API function @ep{xrConvertTimeToWin32PerformanceCounterKHR}
|
||||
XRAPI_ATTR XrResult XRAPI_CALL
|
||||
oxr_xrConvertTimeToWin32PerformanceCounterKHR(XrInstance instance, XrTime time, LARGE_INTEGER *performanceCounter);
|
||||
#endif // XR_USE_PLATFORM_WIN32
|
||||
|
||||
/*
|
||||
*
|
||||
* oxr_api_system.c
|
||||
|
|
|
@ -391,3 +391,43 @@ oxr_xrConvertTimeToTimespecTimeKHR(XrInstance instance, XrTime time, struct time
|
|||
}
|
||||
|
||||
#endif // XR_USE_TIMESPEC
|
||||
|
||||
// ---- XR_KHR_win32_convert_performance_counter_time extension
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
XrResult
|
||||
oxr_xrConvertWin32PerformanceCounterToTimeKHR(XrInstance instance,
|
||||
const LARGE_INTEGER *performanceCounter,
|
||||
XrTime *time)
|
||||
{
|
||||
OXR_TRACE_MARKER();
|
||||
|
||||
//! @todo do we need to check and see if this extension was
|
||||
//! enabled first?
|
||||
struct oxr_instance *inst;
|
||||
struct oxr_logger log;
|
||||
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrConvertWin32PerformanceCounterToTimeKHR");
|
||||
OXR_VERIFY_EXTENSION(&log, inst, KHR_win32_convert_performance_counter_time);
|
||||
OXR_VERIFY_ARG_NOT_NULL(&log, performanceCounter);
|
||||
OXR_VERIFY_ARG_NOT_NULL(&log, time);
|
||||
return oxr_instance_convert_win32perfcounter_to_time(&log, inst, performanceCounter, time);
|
||||
}
|
||||
|
||||
XrResult
|
||||
oxr_xrConvertTimeToWin32PerformanceCounterKHR(XrInstance instance, XrTime time, LARGE_INTEGER *performanceCounter)
|
||||
{
|
||||
OXR_TRACE_MARKER();
|
||||
|
||||
struct oxr_instance *inst;
|
||||
struct oxr_logger log;
|
||||
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrConvertTimeToWin32PerformanceCounterKHR");
|
||||
OXR_VERIFY_EXTENSION(&log, inst, KHR_win32_convert_performance_counter_time);
|
||||
OXR_VERIFY_ARG_NOT_NULL(&log, performanceCounter);
|
||||
|
||||
if (time <= (XrTime)0) {
|
||||
return oxr_error(&log, XR_ERROR_TIME_INVALID, "(time == %" PRIi64 ") is not a valid time.", time);
|
||||
}
|
||||
|
||||
return oxr_instance_convert_time_to_win32perfcounter(&log, inst, time, performanceCounter);
|
||||
}
|
||||
|
||||
#endif // XR_USE_PLATFORM_WIN32
|
||||
|
|
|
@ -213,6 +213,11 @@ handle_non_null(struct oxr_instance *inst, struct oxr_logger *log, const char *n
|
|||
ENTRY_IF_EXT(xrConvertTimeToTimespecTimeKHR, KHR_convert_timespec_time);
|
||||
#endif // OXR_HAVE_KHR_convert_timespec_time
|
||||
|
||||
#ifdef OXR_HAVE_KHR_win32_convert_performance_counter_time
|
||||
ENTRY_IF_EXT(xrConvertWin32PerformanceCounterToTimeKHR, KHR_win32_convert_performance_counter_time);
|
||||
ENTRY_IF_EXT(xrConvertTimeToWin32PerformanceCounterKHR, KHR_win32_convert_performance_counter_time);
|
||||
#endif // OXR_HAVE_KHR_win32_convert_performance_counter_time
|
||||
|
||||
#ifdef OXR_HAVE_EXT_performance_settings
|
||||
ENTRY_IF_EXT(xrPerfSettingsSetPerformanceLevelEXT, EXT_performance_settings);
|
||||
#endif // OXR_HAVE_EXT_performance_settings
|
||||
|
|
|
@ -201,6 +201,18 @@
|
|||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* XR_KHR_win32_convert_performance_counter_time
|
||||
*/
|
||||
#if defined(XR_KHR_win32_convert_performance_counter_time) && defined(XR_USE_PLATFORM_WIN32)
|
||||
#define OXR_HAVE_KHR_win32_convert_performance_counter_time
|
||||
#define OXR_EXTENSION_SUPPORT_KHR_win32_convert_performance_counter_time(_) \
|
||||
_(KHR_win32_convert_performance_counter_time, KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME)
|
||||
#else
|
||||
#define OXR_EXTENSION_SUPPORT_KHR_win32_convert_performance_counter_time(_)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* XR_EXT_debug_utils
|
||||
*/
|
||||
|
@ -341,6 +353,7 @@
|
|||
OXR_EXTENSION_SUPPORT_KHR_swapchain_usage_input_attachment_bit(_) \
|
||||
OXR_EXTENSION_SUPPORT_KHR_vulkan_enable(_) \
|
||||
OXR_EXTENSION_SUPPORT_KHR_vulkan_enable2(_) \
|
||||
OXR_EXTENSION_SUPPORT_KHR_win32_convert_performance_counter_time(_) \
|
||||
OXR_EXTENSION_SUPPORT_EXT_debug_utils(_) \
|
||||
OXR_EXTENSION_SUPPORT_EXT_dpad_binding(_) \
|
||||
OXR_EXTENSION_SUPPORT_EXT_hand_tracking(_) \
|
||||
|
|
|
@ -416,3 +416,27 @@ oxr_instance_convert_timespec_to_time(struct oxr_logger *log,
|
|||
return XR_SUCCESS;
|
||||
}
|
||||
#endif // XR_USE_TIMESPEC
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
|
||||
XrResult
|
||||
oxr_instance_convert_time_to_win32perfcounter(struct oxr_logger *log,
|
||||
struct oxr_instance *inst,
|
||||
XrTime time,
|
||||
LARGE_INTEGER *win32perfcounterTime)
|
||||
{
|
||||
time_state_to_win32perfcounter(inst->timekeeping, time, win32perfcounterTime);
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
XrResult
|
||||
oxr_instance_convert_win32perfcounter_to_time(struct oxr_logger *log,
|
||||
struct oxr_instance *inst,
|
||||
const LARGE_INTEGER *win32perfcounterTime,
|
||||
XrTime *time)
|
||||
{
|
||||
*time = time_state_from_win32perfcounter(inst->timekeeping, win32perfcounterTime);
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // XR_USE_PLATFORM_WIN32
|
||||
|
|
|
@ -314,6 +314,28 @@ oxr_instance_convert_timespec_to_time(struct oxr_logger *log,
|
|||
XrTime *time);
|
||||
#endif // XR_USE_TIMESPEC
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
|
||||
/*!
|
||||
* @public @memberof oxr_instance
|
||||
*/
|
||||
XrResult
|
||||
oxr_instance_convert_time_to_win32perfcounter(struct oxr_logger *log,
|
||||
struct oxr_instance *inst,
|
||||
XrTime time,
|
||||
LARGE_INTEGER *win32perfcounterTime);
|
||||
|
||||
/*!
|
||||
* @public @memberof oxr_instance
|
||||
*/
|
||||
XrResult
|
||||
oxr_instance_convert_win32perfcounter_to_time(struct oxr_logger *log,
|
||||
struct oxr_instance *inst,
|
||||
const LARGE_INTEGER *win32perfcounterTime,
|
||||
XrTime *time);
|
||||
|
||||
#endif // XR_USE_PLATFORM_WIN32
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue