From 94a8dfb65849decee294acf9dd1a15a6738c3574 Mon Sep 17 00:00:00 2001 From: flightlessmango Date: Tue, 7 Nov 2023 20:55:06 +0100 Subject: [PATCH] Add hdr and refresh rate options --- README.md | 2 ++ data/MangoHud.conf | 5 +++++ src/app/main.cpp | 10 ++++++++-- src/hud_elements.cpp | 41 ++++++++++++++++++++++++++--------------- src/hud_elements.h | 4 ++++ src/overlay_params.h | 2 ++ 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 64c5455a..cbee22c3 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,8 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu | `frame_count` | Display frame count | | `frametime` | Display frametime next to FPS text | | `fsr` | Display the status of FSR (only works in gamescope) | +| `hdr` | Display the status of HDR (only works in gamescope) | +| `refresh_rate` | Display the current refresh rate (only works in gamescope) | | `full` | Enable most of the toggleable parameters (currently excludes `histogram`) | | `gamemode` | Show if GameMode is on | | `gpu_color`
`cpu_color`
`vram_color`
`ram_color`
`io_color`
`engine_color`
`frametime_color`
`background_color`
`text_color`
`media_player_color` | Change default colors: `gpu_color=RRGGBB` | diff --git a/data/MangoHud.conf b/data/MangoHud.conf index b2d87431..490a1945 100644 --- a/data/MangoHud.conf +++ b/data/MangoHud.conf @@ -170,6 +170,11 @@ frame_timing # hide_fsr_sharpness ## Shows the graph of gamescope app frametimes and latency (only on gamescope obviously) # debug +## Display the status of HDR (only works in gamescope) +# hdr +## Display the current refresh rate (only works in gamescope) +# refresh_rate + ### graphs displays one or more graphs that you chose ## seperated by ",", available graphs are diff --git a/src/app/main.cpp b/src/app/main.cpp index dadf6e13..258af694 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -51,7 +51,7 @@ static uint32_t screenWidth, screenHeight; static unsigned int get_prop(const char* propName){ Display *x11_display = glfwGetX11Display(); - Atom gamescope_focused = XInternAtom(x11_display, propName, true); + Atom gamescope_focused = XInternAtom(x11_display, propName, false); auto scr = DefaultScreen(x11_display); auto root = RootWindow(x11_display, scr); Atom actual; @@ -73,7 +73,7 @@ static unsigned int get_prop(const char* propName){ } return i; } - return 0; + return -1; } static void ctrl_thread(){ @@ -242,6 +242,11 @@ static void shutdown(GLFWwindow* window){ glfwDestroyWindow(window); } +static void get_atom_info(){ + HUDElements.hdr_status = get_prop("GAMESCOPE_COLOR_APP_WANTS_HDR_FEEDBACK"); + HUDElements.refresh = get_prop("GAMESCOPE_DISPLAY_REFRESH_RATE_FEEDBACK"); +} + static bool render(GLFWwindow* window) { if (HUDElements.colors.update) HUDElements.convert_colors(params); @@ -253,6 +258,7 @@ static bool render(GLFWwindow* window) { overlay_new_frame(params); position_layer(sw_stats, params, window_size); render_imgui(sw_stats, params, window_size, true); + get_atom_info(); overlay_end_frame(); if (screenWidth && screenHeight) glfwSetWindowSize(window, screenWidth, screenHeight); diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 6071050e..8a41bfc6 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -1371,20 +1371,25 @@ void HudElements::fps_metrics(){ ImGui::PopFont(); ImguiNextColumnOrNewRow(); } - - // HUDElements.TextColored(HUDElements.colors.engine, "%s", "AVG"); - // ImguiNextColumnOrNewRow(); - // right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.0f", HUDElements.fps_avg); - // ImGui::SameLine(0, 1.0f); - // ImGui::PushFont(HUDElements.sw_stats->font1); - // HUDElements.TextColored(HUDElements.colors.text, "FPS"); - // ImGui::PopFont(); - // ImguiNextColumnOrNewRow(); - // right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.1f", 1000 / HUDElements.fps_avg); - // ImGui::SameLine(0, 1.0f); - // ImGui::PushFont(HUDElements.sw_stats->font1); - // HUDElements.TextColored(HUDElements.colors.text, "ms"); - // ImGui::PopFont(); + +} + +void HudElements::hdr() { + if (HUDElements.hdr_status > 0) { + ImguiNextColumnFirstItem(); + HUDElements.TextColored(HUDElements.colors.engine, "%s", "HDR"); + ImguiNextColumnOrNewRow(); + right_aligned_text(HUDElements.colors.fps_value_high, HUDElements.ralign_width, "ON"); + } +} + +void HudElements::refresh_rate() { + if (HUDElements.refresh > 0) { + ImguiNextColumnFirstItem(); + HUDElements.TextColored(HUDElements.colors.engine, "%s", "Display Hz"); + ImguiNextColumnOrNewRow(); + right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", HUDElements.refresh); + } } void HudElements::sort_elements(const std::pair& option) { @@ -1429,7 +1434,9 @@ void HudElements::sort_elements(const std::pair& optio {"exec_name", {exec_name}}, {"duration", {duration}}, {"graphs", {graphs}}, - {"fps_metrics", {fps_metrics}} + {"fps_metrics", {fps_metrics}}, + {"hdr", {hdr}}, + {"refresh_rate", {refresh_rate}} }; auto check_param = display_params.find(param); @@ -1497,6 +1504,10 @@ void HudElements::legacy_elements(){ ordered_functions.push_back({fan, "fan", value}); if (params->enabled[OVERLAY_PARAM_ENABLED_fsr]) ordered_functions.push_back({gamescope_fsr, "gamescope_fsr", value}); + if (params->enabled[OVERLAY_PARAM_ENABLED_hdr]) + ordered_functions.push_back({hdr, "hdr", value}); + if (params->enabled[OVERLAY_PARAM_ENABLED_refresh_rate]) + ordered_functions.push_back({refresh_rate, "refresh_rate", value}); if (params->enabled[OVERLAY_PARAM_ENABLED_throttling_status]) ordered_functions.push_back({throttling_status, "throttling_status", value}); if (params->enabled[OVERLAY_PARAM_ENABLED_fps]) diff --git a/src/hud_elements.h b/src/hud_elements.h index 6f7594e2..01ae5600 100644 --- a/src/hud_elements.h +++ b/src/hud_elements.h @@ -44,6 +44,8 @@ class HudElements{ std::vector exec_list; std::chrono::steady_clock::time_point overlay_start = std::chrono::steady_clock::now(); uint32_t vendorID; + int hdr_status = 0; + int refresh = 0; void sort_elements(const std::pair& option); void legacy_elements(); @@ -85,6 +87,8 @@ class HudElements{ static void exec_name(); static void duration(); static void fps_metrics(); + static void hdr(); + static void refresh_rate(); void convert_colors(const struct overlay_params& params); void convert_colors(bool do_conv, const struct overlay_params& params); diff --git a/src/overlay_params.h b/src/overlay_params.h index 7e9e96a8..f561e641 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -106,6 +106,8 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(dynamic_frame_timing) \ OVERLAY_PARAM_BOOL(duration) \ OVERLAY_PARAM_BOOL(inherit) \ + OVERLAY_PARAM_BOOL(hdr) \ + OVERLAY_PARAM_BOOL(refresh_rate) \ OVERLAY_PARAM_CUSTOM(fps_sampling_period) \ OVERLAY_PARAM_CUSTOM(output_folder) \ OVERLAY_PARAM_CUSTOM(output_file) \