Client-side post-processing - Snapdragon Game Super Resolution

This commit is contained in:
Baplar
2025-04-13 22:28:31 +02:00
parent 1c57dae421
commit 99fbedab02
11 changed files with 468 additions and 33 deletions
+37 -3
View File
@@ -18,12 +18,10 @@
*/
#include "configuration.h"
#include "application.h"
#include "hardware.h"
#include <fstream>
#include <magic_enum.hpp>
#include <simdjson.h>
#ifdef __ANDROID__
#include "android/permissions.h"
@@ -188,6 +186,9 @@ configuration::configuration(xr::system & system)
if (auto val = root["resolution_scale"]; val.is_double())
resolution_scale = val.get_double();
if (auto val = root["sgsr"]; val.is_object())
parse_sgsr_options(val.get_object());
if (auto val = root["passthrough_enabled"]; val.is_bool())
passthrough_enabled = val.get_bool();
@@ -215,16 +216,47 @@ configuration::configuration(xr::system & system)
preferred_refresh_rate.reset();
minimum_refresh_rate.reset();
resolution_scale = 1.4;
sgsr = {};
show_performance_metrics = false;
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
}
}
void configuration::parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::object> sgsr_root)
{
sgsr = {};
if (auto val = sgsr_root["enabled"]; val.is_bool())
sgsr.enabled = val.get_bool();
if (auto val = sgsr_root["upscaling_factor"]; val.is_double())
sgsr.upscaling_factor = val.get_double();
if (auto val = sgsr_root["use_edge_direction"]; val.is_bool())
sgsr.use_edge_direction = val.get_bool();
if (auto val = sgsr_root["edge_threshold"]; val.is_double())
sgsr.edge_threshold = val.get_double();
if (auto val = sgsr_root["edge_sharpness"]; val.is_double())
sgsr.edge_sharpness = val.get_double();
}
static std::ostream & operator<<(std::ostream & stream, feature f)
{
return stream << "\"" << magic_enum::enum_name(f) << "\"";
}
static std::ostream & write_sgsr(std::ofstream & stream, const configuration::sgsr_settings & sgsr)
{
stream << "{\"enabled\":" << std::boolalpha << sgsr.enabled;
stream << ",\"upscaling_factor\":" << sgsr.upscaling_factor;
stream << ",\"use_edge_direction\":" << std::boolalpha << sgsr.use_edge_direction;
stream << ",\"edge_threshold\":" << sgsr.edge_threshold;
stream << ",\"edge_sharpness\":" << sgsr.edge_sharpness;
stream << "}";
return stream;
}
void configuration::save()
{
std::lock_guard lock(mutex);
@@ -260,6 +292,8 @@ void configuration::save()
if (minimum_refresh_rate)
json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
json << ",\"resolution_scale\":" << resolution_scale;
json << ",\"sgsr\":";
write_sgsr(json, sgsr);
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
for (auto & [key, value]: features)