From f8341e75d07035f281be7c13e1833c376a796006 Mon Sep 17 00:00:00 2001 From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> Date: Sat, 15 Apr 2023 20:33:57 -0400 Subject: [PATCH] add NVDEC, NVENC, and VIC --- src/gpu.cpp | 9 ++++++ src/gpu.h | 3 ++ src/hud_elements.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++ src/hud_elements.h | 4 +-- src/logging.h | 3 ++ src/overlay.cpp | 3 ++ src/overlay_params.h | 3 ++ 7 files changed, 92 insertions(+), 2 deletions(-) diff --git a/src/gpu.cpp b/src/gpu.cpp index de59468c13a..cddb2c23aae 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -89,6 +89,15 @@ gpu_info.load = std::stoi(read_line("/sys/devices/gpu.0/load")) / 10; // gpu_info.temp = nvidiaTemp; // gpu_info.memoryUsed = nvidiaMemory.used / (1024.f * 1024.f * 1024.f); gpu_info.CoreClock = std::stoi(read_line("/sys/devices/gpu.0/devfreq/57000000.gpu/cur_freq")) / 1000000 ; +if (file_exists("/sys/kernel/debug/clk/nvdec/clk_rate")) { + if (read_line("/sys/kernel/debug/clk/nvdec/clk_state") == "1") gpu_info.NVDECClock = std::stoi(read_line("/sys/kernel/debug/clk/nvdec/clk_rate")) / 1000000 ; else gpu_info.NVDECClock = 0 ; +} +if (file_exists("/sys/kernel/debug/clk/nvenc/clk_rate")) { + if (read_line("/sys/kernel/debug/clk/nvenc/clk_state") == "1") gpu_info.NVENCClock = std::stoi(read_line("/sys/kernel/debug/clk/nvenc/clk_rate")) / 1000000 ; else gpu_info.NVENCClock = 0 ; +} +if (file_exists("/sys/kernel/debug/clk/vic03/clk_rate")) { + if (read_line("/sys/kernel/debug/clk/vic03/clk_state") == "1") gpu_info.VICClock = std::stoi(read_line("/sys/kernel/debug/clk/vic03/clk_rate")) / 1000000 ; else gpu_info.VICClock = 0 ; +} } void getAmdGpuInfo(){ diff --git a/src/gpu.h b/src/gpu.h index c27a36621c5..5e6e2f209ea 100644 --- a/src/gpu.h +++ b/src/gpu.h @@ -34,6 +34,9 @@ struct gpuInfo{ float memoryTotal; int MemClock; int CoreClock; + int NVDECClock; + int NVENCClock; + int VICClock; float powerUsage; float apu_cpu_power; int apu_cpu_temp; diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 47f2ac923ab..94e5bdd9d56 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -297,6 +297,39 @@ void HudElements::gpu_stats(){ HUDElements.TextColored(HUDElements.colors.text, "mV"); ImGui::PopFont(); } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_nvdec_clock]){ + ImGui::TableNextColumn(); + ImGui::TextColored(HUDElements.colors.gpu, "%s", "NVDEC"); + ImGui::TableNextColumn(); + ImguiNextColumnOrNewRow(); + right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.NVDECClock); + ImGui::SameLine(0, 1.0f); + ImGui::PushFont(HUDElements.sw_stats->font1); + ImGui::Text("MHz"); + ImGui::PopFont(); + } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_nvenc_clock]){ + ImGui::TableNextColumn(); + ImGui::TextColored(HUDElements.colors.gpu, "%s", "NVENC"); + ImGui::TableNextColumn(); + ImguiNextColumnOrNewRow(); + right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.NVENCClock); + ImGui::SameLine(0, 1.0f); + ImGui::PushFont(HUDElements.sw_stats->font1); + ImGui::Text("MHz"); + ImGui::PopFont(); + } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_vic_clock]){ + ImGui::TableNextColumn(); + ImGui::TextColored(HUDElements.colors.gpu, "%s", "VIC"); + ImGui::TableNextColumn(); + ImguiNextColumnOrNewRow(); + right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.VICClock); + ImGui::SameLine(0, 1.0f); + ImGui::PushFont(HUDElements.sw_stats->font1); + ImGui::Text("MHz"); + ImGui::PopFont(); + } } } @@ -1338,6 +1371,42 @@ void HudElements::graphs(){ HUDElements.TextColored(HUDElements.colors.engine, "%s", "GPU Core Clock"); } + if (value == "gpu_nvdec_clock"){ + for (auto& it : graph_data){ + arr.push_back(float(it.gpu_nvdec_clock)); + } + if (int(arr.back()) > HUDElements.gpu_nvdec_max) + HUDElements.gpu_nvdec_max = arr.back(); + + HUDElements.max = HUDElements.gpu_nvdec_max; + HUDElements.min = 0; + ImGui::TextColored(HUDElements.colors.engine, "%s", "NVDEC Clock"); + } + + if (value == "gpu_nvenc_clock"){ + for (auto& it : graph_data){ + arr.push_back(float(it.gpu_nvenc_clock)); + } + if (int(arr.back()) > HUDElements.gpu_nvenc_max) + HUDElements.gpu_nvenc_max = arr.back(); + + HUDElements.max = HUDElements.gpu_nvenc_max; + HUDElements.min = 0; + ImGui::TextColored(HUDElements.colors.engine, "%s", "NVENC Clock"); + } + + if (value == "gpu_vic_clock"){ + for (auto& it : graph_data){ + arr.push_back(float(it.gpu_vic_clock)); + } + if (int(arr.back()) > HUDElements.gpu_vic_max) + HUDElements.gpu_vic_max = arr.back(); + + HUDElements.max = HUDElements.gpu_vic_max; + HUDElements.min = 0; + ImGui::TextColored(HUDElements.colors.engine, "%s", "VIC Clock"); + } + if (value == "gpu_mem_clock"){ for (auto& it : graph_data){ arr.push_back(float(it.gpu_mem_clock)); diff --git a/src/hud_elements.h b/src/hud_elements.h index f49fa54a3cc..e0fab4593fe 100644 --- a/src/hud_elements.h +++ b/src/hud_elements.h @@ -42,9 +42,9 @@ class HudElements{ std::vector ordered_functions; std::vector gamescope_debug_latency {}; std::vector gamescope_debug_app {}; - int min, max, gpu_core_max, gpu_mem_max, cpu_temp_max, gpu_temp_max; + int min, max, gpu_core_max, gpu_nvdec_max, gpu_nvenc_max, gpu_vic_max, gpu_mem_max, cpu_temp_max, gpu_temp_max; const std::vector permitted_params = { - "gpu_load", "cpu_load", "gpu_core_clock", "gpu_mem_clock", + "gpu_load", "cpu_load", "gpu_core_clock", "gpu_nvdec_clock", "gpu_nvenc_max", "gpu_vic_max", "gpu_mem_clock", "vram", "ram", "cpu_temp", "gpu_temp" }; std::vector exec_list; diff --git a/src/logging.h b/src/logging.h index 309cdb73e52..c83dbdd45bc 100644 --- a/src/logging.h +++ b/src/logging.h @@ -21,6 +21,9 @@ struct logData{ int cpu_temp; int gpu_temp; int gpu_core_clock; + int gpu_nvdec_clock; + int gpu_nvenc_clock; + int gpu_vic_clock; int gpu_mem_clock; int gpu_power; float gpu_vram_used; diff --git a/src/overlay.cpp b/src/overlay.cpp index 0b8776d3f74..62ebfe041a9 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -164,6 +164,9 @@ void update_hw_info(const struct overlay_params& params, uint32_t vendorID) currentLogData.gpu_load = gpu_info.load; currentLogData.gpu_temp = gpu_info.temp; currentLogData.gpu_core_clock = gpu_info.CoreClock; + currentLogData.gpu_nvdec_clock = gpu_info.NVDECClock; + currentLogData.gpu_nvenc_clock = gpu_info.NVENCClock; + currentLogData.gpu_vic_clock = gpu_info.VICClock; currentLogData.gpu_mem_clock = gpu_info.MemClock; currentLogData.gpu_vram_used = gpu_info.memoryUsed; currentLogData.gpu_power = gpu_info.powerUsage; diff --git a/src/overlay_params.h b/src/overlay_params.h index c77bd8ff8a2..985a7b16ed3 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -54,6 +54,9 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(io_write) \ OVERLAY_PARAM_BOOL(gpu_mem_clock) \ OVERLAY_PARAM_BOOL(gpu_core_clock) \ + OVERLAY_PARAM_BOOL(gpu_nvdec_clock) \ + OVERLAY_PARAM_BOOL(gpu_nvenc_clock) \ + OVERLAY_PARAM_BOOL(gpu_vic_clock) \ OVERLAY_PARAM_BOOL(gpu_power) \ OVERLAY_PARAM_BOOL(arch) \ OVERLAY_PARAM_BOOL(media_player) \