diff --git a/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs b/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs index 1f9532e..93e257f 100644 --- a/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs +++ b/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs @@ -84,25 +84,27 @@ internal class IntelIntegratedGpu : GenericGpu if (_powerSensor != null && Ring0.ReadMsr(MSR_PP1_ENERGY_STATUS, out uint eax, out uint _)) { DateTime time = DateTime.UtcNow; - uint energyConsumed = eax; float deltaTime = (float)(time - _lastEnergyTime).TotalSeconds; if (deltaTime >= 0.01) { - _powerSensor.Value = _energyUnitMultiplier * unchecked(energyConsumed - _lastEnergyConsumed) / deltaTime; + _powerSensor.Value = _energyUnitMultiplier * unchecked(eax - _lastEnergyConsumed) / deltaTime; _lastEnergyTime = time; - _lastEnergyConsumed = energyConsumed; + _lastEnergyConsumed = eax; } } - foreach (D3DDisplayDevice.D3DDeviceNodeInfo node in deviceInfo.Nodes) + if (_nodeUsage.Length == deviceInfo.Nodes.Length) { - long runningTimeDiff = node.RunningTime - _nodeUsagePrevValue[node.Id]; - long timeDiff = node.QueryTime.Ticks - _nodeUsagePrevTick[node.Id].Ticks; + foreach (D3DDisplayDevice.D3DDeviceNodeInfo node in deviceInfo.Nodes) + { + long runningTimeDiff = node.RunningTime - _nodeUsagePrevValue[node.Id]; + long timeDiff = node.QueryTime.Ticks - _nodeUsagePrevTick[node.Id].Ticks; - _nodeUsage[node.Id].Value = 100f * runningTimeDiff / timeDiff; - _nodeUsagePrevValue[node.Id] = node.RunningTime; - _nodeUsagePrevTick[node.Id] = node.QueryTime; - ActivateSensor(_nodeUsage[node.Id]); + _nodeUsage[node.Id].Value = 100f * runningTimeDiff / timeDiff; + _nodeUsagePrevValue[node.Id] = node.RunningTime; + _nodeUsagePrevTick[node.Id] = node.QueryTime; + ActivateSensor(_nodeUsage[node.Id]); + } } } } @@ -118,4 +120,4 @@ internal class IntelIntegratedGpu : GenericGpu return "Intel Integrated Graphics"; } -} \ No newline at end of file +}