Add Fullscreen FPS sensor for AMD GPU (#427)
* Add Fullscreen FPS sensor for AMD GPU * Renamed variable _fullscreenFPS
This commit is contained in:
@@ -16,6 +16,7 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
private readonly int _adapterIndex;
|
||||
|
||||
private readonly IntPtr _context = IntPtr.Zero;
|
||||
private readonly bool _framemetricsStarted = false;
|
||||
|
||||
private readonly Sensor _controlSensor;
|
||||
private readonly Sensor _coreClock;
|
||||
@@ -42,6 +43,7 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
private readonly Sensor _temperaturePlx;
|
||||
private readonly Sensor _temperatureSoC;
|
||||
private readonly Sensor _temperatureVddc;
|
||||
private readonly Sensor _fullscreenFPS;
|
||||
|
||||
public AmdGpu(string name, int adapterIndex, int busNumber, int deviceNumber, ISettings settings)
|
||||
: base(name, new Identifier("gpu-amd", adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
|
||||
@@ -79,10 +81,22 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
_powerSoC = new Sensor("GPU SoC", 2, SensorType.Power, this, settings);
|
||||
_powerTotal = new Sensor("GPU Package", 3, SensorType.Power, this, settings);
|
||||
|
||||
_fullscreenFPS = new Sensor("Fullscreen FPS", 0, SensorType.Factor, this, settings);
|
||||
|
||||
int supported = 0;
|
||||
int enabled = 0;
|
||||
int version = 0;
|
||||
|
||||
if (AtiAdlxx.ADL2_Adapter_FrameMetrics_Caps(_context, _adapterIndex, ref supported) == AtiAdlxx.ADLStatus.ADL_OK)
|
||||
{
|
||||
if (supported == AtiAdlxx.ADL_TRUE && AtiAdlxx.ADL2_Adapter_FrameMetrics_Start(_context, _adapterIndex, 0) == AtiAdlxx.ADLStatus.ADL_OK)
|
||||
{
|
||||
_framemetricsStarted = true;
|
||||
_fullscreenFPS.Value = -1;
|
||||
ActivateSensor(_fullscreenFPS);
|
||||
}
|
||||
}
|
||||
|
||||
if (AtiAdlxx.ADL_Overdrive_Caps(1, ref supported, ref enabled, ref version) == AtiAdlxx.ADLStatus.ADL_OK)
|
||||
{
|
||||
_overdriveApiSupported = supported == AtiAdlxx.ADL_TRUE;
|
||||
@@ -163,7 +177,16 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (_overdriveApiSupported)
|
||||
if(_framemetricsStarted)
|
||||
{
|
||||
float framesPerSecond = 0;
|
||||
if (AtiAdlxx.ADL2_Adapter_FrameMetrics_Get(_context, _adapterIndex, 0, ref framesPerSecond) == AtiAdlxx.ADLStatus.ADL_OK)
|
||||
{
|
||||
_fullscreenFPS.Value = framesPerSecond;
|
||||
}
|
||||
}
|
||||
|
||||
if (_currentOverdriveApiLevel < 8)
|
||||
{
|
||||
if (_currentOverdriveApiLevel >= 6)
|
||||
{
|
||||
@@ -387,6 +410,9 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
if (_fanControl.ControlMode != ControlMode.Undefined)
|
||||
SetDefaultFanSpeed();
|
||||
|
||||
if (_framemetricsStarted)
|
||||
AtiAdlxx.ADL2_Adapter_FrameMetrics_Stop(_context, _adapterIndex, 0);
|
||||
|
||||
if (_context != IntPtr.Zero)
|
||||
AtiAdlxx.ADL2_Main_Control_Destroy(_context);
|
||||
|
||||
|
||||
@@ -120,6 +120,18 @@ namespace LibreHardwareMonitor.Interop
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ADLStatus ADL_Graphics_Versions_Get(out ADLVersionsInfo versionInfo);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ADLStatus ADL2_Adapter_FrameMetrics_Caps(IntPtr context, int adapterIndex, ref int supported);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ADLStatus ADL2_Adapter_FrameMetrics_Get(IntPtr context, int adapterIndex, int displayIndex, ref float fps);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ADLStatus ADL2_Adapter_FrameMetrics_Start(IntPtr context, int adapterIndex, int displayIndex);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ADLStatus ADL2_Adapter_FrameMetrics_Stop(IntPtr context, int adapterIndex, int displayIndex);
|
||||
|
||||
public static ADLStatus ADL_Main_Control_Create(int enumConnectedAdapters)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user