mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Set Balanced plan by default
This commit is contained in:
@@ -280,35 +280,38 @@ namespace GHelper.Mode
|
|||||||
|
|
||||||
public void SetGPUClocks(bool launchAsAdmin = true)
|
public void SetGPUClocks(bool launchAsAdmin = true)
|
||||||
{
|
{
|
||||||
|
Task.Run(() =>
|
||||||
int gpu_core = AppConfig.GetMode("gpu_core");
|
|
||||||
int gpu_memory = AppConfig.GetMode("gpu_memory");
|
|
||||||
|
|
||||||
if (gpu_core == -1 && gpu_memory == -1) return;
|
|
||||||
|
|
||||||
//if ((gpu_core > -5 && gpu_core < 5) && (gpu_memory > -5 && gpu_memory < 5)) launchAsAdmin = false;
|
|
||||||
|
|
||||||
if (Program.acpi.DeviceGet(AsusACPI.GPUEco) == 1) return;
|
|
||||||
if (HardwareControl.GpuControl is null) return;
|
|
||||||
if (!HardwareControl.GpuControl!.IsNvidia) return;
|
|
||||||
|
|
||||||
using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
int getStatus = nvControl.GetClocks(out int current_core, out int current_memory);
|
|
||||||
if (getStatus != -1)
|
int gpu_core = AppConfig.GetMode("gpu_core");
|
||||||
|
int gpu_memory = AppConfig.GetMode("gpu_memory");
|
||||||
|
|
||||||
|
if (gpu_core == -1 && gpu_memory == -1) return;
|
||||||
|
|
||||||
|
//if ((gpu_core > -5 && gpu_core < 5) && (gpu_memory > -5 && gpu_memory < 5)) launchAsAdmin = false;
|
||||||
|
|
||||||
|
if (Program.acpi.DeviceGet(AsusACPI.GPUEco) == 1) return;
|
||||||
|
if (HardwareControl.GpuControl is null) return;
|
||||||
|
if (!HardwareControl.GpuControl!.IsNvidia) return;
|
||||||
|
|
||||||
|
using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (Math.Abs(gpu_core - current_core) < 5 && Math.Abs(gpu_memory - current_memory) < 5) return;
|
int getStatus = nvControl.GetClocks(out int current_core, out int current_memory);
|
||||||
|
if (getStatus != -1)
|
||||||
|
{
|
||||||
|
if (Math.Abs(gpu_core - current_core) < 5 && Math.Abs(gpu_memory - current_memory) < 5) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setStatus = nvControl.SetClocks(gpu_core, gpu_memory);
|
||||||
|
if (launchAsAdmin && setStatus == -1) ProcessHelper.RunAsAdmin("gpu");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
int setStatus = nvControl.SetClocks(gpu_core, gpu_memory);
|
{
|
||||||
if (launchAsAdmin && setStatus == -1) ProcessHelper.RunAsAdmin("gpu");
|
Logger.WriteLine(ex.ToString());
|
||||||
|
}
|
||||||
}
|
});
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.WriteLine(ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetGPUPower()
|
public void SetGPUPower()
|
||||||
|
|||||||
@@ -72,7 +72,12 @@ namespace GHelper.Mode
|
|||||||
[DllImportAttribute("powrprof.dll", EntryPoint = "PowerSetActiveOverlayScheme")]
|
[DllImportAttribute("powrprof.dll", EntryPoint = "PowerSetActiveOverlayScheme")]
|
||||||
public static extern uint PowerSetActiveOverlayScheme(Guid OverlaySchemeGuid);
|
public static extern uint PowerSetActiveOverlayScheme(Guid OverlaySchemeGuid);
|
||||||
|
|
||||||
|
public static Dictionary<string, string> powerModes = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "961cc777-2547-4f9d-8174-7d86181b8a7a", "Best Power Efficiency" },
|
||||||
|
{ "00000000-0000-0000-0000-000000000000", "Balanced" },
|
||||||
|
{ "ded574b5-45a0-4f42-8737-46345c09c238", "Best Performance" },
|
||||||
|
};
|
||||||
static Guid GetActiveScheme()
|
static Guid GetActiveScheme()
|
||||||
{
|
{
|
||||||
IntPtr pActiveSchemeGuid;
|
IntPtr pActiveSchemeGuid;
|
||||||
@@ -135,17 +140,27 @@ namespace GHelper.Mode
|
|||||||
|
|
||||||
if (overlays.Contains(scheme))
|
if (overlays.Contains(scheme))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Guid activeSchemeGuid = GetActiveScheme();
|
||||||
|
Guid balanced = new Guid("381b4222-f694-41f0-9685-ff5bb260df2e");
|
||||||
|
|
||||||
|
if (activeSchemeGuid != balanced && !AppConfig.Is("skip_power_plan"))
|
||||||
|
{
|
||||||
|
PowerSetActiveScheme(IntPtr.Zero, balanced);
|
||||||
|
Logger.WriteLine("Balanced Plan: " + balanced);
|
||||||
|
}
|
||||||
|
|
||||||
uint status = PowerGetEffectiveOverlayScheme(out Guid activeScheme);
|
uint status = PowerGetEffectiveOverlayScheme(out Guid activeScheme);
|
||||||
if (status != 0 || activeScheme != guidScheme)
|
if (status != 0 || activeScheme != guidScheme)
|
||||||
{
|
{
|
||||||
PowerSetActiveOverlayScheme(guidScheme);
|
PowerSetActiveOverlayScheme(guidScheme);
|
||||||
Logger.WriteLine("Power mode: " + scheme);
|
Logger.WriteLine("Power Mode: " + scheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PowerSetActiveScheme(IntPtr.Zero, guidScheme);
|
PowerSetActiveScheme(IntPtr.Zero, guidScheme);
|
||||||
Logger.WriteLine("Power plan: " + scheme);
|
Logger.WriteLine("Power Plan: " + scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user