Default to max framerate if not configured
This commit is contained in:
@@ -209,7 +209,7 @@ configuration::configuration(xr::system & system)
|
||||
|
||||
// Restore default configuration
|
||||
servers.clear();
|
||||
preferred_refresh_rate = 0;
|
||||
preferred_refresh_rate.reset();
|
||||
resolution_scale = 1.4;
|
||||
show_performance_metrics = false;
|
||||
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
|
||||
@@ -251,8 +251,8 @@ void configuration::save()
|
||||
|
||||
json << "{\"servers\":[" << servers_str << "],"
|
||||
<< "\"show_performance_metrics\":" << std::boolalpha << show_performance_metrics;
|
||||
if (preferred_refresh_rate != 0.)
|
||||
json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate;
|
||||
if (preferred_refresh_rate)
|
||||
json << ",\"preferred_refresh_rate\":" << *preferred_refresh_rate;
|
||||
json << ",\"resolution_scale\":" << resolution_scale;
|
||||
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
|
||||
json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace xr
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
};
|
||||
|
||||
std::map<std::string, server_data> servers;
|
||||
float preferred_refresh_rate = 0;
|
||||
std::optional<float> preferred_refresh_rate;
|
||||
float resolution_scale = 1.4;
|
||||
bool show_performance_metrics = false;
|
||||
bool passthrough_enabled = false;
|
||||
|
||||
@@ -1177,7 +1177,7 @@ void scenes::lobby::on_focused()
|
||||
about_picture = imgui_ctx->load_texture("wivrn.png");
|
||||
}
|
||||
setup_passthrough();
|
||||
session.set_refresh_rate(application::get_config().preferred_refresh_rate);
|
||||
session.set_refresh_rate(application::get_config().preferred_refresh_rate.value_or(0));
|
||||
multicast = application::get_wifi_lock().get_multicast_lock();
|
||||
}
|
||||
|
||||
|
||||
@@ -584,14 +584,17 @@ void scenes::lobby::gui_settings()
|
||||
const auto & refresh_rates = session.get_refresh_rates();
|
||||
if (not refresh_rates.empty())
|
||||
{
|
||||
if (ImGui::BeginCombo(_S("Refresh rate"), config.preferred_refresh_rate ? fmt::format("{}", config.preferred_refresh_rate).c_str() : _S("No preference")))
|
||||
float active_rate = config.preferred_refresh_rate.value_or(refresh_rates.back());
|
||||
if (ImGui::BeginCombo(_S("Refresh rate"), active_rate ? fmt::format("{}", active_rate).c_str() : _S("Automatic")))
|
||||
{
|
||||
if (ImGui::Selectable(_S("No preference"), config.preferred_refresh_rate == 0, ImGuiSelectableFlags_SelectOnRelease))
|
||||
if (ImGui::Selectable(_S("Automatic"), config.preferred_refresh_rate == 0, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
session.set_refresh_rate(0);
|
||||
config.preferred_refresh_rate = 0;
|
||||
config.save();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
tooltip(_("Select refresh rate based on measured application performance.\nMay cause flicker when a change happens."));
|
||||
for (float rate: refresh_rates)
|
||||
{
|
||||
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == config.preferred_refresh_rate, ImGuiSelectableFlags_SelectOnRelease))
|
||||
|
||||
@@ -184,14 +184,24 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
if (self->instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
|
||||
{
|
||||
info.available_refresh_rates = self->session.get_refresh_rates();
|
||||
if (utils::contains(info.available_refresh_rates, config.preferred_refresh_rate))
|
||||
info.preferred_refresh_rate = config.preferred_refresh_rate;
|
||||
// I can't find anythin in specification the ensures it won't be empty
|
||||
if (not info.available_refresh_rates.empty())
|
||||
{
|
||||
if (config.preferred_refresh_rate and (config.preferred_refresh_rate == 0 or utils::contains(info.available_refresh_rates, *config.preferred_refresh_rate)))
|
||||
info.preferred_refresh_rate = *config.preferred_refresh_rate;
|
||||
else
|
||||
{
|
||||
// Default to highest refresh rate
|
||||
info.preferred_refresh_rate = info.available_refresh_rates.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (info.available_refresh_rates.empty())
|
||||
{
|
||||
spdlog::warn("Unable to detect refresh rates");
|
||||
info.available_refresh_rates = {guessed_fps};
|
||||
info.preferred_refresh_rate = guessed_fps;
|
||||
}
|
||||
|
||||
info.hand_tracking = config.check_feature(feature::hand_tracking);
|
||||
|
||||
Reference in New Issue
Block a user