mangoapp: move some variables to hudelements

pull/1001/head
FlightlessMango 1 year ago
parent 8e4857a5c6
commit 11bc5111eb

@ -43,10 +43,6 @@ static bool mangoapp_paused = false;
std::mutex mangoapp_m;
std::condition_variable mangoapp_cv;
static uint8_t raw_msg[1024] = {0};
uint8_t g_fsrUpscale = 0;
uint8_t g_fsrSharpness = 0;
std::vector<float> gamescope_debug_latency {};
std::vector<float> gamescope_debug_app {};
static unsigned int get_prop(const char* propName){
Display *x11_display = glfwGetX11Display();
@ -133,22 +129,22 @@ bool new_frame = false;
static void gamescope_frametime(uint64_t app_frametime_ns, uint64_t latency_ns){
float app_frametime_ms = app_frametime_ns / 1000000.f;
gamescope_debug_app.push_back(app_frametime_ms);
if (gamescope_debug_app.size() > 200)
gamescope_debug_app.erase(gamescope_debug_app.begin());
HUDElements.gamescope_debug_app.push_back(app_frametime_ms);
if (HUDElements.gamescope_debug_app.size() > 200)
HUDElements.gamescope_debug_app.erase(HUDElements.gamescope_debug_app.begin());
float latency_ms = latency_ns / 1000000.f;
if (latency_ns == uint64_t(-1))
latency_ms = -1;
gamescope_debug_latency.push_back(latency_ms);
if (gamescope_debug_latency.size() > 200)
gamescope_debug_latency.erase(gamescope_debug_latency.begin());
HUDElements.gamescope_debug_latency.push_back(latency_ms);
if (HUDElements.gamescope_debug_latency.size() > 200)
HUDElements.gamescope_debug_latency.erase(HUDElements.gamescope_debug_latency.begin());
}
static void msg_read_thread(){
for (size_t i = 0; i < 200; i++){
gamescope_debug_app.push_back(0);
gamescope_debug_latency.push_back(0);
HUDElements.gamescope_debug_app.push_back(0);
HUDElements.gamescope_debug_latency.push_back(0);
}
int key = ftok("mangoapp", 65);
msgid = msgget(key, 0666 | IPC_CREAT);
@ -165,11 +161,11 @@ static void msg_read_thread(){
update_hud_info_with_frametime(sw_stats, params, vendorID, mangoapp_v1->visible_frametime_ns);
if (msg_size > offsetof(mangoapp_msg_v1, fsrUpscale)){
g_fsrUpscale = mangoapp_v1->fsrUpscale;
HUDElements.g_fsrUpscale = mangoapp_v1->fsrUpscale;
if (params.fsr_steam_sharpness < 0)
g_fsrSharpness = mangoapp_v1->fsrSharpness;
HUDElements.g_fsrSharpness = mangoapp_v1->fsrSharpness;
else
g_fsrSharpness = params.fsr_steam_sharpness - mangoapp_v1->fsrSharpness;
HUDElements.g_fsrSharpness = params.fsr_steam_sharpness - mangoapp_v1->fsrSharpness;
}
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_mangoapp_steam]){
steam_focused = get_prop("GAMESCOPE_FOCUSED_APP_GFX") == 769;

@ -1,5 +1,4 @@
#ifdef MANGOAPP
#pragma once
#include <stdint.h>
#include <mutex>
#include <condition_variable>
@ -7,10 +6,3 @@
extern std::mutex mangoapp_m;
extern std::condition_variable mangoapp_cv;
extern uint8_t g_fsrUpscale;
extern uint8_t g_fsrSharpness;
extern std::vector<float> gamescope_debug_latency;
extern std::vector<float> gamescope_debug_app;
#endif

@ -808,12 +808,11 @@ void HudElements::battery(){
}
void HudElements::gamescope_fsr(){
#ifdef MANGOAPP
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fsr]) {
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fsr] && HUDElements.g_fsrUpscale >= 0) {
ImGui::TableNextColumn();
string FSR_TEXT;
ImVec4 FSR_COLOR;
if (g_fsrUpscale){
if (HUDElements.g_fsrUpscale){
FSR_TEXT = "ON";
FSR_COLOR = HUDElements.colors.fps_value_high;
} else {
@ -824,10 +823,10 @@ void HudElements::gamescope_fsr(){
ImGui::TextColored(HUDElements.colors.engine, "%s", "FSR");
ImGui::TableNextColumn();
right_aligned_text(FSR_COLOR, HUDElements.ralign_width, "%s", FSR_TEXT.c_str());
if (g_fsrUpscale){
if (HUDElements.g_fsrUpscale){
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_hide_fsr_sharpness]) {
ImguiNextColumnOrNewRow();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", g_fsrSharpness);
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", HUDElements.g_fsrSharpness);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("Sharp");
@ -835,69 +834,64 @@ void HudElements::gamescope_fsr(){
}
}
}
#endif
}
void HudElements::gamescope_frame_timing(){
#ifdef MANGOAPP
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_debug]) {
ImGui::TableNextColumn();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.colors.engine, "%s", "App");
for (size_t i = 0; i < HUDElements.params->table_columns - 1; i++)
static std::vector<float>::iterator min, max;
static double min_time = 0.0f;
static double max_time = 50.0f;
if (HUDElements.gamescope_debug_app.size() > 0){
ImGui::TableNextColumn();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
auto min = std::min_element(gamescope_debug_app.begin(), gamescope_debug_app.end());
auto max = std::max_element(gamescope_debug_app.begin(), gamescope_debug_app.end());
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width * 1.3, "min: %.1fms, max: %.1fms", min[0], max[0]);
ImGui::PopFont();
ImGui::TableNextColumn();
char hash[40];
snprintf(hash, sizeof(hash), "##%s", overlay_param_names[OVERLAY_PARAM_ENABLED_frame_timing]);
HUDElements.sw_stats->stat_selector = OVERLAY_PLOTS_frame_timing;
HUDElements.sw_stats->time_dividor = 1000000.0f; /* ns -> ms */
double min_time = 0.0f;
double max_time = 50.0f;
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PlotLines("", gamescope_debug_app.data(),
gamescope_debug_app.size(), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() * HUDElements.params->table_columns - 30, 50));
ImGui::SameLine();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("%.1fms", gamescope_debug_app.back());
ImGui::TextColored(HUDElements.colors.engine, "%s", "App");
ImGui::TableNextRow();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
auto min = std::min_element(HUDElements.gamescope_debug_app.begin(),
HUDElements.gamescope_debug_app.end());
auto max = std::max_element(HUDElements.gamescope_debug_app.begin(),
HUDElements.gamescope_debug_app.end());
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width * 1.3, "min: %.1fms, max: %.1fms", min[0], max[0]);
ImGui::PopFont();
ImGui::PopStyleColor();
if (gamescope_debug_latency.back() > -1){
ImGui::TableNextColumn();
char hash[40];
snprintf(hash, sizeof(hash), "##%s", overlay_param_names[OVERLAY_PARAM_ENABLED_frame_timing]);
HUDElements.sw_stats->stat_selector = OVERLAY_PLOTS_frame_timing;
HUDElements.sw_stats->time_dividor = 1000000.0f; /* ns -> ms */
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PlotLines("", HUDElements.gamescope_debug_app.data(),
HUDElements.gamescope_debug_app.size(), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() * HUDElements.params->table_columns, 50));
ImGui::PopStyleColor();
}
if (HUDElements.gamescope_debug_latency.size() > 0 && HUDElements.gamescope_debug_latency.back() > -1){
ImGui::TableNextColumn();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.colors.engine, "%s", "Latency");
for (size_t i = 0; i < HUDElements.params->table_columns - 1; i++)
ImGui::TableNextColumn();
ImGui::TableNextRow();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
min = std::min_element(gamescope_debug_latency.begin(), gamescope_debug_latency.end());
max = std::max_element(gamescope_debug_latency.begin(), gamescope_debug_latency.end());
min = std::min_element(HUDElements.gamescope_debug_latency.begin(),
HUDElements.gamescope_debug_latency.end());
max = std::max_element(HUDElements.gamescope_debug_latency.begin(),
HUDElements.gamescope_debug_latency.end());
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width * 1.3, "min: %.1fms, max: %.1fms", min[0], max[0]);
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_PlotLines, ImVec4(0,0,1,1));
ImGui::PlotLines("", gamescope_debug_latency.data(),
gamescope_debug_latency.size(), 0,
ImGui::PlotLines("", HUDElements.gamescope_debug_latency.data(),
HUDElements.gamescope_debug_latency.size(), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() * HUDElements.params->table_columns - 30, 50));
ImGui::SameLine();
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("%.1fms", gamescope_debug_latency.back());
ImGui::PopFont();
ImVec2(ImGui::GetContentRegionAvailWidth() * HUDElements.params->table_columns, 50));
ImGui::PopStyleColor(2);
}
}
#endif
}
void HudElements::gamepad_battery()

@ -21,9 +21,13 @@ class HudElements{
bool is_vulkan, gamemode_bol = false, vkbasalt_bol = false;
int place;
int text_column = 1;
int g_fsrUpscale = -1;
int g_fsrSharpness = -1;
Clock::time_point last_exec;
std::vector<std::pair<std::string, std::string>> options;
std::vector<std::pair<void(*)(), std::string >> ordered_functions;
std::vector<float> gamescope_debug_latency {};
std::vector<float> gamescope_debug_app {};
int min, max, gpu_core_max, gpu_mem_max, cpu_temp_max, gpu_temp_max;
const std::vector<std::string> permitted_params = {
"gpu_load", "cpu_load", "gpu_core_clock", "gpu_mem_clock",

Loading…
Cancel
Save