diff --git a/client/application.cpp b/client/application.cpp index 2a57c845..6c0bd94b 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -840,14 +840,17 @@ void application::initialize() // world_space = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_LOCAL); config.emplace(xr_system_id); - try + if (xr_instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)) { - xr_session.set_refresh_rate(config->preferred_refresh_rate); - } - catch (std::exception & e) - { - spdlog::warn("failed to set refresh rate to {}: {}", config->preferred_refresh_rate, e.what()); - config->preferred_refresh_rate = 0; + try + { + xr_session.set_refresh_rate(config->preferred_refresh_rate); + } + catch (std::exception & e) + { + spdlog::warn("failed to set refresh rate to {}: {}", config->preferred_refresh_rate, e.what()); + config->preferred_refresh_rate = 0; + } } if (hand_tracking_supported) diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index 378bc130..fbed989e 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -337,6 +337,7 @@ void scenes::lobby::gui_settings() ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20, 20)); + if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)) { const auto & refresh_rates = session.get_refresh_rates(); float current = session.get_current_refresh_rate(); diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index f7c8451a..fc7f878a 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -869,13 +869,16 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript { spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y); - try + if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)) { - session.set_refresh_rate(description.fps); - } - catch (std::exception & e) - { - spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what()); + try + { + session.set_refresh_rate(description.fps); + } + catch (std::exception & e) + { + spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what()); + } } accumulator_images dec; diff --git a/client/xr/session.cpp b/client/xr/session.cpp index 3af37a1f..1313c8dd 100644 --- a/client/xr/session.cpp +++ b/client/xr/session.cpp @@ -264,6 +264,7 @@ std::vector xr::session::localized_sources_for_action(XrAction acti float xr::session::get_current_refresh_rate() { + assert(inst->has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)); static auto xrGetDisplayRefreshRateFB = inst->get_proc("xrGetDisplayRefreshRateFB"); float refresh_rate = 0; @@ -275,6 +276,7 @@ float xr::session::get_current_refresh_rate() std::vector xr::session::get_refresh_rates() { + assert(inst->has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)); static auto xrEnumerateDisplayRefreshRatesFB = inst->get_proc("xrEnumerateDisplayRefreshRatesFB"); if (xrEnumerateDisplayRefreshRatesFB) @@ -294,6 +296,7 @@ std::vector xr::session::get_refresh_rates() void xr::session::set_refresh_rate(float refresh_rate) { + assert(inst->has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)); static auto xrRequestDisplayRefreshRateFB = inst->get_proc("xrRequestDisplayRefreshRateFB"); if (xrRequestDisplayRefreshRateFB)