Power based AutoTDP

This commit is contained in:
Serge
2024-04-16 20:56:24 +02:00
parent 4f571e276c
commit 966dd01f1d
2 changed files with 34 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ using GHelper.Input;
using GHelper.Mode;
using GHelper.USB;
using HidSharp;
using System.Diagnostics;
using System.Text;
namespace GHelper.Ally
@@ -348,37 +349,44 @@ namespace GHelper.Ally
if (autoTDP && fpsLimit > 0 && fpsLimit <= 120)
{
if (fps <= Math.Max(fpsLimit - 5, fpsLimit * 0.8)) _upCount++;
int power = (int)amdControl.GetGpuPower();
//Debug.WriteLine($"{power}: {fps}");
if (fps <= fpsLimit * 0.8) _upCount++;
else _upCount = 0;
if (fps >= Math.Min(fpsLimit - 1, fpsLimit * 0.95)) _downCount++;
if (fps >= fpsLimit * 0.90) _downCount++;
else _downCount = 0;
var tdp = GetTDP();
if (_upCount >= 1)
{
_downCount = 0;
_upCount = 0;
SetTDP(GetTDP() + 1, $"AutoTDP+ {fps}");
SetTDP(tdp + 1, $"AutoTDP+ [{power}]{fps}");
}
if (_downCount >= 8)
if (_downCount >= 8 && power < tdp)
{
_upCount = 0;
_downCount--;
SetTDP(GetTDP() - 1, $"AutoTDP- {fps}");
SetTDP(tdp - 1, $"AutoTDP- [{power}]{fps}");
}
}
ControllerMode newMode = (fps > 0) ? ControllerMode.Gamepad : ControllerMode.Mouse;
if (_applyMode != newMode) _autoCount++;
else _autoCount = 0;
if (_autoCount > 2)
if (_mode == ControllerMode.Auto)
{
_autoCount = 0;
ApplyMode(newMode);
Logger.WriteLine($"Controller Mode {fps}: {newMode}");
ControllerMode newMode = (fps > 0) ? ControllerMode.Gamepad : ControllerMode.Mouse;
if (_applyMode != newMode) _autoCount++;
else _autoCount = 0;
if (_autoCount > 2)
{
_autoCount = 0;
ApplyMode(newMode);
Logger.WriteLine($"Controller Mode {fps}: {newMode}");
}
}
}

View File

@@ -119,6 +119,18 @@ public class AmdGpuControl : IGpuControl
}
public int? GetGpuPower()
{
if (_adlContextHandle == nint.Zero || _iGPU == null) return null;
if (ADL2_New_QueryPMLogData_Get(_adlContextHandle, ((ADLAdapterInfo)_iGPU).AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS) return null;
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_ASIC_POWER];
if (gpuUsage.Supported == 0) return null;
return gpuUsage.Value;
}
public bool SetVariBright(int enabled)
{