Rog Ally GPU Memory setting

This commit is contained in:
Serge Samusya
2023-12-01 14:38:50 +01:00
parent 5d945d6b7c
commit 32c4f6168c
5 changed files with 168 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
using GHelper; using FftSharp;
using GHelper;
using GHelper.USB; using GHelper.USB;
using System.Management; using System.Management;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -94,6 +95,9 @@ public class AsusACPI
public const int PPT_APUC1 = 0x001200C1; // fPPT (fast boost limit) public const int PPT_APUC1 = 0x001200C1; // fPPT (fast boost limit)
public const int PPT_GPUC2 = 0x001200C2; // NVIDIA GPU Temp Target (75.. 87 C) public const int PPT_GPUC2 = 0x001200C2; // NVIDIA GPU Temp Target (75.. 87 C)
public const int APU_MEM = 0x000600C1;
public const int APU_MEM_OFFSET = 258;
public const int TUF_KB_BRIGHTNESS = 0x00050021; public const int TUF_KB_BRIGHTNESS = 0x00050021;
public const int TUF_KB = 0x00100056; public const int TUF_KB = 0x00100056;
public const int TUF_KB2 = 0x0010005a; public const int TUF_KB2 = 0x0010005a;
@@ -525,6 +529,16 @@ public class AsusACPI
return DeviceGet(PPT_CPUB0) >= 0 && DeviceGet(PPT_GPUC0) < 0; return DeviceGet(PPT_CPUB0) >= 0 && DeviceGet(PPT_GPUC0) < 0;
} }
public void SetAPUMem(int memory = 4)
{
if (memory < 0 || memory > 8) return;
Program.acpi.DeviceSet(APU_MEM, memory + APU_MEM_OFFSET, "APU Mem");
}
public int GetAPUMem()
{
return Program.acpi.DeviceGet(APU_MEM) - APU_MEM_OFFSET;
}
public void ScanRange() public void ScanRange()
{ {

99
app/Extra.Designer.cs generated
View File

@@ -106,6 +106,7 @@ namespace GHelper
checkAutoToggleClamshellMode = new CheckBox(); checkAutoToggleClamshellMode = new CheckBox();
checkTopmost = new CheckBox(); checkTopmost = new CheckBox();
checkNoOverdrive = new CheckBox(); checkNoOverdrive = new CheckBox();
checkBootSound = new CheckBox();
checkUSBC = new CheckBox(); checkUSBC = new CheckBox();
checkVariBright = new CheckBox(); checkVariBright = new CheckBox();
checkGpuApps = new CheckBox(); checkGpuApps = new CheckBox();
@@ -115,7 +116,10 @@ namespace GHelper
labelHibernateAfter = new Label(); labelHibernateAfter = new Label();
pictureHibernate = new PictureBox(); pictureHibernate = new PictureBox();
toolTip = new ToolTip(components); toolTip = new ToolTip(components);
checkBootSound = new CheckBox(); panelAPU = new Panel();
comboAPU = new RComboBox();
pictureAPUMem = new PictureBox();
labelAPUMem = new Label();
panelServices.SuspendLayout(); panelServices.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureService).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureService).BeginInit();
panelBindingsHeader.SuspendLayout(); panelBindingsHeader.SuspendLayout();
@@ -138,6 +142,8 @@ namespace GHelper
panelPower.SuspendLayout(); panelPower.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericHibernateAfter).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericHibernateAfter).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureHibernate).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureHibernate).BeginInit();
panelAPU.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureAPUMem).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// panelServices // panelServices
@@ -148,7 +154,7 @@ namespace GHelper
panelServices.Controls.Add(labelServices); panelServices.Controls.Add(labelServices);
panelServices.Controls.Add(buttonServices); panelServices.Controls.Add(buttonServices);
panelServices.Dock = DockStyle.Top; panelServices.Dock = DockStyle.Top;
panelServices.Location = new Point(15, 1321); panelServices.Location = new Point(15, 1378);
panelServices.Name = "panelServices"; panelServices.Name = "panelServices";
panelServices.Size = new Size(983, 75); panelServices.Size = new Size(983, 75);
panelServices.TabIndex = 5; panelServices.TabIndex = 5;
@@ -1072,7 +1078,7 @@ namespace GHelper
panelSettings.Controls.Add(checkGpuApps); panelSettings.Controls.Add(checkGpuApps);
panelSettings.Controls.Add(checkGPUFix); panelSettings.Controls.Add(checkGPUFix);
panelSettings.Dock = DockStyle.Top; panelSettings.Dock = DockStyle.Top;
panelSettings.Location = new Point(15, 921); panelSettings.Location = new Point(15, 978);
panelSettings.Name = "panelSettings"; panelSettings.Name = "panelSettings";
panelSettings.Padding = new Padding(20, 5, 11, 5); panelSettings.Padding = new Padding(20, 5, 11, 5);
panelSettings.Size = new Size(983, 346); panelSettings.Size = new Size(983, 346);
@@ -1116,6 +1122,19 @@ namespace GHelper
checkNoOverdrive.Text = Strings.DisableOverdrive; checkNoOverdrive.Text = Strings.DisableOverdrive;
checkNoOverdrive.UseVisualStyleBackColor = true; checkNoOverdrive.UseVisualStyleBackColor = true;
// //
// checkBootSound
//
checkBootSound.AutoSize = true;
checkBootSound.Dock = DockStyle.Top;
checkBootSound.Location = new Point(20, 173);
checkBootSound.Margin = new Padding(4, 3, 4, 3);
checkBootSound.Name = "checkBootSound";
checkBootSound.Padding = new Padding(3);
checkBootSound.Size = new Size(952, 42);
checkBootSound.TabIndex = 10;
checkBootSound.Text = "Boot Sound";
checkBootSound.UseVisualStyleBackColor = true;
//
// checkUSBC // checkUSBC
// //
checkUSBC.AutoSize = true; checkUSBC.AutoSize = true;
@@ -1174,7 +1193,7 @@ namespace GHelper
panelPower.Controls.Add(labelHibernateAfter); panelPower.Controls.Add(labelHibernateAfter);
panelPower.Controls.Add(pictureHibernate); panelPower.Controls.Add(pictureHibernate);
panelPower.Dock = DockStyle.Top; panelPower.Dock = DockStyle.Top;
panelPower.Location = new Point(15, 1267); panelPower.Location = new Point(15, 1324);
panelPower.Name = "panelPower"; panelPower.Name = "panelPower";
panelPower.Size = new Size(983, 54); panelPower.Size = new Size(983, 54);
panelPower.TabIndex = 4; panelPower.TabIndex = 4;
@@ -1211,18 +1230,58 @@ namespace GHelper
pictureHibernate.TabIndex = 22; pictureHibernate.TabIndex = 22;
pictureHibernate.TabStop = false; pictureHibernate.TabStop = false;
// //
// checkBootSound // panelAPU
// //
checkBootSound.AutoSize = true; panelAPU.AutoSize = true;
checkBootSound.Dock = DockStyle.Top; panelAPU.Controls.Add(comboAPU);
checkBootSound.Location = new Point(20, 173); panelAPU.Controls.Add(pictureAPUMem);
checkBootSound.Margin = new Padding(4, 3, 4, 3); panelAPU.Controls.Add(labelAPUMem);
checkBootSound.Name = "checkBootSound"; panelAPU.Dock = DockStyle.Top;
checkBootSound.Padding = new Padding(3); panelAPU.Location = new Point(15, 921);
checkBootSound.Size = new Size(952, 42); panelAPU.Name = "panelAPU";
checkBootSound.TabIndex = 10; panelAPU.Padding = new Padding(11, 5, 11, 0);
checkBootSound.Text = "Boot Sound"; panelAPU.Size = new Size(983, 57);
checkBootSound.UseVisualStyleBackColor = true; panelAPU.TabIndex = 46;
panelAPU.Visible = false;
panelAPU.Paint += panelAPU_Paint;
//
// comboAPU
//
comboAPU.AccessibleName = "Keyboard Animation Speed";
comboAPU.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboAPU.BorderColor = Color.White;
comboAPU.ButtonColor = SystemColors.ControlLight;
comboAPU.FlatStyle = FlatStyle.Flat;
comboAPU.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboAPU.FormattingEnabled = true;
comboAPU.ItemHeight = 32;
comboAPU.Items.AddRange(new object[] { "Auto", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G" });
comboAPU.Location = new Point(663, 8);
comboAPU.Margin = new Padding(4, 12, 4, 9);
comboAPU.Name = "comboAPU";
comboAPU.Size = new Size(293, 40);
comboAPU.TabIndex = 12;
comboAPU.TabStop = false;
//
// pictureAPUMem
//
pictureAPUMem.BackgroundImage = Resources.icons8_video_48;
pictureAPUMem.BackgroundImageLayout = ImageLayout.Zoom;
pictureAPUMem.Location = new Point(20, 11);
pictureAPUMem.Name = "pictureAPUMem";
pictureAPUMem.Size = new Size(32, 32);
pictureAPUMem.TabIndex = 1;
pictureAPUMem.TabStop = false;
//
// labelAPUMem
//
labelAPUMem.AutoSize = true;
labelAPUMem.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelAPUMem.Location = new Point(56, 11);
labelAPUMem.Name = "labelAPUMem";
labelAPUMem.Size = new Size(309, 32);
labelAPUMem.TabIndex = 0;
labelAPUMem.Text = "Memory Assigned to GPU";
// //
// Extra // Extra
// //
@@ -1230,10 +1289,11 @@ namespace GHelper
AutoScaleMode = AutoScaleMode.Dpi; AutoScaleMode = AutoScaleMode.Dpi;
AutoSize = true; AutoSize = true;
AutoSizeMode = AutoSizeMode.GrowAndShrink; AutoSizeMode = AutoSizeMode.GrowAndShrink;
ClientSize = new Size(1013, 1467); ClientSize = new Size(1013, 1515);
Controls.Add(panelServices); Controls.Add(panelServices);
Controls.Add(panelPower); Controls.Add(panelPower);
Controls.Add(panelSettings); Controls.Add(panelSettings);
Controls.Add(panelAPU);
Controls.Add(panelSettingsHeader); Controls.Add(panelSettingsHeader);
Controls.Add(panelBacklight); Controls.Add(panelBacklight);
Controls.Add(panelBacklightHeader); Controls.Add(panelBacklightHeader);
@@ -1282,6 +1342,9 @@ namespace GHelper
panelPower.PerformLayout(); panelPower.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericHibernateAfter).EndInit(); ((System.ComponentModel.ISupportInitialize)numericHibernateAfter).EndInit();
((System.ComponentModel.ISupportInitialize)pictureHibernate).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureHibernate).EndInit();
panelAPU.ResumeLayout(false);
panelAPU.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureAPUMem).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@@ -1372,5 +1435,9 @@ namespace GHelper
private CheckBox checkGPUFix; private CheckBox checkGPUFix;
private ToolTip toolTip; private ToolTip toolTip;
private CheckBox checkBootSound; private CheckBox checkBootSound;
private Panel panelAPU;
private PictureBox pictureAPUMem;
private Label labelAPUMem;
private RComboBox comboAPU;
} }
} }

View File

@@ -13,6 +13,7 @@ namespace GHelper
{ {
ScreenControl screenControl = new ScreenControl(); ScreenControl screenControl = new ScreenControl();
ModeControl modeControl = new ModeControl();
ClamshellModeControl clamshellControl = new ClamshellModeControl(); ClamshellModeControl clamshellControl = new ClamshellModeControl();
const string EMPTY = "--------------"; const string EMPTY = "--------------";
@@ -138,6 +139,8 @@ namespace GHelper
checkGpuApps.Text = Properties.Strings.KillGpuApps; checkGpuApps.Text = Properties.Strings.KillGpuApps;
labelHibernateAfter.Text = Properties.Strings.HibernateAfter; labelHibernateAfter.Text = Properties.Strings.HibernateAfter;
labelAPUMem.Text = Properties.Strings.APUMemory;
Text = Properties.Strings.ExtraSettings; Text = Properties.Strings.ExtraSettings;
if (AppConfig.IsARCNM()) if (AppConfig.IsARCNM())
@@ -147,14 +150,14 @@ namespace GHelper
labelM2.Visible = comboM2.Visible = textM2.Visible = false; labelM2.Visible = comboM2.Visible = textM2.Visible = false;
labelM4.Visible = comboM4.Visible = textM4.Visible = false; labelM4.Visible = comboM4.Visible = textM4.Visible = false;
labelFNF4.Visible = comboFNF4.Visible = textFNF4.Visible = false; labelFNF4.Visible = comboFNF4.Visible = textFNF4.Visible = false;
} }
if (AppConfig.NoMKeys()) if (AppConfig.NoMKeys())
{ {
labelM1.Text = "FN+F2"; labelM1.Text = "FN+F2";
labelM2.Text = "FN+F3"; labelM2.Text = "FN+F3";
labelM3.Text = "FN+F4"; labelM3.Text = "FN+F4";
labelM4.Visible = comboM4.Visible = textM4.Visible = AppConfig.IsDUO(); labelM4.Visible = comboM4.Visible = textM4.Visible = AppConfig.IsDUO();
labelFNF4.Visible = comboFNF4.Visible = textFNF4.Visible = false; labelFNF4.Visible = comboFNF4.Visible = textFNF4.Visible = false;
} }
@@ -174,6 +177,16 @@ namespace GHelper
checkUSBC.Visible = false; checkUSBC.Visible = false;
} }
int apuMem = Program.acpi.GetAPUMem();
if (apuMem >= 0)
{
panelAPU.Visible = true;
comboAPU.DropDownStyle = ComboBoxStyle.DropDownList;
comboAPU.SelectedIndex = apuMem;
}
comboAPU.SelectedIndexChanged += ComboAPU_SelectedIndexChanged;
// Change text and hide irrelevant options on the ROG Ally, // Change text and hide irrelevant options on the ROG Ally,
// which is a bit of a special case piece of hardware. // which is a bit of a special case piece of hardware.
if (AppConfig.IsAlly()) if (AppConfig.IsAlly())
@@ -348,6 +361,19 @@ namespace GHelper
InitHibernate(); InitHibernate();
} }
private void ComboAPU_SelectedIndexChanged(object? sender, EventArgs e)
{
int mem = comboAPU.SelectedIndex;
Program.acpi.SetAPUMem(mem);
DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertAPUMemoryRestart, Properties.Strings.AlertAPUMemoryRestartTitle, MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Process.Start("shutdown", "/r /t 1");
}
}
private void CheckBootSound_CheckedChanged(object? sender, EventArgs e) private void CheckBootSound_CheckedChanged(object? sender, EventArgs e)
{ {
Program.acpi.DeviceSet(AsusACPI.BootSound, (checkBootSound.Checked ? 1 : 0), "BootSound"); Program.acpi.DeviceSet(AsusACPI.BootSound, (checkBootSound.Checked ? 1 : 0), "BootSound");
@@ -604,5 +630,10 @@ namespace GHelper
} }
} }
private void panelAPU_Paint(object sender, PaintEventArgs e)
{
}
} }
} }

View File

@@ -78,6 +78,24 @@ namespace GHelper.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Restart your device to apply changes.
/// </summary>
internal static string AlertAPUMemoryRestart {
get {
return ResourceManager.GetString("AlertAPUMemoryRestart", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restart now?.
/// </summary>
internal static string AlertAPUMemoryRestartTitle {
get {
return ResourceManager.GetString("AlertAPUMemoryRestartTitle", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Looks like GPU is in heavy use, disable it?. /// Looks up a localized string similar to Looks like GPU is in heavy use, disable it?.
/// </summary> /// </summary>
@@ -195,6 +213,15 @@ namespace GHelper.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Memory Assigned to GPU.
/// </summary>
internal static string APUMemory {
get {
return ResourceManager.GetString("APUMemory", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Asus Services Running. /// Looks up a localized string similar to Asus Services Running.
/// </summary> /// </summary>

View File

@@ -123,6 +123,12 @@
<data name="ACPIError" xml:space="preserve"> <data name="ACPIError" xml:space="preserve">
<value>Can't connect to ASUS ACPI. Application can't function without it. Try to install Asus System Control Interface</value> <value>Can't connect to ASUS ACPI. Application can't function without it. Try to install Asus System Control Interface</value>
</data> </data>
<data name="AlertAPUMemoryRestart" xml:space="preserve">
<value>Restart your device to apply changes</value>
</data>
<data name="AlertAPUMemoryRestartTitle" xml:space="preserve">
<value>Restart now?</value>
</data>
<data name="AlertDGPU" xml:space="preserve"> <data name="AlertDGPU" xml:space="preserve">
<value>Looks like GPU is in heavy use, disable it?</value> <value>Looks like GPU is in heavy use, disable it?</value>
</data> </data>
@@ -162,6 +168,9 @@
<data name="ApplyWindowsPowerPlan" xml:space="preserve"> <data name="ApplyWindowsPowerPlan" xml:space="preserve">
<value>Auto adjust Windows Power Modes</value> <value>Auto adjust Windows Power Modes</value>
</data> </data>
<data name="APUMemory" xml:space="preserve">
<value>Memory Assigned to GPU</value>
</data>
<data name="AsusServicesRunning" xml:space="preserve"> <data name="AsusServicesRunning" xml:space="preserve">
<value>Asus Services Running</value> <value>Asus Services Running</value>
</data> </data>