mangoapp: show_fps_limit

mangoapp-fpslimit
FlightlessMango 2 years ago
parent e289a55c6f
commit 0461b10e2d

@ -38,9 +38,9 @@ uint8_t g_fsrSharpness = 0;
std::vector<float> gamescope_debug_latency {};
std::vector<float> gamescope_debug_app {};
static unsigned int get_prop(){
unsigned int get_prop(const char* name){
Display *x11_display = glfwGetX11Display();
Atom gamescope_focused = XInternAtom(x11_display, "GAMESCOPE_FOCUSED_APP", true);
Atom gamescope_focused = XInternAtom(x11_display, name, true);
auto scr = DefaultScreen(x11_display);
auto root = RootWindow(x11_display, scr);
Atom actual;
@ -144,7 +144,7 @@ void msg_read_thread(){
std::unique_lock<std::mutex> lk(mangoapp_m);
new_frame = true;
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_mangoapp_steam]){
if (get_prop() == 769)
if (get_prop("GAMESCOPE_FOCUSED_APP") == 769)
steam_focused = true;
else
steam_focused = false;

@ -48,4 +48,5 @@ struct mangoapp_ctrl_msgid1_v1 {
extern uint8_t g_fsrUpscale;
extern uint8_t g_fsrSharpness;
extern std::vector<float> gamescope_debug_latency;
extern std::vector<float> gamescope_debug_app;
extern std::vector<float> gamescope_debug_app;
extern unsigned int get_prop(const char* name);

@ -632,17 +632,14 @@ void HudElements::resolution(){
void HudElements::show_fps_limit(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_show_fps_limit]){
int fps = 0;
double frame_time = (double)fps_limit_stats.targetFrameTime.count()/1000000;
fps = (1 / frame_time) *1000;
if (frame_time == 0.0){
fps = 0;
}
ImGui::TableNextRow(); ImGui::TableNextColumn();
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.colors.engine, "%s","FPS limit");
ImGui::TableNextColumn();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", fps);
if (current_fps_limit == 0)
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", "OFF");
else
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", current_fps_limit);
ImGui::PopFont();
}
}
@ -981,8 +978,8 @@ void HudElements::sort_elements(const std::pair<std::string, std::string>& optio
if (param == "engine_version") { ordered_functions.push_back({engine_version, value}); }
if (param == "vulkan_driver") { ordered_functions.push_back({vulkan_driver, value}); }
if (param == "resolution") { ordered_functions.push_back({resolution, value}); }
if (param == "show_fps_limit") { ordered_functions.push_back({show_fps_limit, value}); }
#endif
if (param == "show_fps_limit") { ordered_functions.push_back({show_fps_limit, value}); }
if (param == "vram") { ordered_functions.push_back({vram, value}); }
if (param == "ram") { ordered_functions.push_back({ram, value}); }
if (param == "fps") { ordered_functions.push_back({fps, value}); }
@ -1044,7 +1041,9 @@ void HudElements::legacy_elements(){
#ifndef MANGOAPP
ordered_functions.push_back({gamemode, value});
ordered_functions.push_back({vkbasalt, value});
#endif
ordered_functions.push_back({show_fps_limit, value});
#ifndef MANGOAPP
ordered_functions.push_back({resolution, value});
#endif
ordered_functions.push_back({media_player, value});

@ -23,6 +23,7 @@
#include "memory.h"
#include "pci_ids.h"
#include "timing.hpp"
#include "app/mangoapp.h"
#ifdef __linux__
#include <libgen.h>
@ -47,6 +48,7 @@ overlay_params *_params {};
double min_frametime, max_frametime;
bool gpu_metrics_exists = false;
bool steam_focused = false;
int current_fps_limit = 0;
void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID)
{
@ -197,7 +199,16 @@ void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, struct ove
sw_stats.n_frames_since_update = 0;
sw_stats.last_fps_update = now;
#ifdef MANGOAPP
current_fps_limit = get_prop("GAMESCOPE_FPS_LIMIT");
#else
int limit = 0;
double frame_time_limit = (double)fps_limit_stats.targetFrameTime.count() / 1000000;
limit = (1 / frame_time_limit) *1000;
if (frame_time_limit == 0.0)
limit = 0;
current_fps_limit = limit;
#endif
}
double min_time = UINT64_MAX, max_time = 0;
for (auto& stat : sw_stats.frames_stats ){

@ -148,6 +148,7 @@ extern std::deque<logData> graph_data;
extern overlay_params *_params;
extern double min_frametime, max_frametime;
extern bool steam_focused;
extern int current_fps_limit;
void position_layer(struct swapchain_stats& data, struct overlay_params& params, ImVec2 window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);

Loading…
Cancel
Save