Merge pull request #1084 from seerge/gpu_clock_limit

Gpu clock limit
This commit is contained in:
Serge
2023-08-14 16:51:45 +02:00
committed by GitHub
10 changed files with 299 additions and 127 deletions

View File

@@ -348,7 +348,8 @@ public static class AppConfig
return
Is("manual_mode") ||
ContainsModel("GU604") ||
ContainsModel("G733");
ContainsModel("G733") ||
ContainsModel("FX507Z");
}
public static bool IsFanRequired()
@@ -363,7 +364,7 @@ public static class AppConfig
public static bool IsGPUFixNeeded()
{
return ContainsModel("GA402X") || ContainsModel("GV302");
return ContainsModel("GA402X") || ContainsModel("GV302") || ContainsModel("FX506") || ContainsModel("GU603V");
}
public static bool IsGPUFix()

View File

@@ -1,5 +1,8 @@
using GHelper.Helpers;
using GHelper.Gpu;
using GHelper.Helpers;
using HidLibrary;
using NAudio.Gui;
using System.Drawing;
using System.Text;
namespace GHelper
@@ -37,6 +40,7 @@ namespace GHelper
public static class AsusUSB
{
public const int HEATMAP = 20;
public const int GPUMODE = 21;
public const int ASUS_ID = 0x0b05;
@@ -161,7 +165,8 @@ namespace GHelper
{ 2, Properties.Strings.AuraColorCycle },
{ 3, Properties.Strings.AuraRainbow },
{ 10, Properties.Strings.AuraStrobe },
{ HEATMAP, "Heatmap"}
{ HEATMAP, "Heatmap"},
{ GPUMODE, "GPU Mode" }
};
static Dictionary<int, string> _modesStrix = new Dictionary<int, string>
@@ -194,6 +199,7 @@ namespace GHelper
_modes.Remove(2);
_modes.Remove(3);
_modes.Remove(HEATMAP);
_modes.Remove(GPUMODE);
}
if (AppConfig.IsAdvantageEdition())
@@ -531,6 +537,25 @@ namespace GHelper
}
public static void ApplyGPUColor()
{
if (AppConfig.Get("aura_mode") != GPUMODE) return;
switch (GPUModeControl.GpuMode)
{
case AsusACPI.GPUModeUltimate:
ApplyColor(Color.Red, true);
break;
case AsusACPI.GPUModeEco:
ApplyColor(Color.Green, true);
break;
default:
ApplyColor(Color.Yellow, true);
break;
}
}
public static void ApplyAura()
{
@@ -539,17 +564,22 @@ namespace GHelper
SetColor(AppConfig.Get("aura_color"));
SetColor2(AppConfig.Get("aura_color2"));
timer.Enabled = false;
if (Mode == HEATMAP)
{
SetHeatmap(true);
timer.Enabled = true;
return;
}
else
}
if (Mode == GPUMODE)
{
timer.Enabled = false;
ApplyGPUColor();
return;
}
Task.Run(async () =>
{

View File

@@ -331,16 +331,10 @@ namespace GHelper
{
try
{
Task.Run(() =>
{
int hibernate = PowerNative.GetHibernateAfter();
if (hibernate < 0 || hibernate > numericHibernateAfter.Maximum) hibernate = 0;
BeginInvoke(delegate
{
numericHibernateAfter.Value = hibernate;
numericHibernateAfter.ValueChanged += NumericHibernateAfter_ValueChanged;
});
});
int hibernate = PowerNative.GetHibernateAfter();
if (hibernate < 0 || hibernate > numericHibernateAfter.Maximum) hibernate = 0;
numericHibernateAfter.Value = hibernate;
numericHibernateAfter.ValueChanged += NumericHibernateAfter_ValueChanged;
}
catch (Exception ex)

210
app/Fans.Designer.cs generated
View File

@@ -103,11 +103,14 @@ namespace GHelper
pictureBoxCPU = new PictureBox();
labelPowerLimits = new Label();
panelBoost = new Panel();
panelPowerMode = new Panel();
comboPowerMode = new RComboBox();
panelBoostTitle = new Panel();
pictureBoost = new PictureBox();
labelBoost = new Label();
panelPowerMode = new Panel();
comboPowerMode = new RComboBox();
panelPowerModeTItle = new Panel();
picturePowerMode = new PictureBox();
labelPowerModeTitle = new Label();
panelGPU = new Panel();
panelGPUTemp = new Panel();
labelGPUTemp = new Label();
@@ -133,9 +136,10 @@ namespace GHelper
buttonAdvanced = new RButton();
buttonGPU = new RButton();
buttonCPU = new RButton();
panelPowerModeTItle = new Panel();
picturePowerMode = new PictureBox();
labelPowerModeTitle = new Label();
panelGPUClockLimit = new Panel();
labelGPUClockLimit = new Label();
trackGPUClockLimit = new TrackBar();
labelGPUClockLimitTitle = new Label();
panelFans.SuspendLayout();
tableFanCharts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
@@ -170,9 +174,11 @@ namespace GHelper
panelTitleCPU.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCPU).BeginInit();
panelBoost.SuspendLayout();
panelPowerMode.SuspendLayout();
panelBoostTitle.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoost).BeginInit();
panelPowerMode.SuspendLayout();
panelPowerModeTItle.SuspendLayout();
((System.ComponentModel.ISupportInitialize)picturePowerMode).BeginInit();
panelGPU.SuspendLayout();
panelGPUTemp.SuspendLayout();
((System.ComponentModel.ISupportInitialize)trackGPUTemp).BeginInit();
@@ -186,8 +192,8 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureGPU).BeginInit();
panelNav.SuspendLayout();
tableNav.SuspendLayout();
panelPowerModeTItle.SuspendLayout();
((System.ComponentModel.ISupportInitialize)picturePowerMode).BeginInit();
panelGPUClockLimit.SuspendLayout();
((System.ComponentModel.ISupportInitialize)trackGPUClockLimit).BeginInit();
SuspendLayout();
//
// panelFans
@@ -499,7 +505,7 @@ namespace GHelper
panelAdvanced.Controls.Add(panelTemperature);
panelAdvanced.Controls.Add(panelTitleTemp);
panelAdvanced.Dock = DockStyle.Top;
panelAdvanced.Location = new Point(10, 1396);
panelAdvanced.Location = new Point(10, 1520);
panelAdvanced.Name = "panelAdvanced";
panelAdvanced.Size = new Size(520, 888);
panelAdvanced.TabIndex = 14;
@@ -797,7 +803,7 @@ namespace GHelper
panelPower.Controls.Add(panelPowerMode);
panelPower.Controls.Add(panelPowerModeTItle);
panelPower.Dock = DockStyle.Top;
panelPower.Location = new Point(10, 640);
panelPower.Location = new Point(10, 764);
panelPower.Margin = new Padding(4);
panelPower.Name = "panelPower";
panelPower.Size = new Size(520, 756);
@@ -1020,30 +1026,6 @@ namespace GHelper
panelBoost.Size = new Size(520, 64);
panelBoost.TabIndex = 13;
//
// panelPowerMode
//
panelPowerMode.Controls.Add(comboPowerMode);
panelPowerMode.Dock = DockStyle.Top;
panelPowerMode.Location = new Point(0, 60);
panelPowerMode.Margin = new Padding(4);
panelPowerMode.Name = "panelPowerMode";
panelPowerMode.Size = new Size(520, 64);
panelPowerMode.TabIndex = 49;
//
// comboPowerMode
//
comboPowerMode.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboPowerMode.BorderColor = Color.White;
comboPowerMode.ButtonColor = Color.FromArgb(255, 255, 255);
comboPowerMode.DropDownStyle = ComboBoxStyle.DropDownList;
comboPowerMode.FormattingEnabled = true;
comboPowerMode.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive", "Aggressive at Guaranteed", "Efficient at Guaranteed" });
comboPowerMode.Location = new Point(13, 12);
comboPowerMode.Margin = new Padding(4);
comboPowerMode.Name = "comboPowerMode";
comboPowerMode.Size = new Size(329, 40);
comboPowerMode.TabIndex = 42;
//
// panelBoostTitle
//
panelBoostTitle.AutoSize = true;
@@ -1080,6 +1062,66 @@ namespace GHelper
labelBoost.TabIndex = 39;
labelBoost.Text = "CPU Boost";
//
// panelPowerMode
//
panelPowerMode.Controls.Add(comboPowerMode);
panelPowerMode.Dock = DockStyle.Top;
panelPowerMode.Location = new Point(0, 60);
panelPowerMode.Margin = new Padding(4);
panelPowerMode.Name = "panelPowerMode";
panelPowerMode.Size = new Size(520, 64);
panelPowerMode.TabIndex = 49;
//
// comboPowerMode
//
comboPowerMode.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboPowerMode.BorderColor = Color.White;
comboPowerMode.ButtonColor = Color.FromArgb(255, 255, 255);
comboPowerMode.DropDownStyle = ComboBoxStyle.DropDownList;
comboPowerMode.FormattingEnabled = true;
comboPowerMode.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive", "Aggressive at Guaranteed", "Efficient at Guaranteed" });
comboPowerMode.Location = new Point(13, 12);
comboPowerMode.Margin = new Padding(4);
comboPowerMode.Name = "comboPowerMode";
comboPowerMode.Size = new Size(329, 40);
comboPowerMode.TabIndex = 42;
//
// panelPowerModeTItle
//
panelPowerModeTItle.AutoSize = true;
panelPowerModeTItle.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelPowerModeTItle.Controls.Add(picturePowerMode);
panelPowerModeTItle.Controls.Add(labelPowerModeTitle);
panelPowerModeTItle.Dock = DockStyle.Top;
panelPowerModeTItle.Location = new Point(0, 0);
panelPowerModeTItle.Margin = new Padding(4);
panelPowerModeTItle.Name = "panelPowerModeTItle";
panelPowerModeTItle.Size = new Size(520, 60);
panelPowerModeTItle.TabIndex = 50;
//
// picturePowerMode
//
picturePowerMode.BackgroundImage = Properties.Resources.icons8_gauge_32;
picturePowerMode.BackgroundImageLayout = ImageLayout.Zoom;
picturePowerMode.InitialImage = null;
picturePowerMode.Location = new Point(10, 18);
picturePowerMode.Margin = new Padding(4, 2, 4, 10);
picturePowerMode.Name = "picturePowerMode";
picturePowerMode.Size = new Size(32, 32);
picturePowerMode.TabIndex = 40;
picturePowerMode.TabStop = false;
//
// labelPowerModeTitle
//
labelPowerModeTitle.AutoSize = true;
labelPowerModeTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelPowerModeTitle.Location = new Point(46, 18);
labelPowerModeTitle.Margin = new Padding(4, 0, 4, 0);
labelPowerModeTitle.Name = "labelPowerModeTitle";
labelPowerModeTitle.Size = new Size(271, 32);
labelPowerModeTitle.TabIndex = 39;
labelPowerModeTitle.Text = "Windows Power Mode";
//
// panelGPU
//
panelGPU.AutoSize = true;
@@ -1087,13 +1129,14 @@ namespace GHelper
panelGPU.Controls.Add(panelGPUBoost);
panelGPU.Controls.Add(panelGPUMemory);
panelGPU.Controls.Add(panelGPUCore);
panelGPU.Controls.Add(panelGPUClockLimit);
panelGPU.Controls.Add(panelTitleGPU);
panelGPU.Dock = DockStyle.Top;
panelGPU.Location = new Point(10, 66);
panelGPU.Margin = new Padding(4);
panelGPU.Name = "panelGPU";
panelGPU.Padding = new Padding(0, 0, 0, 18);
panelGPU.Size = new Size(520, 574);
panelGPU.Size = new Size(520, 698);
panelGPU.TabIndex = 44;
panelGPU.Visible = false;
//
@@ -1105,7 +1148,7 @@ namespace GHelper
panelGPUTemp.Controls.Add(labelGPUTempTitle);
panelGPUTemp.Controls.Add(trackGPUTemp);
panelGPUTemp.Dock = DockStyle.Top;
panelGPUTemp.Location = new Point(0, 432);
panelGPUTemp.Location = new Point(0, 556);
panelGPUTemp.Margin = new Padding(4);
panelGPUTemp.MaximumSize = new Size(0, 124);
panelGPUTemp.Name = "panelGPUTemp";
@@ -1154,7 +1197,7 @@ namespace GHelper
panelGPUBoost.Controls.Add(labelGPUBoostTitle);
panelGPUBoost.Controls.Add(trackGPUBoost);
panelGPUBoost.Dock = DockStyle.Top;
panelGPUBoost.Location = new Point(0, 308);
panelGPUBoost.Location = new Point(0, 432);
panelGPUBoost.Margin = new Padding(4);
panelGPUBoost.MaximumSize = new Size(0, 124);
panelGPUBoost.Name = "panelGPUBoost";
@@ -1203,7 +1246,7 @@ namespace GHelper
panelGPUMemory.Controls.Add(labelGPUMemoryTitle);
panelGPUMemory.Controls.Add(trackGPUMemory);
panelGPUMemory.Dock = DockStyle.Top;
panelGPUMemory.Location = new Point(0, 184);
panelGPUMemory.Location = new Point(0, 308);
panelGPUMemory.Margin = new Padding(4);
panelGPUMemory.MaximumSize = new Size(0, 124);
panelGPUMemory.Name = "panelGPUMemory";
@@ -1252,7 +1295,7 @@ namespace GHelper
panelGPUCore.Controls.Add(trackGPUCore);
panelGPUCore.Controls.Add(labelGPUCoreTitle);
panelGPUCore.Dock = DockStyle.Top;
panelGPUCore.Location = new Point(0, 60);
panelGPUCore.Location = new Point(0, 184);
panelGPUCore.Margin = new Padding(4);
panelGPUCore.MaximumSize = new Size(0, 124);
panelGPUCore.Name = "panelGPUCore";
@@ -1416,41 +1459,55 @@ namespace GHelper
buttonCPU.TextImageRelation = TextImageRelation.ImageBeforeText;
buttonCPU.UseVisualStyleBackColor = false;
//
// panelPowerModeTItle
// panelGPUClockLimit
//
panelPowerModeTItle.AutoSize = true;
panelPowerModeTItle.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelPowerModeTItle.Controls.Add(picturePowerMode);
panelPowerModeTItle.Controls.Add(labelPowerModeTitle);
panelPowerModeTItle.Dock = DockStyle.Top;
panelPowerModeTItle.Location = new Point(0, 0);
panelPowerModeTItle.Margin = new Padding(4);
panelPowerModeTItle.Name = "panelPowerModeTItle";
panelPowerModeTItle.Size = new Size(520, 60);
panelPowerModeTItle.TabIndex = 50;
panelGPUClockLimit.AutoSize = true;
panelGPUClockLimit.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelGPUClockLimit.Controls.Add(labelGPUClockLimit);
panelGPUClockLimit.Controls.Add(trackGPUClockLimit);
panelGPUClockLimit.Controls.Add(labelGPUClockLimitTitle);
panelGPUClockLimit.Dock = DockStyle.Top;
panelGPUClockLimit.Location = new Point(0, 60);
panelGPUClockLimit.Margin = new Padding(4);
panelGPUClockLimit.MaximumSize = new Size(0, 124);
panelGPUClockLimit.Name = "panelGPUClockLimit";
panelGPUClockLimit.Size = new Size(520, 124);
panelGPUClockLimit.TabIndex = 48;
//
// picturePowerMode
// labelGPUClockLimit
//
picturePowerMode.BackgroundImage = Properties.Resources.icons8_gauge_32;
picturePowerMode.BackgroundImageLayout = ImageLayout.Zoom;
picturePowerMode.InitialImage = null;
picturePowerMode.Location = new Point(10, 18);
picturePowerMode.Margin = new Padding(4, 2, 4, 10);
picturePowerMode.Name = "picturePowerMode";
picturePowerMode.Size = new Size(32, 32);
picturePowerMode.TabIndex = 40;
picturePowerMode.TabStop = false;
labelGPUClockLimit.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelGPUClockLimit.Location = new Point(326, 16);
labelGPUClockLimit.Margin = new Padding(4, 0, 4, 0);
labelGPUClockLimit.Name = "labelGPUClockLimit";
labelGPUClockLimit.Size = new Size(176, 32);
labelGPUClockLimit.TabIndex = 29;
labelGPUClockLimit.Text = "1500 MHz";
labelGPUClockLimit.TextAlign = ContentAlignment.TopRight;
//
// labelPowerModeTitle
// trackGPUClockLimit
//
labelPowerModeTitle.AutoSize = true;
labelPowerModeTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelPowerModeTitle.Location = new Point(46, 18);
labelPowerModeTitle.Margin = new Padding(4, 0, 4, 0);
labelPowerModeTitle.Name = "labelPowerModeTitle";
labelPowerModeTitle.Size = new Size(271, 32);
labelPowerModeTitle.TabIndex = 39;
labelPowerModeTitle.Text = "Windows Power Mode";
trackGPUClockLimit.LargeChange = 100;
trackGPUClockLimit.Location = new Point(6, 48);
trackGPUClockLimit.Margin = new Padding(4, 2, 4, 2);
trackGPUClockLimit.Maximum = 3000;
trackGPUClockLimit.Name = "trackGPUClockLimit";
trackGPUClockLimit.RightToLeft = RightToLeft.No;
trackGPUClockLimit.Size = new Size(496, 90);
trackGPUClockLimit.SmallChange = 10;
trackGPUClockLimit.TabIndex = 18;
trackGPUClockLimit.TickFrequency = 50;
trackGPUClockLimit.TickStyle = TickStyle.TopLeft;
//
// labelGPUClockLimitTitle
//
labelGPUClockLimitTitle.AutoSize = true;
labelGPUClockLimitTitle.Location = new Point(10, 16);
labelGPUClockLimitTitle.Margin = new Padding(4, 0, 4, 0);
labelGPUClockLimitTitle.Name = "labelGPUClockLimitTitle";
labelGPUClockLimitTitle.Size = new Size(188, 32);
labelGPUClockLimitTitle.TabIndex = 17;
labelGPUClockLimitTitle.Text = "Core Clock Limit";
//
// Fans
//
@@ -1519,10 +1576,13 @@ namespace GHelper
panelTitleCPU.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCPU).EndInit();
panelBoost.ResumeLayout(false);
panelPowerMode.ResumeLayout(false);
panelBoostTitle.ResumeLayout(false);
panelBoostTitle.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoost).EndInit();
panelPowerMode.ResumeLayout(false);
panelPowerModeTItle.ResumeLayout(false);
panelPowerModeTItle.PerformLayout();
((System.ComponentModel.ISupportInitialize)picturePowerMode).EndInit();
panelGPU.ResumeLayout(false);
panelGPU.PerformLayout();
panelGPUTemp.ResumeLayout(false);
@@ -1542,9 +1602,9 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureGPU).EndInit();
panelNav.ResumeLayout(false);
tableNav.ResumeLayout(false);
panelPowerModeTItle.ResumeLayout(false);
panelPowerModeTItle.PerformLayout();
((System.ComponentModel.ISupportInitialize)picturePowerMode).EndInit();
panelGPUClockLimit.ResumeLayout(false);
panelGPUClockLimit.PerformLayout();
((System.ComponentModel.ISupportInitialize)trackGPUClockLimit).EndInit();
ResumeLayout(false);
PerformLayout();
}
@@ -1647,5 +1707,9 @@ namespace GHelper
private Panel panelPowerModeTItle;
private PictureBox picturePowerMode;
private Label labelPowerModeTitle;
private Panel panelGPUClockLimit;
private Label labelGPUClockLimit;
private TrackBar trackGPUClockLimit;
private Label labelGPUClockLimitTitle;
}
}

View File

@@ -109,6 +109,9 @@ namespace GHelper
checkApplyFans.Click += CheckApplyFans_Click;
checkApplyPower.Click += CheckApplyPower_Click;
trackGPUClockLimit.Minimum = NvidiaGpuControl.MinClockLimit;
trackGPUClockLimit.Maximum = NvidiaGpuControl.MaxClockLimit;
trackGPUCore.Minimum = NvidiaGpuControl.MinCoreOffset;
trackGPUCore.Maximum = NvidiaGpuControl.MaxCoreOffset;
@@ -121,6 +124,7 @@ namespace GHelper
trackGPUTemp.Minimum = AsusACPI.MinGPUTemp;
trackGPUTemp.Maximum = AsusACPI.MaxGPUTemp;
trackGPUClockLimit.Scroll += trackGPUClockLimit_Scroll;
trackGPUCore.Scroll += trackGPU_Scroll;
trackGPUMemory.Scroll += trackGPU_Scroll;
@@ -131,6 +135,7 @@ namespace GHelper
trackGPUMemory.MouseUp += TrackGPU_MouseUp;
trackGPUBoost.MouseUp += TrackGPU_MouseUp;
trackGPUTemp.MouseUp += TrackGPU_MouseUp;
trackGPUClockLimit.MouseUp += TrackGPU_MouseUp;
//labelInfo.MaximumSize = new Size(280, 0);
labelFansResult.Visible = false;
@@ -435,24 +440,29 @@ namespace GHelper
int gpu_boost = AppConfig.GetMode("gpu_boost");
int gpu_temp = AppConfig.GetMode("gpu_temp");
int core = AppConfig.GetMode("gpu_core");
int memory = AppConfig.GetMode("gpu_memory");
int clock_limit = AppConfig.GetMode("gpu_clock_limit");
if (gpu_boost < 0) gpu_boost = AsusACPI.MaxGPUBoost;
if (gpu_temp < 0) gpu_temp = AsusACPI.MaxGPUTemp;
if (core == -1) core = 0;
if (memory == -1) memory = 0;
if (clock_limit == -1) clock_limit = NvidiaGpuControl.MaxClockLimit;
//if (readClocks)
//{
int status = nvControl.GetClocks(out int current_core, out int current_memory);
if (status != -1)
if (nvControl.GetClocks(out int current_core, out int current_memory))
{
core = current_core;
memory = current_memory;
}
int _clockLimit = nvControl.GetMaxGPUCLock();
if (_clockLimit == 0) clock_limit = NvidiaGpuControl.MaxClockLimit;
else if (_clockLimit > 0) clock_limit = _clockLimit;
try
{
labelGPU.Text = nvControl.FullName;
@@ -463,6 +473,7 @@ namespace GHelper
}
//}
trackGPUClockLimit.Value = Math.Max(Math.Min(clock_limit, NvidiaGpuControl.MaxClockLimit), NvidiaGpuControl.MinClockLimit);
trackGPUCore.Value = Math.Max(Math.Min(core, NvidiaGpuControl.MaxCoreOffset), NvidiaGpuControl.MinCoreOffset);
trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset);
@@ -488,8 +499,24 @@ namespace GHelper
{
labelGPUCore.Text = $"{trackGPUCore.Value} MHz";
labelGPUMemory.Text = $"{trackGPUMemory.Value} MHz";
labelGPUBoost.Text = $"{trackGPUBoost.Value}W";
labelGPUTemp.Text = $"{trackGPUTemp.Value}°C";
if (trackGPUClockLimit.Value >= NvidiaGpuControl.MaxClockLimit)
labelGPUClockLimit.Text = "Default";
else
labelGPUClockLimit.Text = $"{trackGPUClockLimit.Value} MHz";
}
private void trackGPUClockLimit_Scroll(object? sender, EventArgs e)
{
int maxClock = (int)Math.Round((float)trackGPUClockLimit.Value / 50) * 50;
trackGPUClockLimit.Value = maxClock;
AppConfig.SetMode("gpu_clock_limit", maxClock);
VisualiseGPUSettings();
}
private void trackGPU_Scroll(object? sender, EventArgs e)
@@ -501,6 +528,7 @@ namespace GHelper
AppConfig.SetMode("gpu_core", trackGPUCore.Value);
AppConfig.SetMode("gpu_memory", trackGPUMemory.Value);
VisualiseGPUSettings();
}
@@ -615,7 +643,7 @@ namespace GHelper
{
string powerMode = (string)comboPowerMode.SelectedValue;
PowerNative.SetPowerMode(powerMode);
if (PowerNative.GetDefaultPowerMode(Modes.GetCurrentBase()) != powerMode)
AppConfig.SetMode("powermode", powerMode);
}
@@ -897,13 +925,17 @@ namespace GHelper
if (gpuVisible)
{
trackGPUClockLimit.Value = NvidiaGpuControl.MaxClockLimit;
trackGPUCore.Value = 0;
trackGPUMemory.Value = 0;
trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;
AppConfig.SetMode("gpu_clock_limit", trackGPUClockLimit.Value);
AppConfig.SetMode("gpu_boost", trackGPUBoost.Value);
AppConfig.SetMode("gpu_temp", trackGPUTemp.Value);
AppConfig.SetMode("gpu_core", trackGPUCore.Value);
AppConfig.SetMode("gpu_memory", trackGPUMemory.Value);

View File

@@ -10,6 +10,8 @@ namespace GHelper.Gpu
SettingsForm settings;
ScreenControl screenControl = new ScreenControl();
public static int GpuMode;
public GPUModeControl(SettingsForm settingsForm)
{
settings = settingsForm;
@@ -23,8 +25,6 @@ namespace GHelper.Gpu
Logger.WriteLine("Eco flag : " + eco);
Logger.WriteLine("Mux flag : " + mux);
int GpuMode;
if (mux == 0)
{
GpuMode = AsusACPI.GPUModeUltimate;

View File

@@ -18,6 +18,9 @@ public class NvidiaGpuControl : IGpuControl
public const int MinCoreOffset = -250;
public const int MinMemoryOffset = -250;
public const int MinClockLimit = 1000;
public const int MaxClockLimit = 3000;
private static PhysicalGPU? _internalGpu;
public NvidiaGpuControl()
@@ -76,7 +79,7 @@ public class NvidiaGpuControl : IGpuControl
}
public int GetClocks(out int core, out int memory)
public bool GetClocks(out int core, out int memory)
{
PhysicalGPU internalGpu = _internalGpu!;
@@ -95,28 +98,24 @@ public class NvidiaGpuControl : IGpuControl
Logger.WriteLine("GPU VOLT:" + delta.IsEditable + " - " + delta.ValueDeltaInMicroVolt.DeltaValue);
}
return 0;
return true;
}
catch (Exception ex)
{
Logger.WriteLine("GET GPU CLOCKS:" + ex.Message);
core = memory = 0;
return -1;
return false;
}
}
public bool RestartGPU()
private bool RunPowershellCommand(string script)
{
try
{
string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 5; Enable-PnpDevice $device.InstanceId -Confirm:$false";
Logger.WriteLine(script);
ProcessHelper.RunCMD("powershell", script);
//Thread.Sleep(2000);
return true;
}
catch (Exception ex)
@@ -124,27 +123,71 @@ public class NvidiaGpuControl : IGpuControl
Logger.WriteLine(ex.ToString());
return false;
}
}
public int SetClocksFromConfig()
public int GetMaxGPUCLock()
{
int core = AppConfig.Get("gpu_core", 0);
int memory = AppConfig.Get("gpu_memory", 0);
int status = SetClocks(core, memory);
return status;
PhysicalGPU internalGpu = _internalGpu!;
try
{
PrivateClockBoostLockV2 data = GPUApi.GetClockBoostLock(internalGpu.Handle);
int limit = (int)data.ClockBoostLocks[0].VoltageInMicroV / 1000;
Logger.WriteLine("GET CLOCK LIMIT: " + limit);
return limit;
}
catch (Exception ex)
{
Logger.WriteLine("GET CLOCK LIMIT: " + ex.Message);
return -1;
}
}
public int SetClocks(int core, int memory, int voltage = 0)
public int SetMaxGPUClock(int clock)
{
if (clock < MinClockLimit || clock >= MaxClockLimit) clock = 0;
int _clockLimit = GetMaxGPUCLock();
if (_clockLimit != clock)
{
if (clock > 0) RunPowershellCommand($"nvidia-smi -lgc 0,{clock}");
else RunPowershellCommand($"nvidia-smi -rgc");
return 1;
}
else
{
return 0;
}
}
public bool RestartGPU()
{
return RunPowershellCommand(@"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 5; Enable-PnpDevice $device.InstanceId -Confirm:$false");
}
public int SetClocks(int core, int memory)
{
if (core < MinCoreOffset || core > MaxCoreOffset) return 0;
if (memory < MinMemoryOffset || memory > MaxMemoryOffset) return 0;
if (GetClocks(out int currentCore, out int currentMemory))
{
if (Math.Abs(core - currentCore) < 5 && Math.Abs(memory - currentMemory) < 5) return 0;
}
PhysicalGPU internalGpu = _internalGpu!;
var coreClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Graphics, new PerformanceStates20ParameterDelta(core * 1000));
var memoryClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Memory, new PerformanceStates20ParameterDelta(memory * 1000));
var voltageEntry = new PerformanceStates20BaseVoltageEntryV1(PerformanceVoltageDomain.Core, new PerformanceStates20ParameterDelta(voltage));
//var voltageEntry = new PerformanceStates20BaseVoltageEntryV1(PerformanceVoltageDomain.Core, new PerformanceStates20ParameterDelta(voltage));
PerformanceStates20ClockEntryV1[] clocks = { coreClock, memoryClock };
PerformanceStates20BaseVoltageEntryV1[] voltages = { };
@@ -164,8 +207,6 @@ public class NvidiaGpuControl : IGpuControl
return -1;
}
return 1;
}

View File

@@ -132,7 +132,12 @@ namespace GHelper.Helpers
cmd.StartInfo.FileName = name;
cmd.StartInfo.Arguments = args;
cmd.Start();
Logger.WriteLine(cmd.StandardOutput.ReadToEnd());
string result = cmd.StandardOutput.ReadToEnd().Replace(Environment.NewLine, " ").Trim(' ');
Logger.WriteLine(args);
Logger.WriteLine(result);
cmd.WaitForExit();
}

View File

@@ -291,10 +291,11 @@ namespace GHelper.Mode
Task.Run(() =>
{
int gpu_core = AppConfig.GetMode("gpu_core");
int gpu_memory = AppConfig.GetMode("gpu_memory");
int core = AppConfig.GetMode("gpu_core");
int memory = AppConfig.GetMode("gpu_memory");
int clock_limit = AppConfig.GetMode("gpu_clock_limit");
if (gpu_core == -1 && gpu_memory == -1) return;
if (core == -1 && memory == -1) return;
//if ((gpu_core > -5 && gpu_core < 5) && (gpu_memory > -5 && gpu_memory < 5)) launchAsAdmin = false;
@@ -305,20 +306,16 @@ namespace GHelper.Mode
using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
try
{
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");
int statusLimit = nvControl.SetMaxGPUClock(clock_limit);
int statusClocks = nvControl.SetClocks(core, memory);
if ((statusLimit != 0 || statusClocks != 0) && launchAsAdmin) ProcessHelper.RunAsAdmin("gpu");
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
settings.GPUInit();
});
}

View File

@@ -582,6 +582,14 @@ namespace GHelper
});
}
public void GPUInit()
{
Invoke(delegate
{
if (fans != null && fans.Text != "") fans.InitGPU();
});
}
public void FansToggle(int index = 0)
{
if (fans == null || fans.Text == "")