The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Implement a basic version of XR_FB_display_refresh_rate

authored by

Christoph Haag and committed by
Christoph Haag
a1c00e14 eae7231f

+91
+4
src/xrt/compositor/main/comp_compositor.c
··· 1276 1276 1277 1277 float target_frame_time_ms = ns_to_ms(c->settings.nominal_frame_interval_ns); 1278 1278 1279 + //! @todo: Query all supported refresh rates of the current mode 1280 + sys_info->num_refresh_rates = 1; 1281 + sys_info->refresh_rates[0] = 1. / time_ns_to_s(c->settings.nominal_frame_interval_ns); 1282 + 1279 1283 uint64_t now = os_monotonic_get_ns(); 1280 1284 for (int i = 0; i < NUM_FRAME_TIMES; i++) { 1281 1285 c->compositor_frame_times.times_ns[i] = now + i;
+3
src/xrt/include/xrt/xrt_compositor.h
··· 1557 1557 //! Number of meaningful elements in xrt_system_compositor_info::supported_blend_modes 1558 1558 uint8_t supported_blend_mode_count; 1559 1559 1560 + uint32_t num_refresh_rates; 1561 + float refresh_rates[1]; 1562 + 1560 1563 //! The vk device as used by the compositor, never changes. 1561 1564 uint8_t compositor_vk_deviceUUID[XRT_GPU_UUID_SIZE]; 1562 1565
+15
src/xrt/state_trackers/oxr/oxr_api_funcs.h
··· 515 515 const XrHandJointsLocateInfoEXT *locateInfo, 516 516 XrHandJointLocationsEXT *locations); 517 517 518 + //! OpenXR API function @ep{xrEnumerateDisplayRefreshRatesFB} 519 + XRAPI_ATTR XrResult XRAPI_CALL 520 + oxr_xrEnumerateDisplayRefreshRatesFB(XrSession session, 521 + uint32_t displayRefreshRateCapacityInput, 522 + uint32_t *displayRefreshRateCountOutput, 523 + float *displayRefreshRates); 524 + 525 + //! OpenXR API function @ep{xrGetDisplayRefreshRateFB} 526 + XRAPI_ATTR XrResult XRAPI_CALL 527 + oxr_xrGetDisplayRefreshRateFB(XrSession session, float *displayRefreshRate); 528 + 529 + //! OpenXR API function @ep{xrRequestDisplayRefreshRateFB} 530 + XRAPI_ATTR XrResult XRAPI_CALL 531 + oxr_xrRequestDisplayRefreshRateFB(XrSession session, float displayRefreshRate); 532 + 518 533 /*! 519 534 * @} 520 535 */
+6
src/xrt/state_trackers/oxr/oxr_api_negotiate.c
··· 226 226 ENTRY_IF_EXT(xrLocateHandJointsEXT, EXT_hand_tracking); 227 227 #endif 228 228 229 + #ifdef OXR_HAVE_FB_display_refresh_rate 230 + ENTRY_IF_EXT(xrEnumerateDisplayRefreshRatesFB, FB_display_refresh_rate); 231 + ENTRY_IF_EXT(xrGetDisplayRefreshRateFB, FB_display_refresh_rate); 232 + ENTRY_IF_EXT(xrRequestDisplayRefreshRateFB, FB_display_refresh_rate); 233 + #endif 234 + 229 235 #if 0 230 236 #ifdef OXR_HAVE_EXT_debug_utils 231 237 ENTRY_IF_EXT(xrSetDebugUtilsObjectNameEXT, EXT_debug_utils);
+63
src/xrt/state_trackers/oxr/oxr_api_session.c
··· 441 441 } 442 442 443 443 #endif 444 + 445 + /* 446 + * 447 + * XR_FB_display_refresh_rate 448 + * 449 + */ 450 + 451 + #ifdef XR_FB_display_refresh_rate 452 + 453 + XrResult 454 + oxr_xrEnumerateDisplayRefreshRatesFB(XrSession session, 455 + uint32_t displayRefreshRateCapacityInput, 456 + uint32_t *displayRefreshRateCountOutput, 457 + float *displayRefreshRates) 458 + { 459 + struct oxr_session *sess = NULL; 460 + struct oxr_logger log; 461 + OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrEnumerateDisplayRefreshRatesFB"); 462 + 463 + // headless 464 + if (!sess->sys->xsysc) { 465 + *displayRefreshRateCountOutput = 0; 466 + return XR_SUCCESS; 467 + } 468 + 469 + OXR_TWO_CALL_HELPER(&log, displayRefreshRateCapacityInput, displayRefreshRateCountOutput, displayRefreshRates, 470 + sess->sys->xsysc->info.num_refresh_rates, sess->sys->xsysc->info.refresh_rates, XR_SUCCESS); 471 + } 472 + 473 + XrResult 474 + oxr_xrGetDisplayRefreshRateFB(XrSession session, float *displayRefreshRate) 475 + { 476 + struct oxr_session *sess = NULL; 477 + struct oxr_logger log; 478 + OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrEnumerateDisplayRefreshRatesFB"); 479 + 480 + // headless 481 + if (!sess->sys->xsysc) { 482 + *displayRefreshRate = 0.0f; 483 + return XR_SUCCESS; 484 + } 485 + 486 + OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrGetDisplayRefreshRateFB"); 487 + if (sess->sys->xsysc->info.num_refresh_rates < 1) { 488 + return XR_ERROR_RUNTIME_FAILURE; 489 + } 490 + 491 + *displayRefreshRate = sess->sys->xsysc->info.refresh_rates[0]; 492 + return XR_SUCCESS; 493 + } 494 + 495 + XrResult 496 + oxr_xrRequestDisplayRefreshRateFB(XrSession session, float displayRefreshRate) 497 + { 498 + struct oxr_session *sess = NULL; 499 + struct oxr_logger log; 500 + OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrRequestDisplayRefreshRateFB"); 501 + 502 + //! @todo support for changing refresh rates 503 + return XR_SUCCESS; 504 + } 505 + 506 + #endif