From dcf42adac98eaad03267640b658365d8bbe3e68c Mon Sep 17 00:00:00 2001 From: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> Date: Wed, 15 Mar 2023 19:28:56 +0100 Subject: [PATCH] Check if number of nodes is still identical for Intel iGPU. --- .../Hardware/Gpu/IntelIntegratedGpu.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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 +}