Add meson option `with_nvml`

pull/208/head
jackun 4 years ago
parent a236af66ee
commit 953c8d0e0f
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -4,6 +4,7 @@ option('use_system_nvml', type : 'boolean', value : false, description : 'Use sy
option('mangohud_prefix', type : 'string', value : '', description: 'Add prefix to cross-compiled library, like "lib32-".')
option('append_libdir_mangohud', type : 'boolean', value : true, description: 'Append "mangohud" to libdir path or not.')
option('include_doc', type : 'boolean', value : true, description: 'Include the example config')
option('with_nvml', type : 'combo', value : 'enabled', choices: ['enabled', 'system', 'disabled'], description: 'Enable NVML support')
option('with_xnvctrl', type : 'feature', value : 'enabled', description: 'Enable XNVCtrl support')
option('with_x11', type : 'feature', value : 'enabled')
option('with_wayland', type : 'feature', value : 'disabled')

@ -6,6 +6,7 @@ struct gpuInfo gpu_info;
amdgpu_files amdgpu {};
void getNvidiaGpuInfo(){
#ifdef HAVE_NVML
if (nvmlSuccess){
getNVMLInfo();
gpu_info.load = nvidiaUtilization.gpu;
@ -14,9 +15,11 @@ void getNvidiaGpuInfo(){
gpu_info.CoreClock = nvidiaCoreClock;
gpu_info.MemClock = nvidiaMemClock;
gpu_info.powerUsage = nvidiaPowerUsage / 1000;
return;
}
#endif
#ifdef HAVE_XNVCTRL
else if (nvctrlSuccess) {
if (nvctrlSuccess) {
getNvctrlInfo();
gpu_info.load = nvctrl_info.load;
gpu_info.temp = nvctrl_info.temp;
@ -24,6 +27,7 @@ void getNvidiaGpuInfo(){
gpu_info.CoreClock = nvctrl_info.CoreClock;
gpu_info.MemClock = nvctrl_info.MemClock;
gpu_info.powerUsage = 0;
return;
}
#endif
}

@ -24,8 +24,6 @@ vklayer_files = files(
'font_unispace.c',
'blacklist.cpp',
'cpu.cpp',
'loaders/loader_nvml.cpp',
'nvml.cpp',
'file_utils.cpp',
'memory.cpp',
'config.cpp',
@ -48,6 +46,22 @@ if get_option('with_dlsym').enabled()
pre_args += '-DHOOK_DLSYM'
endif
nvml_h_found = get_option('with_nvml') == 'enabled'
if get_option('with_nvml') == 'system'
nvml_h_found = cc.has_header('nvml.h')
if not nvml_h_found
error('nvml.h was not found. Disable with \'-Dwith_nvml=disabled\' if gpu stats by NVML is not needed.')
endif
endif
if nvml_h_found
pre_args += '-DHAVE_NVML'
vklayer_files += files(
'nvml.cpp',
'loaders/loader_nvml.cpp',
)
endif
if get_option('with_xnvctrl').enabled()
if not get_option('with_x11').enabled()
@ -56,7 +70,7 @@ if get_option('with_xnvctrl').enabled()
xnvctrl_h_found = cc.has_header('NVCtrl/NVCtrl.h')
if not xnvctrl_h_found
error('NVCtrl.h was not found. Disable with \'with_xnvctrl\' if this feature is not needed.')
error('NVCtrl.h was not found. Disable with \'-Dwith_xnvctrl=disabled\' if gpu stats by XNVCtrl is not needed.')
endif
pre_args += '-DHAVE_XNVCTRL'

@ -797,8 +797,10 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
if (vendorID == 0x8086
|| vendorID == 0x10de) {
bool nvSuccess = (checkNVML(pci_dev) && getNVMLInfo());
bool nvSuccess = false;
#ifdef HAVE_NVML
nvSuccess = checkNVML(pci_dev) && getNVMLInfo();
#endif
#ifdef HAVE_XNVCTRL
if (!nvSuccess)
nvSuccess = checkXNVCtrl();

Loading…
Cancel
Save