From 2428baf158d853338a2ccad54b180b3613c64ec4 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Wed, 9 Feb 2022 00:32:17 +0100 Subject: [PATCH] mangoapp: gamescope fsr --- src/app/main.cpp | 4 ++++ src/app/mangoapp.h | 7 ++++++- src/hud_elements.cpp | 30 ++++++++++++++++++++++++++++++ src/hud_elements.h | 1 + src/overlay_params.h | 1 + 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index cbf84371..a021131f 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -33,6 +33,8 @@ bool mangoapp_paused = false; std::mutex mangoapp_m; std::condition_variable mangoapp_cv; static uint8_t raw_msg[1024] = {0}; +uint8_t g_fsrUpscale; +uint8_t g_fsrSharpness; void ctrl_thread(){ while (1){ @@ -87,6 +89,8 @@ void msg_read_thread(){ if (hdr->version == 1){ if (msg_size > offsetof(struct mangoapp_msg_v1, frametime_ns)){ update_hud_info_with_frametime(sw_stats, *params, vendorID, mangoapp_v1->frametime_ns); + g_fsrUpscale = mangoapp_v1->fsrUpscale; + g_fsrSharpness = mangoapp_v1->fsrSharpness; { std::unique_lock lk(mangoapp_m); new_frame = true; diff --git a/src/app/mangoapp.h b/src/app/mangoapp.h index 86dfb1b1..c8c6b288 100644 --- a/src/app/mangoapp.h +++ b/src/app/mangoapp.h @@ -19,6 +19,8 @@ struct mangoapp_msg_v1 { uint32_t pid; uint64_t frametime_ns; + uint8_t fsrUpscale; + uint8_t fsrSharpness; // WARNING: Always ADD fields, never remove or repurpose fields } __attribute__((packed)); @@ -37,4 +39,7 @@ struct mangoapp_ctrl_msgid1_v1 { char log_session_name[64]; // if byte 0 is NULL, ignore. Needs to be set when starting/toggling a session if we want to override the default name // WARNING: Always ADD fields, never remove or repurpose fields -} __attribute__((packed)); \ No newline at end of file +} __attribute__((packed)); + +extern uint8_t g_fsrUpscale; +extern uint8_t g_fsrSharpness; \ No newline at end of file diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 8f0de846..dd964085 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -12,6 +12,7 @@ #include "memory.h" #include "mesa/util/macros.h" #include "string_utils.h" +#include "app/mangoapp.h" #include #define CHAR_CELSIUS "\xe2\x84\x83" @@ -734,6 +735,33 @@ void HudElements::battery(){ #endif } +void HudElements::gamescope_fsr(){ +#ifdef MANGOAPP + ImGui::TableNextRow(); ImGui::TableNextColumn(); + string FSR_TEXT; + ImVec4 FSR_COLOR; + if (g_fsrUpscale){ + FSR_TEXT = "ON"; + FSR_COLOR = HUDElements.colors.fps_value_high; + } else { + FSR_TEXT = "OFF"; + FSR_COLOR = HUDElements.colors.fps_value_low; + } + + ImGui::TextColored(HUDElements.colors.engine, "%s", "FSR"); + if (g_fsrUpscale){ + ImGui::SameLine(); + ImGui::TextColored(FSR_COLOR, "%s", FSR_TEXT.c_str()); + ImGui::TableNextColumn(); + ImGui::TextColored(HUDElements.colors.engine, "Sharpness"); + ImGui::TableNextColumn(); + right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", g_fsrSharpness); + } else { + ImGui::TableNextColumn(); + right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", FSR_TEXT.c_str()); + } +#endif +} void HudElements::graphs(){ ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -884,6 +912,7 @@ void HudElements::sort_elements(const std::pair& optio exec_list.push_back({int(ordered_functions.size() - 1), value}); } if (param == "battery") { ordered_functions.push_back({battery, value}); } if (param == "fps_only") { ordered_functions.push_back({fps_only, value}); } + if (param == "fsr") { ordered_functions.push_back({gamescope_fsr, value}); } if (param == "graphs"){ if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs]) HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs] = true; @@ -914,6 +943,7 @@ void HudElements::legacy_elements(){ ordered_functions.push_back({vram, value}); ordered_functions.push_back({ram, value}); ordered_functions.push_back({battery, value}); + ordered_functions.push_back({gamescope_fsr, value}); ordered_functions.push_back({fps, value}); ordered_functions.push_back({fps_only, value}); #ifndef MANGOAPP diff --git a/src/hud_elements.h b/src/hud_elements.h index ac156a5d..75c2f19c 100644 --- a/src/hud_elements.h +++ b/src/hud_elements.h @@ -59,6 +59,7 @@ class HudElements{ static void _exec(); static void battery(); static void fps_only(); + static void gamescope_fsr(); void convert_colors(struct overlay_params& params); void convert_colors(bool do_conv, struct overlay_params& params); diff --git a/src/overlay_params.h b/src/overlay_params.h index a495ca8d..4d4a9b2c 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -75,6 +75,7 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(battery_icon) \ OVERLAY_PARAM_BOOL(force_amdgpu_hwmon) \ OVERLAY_PARAM_BOOL(fps_only) \ + OVERLAY_PARAM_BOOL(fsr) \ OVERLAY_PARAM_CUSTOM(fps_sampling_period) \ OVERLAY_PARAM_CUSTOM(output_folder) \ OVERLAY_PARAM_CUSTOM(output_file) \