From d41a74ca1aa018a01e22a0a6f7983d54490cf656 Mon Sep 17 00:00:00 2001 From: Arvind Doobary Date: Thu, 29 Sep 2022 11:33:11 +0400 Subject: [PATCH] Show amdgpu junction and memory temp, if available Added config parameter `gpu_junction_temp` and `gpu_mem_temp` Closes #841 --- README.md | 2 +- data/MangoHud.conf | 4 +++- src/gpu.cpp | 20 +++++++++++++++++++- src/gpu.h | 4 ++++ src/hud_elements.cpp | 23 +++++++++++++++++++++++ src/overlay.cpp | 7 ++++++- src/overlay_params.cpp | 2 ++ src/overlay_params.h | 2 ++ 8 files changed, 60 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6242413a..467cff11 100644 --- a/README.md +++ b/README.md @@ -318,7 +318,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu | `cpu_load_value` | Set the values for medium and high load e.g `cpu_load_value=50,90` | | `cpu_mhz` | Show the CPUs current MHz | | `cpu_power`
`gpu_power` | Display CPU/GPU draw in watts | -| `cpu_temp`
`gpu_temp` | Display current CPU/GPU temperature | +| `cpu_temp`
`gpu_temp`
`gpu_junction_temp`
`gpu_mem_temp` | Display current CPU/GPU temperature | | `cpu_text`
`gpu_text` | Override CPU and GPU text | | `custom_text_center` | Display a custom text centered useful for a header e.g `custom_text_center=FlightLessMango Benchmarks` | | `custom_text` | Display a custom text e.g `custom_text=Fsync enabled` | diff --git a/data/MangoHud.conf b/data/MangoHud.conf index f50d0052..ff164e5b 100644 --- a/data/MangoHud.conf +++ b/data/MangoHud.conf @@ -53,10 +53,12 @@ # version ### Display the current GPU information -## Note: gpu_mem_clock also needs "vram" to be enabled +## Note: gpu_mem_clock and gpu_mem_temp also need "vram" to be enabled gpu_stats # gpu_temp +# gpu_junction_temp # gpu_core_clock +# gpu_mem_temp # gpu_mem_clock # gpu_power # gpu_text=GPU diff --git a/src/gpu.cpp b/src/gpu.cpp index 93876e3c..f046f20b 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -138,7 +138,7 @@ void getAmdGpuInfo(){ gpu_info.memoryUsed = float(value) / (1024 * 1024 * 1024); } // On some GPUs SMU can sometimes return the wrong temperature. - // As HWMON is way more visible than the SMU metrics, let's always trust it as it is the most likely to work + // As HWMON is way more visible than the SMU metrics, let's always trust it as it is the most likely to work if (amdgpu.temp){ rewind(amdgpu.temp); fflush(amdgpu.temp); @@ -148,6 +148,24 @@ void getAmdGpuInfo(){ gpu_info.temp = value / 1000; } + if (amdgpu.junction_temp){ + rewind(amdgpu.junction_temp); + fflush(amdgpu.junction_temp); + int value = 0; + if (fscanf(amdgpu.junction_temp, "%d", &value) != 1) + value = 0; + gpu_info.junction_temp = value / 1000; + } + + if (amdgpu.memory_temp){ + rewind(amdgpu.memory_temp); + fflush(amdgpu.memory_temp); + int value = 0; + if (fscanf(amdgpu.memory_temp, "%d", &value) != 1) + value = 0; + gpu_info.memory_temp = value / 1000; + } + if (amdgpu.gtt_used) { rewind(amdgpu.gtt_used); fflush(amdgpu.gtt_used); diff --git a/src/gpu.h b/src/gpu.h index a78f292f..07ceeb77 100644 --- a/src/gpu.h +++ b/src/gpu.h @@ -13,6 +13,8 @@ struct amdgpu_files /* The following can be NULL, in that case we're using the gpu_metrics node */ FILE *busy; FILE *temp; + FILE *junction_temp; + FILE *memory_temp; FILE *core_clock; FILE *memory_clock; FILE *power_usage; @@ -25,6 +27,8 @@ extern amdgpu_files amdgpu; struct gpuInfo{ int load; int temp; + int junction_temp {-1}; + int memory_temp {-1}; float memoryUsed; float memoryTotal; int MemClock; diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 904c025b..4519d44e 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -172,6 +172,7 @@ void HudElements::gpu_stats(){ // ImGui::SameLine(150); // ImGui::Text("%s", "%"); } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp]){ ImguiNextColumnOrNewRow(); right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.temp); @@ -181,6 +182,18 @@ void HudElements::gpu_stats(){ else ImGui::Text("°C"); } + + if (gpu_info.junction_temp > -1 && HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_junction_temp]) { + ImguiNextColumnOrNewRow(); + right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.junction_temp); + ImGui::SameLine(0, 1.0f); + ImGui::Text("°C"); + ImGui::SameLine(0, 1.0f); + ImGui::PushFont(HUDElements.sw_stats->font1); + ImGui::Text("Jnc"); + ImGui::PopFont(); + } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_fan] && cpuStats.cpu_type != "APU"){ ImguiNextColumnOrNewRow(); right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.fan_speed); @@ -189,6 +202,7 @@ void HudElements::gpu_stats(){ ImGui::Text("RPM"); ImGui::PopFont(); } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock]){ ImguiNextColumnOrNewRow(); right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.CoreClock); @@ -197,6 +211,7 @@ void HudElements::gpu_stats(){ ImGui::Text("MHz"); ImGui::PopFont(); } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_power]) { ImguiNextColumnOrNewRow(); char str[16]; @@ -370,6 +385,14 @@ void HudElements::vram(){ ImGui::PushFont(HUDElements.sw_stats->font1); ImGui::Text("GiB"); ImGui::PopFont(); + + if (gpu_info.memory_temp > -1 && HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_mem_temp]) { + ImguiNextColumnOrNewRow(); + right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", gpu_info.memory_temp); + ImGui::SameLine(0, 1.0f); + ImGui::Text("°C"); + } + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_mem_clock]){ ImguiNextColumnOrNewRow(); right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", gpu_info.MemClock); diff --git a/src/overlay.cpp b/src/overlay.cpp index d4583839..24f573cb 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -772,9 +772,14 @@ void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_para const std::string hwmon_path = device_path + "/hwmon/"; const auto dirs = ls(hwmon_path.c_str(), "hwmon", LS_DIRS); - for (const auto& dir : dirs) + for (const auto& dir : dirs) { if (!amdgpu.temp) amdgpu.temp = fopen((hwmon_path + dir + "/temp1_input").c_str(), "r"); + if (!amdgpu.junction_temp) + amdgpu.junction_temp = fopen((hwmon_path + dir + "/temp2_input").c_str(), "r"); + if (!amdgpu.memory_temp) + amdgpu.memory_temp = fopen((hwmon_path + dir + "/temp3_input").c_str(), "r"); + } if (!metrics_path.empty()) break; diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 3bac1e81..16042ba0 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -591,6 +591,8 @@ parse_overlay_config(struct overlay_params *params, params->enabled[OVERLAY_PARAM_ENABLED_cpu_temp] = false; params->enabled[OVERLAY_PARAM_ENABLED_cpu_power] = false; params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp] = false; + params->enabled[OVERLAY_PARAM_ENABLED_gpu_junction_temp] = false; + params->enabled[OVERLAY_PARAM_ENABLED_gpu_mem_temp] = false; params->enabled[OVERLAY_PARAM_ENABLED_cpu_stats] = true; params->enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = true; params->enabled[OVERLAY_PARAM_ENABLED_ram] = false; diff --git a/src/overlay_params.h b/src/overlay_params.h index 872f1f8c..b3c69362 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -31,6 +31,8 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(cpu_temp) \ OVERLAY_PARAM_BOOL(cpu_power) \ OVERLAY_PARAM_BOOL(gpu_temp) \ + OVERLAY_PARAM_BOOL(gpu_junction_temp) \ + OVERLAY_PARAM_BOOL(gpu_mem_temp) \ OVERLAY_PARAM_BOOL(cpu_stats) \ OVERLAY_PARAM_BOOL(gpu_stats) \ OVERLAY_PARAM_BOOL(ram) \