From bb58f18b36f1ad7e3beffdbbfaad26ce1087066a Mon Sep 17 00:00:00 2001 From: Krzysztof Bogacki Date: Mon, 6 Jun 2022 02:52:54 +0200 Subject: nvml: Allow some NVML functions to be missing --- src/nvapi_gpu.cpp | 11 +++++++++++ src/sysinfo/nvml.cpp | 32 +++++++++++++++++++------------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/nvapi_gpu.cpp b/src/nvapi_gpu.cpp index 31c2e6a..91f0968 100644 --- a/src/nvapi_gpu.cpp +++ b/src/nvapi_gpu.cpp @@ -307,6 +307,9 @@ extern "C" { case NVML_SUCCESS: str::tonvss(szBiosRevision, version); return Ok(n); + case NVML_ERROR_FUNCTION_NOT_FOUND: + str::tonvss(szBiosRevision, "N/A"); + return Ok(n); case NVML_ERROR_NOT_SUPPORTED: return NotSupported(n); case NVML_ERROR_GPU_IS_LOST: @@ -358,6 +361,8 @@ extern "C" { pDynamicPstatesInfoEx->utilization[i].bIsPresent = 0; return Ok(n, alreadyLoggedOk); + case NVML_ERROR_FUNCTION_NOT_FOUND: + return NoImplementation(n, alreadyLoggedNoNvml); case NVML_ERROR_NOT_SUPPORTED: pDynamicPstatesInfoEx->flags = 0; for (auto& util : pDynamicPstatesInfoEx->utilization) @@ -428,6 +433,8 @@ extern "C" { return Error(n); // Unreachable, but just to be sure } return Ok(n, alreadyLoggedOk); + case NVML_ERROR_FUNCTION_NOT_FOUND: + return NoImplementation(n, alreadyLoggedNoNvml); case NVML_ERROR_NOT_SUPPORTED: switch (pThermalSettings->version) { case NV_GPU_THERMAL_SETTINGS_VER_1: { @@ -477,6 +484,8 @@ extern "C" { case NVML_SUCCESS: *pCurrentPstate = static_cast(pState); return Ok(n, alreadyLoggedOk); + case NVML_ERROR_FUNCTION_NOT_FOUND: + return NoImplementation(n, alreadyLoggedNoNvml); case NVML_ERROR_NOT_SUPPORTED: return NotSupported(n); case NVML_ERROR_GPU_IS_LOST: @@ -545,6 +554,8 @@ extern "C" { return Error(n); // Unreachable, but just to be sure } break; + case NVML_ERROR_FUNCTION_NOT_FOUND: + return NoImplementation(n, alreadyLoggedNoNvml); case NVML_ERROR_NOT_SUPPORTED: break; case NVML_ERROR_GPU_IS_LOST: diff --git a/src/sysinfo/nvml.cpp b/src/sysinfo/nvml.cpp index e1ef64a..a4f1034 100644 --- a/src/sysinfo/nvml.cpp +++ b/src/sysinfo/nvml.cpp @@ -32,13 +32,7 @@ namespace dxvk { if (m_nvmlInit_v2 == nullptr || m_nvmlShutdown == nullptr || m_nvmlErrorString == nullptr - || m_nvmlDeviceGetHandleByPciBusId_v2 == nullptr - || m_nvmlDeviceGetPciInfo_v3 == nullptr - || m_nvmlDeviceGetTemperature == nullptr - || m_nvmlDeviceGetUtilizationRates == nullptr - || m_nvmlDeviceGetVbiosVersion == nullptr - || m_nvmlDeviceGetPerformanceState == nullptr - || m_nvmlDeviceGetClockInfo == nullptr) + || m_nvmlDeviceGetHandleByPciBusId_v2 == nullptr) log::write(str::format("NVML loaded but initialization failed")); else { auto result = m_nvmlInit_v2(); @@ -74,27 +68,39 @@ namespace dxvk { } nvmlReturn_t Nvml::DeviceGetPciInfo_v3(nvmlDevice_t device, nvmlPciInfo_t* pci) const { - return m_nvmlDeviceGetPciInfo_v3(device, pci); + return m_nvmlDeviceGetPciInfo_v3 + ? m_nvmlDeviceGetPciInfo_v3(device, pci) + : NVML_ERROR_FUNCTION_NOT_FOUND; } nvmlReturn_t Nvml::DeviceGetTemperature(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int* temp) const { - return m_nvmlDeviceGetTemperature(device, sensorType, temp); + return m_nvmlDeviceGetTemperature + ? m_nvmlDeviceGetTemperature(device, sensorType, temp) + : NVML_ERROR_FUNCTION_NOT_FOUND; } nvmlReturn_t Nvml::DeviceGetUtilizationRates(nvmlDevice_t device, nvmlUtilization_t* utilization) const { - return m_nvmlDeviceGetUtilizationRates(device, utilization); + return m_nvmlDeviceGetUtilizationRates + ? m_nvmlDeviceGetUtilizationRates(device, utilization) + : NVML_ERROR_FUNCTION_NOT_FOUND; } nvmlReturn_t Nvml::DeviceGetVbiosVersion(nvmlDevice_t device, char* version, unsigned int length) const { - return m_nvmlDeviceGetVbiosVersion(device, version, length); + return m_nvmlDeviceGetVbiosVersion + ? m_nvmlDeviceGetVbiosVersion(device, version, length) + : NVML_ERROR_FUNCTION_NOT_FOUND; } nvmlReturn_t Nvml::DeviceGetPerformanceState(nvmlDevice_t device, nvmlPstates_t* pState) const { - return m_nvmlDeviceGetPerformanceState(device, pState); + return m_nvmlDeviceGetPerformanceState + ? m_nvmlDeviceGetPerformanceState(device, pState) + : NVML_ERROR_FUNCTION_NOT_FOUND; } nvmlReturn_t Nvml::DeviceGetClockInfo(nvmlDevice_t device, nvmlClockType_t type, unsigned int* clock) const { - return m_nvmlDeviceGetClockInfo(device, type, clock); + return m_nvmlDeviceGetClockInfo + ? m_nvmlDeviceGetClockInfo(device, type, clock) + : NVML_ERROR_FUNCTION_NOT_FOUND; } template -- cgit v1.2.3