diff --git a/app/ASUSWmi.cs b/app/ASUSWmi.cs index 68995f8f..255c1b9a 100644 --- a/app/ASUSWmi.cs +++ b/app/ASUSWmi.cs @@ -49,9 +49,9 @@ public class ASUSWmi public const int PPT_CPUB0 = 0x001200B0; // CPU PPT on 2022 (PPT_LIMIT_APU) public const int PPT_CPUB1 = 0x001200B1; // Total PPT on 2022 (PPT_LIMIT_SLOW) - public const int PPT_APUC0 = 0x001200C0; // does nothing on G14 2022 + public const int PPT_GPUC0 = 0x001200C0; // NVIDIA GPU Boost public const int PPT_APUC1 = 0x001200C1; // Actual Power Limit (PPT_LIMIT_FAST) AND Sustained Power Limit (STAPM_LIMIT) - public const int PPT_APUC2 = 0x001200C2; // does nothing on G14 2022 + public const int PPT_GPUC2 = 0x001200C2; // NVIDIA GPU Temp Target (75.. 87 C) public const int TUF_KB_BRIGHTNESS = 0x00050021; public const int TUF_KB = 0x00100056; @@ -74,6 +74,12 @@ public class ASUSWmi public const int MinCPU = 5; public const int DefaultCPU = 80; + public const int MinGPUBoost = 5; + public const int MaxGPUBoost = 25; + + public const int MinGPUTemp = 75; + public const int MaxGPUTemp = 87; + [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] private static extern IntPtr CreateFile( diff --git a/app/Fans.Designer.cs b/app/Fans.Designer.cs index 7eda2e72..ac3aaee8 100644 --- a/app/Fans.Designer.cs +++ b/app/Fans.Designer.cs @@ -31,12 +31,12 @@ namespace GHelper /// private void InitializeComponent() { - ChartArea chartArea1 = new ChartArea(); - Title title1 = new Title(); - ChartArea chartArea2 = new ChartArea(); - Title title2 = new Title(); - ChartArea chartArea3 = new ChartArea(); - Title title3 = new Title(); + ChartArea chartArea13 = new ChartArea(); + Title title13 = new Title(); + ChartArea chartArea14 = new ChartArea(); + Title title14 = new Title(); + ChartArea chartArea15 = new ChartArea(); + Title title15 = new Title(); panelFans = new Panel(); labelFansResult = new Label(); labelTip = new Label(); @@ -78,6 +78,14 @@ namespace GHelper panelTitleGPU = new Panel(); pictureGPU = new PictureBox(); labelGPU = new Label(); + panelGPUBoost = new Panel(); + labelGPUBoost = new Label(); + labelGPUBoostTitle = new Label(); + trackGPUBoost = new TrackBar(); + panelGPUTemp = new Panel(); + labelGPUTemp = new Label(); + labelGPUTempTitle = new Label(); + trackGPUTemp = new TrackBar(); panelFans.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit(); tableFanCharts.SuspendLayout(); @@ -100,6 +108,10 @@ namespace GHelper ((System.ComponentModel.ISupportInitialize)trackGPUCore).BeginInit(); panelTitleGPU.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureGPU).BeginInit(); + panelGPUBoost.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)trackGPUBoost).BeginInit(); + panelGPUTemp.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)trackGPUTemp).BeginInit(); SuspendLayout(); // // panelFans @@ -199,8 +211,8 @@ namespace GHelper // // chartGPU // - chartArea1.Name = "ChartArea1"; - chartGPU.ChartAreas.Add(chartArea1); + chartArea13.Name = "ChartArea1"; + chartGPU.ChartAreas.Add(chartArea13); chartGPU.Dock = DockStyle.Fill; chartGPU.Location = new Point(2, 350); chartGPU.Margin = new Padding(2, 10, 2, 10); @@ -208,13 +220,13 @@ namespace GHelper chartGPU.Size = new Size(760, 320); chartGPU.TabIndex = 17; chartGPU.Text = "chartGPU"; - title1.Name = "Title1"; - chartGPU.Titles.Add(title1); + title13.Name = "Title1"; + chartGPU.Titles.Add(title13); // // chartCPU // - chartArea2.Name = "ChartArea1"; - chartCPU.ChartAreas.Add(chartArea2); + chartArea14.Name = "ChartArea1"; + chartCPU.ChartAreas.Add(chartArea14); chartCPU.Dock = DockStyle.Fill; chartCPU.Location = new Point(2, 10); chartCPU.Margin = new Padding(2, 10, 2, 10); @@ -222,13 +234,13 @@ namespace GHelper chartCPU.Size = new Size(760, 320); chartCPU.TabIndex = 14; chartCPU.Text = "chartCPU"; - title2.Name = "Title1"; - chartCPU.Titles.Add(title2); + title14.Name = "Title1"; + chartCPU.Titles.Add(title14); // // chartMid // - chartArea3.Name = "ChartArea3"; - chartMid.ChartAreas.Add(chartArea3); + chartArea15.Name = "ChartArea3"; + chartMid.ChartAreas.Add(chartArea15); chartMid.Dock = DockStyle.Fill; chartMid.Location = new Point(2, 690); chartMid.Margin = new Padding(2, 10, 2, 10); @@ -236,8 +248,8 @@ namespace GHelper chartMid.Size = new Size(760, 322); chartMid.TabIndex = 14; chartMid.Text = "chartMid"; - title3.Name = "Title3"; - chartMid.Titles.Add(title3); + title15.Name = "Title3"; + chartMid.Titles.Add(title15); chartMid.Visible = false; // // labelFans @@ -304,16 +316,16 @@ namespace GHelper panelPower.Controls.Add(panelTotal); panelPower.Controls.Add(panelTitleCPU); panelPower.Dock = DockStyle.Fill; - panelPower.Location = new Point(10, 345); + panelPower.Location = new Point(10, 634); panelPower.Name = "panelPower"; - panelPower.Size = new Size(523, 844); + panelPower.Size = new Size(523, 555); panelPower.TabIndex = 43; // // panelApplyPower // panelApplyPower.Controls.Add(checkApplyPower); panelApplyPower.Dock = DockStyle.Bottom; - panelApplyPower.Location = new Point(0, 752); + panelApplyPower.Location = new Point(0, 463); panelApplyPower.Name = "panelApplyPower"; panelApplyPower.Padding = new Padding(10); panelApplyPower.Size = new Size(523, 92); @@ -482,13 +494,15 @@ namespace GHelper // panelGPU // panelGPU.AutoSize = true; + panelGPU.Controls.Add(panelGPUTemp); + panelGPU.Controls.Add(panelGPUBoost); panelGPU.Controls.Add(panelGPUMemory); panelGPU.Controls.Add(panelGPUCore); panelGPU.Controls.Add(panelTitleGPU); panelGPU.Dock = DockStyle.Top; panelGPU.Location = new Point(10, 0); panelGPU.Name = "panelGPU"; - panelGPU.Size = new Size(523, 345); + panelGPU.Size = new Size(523, 634); panelGPU.TabIndex = 44; // // panelGPUMemory @@ -532,7 +546,7 @@ namespace GHelper trackGPUMemory.Margin = new Padding(4, 2, 4, 2); trackGPUMemory.Maximum = 300; trackGPUMemory.Name = "trackGPUMemory"; - trackGPUMemory.Size = new Size(513, 90); + trackGPUMemory.Size = new Size(502, 90); trackGPUMemory.SmallChange = 10; trackGPUMemory.TabIndex = 42; trackGPUMemory.TickFrequency = 50; @@ -571,7 +585,7 @@ namespace GHelper trackGPUCore.Maximum = 300; trackGPUCore.Name = "trackGPUCore"; trackGPUCore.RightToLeft = RightToLeft.No; - trackGPUCore.Size = new Size(513, 90); + trackGPUCore.Size = new Size(502, 90); trackGPUCore.SmallChange = 10; trackGPUCore.TabIndex = 18; trackGPUCore.TickFrequency = 50; @@ -622,6 +636,100 @@ namespace GHelper labelGPU.TabIndex = 40; labelGPU.Text = "GPU Settings"; // + // panelGPUBoost + // + panelGPUBoost.AutoSize = true; + panelGPUBoost.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelGPUBoost.Controls.Add(labelGPUBoost); + panelGPUBoost.Controls.Add(labelGPUBoostTitle); + panelGPUBoost.Controls.Add(trackGPUBoost); + panelGPUBoost.Dock = DockStyle.Top; + panelGPUBoost.Location = new Point(0, 345); + panelGPUBoost.Name = "panelGPUBoost"; + panelGPUBoost.Size = new Size(523, 140); + panelGPUBoost.TabIndex = 46; + // + // labelGPUBoost + // + labelGPUBoost.Anchor = AnchorStyles.Top | AnchorStyles.Right; + labelGPUBoost.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelGPUBoost.Location = new Point(374, 14); + labelGPUBoost.Name = "labelGPUBoost"; + labelGPUBoost.Size = new Size(130, 32); + labelGPUBoost.TabIndex = 44; + labelGPUBoost.Text = "25W"; + labelGPUBoost.TextAlign = ContentAlignment.TopRight; + // + // labelGPUBoostTitle + // + labelGPUBoostTitle.AutoSize = true; + labelGPUBoostTitle.Location = new Point(10, 14); + labelGPUBoostTitle.Name = "labelGPUBoostTitle"; + labelGPUBoostTitle.Size = new Size(174, 32); + labelGPUBoostTitle.TabIndex = 43; + labelGPUBoostTitle.Text = "Dynamic Boost"; + // + // trackGPUBoost + // + trackGPUBoost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + trackGPUBoost.Location = new Point(6, 48); + trackGPUBoost.Margin = new Padding(4, 2, 4, 2); + trackGPUBoost.Maximum = 25; + trackGPUBoost.Minimum = 5; + trackGPUBoost.Name = "trackGPUBoost"; + trackGPUBoost.Size = new Size(502, 90); + trackGPUBoost.TabIndex = 42; + trackGPUBoost.TickFrequency = 5; + trackGPUBoost.TickStyle = TickStyle.TopLeft; + trackGPUBoost.Value = 25; + // + // panelGPUTemp + // + panelGPUTemp.AutoSize = true; + panelGPUTemp.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelGPUTemp.Controls.Add(labelGPUTemp); + panelGPUTemp.Controls.Add(labelGPUTempTitle); + panelGPUTemp.Controls.Add(trackGPUTemp); + panelGPUTemp.Dock = DockStyle.Top; + panelGPUTemp.Location = new Point(0, 485); + panelGPUTemp.Name = "panelGPUTemp"; + panelGPUTemp.Size = new Size(523, 149); + panelGPUTemp.TabIndex = 47; + // + // labelGPUTemp + // + labelGPUTemp.Anchor = AnchorStyles.Top | AnchorStyles.Right; + labelGPUTemp.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelGPUTemp.Location = new Point(378, 14); + labelGPUTemp.Name = "labelGPUTemp"; + labelGPUTemp.Size = new Size(130, 32); + labelGPUTemp.TabIndex = 44; + labelGPUTemp.Text = "87C"; + labelGPUTemp.TextAlign = ContentAlignment.TopRight; + // + // labelGPUTempTitle + // + labelGPUTempTitle.AutoSize = true; + labelGPUTempTitle.Location = new Point(10, 14); + labelGPUTempTitle.Name = "labelGPUTempTitle"; + labelGPUTempTitle.Size = new Size(173, 32); + labelGPUTempTitle.TabIndex = 43; + labelGPUTempTitle.Text = "Thermal Target"; + // + // trackGPUTemp + // + trackGPUTemp.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + trackGPUTemp.Location = new Point(6, 57); + trackGPUTemp.Margin = new Padding(4, 2, 4, 2); + trackGPUTemp.Maximum = 87; + trackGPUTemp.Minimum = 75; + trackGPUTemp.Name = "trackGPUTemp"; + trackGPUTemp.Size = new Size(502, 90); + trackGPUTemp.TabIndex = 42; + trackGPUTemp.TickFrequency = 5; + trackGPUTemp.TickStyle = TickStyle.TopLeft; + trackGPUTemp.Value = 87; + // // Fans // AutoScaleDimensions = new SizeF(192F, 192F); @@ -674,6 +782,12 @@ namespace GHelper panelTitleGPU.ResumeLayout(false); panelTitleGPU.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureGPU).EndInit(); + panelGPUBoost.ResumeLayout(false); + panelGPUBoost.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)trackGPUBoost).EndInit(); + panelGPUTemp.ResumeLayout(false); + panelGPUTemp.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)trackGPUTemp).EndInit(); ResumeLayout(false); } @@ -719,5 +833,13 @@ namespace GHelper private Label labelGPU; private Panel panelApplyPower; private RCheckBox checkApplyPower; + private Panel panelGPUBoost; + private Label labelGPUBoost; + private Label labelGPUBoostTitle; + private TrackBar trackGPUBoost; + private Panel panelGPUTemp; + private Label labelGPUTemp; + private Label labelGPUTempTitle; + private TrackBar trackGPUTemp; } } \ No newline at end of file diff --git a/app/Fans.cs b/app/Fans.cs index 0c4809fb..4adc9dd8 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -79,12 +79,23 @@ namespace GHelper trackGPUMemory.Minimum = NvidiaGpuControl.MinMemoryOffset; trackGPUMemory.Maximum = NvidiaGpuControl.MaxMemoryOffset; + trackGPUBoost.Minimum = ASUSWmi.MinGPUBoost; + trackGPUBoost.Maximum = ASUSWmi.MaxGPUBoost; + + trackGPUTemp.Minimum = ASUSWmi.MinGPUTemp; + trackGPUTemp.Maximum = ASUSWmi.MaxGPUTemp; + trackGPUCore.Scroll += trackGPU_Scroll; trackGPUMemory.Scroll += trackGPU_Scroll; + trackGPUBoost.Scroll += trackGPU_Scroll; + trackGPUTemp.Scroll += trackGPU_Scroll; trackGPUCore.MouseUp += TrackGPU_MouseUp; trackGPUMemory.MouseUp += TrackGPU_MouseUp; + trackGPUBoost.MouseUp += TrackGPUBoost_MouseUp; + trackGPUTemp.MouseUp += TrackGPUBoost_MouseUp; + //labelInfo.MaximumSize = new Size(280, 0); labelInfo.Text = Properties.Strings.PPTExperimental; labelFansResult.Visible = false; @@ -101,12 +112,19 @@ namespace GHelper } + private void TrackGPUBoost_MouseUp(object? sender, MouseEventArgs e) + { + Program.config.setConfig("gpu_boost", trackGPUBoost.Value); + Program.config.setConfig("gpu_temp", trackGPUTemp.Value); + Program.settingsForm.SetGPUPower(); + } + private void TrackGPU_MouseUp(object? sender, MouseEventArgs e) { try { - Program.config.setConfig("GPUCore", trackGPUCore.Value); - Program.config.setConfig("GPUMemory", trackGPUMemory.Value); + Program.config.setConfig("gpu_core", trackGPUCore.Value); + Program.config.setConfig("gpu_memory", trackGPUMemory.Value); int status = Program.nvControl.SetClocks(trackGPUCore.Value, trackGPUMemory.Value); if (status == -1) Program.RunAsAdmin("gpu"); @@ -135,41 +153,37 @@ namespace GHelper trackGPUCore.Value = Math.Max(Math.Min(core, NvidiaGpuControl.MaxCoreOffset), NvidiaGpuControl.MinCoreOffset); trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset); - VisualiseGPUClocks(); + int gpu_boost = Program.config.getConfig("gpu_boost"); + int gpu_temp = Program.config.getConfig("gpu_temp"); + + if (gpu_boost < 0) gpu_boost = ASUSWmi.MaxGPUBoost; + if (gpu_temp < 0) gpu_temp = ASUSWmi.MaxGPUTemp; + + trackGPUBoost.Value = Math.Max(Math.Min(gpu_boost, ASUSWmi.MaxGPUBoost), ASUSWmi.MinGPUBoost); + trackGPUTemp.Value = Math.Max(Math.Min(gpu_temp, ASUSWmi.MaxGPUTemp), ASUSWmi.MinGPUTemp); + + VisualiseGPUSettings(); } catch (Exception ex) { - Debug.WriteLine(ex); + Logger.WriteLine(ex.ToString()); panelGPU.Visible = false; } } - private void ButtonResetGPU_Click(object? sender, EventArgs e) - { - - try - { - trackGPUCore.Value = 0; - trackGPUMemory.Value = 0; - VisualiseGPUClocks(); - } - catch (Exception ex) - { - Logger.WriteLine(ex.ToString()); - } - } - - private void VisualiseGPUClocks() + private void VisualiseGPUSettings() { labelGPUCore.Text = $"{trackGPUCore.Value} MHz"; labelGPUMemory.Text = $"{trackGPUMemory.Value} MHz"; + labelGPUBoost.Text = $"{trackGPUBoost.Value}W"; + labelGPUTemp.Text = $"{trackGPUTemp.Value}°C"; } private void trackGPU_Scroll(object? sender, EventArgs e) { - VisualiseGPUClocks(); + VisualiseGPUSettings(); } static string ChartPercToRPM(int percentage, string unit = "") diff --git a/app/GHelper.csproj b/app/GHelper.csproj index c171c5a7..6d225211 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ AnyCPU False True - 0.57 + 0.58 diff --git a/app/Gpu/NvidiaGpuControl.cs b/app/Gpu/NvidiaGpuControl.cs index 58caf5e6..009d858c 100644 --- a/app/Gpu/NvidiaGpuControl.cs +++ b/app/Gpu/NvidiaGpuControl.cs @@ -48,15 +48,15 @@ public class NvidiaGpuControl : IGpuControl public void GetClocks(out int core, out int memory) { PhysicalGPU internalGpu = _internalGpu!; - PerformanceStates20InfoV3 states = (PerformanceStates20InfoV3)GPUApi.GetPerformanceStates20(internalGpu.Handle); + PerformanceStates20InfoV1 states = (PerformanceStates20InfoV1)GPUApi.GetPerformanceStates20(internalGpu.Handle); core = states.Clocks[PerformanceStateId.P0_3DPerformance][0].FrequencyDeltaInkHz.DeltaValue / 1000; memory = states.Clocks[PerformanceStateId.P0_3DPerformance][1].FrequencyDeltaInkHz.DeltaValue / 1000; } public int SetClocksFromConfig() { - int core = Program.config.getConfig("GPUCore"); - int memory = Program.config.getConfig("GPUMemory"); + int core = Program.config.getConfig("gpu_core"); + int memory = Program.config.getConfig("gpu_memory"); int status = SetClocks(core, memory); return status; } @@ -68,7 +68,7 @@ public class NvidiaGpuControl : IGpuControl if (memory < MinMemoryOffset || memory > MaxMemoryOffset) return 0; PhysicalGPU internalGpu = _internalGpu!; - PerformanceStates20InfoV3 states = (PerformanceStates20InfoV3)GPUApi.GetPerformanceStates20(internalGpu.Handle); + PerformanceStates20InfoV1 states = (PerformanceStates20InfoV1)GPUApi.GetPerformanceStates20(internalGpu.Handle); states._NumberOfPerformanceStates = 1; states._NumberOfClocks = 2; @@ -96,8 +96,9 @@ public class NvidiaGpuControl : IGpuControl .GetPhysicalGPUs() .FirstOrDefault(gpu => gpu.SystemType == SystemType.Laptop); } - catch + catch (Exception ex) { + Logger.WriteLine(ex.ToString()); return null; } } diff --git a/app/NvAPIWrapper/Native/Delegates/GPU.cs b/app/NvAPIWrapper/Native/Delegates/GPU.cs index 5ff86598..a199f35c 100644 --- a/app/NvAPIWrapper/Native/Delegates/GPU.cs +++ b/app/NvAPIWrapper/Native/Delegates/GPU.cs @@ -430,9 +430,9 @@ namespace NvAPIWrapper.Native.Delegates public delegate Status NvAPI_GPU_GetPStates20( [In] PhysicalGPUHandle physicalGpu, [Accepts( - typeof(PerformanceStates20InfoV3), + typeof(PerformanceStates20InfoV1), typeof(PerformanceStates20InfoV2), - typeof(PerformanceStates20InfoV1) + typeof(PerformanceStates20InfoV3) )] [In] ValueTypeReference performanceStatesInfo); diff --git a/app/Settings.cs b/app/Settings.cs index e74851cf..7ee44e10 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1043,6 +1043,26 @@ namespace GHelper } + public void SetGPUPower() + { + + int gpu_boost = Program.config.getConfig("gpu_boost"); + int gpu_temp = Program.config.getConfig("gpu_temp"); + + if (gpu_boost < ASUSWmi.MinGPUBoost || gpu_boost > ASUSWmi.MaxGPUBoost ) return; + if (gpu_temp < ASUSWmi.MinGPUTemp || gpu_temp > ASUSWmi.MaxGPUTemp) return; + + if (Program.wmi.DeviceGet(ASUSWmi.PPT_GPUC0) >= 0) + { + Program.wmi.DeviceSet(ASUSWmi.PPT_GPUC0, gpu_boost, "PowerLimit C0"); + } + + if (Program.wmi.DeviceGet(ASUSWmi.PPT_GPUC2) >= 0) + { + Program.wmi.DeviceSet(ASUSWmi.PPT_GPUC2, gpu_temp, "PowerLimit C2"); + } + + } protected void LabelFansResult(string text) { diff --git a/app/global.json b/app/global.json new file mode 100644 index 00000000..0f11ff6e --- /dev/null +++ b/app/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "7.0.203" + } +} \ No newline at end of file