use intel_gpu_top for gpu stats

pull/853/head
FlightlessMango 2 years ago
parent 2f01d15690
commit e38413b2d8

@ -134,7 +134,9 @@ void imgui_create(void *ctx)
|| deviceName.find("AMD") != std::string::npos
|| deviceName.find("NAVI") != std::string::npos) {
vendorID = 0x1002;
} else {
} else if (deviceName.find("Intel") != std::string::npos) {
vendorID = 0x8086;
} else {
vendorID = 0x10de;
}
if (deviceName.find("zink") != std::string::npos)

@ -42,6 +42,7 @@ extern struct gpuInfo gpu_info;
void getNvidiaGpuInfo(const struct overlay_params& params);
void getAmdGpuInfo(void);
void getIntelGpuInfo();
bool checkNvidia(const char *pci_dev);
extern void nvapi_util();
extern bool checkNVAPI();

@ -0,0 +1,57 @@
#include <thread>
#include "overlay.h"
#include "gpu.h"
#include "spdlog/spdlog.h"
static bool init_intel = false;
struct gpuInfo gpu_info_intel {};
void intelGpuThread(){
init_intel = true;
static char stdout_buffer[1024];
FILE* intel_gpu_top = popen("intel_gpu_top -l -s 500", "r");
while (fgets(stdout_buffer, sizeof(stdout_buffer), intel_gpu_top)) {
if (strstr(stdout_buffer, "Freq") == NULL &&
strstr(stdout_buffer, "req") == NULL) {
char * pch;
pch = strtok(stdout_buffer, " ");
int i = 0;
while (pch != NULL){
switch (i){
case 0:
gpu_info_intel.CoreClock = atoi(pch);
break;
case 4:
gpu_info_intel.powerUsage = atof(pch);
break;
case 5:
gpu_info_intel.apu_cpu_power = atof(pch);
break;
case 8:
gpu_info_intel.load = atoi(pch);
break;
}
pch = strtok(NULL, " ");
i++;
}
}
}
int exitcode = pclose(intel_gpu_top) / 256;
if (exitcode > 0){
if (exitcode == 127)
SPDLOG_INFO("Failed to open '{}'", "intel_gpu_top");
if (exitcode == 1)
SPDLOG_INFO("Missing permissions for '{}'", "intel_gpu_top");
SPDLOG_INFO("Disabling gpu_stats");
_params->enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = false;
}
}
void getIntelGpuInfo(){
if (!init_intel)
std::thread(intelGpuThread).detach();
gpu_info = gpu_info_intel;
}

@ -55,6 +55,7 @@ vklayer_files = files(
'blacklist.cpp',
'file_utils.cpp',
'amdgpu.cpp',
'intel.cpp'
)
opengl_files = []
if ['windows', 'mingw'].contains(host_machine.system())

@ -128,6 +128,9 @@ void update_hw_info(const struct overlay_params& params, uint32_t vendorID)
if (vendorID == 0x10de)
getNvidiaGpuInfo(params);
if (vendorID== 0x8086)
getIntelGpuInfo();
}
#ifdef __linux__
@ -681,12 +684,10 @@ void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_para
if(checkNvidia(pci_dev))
vendorID = 0x10de;
else
params.enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = false;
}
#ifdef __linux__
if (vendorID == 0x8086 || vendorID == 0x1002
if (vendorID == 0x1002
|| gpu.find("Radeon") != std::string::npos
|| gpu.find("AMD") != std::string::npos) {
string path;

Loading…
Cancel
Save