From f84bef916f3b115c2df35f2a97a4ad75ee59e2e6 Mon Sep 17 00:00:00 2001 From: Zhongwang Zhang Date: Tue, 18 Apr 2023 14:25:03 +0800 Subject: [PATCH] xrt: Add hz suffix, follow code style and add limit to refresh rate array --- src/xrt/compositor/main/comp_compositor.c | 4 ++-- src/xrt/compositor/null/null_compositor.c | 4 ++-- src/xrt/include/xrt/xrt_compositor.h | 4 ++-- src/xrt/include/xrt/xrt_limits.h | 5 +++++ src/xrt/state_trackers/oxr/oxr_api_session.c | 7 ++++--- src/xrt/targets/sdl_test/sdl_compositor.c | 4 ++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index f4ff25fa0..766d300dd 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -1078,8 +1078,8 @@ comp_main_create_system_compositor(struct xrt_device *xdev, //! @todo: Query all supported refresh rates of the current mode - sys_info->num_refresh_rates = 1; - sys_info->refresh_rates[0] = (float)(1. / time_ns_to_s(c->settings.nominal_frame_interval_ns)); + sys_info->refresh_rate_count = 1; + sys_info->refresh_rates_hz[0] = (float)(1. / time_ns_to_s(c->settings.nominal_frame_interval_ns)); // Needs to be delayed until after compositor's u_var has been setup. if (!c->deferred_surface) { diff --git a/src/xrt/compositor/null/null_compositor.c b/src/xrt/compositor/null/null_compositor.c index 01d4def2e..340d9e8db 100644 --- a/src/xrt/compositor/null/null_compositor.c +++ b/src/xrt/compositor/null/null_compositor.c @@ -291,8 +291,8 @@ compositor_init_sys_info(struct null_compositor *c, struct xrt_device *xdev) sys_info->supported_blend_mode_count = (uint8_t)xdev->hmd->blend_mode_count; // Refresh rates. - sys_info->num_refresh_rates = 1; - sys_info->refresh_rates[0] = (float)(1. / time_ns_to_s(c->settings.frame_interval_ns)); + sys_info->refresh_rate_count = 1; + sys_info->refresh_rates_hz[0] = (float)(1. / time_ns_to_s(c->settings.frame_interval_ns)); return true; } diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 543fc5a77..2711adbaf 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -2086,8 +2086,8 @@ struct xrt_system_compositor_info //! Number of meaningful elements in xrt_system_compositor_info::supported_blend_modes uint8_t supported_blend_mode_count; - uint32_t num_refresh_rates; - float refresh_rates[1]; + uint32_t refresh_rate_count; + float refresh_rates_hz[XRT_MAX_SUPPORTED_REFRESH_RATES]; //! The vk device as used by the compositor, never changes. xrt_uuid_t compositor_vk_deviceUUID; diff --git a/src/xrt/include/xrt/xrt_limits.h b/src/xrt/include/xrt/xrt_limits.h index 4b5d21477..b4b23f8a0 100644 --- a/src/xrt/include/xrt/xrt_limits.h +++ b/src/xrt/include/xrt/xrt_limits.h @@ -39,6 +39,11 @@ */ #define XRT_MAX_SWAPCHAIN_CREATE_INFO_FORMAT_LIST_COUNT 8 +/*! + * Max number of supported display refresh rates, artificial limit. + */ +#define XRT_MAX_SUPPORTED_REFRESH_RATES 16 + /*! * @} */ diff --git a/src/xrt/state_trackers/oxr/oxr_api_session.c b/src/xrt/state_trackers/oxr/oxr_api_session.c index 614053c80..6d6bb64da 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_session.c +++ b/src/xrt/state_trackers/oxr/oxr_api_session.c @@ -577,7 +577,8 @@ oxr_xrEnumerateDisplayRefreshRatesFB(XrSession session, } OXR_TWO_CALL_HELPER(&log, displayRefreshRateCapacityInput, displayRefreshRateCountOutput, displayRefreshRates, - sess->sys->xsysc->info.num_refresh_rates, sess->sys->xsysc->info.refresh_rates, XR_SUCCESS); + sess->sys->xsysc->info.refresh_rate_count, sess->sys->xsysc->info.refresh_rates_hz, + XR_SUCCESS); } XRAPI_ATTR XrResult XRAPI_CALL @@ -594,11 +595,11 @@ oxr_xrGetDisplayRefreshRateFB(XrSession session, float *displayRefreshRate) return XR_SUCCESS; } - if (sess->sys->xsysc->info.num_refresh_rates < 1) { + if (sess->sys->xsysc->info.refresh_rate_count < 1) { return XR_ERROR_RUNTIME_FAILURE; } - *displayRefreshRate = sess->sys->xsysc->info.refresh_rates[0]; + *displayRefreshRate = sess->sys->xsysc->info.refresh_rates_hz[0]; return XR_SUCCESS; } diff --git a/src/xrt/targets/sdl_test/sdl_compositor.c b/src/xrt/targets/sdl_test/sdl_compositor.c index 8ffe99f21..47caf33ae 100644 --- a/src/xrt/targets/sdl_test/sdl_compositor.c +++ b/src/xrt/targets/sdl_test/sdl_compositor.c @@ -299,8 +299,8 @@ compositor_init_sys_info(struct sdl_compositor *c, struct sdl_program *sp, struc sys_info->supported_blend_mode_count = (uint8_t)xdev->hmd->blend_mode_count; // Refresh rates. - sys_info->num_refresh_rates = 1; - sys_info->refresh_rates[0] = (float)(1. / time_ns_to_s(c->settings.frame_interval_ns)); + sys_info->refresh_rate_count = 1; + sys_info->refresh_rates_hz[0] = (float)(1. / time_ns_to_s(c->settings.frame_interval_ns)); return true; }