factorize post-processing GUI code

This commit is contained in:
Patrick Nicolas
2026-04-27 11:22:44 +02:00
parent 63a22d32db
commit 51e3dd5adc
4 changed files with 97 additions and 142 deletions
+83
View File
@@ -19,6 +19,7 @@
#include "gui_common.h"
#include "application.h"
#include "configuration.h"
#include "render/imgui_impl.h"
#include "utils/i18n.h"
@@ -114,4 +115,86 @@ bool refresh_rate(
}
return changed;
}
static std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag)
{
switch (flag)
{
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB:
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB:
return _C("openxr_post_processing", "Normal");
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB:
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB:
return _C("openxr_post_processing", "Quality");
default:
return _C("openxr_post_processing", "Disabled");
}
}
bool post_processing(
imgui_context & imgui_ctx,
configuration & config)
{
bool changed = false;
if (not application::get_openxr_post_processing_supported())
return changed;
ImGui::Text("%s", _S("OpenXR post-processing"));
ImGui::Indent();
{
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.super_sampling;
if (ImGui::BeginCombo(_S("Supersampling"), openxr_post_processing_flag_name(current).c_str()))
{
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
0,
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB,
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB};
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
{
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
{
spdlog::info("Setting OpenXR super sampling to {}", openxr_post_processing_flag_name(option));
config.openxr_post_processing.super_sampling = option;
config.save();
changed = true;
}
imgui_ctx.vibrate_on_hover();
}
ImGui::EndCombo();
}
imgui_ctx.vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx.tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
}
{
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.sharpening;
if (ImGui::BeginCombo(_S("Sharpening"), openxr_post_processing_flag_name(current).c_str()))
{
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
0,
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB,
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB};
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
{
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
{
spdlog::info("Setting OpenXR sharpening to {}", openxr_post_processing_flag_name(option));
config.openxr_post_processing.sharpening = option;
config.save();
changed = true;
}
imgui_ctx.vibrate_on_hover();
}
ImGui::EndCombo();
}
imgui_ctx.vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx.tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
}
ImGui::Unindent();
return changed;
}
} // namespace wivrn::gui
+5 -1
View File
@@ -40,5 +40,9 @@ bool refresh_rate(
imgui_context & imgui_ctx,
configuration & config);
}
bool post_processing(
imgui_context & imgui_ctx,
configuration & config);
} // namespace gui
} // namespace wivrn
+1 -75
View File
@@ -93,21 +93,6 @@ static void display_recentering_tip(imgui_context & ctx, const std::string & tip
ImGui::PopFont();
}
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag)
{
switch (flag)
{
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB:
case XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB:
return _cS("openxr_post_processing", "Normal");
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB:
case XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB:
return _cS("openxr_post_processing", "Quality");
default:
return _cS("openxr_post_processing", "Disabled");
}
}
void scenes::lobby::gui_connecting(locked_notifiable<pin_request_data> & pin_request)
{
using constants::style::button_size;
@@ -883,67 +868,8 @@ void scenes::lobby::gui_settings()
void scenes::lobby::gui_post_processing()
{
auto & config = application::get_config();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20, 20));
if (application::get_openxr_post_processing_supported())
{
ImGui::Text("%s", _S("OpenXR post-processing"));
ImGui::Indent();
{
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.super_sampling;
if (ImGui::BeginCombo(_S("Supersampling"), openxr_post_processing_flag_name(current).c_str()))
{
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
0,
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB,
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB};
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
{
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
{
config.openxr_post_processing.super_sampling = option;
config.save();
}
imgui_ctx->vibrate_on_hover();
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
{
imgui_ctx->tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
}
}
{
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.sharpening;
if (ImGui::BeginCombo(_S("Sharpening"), openxr_post_processing_flag_name(current).c_str()))
{
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
0,
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB,
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB};
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
{
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
{
config.openxr_post_processing.sharpening = option;
config.save();
}
imgui_ctx->vibrate_on_hover();
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
{
imgui_ctx->tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
}
}
ImGui::Unindent();
}
gui::post_processing(*imgui_ctx, application::get_config());
ImGui::PopStyleVar();
}
+8 -66
View File
@@ -380,16 +380,15 @@ void scenes::stream::gui_compact_view()
static void send_settings_changed_packet(xr::session & session, wivrn_session * network, const configuration & config)
{
from_headset::settings_changed packet{
.preferred_refresh_rate = config.preferred_refresh_rate,
.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0),
.fps_divider = config.fps_divider,
.bitrate_bps = config.bitrate_bps,
};
network->send_control(std::move(packet));
network->send_control(
from_headset::settings_changed{
.preferred_refresh_rate = config.preferred_refresh_rate,
.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0),
.fps_divider = config.fps_divider,
.bitrate_bps = config.bitrate_bps,
});
}
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag); // TODO declaration in a .h file
void scenes::stream::gui_settings(float predicted_display_period)
{
const ImGuiStyle & style = ImGui::GetStyle();
@@ -414,64 +413,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
imgui_ctx->tooltip(_("Click to adjust bitrate"));
}
if (application::get_openxr_post_processing_supported())
{
ImGui::Text("%s", _S("OpenXR post-processing"));
ImGui::Indent();
{
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.super_sampling;
if (ImGui::BeginCombo(_S("Supersampling"), openxr_post_processing_flag_name(current).c_str()))
{
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
0,
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB,
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB};
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
{
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
{
spdlog::info("Setting OpenXR super sampling to {}", openxr_post_processing_flag_name(option));
config.openxr_post_processing.super_sampling = option;
config.save();
}
imgui_ctx->vibrate_on_hover();
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
{
imgui_ctx->tooltip(_("Reduce flicker for high contrast edges.\nUseful when the input resolution is high compared to the headset display"));
}
}
{
XrCompositionLayerSettingsFlagsFB current = config.openxr_post_processing.sharpening;
if (ImGui::BeginCombo(_S("Sharpening"), openxr_post_processing_flag_name(current).c_str()))
{
const XrCompositionLayerSettingsFlagsFB selectable_options[]{
0,
XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB,
XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB};
for (XrCompositionLayerSettingsFlagsFB option: selectable_options)
{
if (ImGui::Selectable(openxr_post_processing_flag_name(option).c_str(), current == option, ImGuiSelectableFlags_SelectOnRelease))
{
spdlog::info("Setting OpenXR sharpening to {}", openxr_post_processing_flag_name(option));
config.openxr_post_processing.sharpening = option;
config.save();
}
imgui_ctx->vibrate_on_hover();
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
{
imgui_ctx->tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
}
}
ImGui::Unindent();
}
gui::post_processing(*imgui_ctx, config);
bool send_packet = false;
bool save_config = false;