flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.28k stars 272 forks source link

`fps_only` shows FPS counter multiple times #1236

Closed jon4hz closed 3 months ago

jon4hz commented 6 months ago

Describe the bug

When using the fps_only option, the fps counter is displayed three times instead of once. And when I reload the config using Shift_L+F4 it just adds another FPS counter. So if I reload the config twice, I end up with five fps counters.

List relevant hardware/software information

To Reproduce Steam Launch Command: env MANGOHUD=1 MANGOHUD_CONFIG=fps_only=1 %command%

Expected behavior The fps counter should be displayed only once.

Screenshots

image

after one reload:

image

gort818 commented 6 months ago

Thanks for the issue, I can confirm. I will look into it.

gort818 commented 6 months ago

I guess the easiest way is to check if fps_only is enabled and do not do a reload. Is there any reason or are reloading the config when you are using fps_only ?

jon4hz commented 6 months ago

I'm quite new to mangohud so I might not see certain use cases for the reload. But I didn't do the reload to do an actual reload - but only to play around and test how mangohud behaves.

Maybe a reload could be useful, if you use a config file to control mangohud and want to switch from fps_only to another display option without having to restart the entire game.

Dr-Voctor commented 4 months ago

I think I'm having the same issue when launching games with Heroic. For my config I have MANGOHUD_CONFIG=fps_limit=100,fps_only,vsync=0,gl_vsync=-1 in /etc/environment, and all games launch with three FPS counters right from the get-go, no need to Shift_L+F4 even. Steam games are fine, one game I tested with only displays the counter once. Linux distro: Kubuntu Mangohud version: 0.7.1 GPU: radeon RX 6800 XT

Edit: tested with one more Steam game, had the same issue. Difference between them was that game 1 was linux-native (Total War Warhammer 3) and game 2 was windows-native (Ready or Not)

zaps166 commented 4 months ago

Generally it duplicates items when legacy_layout is disabled, this should fix the issue:

diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp
index caa4202..82ad23c 100644
--- a/src/overlay_params.cpp
+++ b/src/overlay_params.cpp
@@ -976,6 +976,7 @@ parse_overlay_config(struct overlay_params *params,
    if (params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout]) {
       HUDElements.legacy_elements();
    } else {
+      HUDElements.ordered_functions.clear();
       for (auto& option : HUDElements.options) {
          HUDElements.sort_elements(option);
       }