diff --git a/client/configuration.cpp b/client/configuration.cpp index 93186647..52980ab5 100644 --- a/client/configuration.cpp +++ b/client/configuration.cpp @@ -129,6 +129,9 @@ configuration::configuration(xr::system & system) if (auto val = root["resolution_scale"]; val.is_double()) resolution_scale = val.get_double(); + if (auto val = root["stream_scale"]; val.is_double()) + stream_scale = val.get_double(); + if (auto val = root["enable_stream_gui"]; val.is_bool()) enable_stream_gui = val.get_bool(); @@ -188,6 +191,7 @@ configuration::configuration(xr::system & system) preferred_refresh_rate.reset(); minimum_refresh_rate.reset(); resolution_scale = 1.0; + stream_scale = 0.5; openxr_post_processing = {}; passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color; } @@ -250,6 +254,7 @@ void configuration::save() if (minimum_refresh_rate) json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate; json << ",\"resolution_scale\":" << resolution_scale; + json << ",\"stream_scale\":" << stream_scale; json << ",\"openxr_post_processing\":"; write_openxr_post_processing(json, openxr_post_processing); json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled; diff --git a/client/configuration.h b/client/configuration.h index 12007ebb..f84bc98f 100644 --- a/client/configuration.h +++ b/client/configuration.h @@ -50,6 +50,7 @@ public: std::optional preferred_refresh_rate; std::optional minimum_refresh_rate; float resolution_scale = 1.0; + float stream_scale = 0.5; bool passthrough_enabled = false; bool mic_unprocessed_audio = false; diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index 150649d6..f5d6c4a9 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -642,13 +642,14 @@ void scenes::lobby::gui_settings() imgui_ctx->vibrate_on_hover(); } + // Render resolution { const auto current = config.resolution_scale; const auto width = stream_view.recommendedImageRectWidth; const auto height = stream_view.recommendedImageRectHeight; auto intScale = int(current * 10); const auto slider = ImGui::SliderInt( - _("Resolution scale").append("##resolution_scale").c_str(), + _("Render resolution").append("##resolution_scale").c_str(), &intScale, 5, 35, @@ -667,6 +668,27 @@ void scenes::lobby::gui_settings() } } + // Stream resolution + { + const int step = 10; + const auto current = config.stream_scale; + auto intval = int(current * 100 / step); + const auto slider = ImGui::SliderInt( + _("Stream resolution").append("##stream_scale").c_str(), + &intval, + 0, + 100 / step, + fmt::format(_F("{}%%"), intval * step).c_str()); + if (slider) + { + // clamp out of the slider to have the 50% value centered + intval = std::clamp(intval, 20 / step, 100 / step); + config.stream_scale = intval * step * 0.01; + config.save(); + } + imgui_ctx->vibrate_on_hover(); + } + if (instance.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME)) { if (ImGui::Checkbox(_S("High power mode"), &config.high_power_mode)) diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index 23523f66..725df90e 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -155,6 +155,9 @@ scenes::stream::stream(std::string server_name, scene & parent_scene) : scene_impl(supported_color_formats, supported_depth_formats, parent_scene), apps{*this, std::move(server_name)} { + auto views = system.view_configuration_views(viewconfig); + width = views[0].recommendedImageRectWidth; + height = views[0].recommendedImageRectHeight; } static from_headset::visibility_mask_changed::masks get_visibility_mask(xr::instance & inst, xr::session & session, int view) @@ -197,35 +200,31 @@ std::shared_ptr scenes::stream::create(std::unique_ptrsystem.view_configuration_views(self->viewconfig)[0]; - view = override_view(view, guess_model()); - - auto resolution_scale = application::get_config().resolution_scale; - - view.recommendedImageRectWidth *= resolution_scale; - view.recommendedImageRectHeight *= resolution_scale; - - info.render_eye_width = view.recommendedImageRectWidth; - info.render_eye_height = view.recommendedImageRectHeight; - - // FIXME: make this configurable - info.stream_eye_width = info.render_eye_width / 2; - info.stream_eye_height = info.render_eye_height / 2; - - auto [flags, views] = self->session.locate_views( - XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, - self->instance.now(), - application::space(xr::spaces::view)); - - assert(views.size() == info.fov.size()); - - for (auto [i, j]: std::views::zip(views, info.fov)) { - j = i.fov; + auto [flags, views] = self->session.locate_views( + XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, + self->instance.now(), + application::space(xr::spaces::view)); + + assert(views.size() == info.fov.size()); + + for (auto [i, j]: std::views::zip(views, info.fov)) + j = i.fov; } const auto & config = application::get_config(); + { + auto view = self->system.view_configuration_views(self->viewconfig)[0]; + view = override_view(view, guess_model()); + + info.render_eye_width = view.recommendedImageRectWidth * config.resolution_scale; + info.render_eye_height = view.recommendedImageRectHeight * config.resolution_scale; + } + + info.stream_eye_width = info.render_eye_width * config.stream_scale; + info.stream_eye_height = info.render_eye_height * config.stream_scale; + if (self->instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME)) { info.available_refresh_rates = self->session.get_refresh_rates(); @@ -404,11 +403,6 @@ void scenes::stream::on_focused() { gui_status_last_change = instance.now(); - auto views = system.view_configuration_views(viewconfig); - // stream_view = override_view(views[0], guess_model()); - width = views[0].recommendedImageRectWidth; - height = views[0].recommendedImageRectHeight; - std::string profile = controller_name(); input.emplace( *this,