mirror of
https://github.com/flightlessmango/MangoHud.git
synced 2024-11-10 01:10:27 +00:00
fetch nvidia vram used from nvctrl
This commit is contained in:
parent
23280e0e78
commit
6affdb8c51
@ -14,6 +14,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include "nvidia_info.h"
|
#include "nvidia_info.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "nvctrl.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -74,6 +76,7 @@ void *getNvidiaGpuInfo(void *){
|
|||||||
getNvidiaInfo();
|
getNvidiaInfo();
|
||||||
gpuLoad = nvidiaUtilization.gpu;
|
gpuLoad = nvidiaUtilization.gpu;
|
||||||
gpuTemp = nvidiaTemp;
|
gpuTemp = nvidiaTemp;
|
||||||
|
gpuMemUsed = nvidiaMemUsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_detach(nvidiaSmiThread);
|
pthread_detach(nvidiaSmiThread);
|
||||||
|
@ -40,8 +40,10 @@ vklayer_files = files(
|
|||||||
'nvml.cpp',
|
'nvml.cpp',
|
||||||
'file_utils.cpp',
|
'file_utils.cpp',
|
||||||
'memory.cpp',
|
'memory.cpp',
|
||||||
|
'nvctrl.cpp',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lib_xnvctrl = cc.find_library('XNVCtrl')
|
||||||
vklayer_mesa_overlay = shared_library(
|
vklayer_mesa_overlay = shared_library(
|
||||||
'MangoHud',
|
'MangoHud',
|
||||||
util_files,
|
util_files,
|
||||||
@ -64,7 +66,8 @@ vklayer_mesa_overlay = shared_library(
|
|||||||
vulkan_wsi_deps,
|
vulkan_wsi_deps,
|
||||||
libimgui_core_dep,
|
libimgui_core_dep,
|
||||||
dep_dl,
|
dep_dl,
|
||||||
dep_pthread],
|
dep_pthread,
|
||||||
|
lib_xnvctrl],
|
||||||
include_directories : inc_common,
|
include_directories : inc_common,
|
||||||
link_args : cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro']),
|
link_args : cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro']),
|
||||||
install : true
|
install : true
|
||||||
|
13
src/nvctrl.cpp
Normal file
13
src/nvctrl.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "nvctrl.h"
|
||||||
|
Display *display = XOpenDisplay(NULL);
|
||||||
|
|
||||||
|
int nvidiaMemUsed(){
|
||||||
|
int ret;
|
||||||
|
XNVCTRLQueryTargetAttribute(display,
|
||||||
|
NV_CTRL_TARGET_TYPE_GPU,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NV_CTRL_USED_DEDICATED_GPU_MEMORY,
|
||||||
|
&ret);
|
||||||
|
return ret;
|
||||||
|
}
|
5
src/nvctrl.h
Normal file
5
src/nvctrl.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include "NVCtrl/NVCtrl.h"
|
||||||
|
#include "NVCtrl/NVCtrlLib.h"
|
||||||
|
|
||||||
|
int nvidiaMemUsed(void);
|
@ -29,5 +29,5 @@ void getNvidiaInfo(){
|
|||||||
nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice);
|
nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice);
|
||||||
nvml.nvmlDeviceGetUtilizationRates(nvidiaDevice, &nvidiaUtilization);
|
nvml.nvmlDeviceGetUtilizationRates(nvidiaDevice, &nvidiaUtilization);
|
||||||
nvml.nvmlDeviceGetTemperature(nvidiaDevice, NVML_TEMPERATURE_GPU, &nvidiaTemp);
|
nvml.nvmlDeviceGetTemperature(nvidiaDevice, NVML_TEMPERATURE_GPU, &nvidiaTemp);
|
||||||
nvml.nvmlDeviceGetMemoryInfo(nvidiaDevice, &nvidiaMemory);
|
// nvml.nvmlDeviceGetMemoryInfo(nvidiaDevice, &nvidiaMemory);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user