diff --git a/src/gpu.cpp b/src/gpu.cpp index 7d3fb69c..57724f38 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -1,9 +1,29 @@ -#include "memory.h" #include "gpu.h" +#include +#include "nvctrl.h" +#ifdef HAVE_NVML +#include "nvidia_info.h" +#endif struct gpuInfo gpu_info; amdgpu_files amdgpu {}; +bool checkNvidia(const char *pci_dev){ + bool nvSuccess = false; +#ifdef HAVE_NVML + nvSuccess = checkNVML(pci_dev) && getNVMLInfo(); +#endif +#ifdef HAVE_XNVCTRL + if (!nvSuccess) + nvSuccess = checkXNVCtrl(); +#endif +#ifdef _WIN32 + if (!nvSuccess) + nvSuccess = checkNVAPI(); +#endif + return nvSuccess; +} + void getNvidiaGpuInfo(){ #ifdef HAVE_NVML if (nvmlSuccess){ diff --git a/src/gpu.h b/src/gpu.h index 16122b70..8c2b0638 100644 --- a/src/gpu.h +++ b/src/gpu.h @@ -2,14 +2,7 @@ #ifndef MANGOHUD_GPU_H #define MANGOHUD_GPU_H -#include -#include -#include #include -#include "nvctrl.h" -#ifdef HAVE_NVML -#include "nvidia_info.h" -#endif struct amdgpu_files { @@ -38,6 +31,7 @@ extern struct gpuInfo gpu_info; void getNvidiaGpuInfo(void); void getAmdGpuInfo(void); +bool checkNvidia(const char *pci_dev); extern void nvapi_util(); extern bool checkNVAPI(); #endif //MANGOHUD_GPU_H diff --git a/src/vulkan.cpp b/src/vulkan.cpp index 264b4662..eb44764e 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -518,26 +518,12 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params) if (vendorID == 0x8086 || vendorID == 0x10de) { - bool nvSuccess = false; -#ifdef HAVE_NVML - nvSuccess = checkNVML(pci_dev) && getNVMLInfo(); -#endif -#ifdef HAVE_XNVCTRL - if (!nvSuccess) - nvSuccess = checkXNVCtrl(); -#endif -#ifdef _WIN32 - if (!nvSuccess) - nvSuccess = checkNVAPI(); -#endif - - if(not nvSuccess) { - params.enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = false; - } - else { + if(checkNvidia(pci_dev)) vendorID = 0x10de; - } + else + params.enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = false; } + #ifdef __gnu_linux__ if (vendorID == 0x8086 || vendorID == 0x1002 || gpu.find("Radeon") != std::string::npos