Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jp7677/dxvk-nvapi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Peters <jp7677@gmail.com>2022-08-28 11:26:11 +0300
committerJens Peters <jp7677@gmail.com>2022-08-28 14:27:47 +0300
commitbbda12037f9ae860e621b2435292ecf6f78963d0 (patch)
tree5259f2dd65a73e5f4f001e21bff139f5d71f6b33 /src
parent42ad10b8418d986f74759e31ffaab34bc1ecabac (diff)
nvapi-gpu: Implement GetIrq using nvml
Diffstat (limited to 'src')
-rw-r--r--src/nvapi_gpu.cpp39
-rw-r--r--src/nvapi_interface.cpp1
-rw-r--r--src/sysinfo/nvapi_adapter.cpp4
-rw-r--r--src/sysinfo/nvapi_adapter.h1
-rw-r--r--src/sysinfo/nvml.cpp7
-rw-r--r--src/sysinfo/nvml.h2
6 files changed, 54 insertions, 0 deletions
diff --git a/src/nvapi_gpu.cpp b/src/nvapi_gpu.cpp
index c667b73..e0341bc 100644
--- a/src/nvapi_gpu.cpp
+++ b/src/nvapi_gpu.cpp
@@ -45,6 +45,45 @@ extern "C" {
}
}
+ NvAPI_Status __cdecl NvAPI_GPU_GetIRQ(NvPhysicalGpuHandle hPhysicalGpu, NvU32* pIRQ) {
+ constexpr auto n = __func__;
+ static bool alreadyLoggedNoNvml = false;
+ static bool alreadyLoggedHandleInvalidated = false;
+ static bool alreadyLoggedOk = false;
+
+ if (nvapiAdapterRegistry == nullptr)
+ return ApiNotInitialized(n);
+
+ if (pIRQ == nullptr)
+ return InvalidArgument(n);
+
+ auto adapter = reinterpret_cast<NvapiAdapter*>(hPhysicalGpu);
+ if (!nvapiAdapterRegistry->IsAdapter(adapter))
+ return ExpectedPhysicalGpuHandle(n);
+
+ if (!adapter->HasNvml())
+ return NoImplementation(n, alreadyLoggedNoNvml);
+
+ if (!adapter->HasNvmlDevice())
+ return HandleInvalidated(str::format(n, ": NVML available but current adapter is not NVML compatible"), alreadyLoggedHandleInvalidated);
+
+ unsigned int irq;
+ auto result = adapter->GetNvmlDeviceGetIrqNum(&irq);
+ switch (result) {
+ case NVML_SUCCESS:
+ *pIRQ = irq;
+ 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:
+ return HandleInvalidated(n);
+ default:
+ return Error(str::format(n, ": ", adapter->GetNvmlErrorString(result)));
+ }
+ }
+
NvAPI_Status __cdecl NvAPI_GPU_GetGpuCoreCount(NvPhysicalGpuHandle hPhysicalGpu, NvU32* pCount) {
constexpr auto n = __func__;
static bool alreadyLoggedNoNvml = false;
diff --git a/src/nvapi_interface.cpp b/src/nvapi_interface.cpp
index a62398a..64f13a6 100644
--- a/src/nvapi_interface.cpp
+++ b/src/nvapi_interface.cpp
@@ -72,6 +72,7 @@ extern "C" {
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D_GetLatency)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D_SetLatencyMarker)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetCurrentPCIEDownstreamWidth)
+ INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetIRQ)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetGpuCoreCount)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetGPUType)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_GPU_GetPCIIdentifiers)
diff --git a/src/sysinfo/nvapi_adapter.cpp b/src/sysinfo/nvapi_adapter.cpp
index fc56da5..0fd6a28 100644
--- a/src/sysinfo/nvapi_adapter.cpp
+++ b/src/sysinfo/nvapi_adapter.cpp
@@ -278,6 +278,10 @@ namespace dxvk {
return m_nvml.DeviceGetCurrPcieLinkWidth(m_nvmlDevice, width);
}
+ nvmlReturn_t NvapiAdapter::GetNvmlDeviceGetIrqNum(unsigned int* irq) const {
+ return m_nvml.DeviceGetIrqNum(m_nvmlDevice, irq);
+ }
+
nvmlReturn_t NvapiAdapter::GetNvmlDeviceNumGpuCores(unsigned int* numCores) const {
return m_nvml.DeviceGetNumGpuCores(m_nvmlDevice, numCores);
}
diff --git a/src/sysinfo/nvapi_adapter.h b/src/sysinfo/nvapi_adapter.h
index 364dd01..131627b 100644
--- a/src/sysinfo/nvapi_adapter.h
+++ b/src/sysinfo/nvapi_adapter.h
@@ -38,6 +38,7 @@ namespace dxvk {
[[nodiscard]] nvmlReturn_t GetNvmlDeviceUtilizationRates(nvmlUtilization_t* utilization) const;
[[nodiscard]] nvmlReturn_t GetNvmlDeviceVbiosVersion(char* version, unsigned int length) const;
[[nodiscard]] nvmlReturn_t GetNvmlDeviceGetCurrPcieLinkWidth(unsigned int* width) const;
+ [[nodiscard]] nvmlReturn_t GetNvmlDeviceGetIrqNum(unsigned int* irq) const;
[[nodiscard]] nvmlReturn_t GetNvmlDeviceNumGpuCores(unsigned int* numCores) const;
[[nodiscard]] nvmlReturn_t GetNvmlDeviceBusType(nvmlBusType_t* type) const;
[[nodiscard]] nvmlReturn_t GetNvmlDeviceDynamicPstatesInfo(nvmlGpuDynamicPstatesInfo_t* pDynamicPstatesInfo) const;
diff --git a/src/sysinfo/nvml.cpp b/src/sysinfo/nvml.cpp
index a34fcd3..674fb78 100644
--- a/src/sysinfo/nvml.cpp
+++ b/src/sysinfo/nvml.cpp
@@ -28,6 +28,7 @@ namespace dxvk {
GETPROCADDR(nvmlDeviceGetUtilizationRates);
GETPROCADDR(nvmlDeviceGetVbiosVersion);
GETPROCADDR(nvmlDeviceGetCurrPcieLinkWidth);
+ GETPROCADDR(nvmlDeviceGetIrqNum);
GETPROCADDR(nvmlDeviceGetNumGpuCores);
GETPROCADDR(nvmlDeviceGetBusType);
GETPROCADDR(nvmlDeviceGetDynamicPstatesInfo);
@@ -120,6 +121,12 @@ namespace dxvk {
: NVML_ERROR_FUNCTION_NOT_FOUND;
}
+ nvmlReturn_t Nvml::DeviceGetIrqNum(nvmlDevice_t device, unsigned int* irqNum) const {
+ return m_nvmlDeviceGetIrqNum
+ ? m_nvmlDeviceGetIrqNum(device, irqNum)
+ : NVML_ERROR_FUNCTION_NOT_FOUND;
+ }
+
nvmlReturn_t Nvml::DeviceGetNumGpuCores(nvmlDevice_t device, unsigned int* numCores) const {
return m_nvmlDeviceGetNumGpuCores
? m_nvmlDeviceGetNumGpuCores(device, numCores)
diff --git a/src/sysinfo/nvml.h b/src/sysinfo/nvml.h
index 5ee8444..d2b354e 100644
--- a/src/sysinfo/nvml.h
+++ b/src/sysinfo/nvml.h
@@ -20,6 +20,7 @@ namespace dxvk {
[[nodiscard]] virtual nvmlReturn_t DeviceGetUtilizationRates(nvmlDevice_t device, nvmlUtilization_t* utilization) const;
[[nodiscard]] virtual nvmlReturn_t DeviceGetVbiosVersion(nvmlDevice_t device, char* version, unsigned int length) const;
[[nodiscard]] virtual nvmlReturn_t DeviceGetCurrPcieLinkWidth(nvmlDevice_t device, unsigned int* width) const;
+ [[nodiscard]] virtual nvmlReturn_t DeviceGetIrqNum(nvmlDevice_t device, unsigned int* irqNum) const;
[[nodiscard]] virtual nvmlReturn_t DeviceGetNumGpuCores(nvmlDevice_t device, unsigned int* numCores) const;
[[nodiscard]] virtual nvmlReturn_t DeviceGetBusType(nvmlDevice_t device, nvmlBusType_t* type) const;
[[nodiscard]] virtual nvmlReturn_t DeviceGetDynamicPstatesInfo(nvmlDevice_t device, nvmlGpuDynamicPstatesInfo_t* pDynamicPstatesInfo) const;
@@ -46,6 +47,7 @@ namespace dxvk {
DECLARE_PFN(nvmlDeviceGetUtilizationRates);
DECLARE_PFN(nvmlDeviceGetVbiosVersion);
DECLARE_PFN(nvmlDeviceGetCurrPcieLinkWidth);
+ DECLARE_PFN(nvmlDeviceGetIrqNum);
DECLARE_PFN(nvmlDeviceGetNumGpuCores);
DECLARE_PFN(nvmlDeviceGetBusType);
DECLARE_PFN(nvmlDeviceGetDynamicPstatesInfo);