Skip to content

Commit f0681e1

Browse files
DaVargaPhyxionNL
andauthored
Fix duplicate sensor index in nvidia-gpu (#1441) (#1442)
* Fix duplicate sensor index in nvidia-gpu (#1441) * Update NvidiaGpu.cs --------- Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
1 parent 1ca4ebc commit f0681e1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

LibreHardwareMonitorLib/Hardware/Gpu/NvidiaGpu.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,22 @@ public NvidiaGpu(int adapterIndex, NvApi.NvPhysicalGpuHandle handle, NvApi.NvDis
391391

392392
if (isMatch && D3DDisplayDevice.GetDeviceInfoByIdentifier(deviceId, out D3DDisplayDevice.D3DDeviceInfo deviceInfo))
393393
{
394-
int nodeSensorIndex = (_loads?.Length ?? 0) + (_powers?.Length ?? 0);
395-
int memorySensorIndex = 4; // There are 4 normal GPU memory sensors.
394+
int sensorCount = (_loads?.Length ?? 0) + (_powers?.Length ?? 0);
395+
int loadSensorIndex = sensorCount > 0 ? sensorCount + 1 : 0;
396+
int smallDataSensorIndex = 3; // There are three normal GPU memory sensors.
396397

397398
_d3dDeviceId = deviceId;
398399

399-
_gpuDedicatedMemoryUsage = new Sensor("D3D Dedicated Memory Used", memorySensorIndex++, SensorType.SmallData, this, settings);
400-
_gpuSharedMemoryUsage = new Sensor("D3D Shared Memory Used", memorySensorIndex, SensorType.SmallData, this, settings);
400+
_gpuDedicatedMemoryUsage = new Sensor("D3D Dedicated Memory Used", smallDataSensorIndex++, SensorType.SmallData, this, settings);
401+
_gpuSharedMemoryUsage = new Sensor("D3D Shared Memory Used", smallDataSensorIndex, SensorType.SmallData, this, settings);
401402

402403
_gpuNodeUsage = new Sensor[deviceInfo.Nodes.Length];
403404
_gpuNodeUsagePrevValue = new long[deviceInfo.Nodes.Length];
404405
_gpuNodeUsagePrevTick = new DateTime[deviceInfo.Nodes.Length];
405406

406407
foreach (D3DDisplayDevice.D3DDeviceNodeInfo node in deviceInfo.Nodes.OrderBy(x => x.Name))
407408
{
408-
_gpuNodeUsage[node.Id] = new Sensor(node.Name, nodeSensorIndex++, SensorType.Load, this, settings);
409+
_gpuNodeUsage[node.Id] = new Sensor(node.Name, loadSensorIndex++, SensorType.Load, this, settings);
409410
_gpuNodeUsagePrevValue[node.Id] = node.RunningTime;
410411
_gpuNodeUsagePrevTick[node.Id] = node.QueryTime;
411412
}

0 commit comments

Comments
 (0)