From 418888502afc2e147d973a04e476d2f6762bb354 Mon Sep 17 00:00:00 2001 From: Emerson Pinter Date: Fri, 3 May 2024 05:23:21 -0300 Subject: [PATCH] Add shared memory free/total for Intel iGPU (#1328) --- .../Hardware/Gpu/IntelIntegratedGpu.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs b/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs index 4057e05..1441b1d 100644 --- a/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs +++ b/LibreHardwareMonitorLib/Hardware/Gpu/IntelIntegratedGpu.cs @@ -11,6 +11,8 @@ internal class IntelIntegratedGpu : GenericGpu private const uint MSR_RAPL_POWER_UNIT = 0x606; private readonly Sensor _dedicatedMemoryUsage; + private readonly Sensor _sharedMemoryLimit; + private readonly Sensor _sharedMemoryFree; private readonly string _deviceId; private readonly float _energyUnitMultiplier; private readonly Sensor[] _nodeUsage; @@ -38,6 +40,12 @@ internal class IntelIntegratedGpu : GenericGpu _sharedMemoryUsage = new Sensor("D3D Shared Memory Used", memorySensorIndex++, SensorType.SmallData, this, settings); + if (deviceInfo.GpuSharedLimit > 0) + { + _sharedMemoryFree = new Sensor("D3D Shared Memory Free", memorySensorIndex++, SensorType.SmallData, this, settings); + _sharedMemoryLimit = new Sensor("D3D Shared Memory Total", memorySensorIndex++, SensorType.SmallData, this, settings); + } + if (Ring0.ReadMsr(MSR_RAPL_POWER_UNIT, out uint eax, out uint _)) { _energyUnitMultiplier = intelCpu.EnergyUnitsMultiplier; @@ -78,6 +86,17 @@ internal class IntelIntegratedGpu : GenericGpu ActivateSensor(_dedicatedMemoryUsage); } + if (_sharedMemoryLimit != null) + { + _sharedMemoryLimit.Value = 1f * deviceInfo.GpuSharedLimit / 1024 / 1024; + ActivateSensor(_sharedMemoryLimit); + if (_sharedMemoryUsage != null) + { + _sharedMemoryFree.Value = _sharedMemoryLimit.Value - _sharedMemoryUsage.Value; + ActivateSensor(_sharedMemoryFree); + } + } + _sharedMemoryUsage.Value = 1f * deviceInfo.GpuSharedUsed / 1024 / 1024; ActivateSensor(_sharedMemoryUsage);