diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 07031c43..832e3d3b 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -235,13 +235,24 @@ void HudElements::gpu_stats(){ 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); - ImGui::SameLine(0, 1.0f); - ImGui::PushFont(HUDElements.sw_stats->font1); - HUDElements.TextColored(HUDElements.colors.text, "RPM"); - ImGui::PopFont(); + if (deviceID == 7815 || deviceID == 29772){ + 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); + ImGui::SameLine(0, 1.0f); + // if Nvidia GPU + if (deviceID == 7815) { + HUDElements.TextColored(HUDElements.colors.text, "%%"); + ImGui::PushFont(HUDElements.sw_stats->font1); + ImGui::SameLine(0, 1.0f); + HUDElements.TextColored(HUDElements.colors.text, "FAN"); + // if AMD GPU + } else if (deviceID == 29772) { + ImGui::PushFont(HUDElements.sw_stats->font1); + HUDElements.TextColored(HUDElements.colors.text, "RPM"); + } + ImGui::PopFont(); + } } if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock]){ diff --git a/src/loaders/loader_nvml.cpp b/src/loaders/loader_nvml.cpp index fdf3e406..5b850117 100644 --- a/src/loaders/loader_nvml.cpp +++ b/src/loaders/loader_nvml.cpp @@ -240,6 +240,19 @@ bool libnvml_loader::Load(const std::string& library_name) { return false; } +#if defined(LIBRARY_LOADER_NVML_H_DLOPEN) + nvmlDeviceGetFanSpeed = + reinterpret_castnvmlDeviceGetFanSpeed)>( + dlsym(library_, "nvmlDeviceGetFanSpeed")); +#endif +#if defined(LIBRARY_LOADER_NVML_H_DT_NEEDED) + nvmlDeviceGetFanSpeed = &::nvmlDeviceGetFanSpeed; +#endif + if (!nvmlDeviceGetFanSpeed) { + CleanUp(true); + return false; + } + loaded_ = true; return true; } @@ -264,4 +277,5 @@ void libnvml_loader::CleanUp(bool unload) { nvmlDeviceGetCurrentClocksThrottleReasons = NULL; nvmlUnitGetFanSpeedInfo = NULL; nvmlUnitGetHandleByIndex = NULL; + nvmlDeviceGetFanSpeed = NULL; } diff --git a/src/loaders/loader_nvml.h b/src/loaders/loader_nvml.h index e5b99a91..4277ddf8 100644 --- a/src/loaders/loader_nvml.h +++ b/src/loaders/loader_nvml.h @@ -40,7 +40,8 @@ class libnvml_loader { decltype(&::nvmlDeviceGetCurrentClocksThrottleReasons) nvmlDeviceGetCurrentClocksThrottleReasons; decltype(&::nvmlUnitGetFanSpeedInfo) nvmlUnitGetFanSpeedInfo; decltype(&::nvmlUnitGetHandleByIndex) nvmlUnitGetHandleByIndex; - + decltype(&::nvmlDeviceGetFanSpeed) nvmlDeviceGetFanSpeed; + private: void CleanUp(bool unload); diff --git a/src/nvml.cpp b/src/nvml.cpp index 7bf3c03e..4c1abba7 100644 --- a/src/nvml.cpp +++ b/src/nvml.cpp @@ -14,7 +14,6 @@ unsigned int nvidiaTemp = 0, nvidiaCoreClock = 0, nvidiaMemClock = 0, nvidiaPowe unsigned long long nvml_throttle_reasons; struct nvmlUtilization_st nvidiaUtilization; struct nvmlMemory_st nvidiaMemory {}; -struct nvmlUnitFanSpeeds_st nvidiaFanSpeeds {}; struct nvmlUnit_st* nvidiaUnit {}; bool checkNVML(const char* pciBusId){ @@ -62,6 +61,8 @@ bool getNVMLInfo(const struct overlay_params& params){ if (params.enabled[OVERLAY_PARAM_ENABLED_throttling_status]) nvml.nvmlDeviceGetCurrentClocksThrottleReasons(nvidiaDevice, &nvml_throttle_reasons); + nvml.nvmlDeviceGetFanSpeed(nvidiaDevice, &nvidiaFanSpeed); + if (response == NVML_ERROR_NOT_SUPPORTED) { if (nvmlSuccess) SPDLOG_ERROR("nvmlDeviceGetUtilizationRates failed");