Client-side post-processing - OpenXR native post-processing

This commit is contained in:
Baplar
2025-04-13 22:28:31 +02:00
parent 99fbedab02
commit 5f361f271a
8 changed files with 304 additions and 73 deletions
+7
View File
@@ -1044,6 +1044,7 @@ void application::initialize()
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_DEPTH_TEST_EXTENSION_NAME);
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME);
opt_extensions.push_back(XR_KHR_VISIBILITY_MASK_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME);
for (const auto & i: interaction_profiles)
{
@@ -1120,6 +1121,12 @@ void application::initialize()
htc_face_tracking_lip_supported = htc_face_properties.supportLipFacialTracking;
}
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
{
spdlog::info(" OpenXR post-processing extension support: true");
openxr_post_processing_supported = true;
}
switch (xr_system_id.passthrough_supported())
{
case xr::system::passthrough_type::no_passthrough:
+7
View File
@@ -135,6 +135,8 @@ class application : public singleton<application>
bool eye_gaze_supported = false;
bool openxr_post_processing_supported = false;
bool session_running = false;
bool session_focused = false;
bool session_visible = false;
@@ -439,6 +441,11 @@ public:
return instance().eye_gaze_supported;
}
static bool get_openxr_post_processing_supported()
{
return instance().openxr_post_processing_supported;
}
static xr::hand_tracker & get_left_hand()
{
return instance().left_hand;
+24
View File
@@ -189,6 +189,9 @@ configuration::configuration(xr::system & system)
if (auto val = root["sgsr"]; val.is_object())
parse_sgsr_options(val.get_object());
if (auto val = root["openxr_post_processing"]; val.is_object())
parse_openxr_post_processing_options(val.get_object());
if (auto val = root["passthrough_enabled"]; val.is_bool())
passthrough_enabled = val.get_bool();
@@ -217,6 +220,7 @@ configuration::configuration(xr::system & system)
minimum_refresh_rate.reset();
resolution_scale = 1.4;
sgsr = {};
openxr_post_processing = {};
show_performance_metrics = false;
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
}
@@ -241,6 +245,16 @@ void configuration::parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::
sgsr.edge_sharpness = val.get_double();
}
void configuration::parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> openxr_post_processing_root)
{
openxr_post_processing = {};
if (auto val = openxr_post_processing_root["super_sampling"]; val.is_int64())
openxr_post_processing.super_sampling = val.get_int64();
if (auto val = openxr_post_processing_root["sharpening"]; val.is_int64())
openxr_post_processing.sharpening = val.get_int64();
}
static std::ostream & operator<<(std::ostream & stream, feature f)
{
return stream << "\"" << magic_enum::enum_name(f) << "\"";
@@ -257,6 +271,14 @@ static std::ostream & write_sgsr(std::ofstream & stream, const configuration::sg
return stream;
}
static std::ostream & write_openxr_post_processing(std::ofstream & stream, const configuration::openxr_post_processing_settings & openxr_post_processing)
{
stream << "{\"super_sampling\":" << openxr_post_processing.super_sampling;
stream << ",\"sharpening\":" << openxr_post_processing.sharpening;
stream << "}";
return stream;
}
void configuration::save()
{
std::lock_guard lock(mutex);
@@ -294,6 +316,8 @@ void configuration::save()
json << ",\"resolution_scale\":" << resolution_scale;
json << ",\"sgsr\":";
write_sgsr(json, sgsr);
json << ",\"openxr_post_processing\":";
write_openxr_post_processing(json, openxr_post_processing);
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
for (auto & [key, value]: features)
+9
View File
@@ -65,6 +65,14 @@ public:
};
sgsr_settings sgsr{};
// XR_FB_composition_layer_settings extension flags
struct openxr_post_processing_settings
{
XrCompositionLayerSettingsFlagsFB super_sampling = 0;
XrCompositionLayerSettingsFlagsFB sharpening = 0;
};
openxr_post_processing_settings openxr_post_processing{};
std::string virtual_keyboard_layout = "QWERTY";
bool check_feature(feature f) const;
@@ -75,6 +83,7 @@ private:
std::map<feature, bool> features;
void parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::object> root);
void parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> root);
public:
configuration(xr::system &);
+81 -1
View File
@@ -122,6 +122,21 @@ 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::tooltip(std::string_view text)
{
// FIXME: this is incorrect if we use the docking branch of imgui
@@ -805,6 +820,63 @@ void scenes::lobby::gui_post_processing()
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();
}
vibrate_on_hover();
}
ImGui::EndCombo();
}
vibrate_on_hover();
if (ImGui::IsItemHovered())
{
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();
}
vibrate_on_hover();
}
ImGui::EndCombo();
}
vibrate_on_hover();
if (ImGui::IsItemHovered())
{
tooltip(_("Improve clarity of high contrast edges and counteract blur.\nUseful when the input resolution is low compared to the headset display"));
}
}
ImGui::Unindent();
}
{
// SGSR
{
@@ -815,7 +887,15 @@ void scenes::lobby::gui_post_processing()
vibrate_on_hover();
if (ImGui::IsItemHovered())
{
tooltip(_("Client-side upscaling and sharpening, adds a performance cost on the headset"));
if (application::get_openxr_post_processing_supported())
tooltip(_("On this headset, this setting has been fully superseded by the native Sharpening setting above.\nOnly enable if you know what you’re doing."));
else
tooltip(_("Client-side upscaling and sharpening, adds a performance cost on the headset"));
}
if (application::get_openxr_post_processing_supported())
{
ImGui::SameLine();
ImGui::TextColored(ImColor(0xf9, 0x73, 0x06) /*orange*/, ICON_FA_TRIANGLE_EXCLAMATION);
}
}
+11
View File
@@ -924,6 +924,17 @@ void scenes::stream::render(const XrFrameState & frame_state)
.views = layer_view.data(),
};
XrCompositionLayerSettingsFB settings;
const configuration::openxr_post_processing_settings openxr_post_processing = application::get_config().openxr_post_processing;
if ((openxr_post_processing.sharpening | openxr_post_processing.super_sampling) > 0)
{
settings = {
.type = XR_TYPE_COMPOSITION_LAYER_SETTINGS_FB,
.layerFlags = openxr_post_processing.sharpening | openxr_post_processing.super_sampling,
};
layer.next = &settings;
}
std::vector<XrCompositionLayerQuad> imgui_layers;
if (imgui_ctx)
{