xrt: Add performance settings interface

Used to implement XR_EXT_performance_settings.
This commit is contained in:
huanchen 2023-08-23 16:17:40 +08:00 committed by Jakob Bornecrantz
parent 921a373352
commit 3d5c16fdba
3 changed files with 75 additions and 0 deletions

View file

@ -1271,6 +1271,13 @@ struct xrt_compositor
/*! @} */
/*!
* @brief Set CPU/GPU performance level.
*/
xrt_result_t (*set_performance_level)(struct xrt_compositor *xc,
enum xrt_perf_domain domain,
enum xrt_perf_set_level level);
/*!
* Teardown the compositor.
*
@ -1696,6 +1703,19 @@ xrt_comp_request_display_refresh_rate(struct xrt_compositor *xc, float display_r
}
/*!
* @copydoc xrt_compositor::set_performance_level
*
* Helper for calling through the function pointer.
*
* @public @memberof xrt_compositor
*/
static inline xrt_result_t
xrt_comp_set_performance_level(struct xrt_compositor *xc, enum xrt_perf_domain domain, enum xrt_perf_set_level level)
{
return xc->set_performance_level(xc, domain, level);
}
/*!
* @copydoc xrt_compositor::destroy
*

View file

@ -1321,6 +1321,45 @@ enum xrt_form_factor
XRT_FORM_FACTOR_HANDHELD, //!< Handheld display.
};
/*!
* Domain type.
* Use for performance level setting
* Which hardware should be boost/decrease
*/
enum xrt_perf_domain
{
XRT_PERF_DOMAIN_CPU = 1,
XRT_PERF_DOMAIN_GPU = 2,
};
enum xrt_perf_sub_domain
{
XRT_PERF_SUB_DOMAIN_COMPOSITING = 1,
XRT_PERF_SUB_DOMAIN_RENDERING = 2,
XRT_PERF_SUB_DOMAIN_THERMAL = 3
};
/*!
* Performance level.
*/
enum xrt_perf_set_level
{
XRT_PERF_SET_LEVEL_POWER_SAVINGS = 0,
XRT_PERF_SET_LEVEL_SUSTAINED_LOW = 25,
XRT_PERF_SET_LEVEL_SUSTAINED_HIGH = 50,
XRT_PERF_SET_LEVEL_BOOST = 75,
};
/*!
* Performance level.
*/
enum xrt_perf_notify_level
{
XRT_PERF_NOTIFY_LEVEL_NORMAL = 0,
XRT_PERF_NOTIFY_LEVEL_WARNING = 25,
XRT_PERF_NOTIFY_LEVEL_IMPAIRED = 75,
};
/*!
* Visibility mask, mirror of XrVisibilityMaskKHR
*

View file

@ -55,6 +55,9 @@ enum xrt_session_event_type
//! A reference space for this session has a pending change.
XRT_SESSION_EVENT_REFERENCE_SPACE_CHANGE_PENDING = 6,
//! The performance of the session has changed
XRT_SESSION_EVENT_PERFORMANCE_CHANGE = 7,
};
/*!
@ -137,6 +140,18 @@ struct xrt_session_event_reference_space_change_pending
bool pose_valid;
};
/*!
* Performance metrics change event.
*/
struct xrt_session_event_perf_change
{
enum xrt_session_event_type type;
enum xrt_perf_domain domain;
enum xrt_perf_sub_domain sub_domain;
enum xrt_perf_notify_level from_level;
enum xrt_perf_notify_level to_level;
};
/*!
* Union of all session events, used to return multiple events through one call.
* Each event struct must start with a @ref xrt_session_event_type field.
@ -152,6 +167,7 @@ union xrt_session_event {
struct xrt_session_event_lost lost;
struct xrt_session_event_display_refresh_rate_change display;
struct xrt_session_event_reference_space_change_pending ref_change;
struct xrt_session_event_perf_change performance;
};
/*!