2023-01-12 22:58:40 +01:00
|
|
|
using CommonHelpers;
|
2022-12-19 22:47:10 +01:00
|
|
|
using PowerControl.Helpers.AMD;
|
|
|
|
|
|
|
|
|
|
namespace PowerControl.Options
|
|
|
|
|
{
|
|
|
|
|
public static class GPUFrequency
|
|
|
|
|
{
|
|
|
|
|
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
|
|
|
|
{
|
|
|
|
|
Name = "GPU",
|
2023-01-10 11:12:31 +01:00
|
|
|
PersistentKey = "GPUFrequency",
|
|
|
|
|
PersistOnCreate = false,
|
2022-12-19 22:47:10 +01:00
|
|
|
Options = { "Default", "400MHz", "800MHz", "1200MHz", "1600MHz" },
|
|
|
|
|
ApplyDelay = 1000,
|
|
|
|
|
Visible = VangoghGPU.IsSupported,
|
|
|
|
|
ActiveOption = "?",
|
|
|
|
|
ResetValue = () => { return "Default"; },
|
2022-12-19 23:36:22 +01:00
|
|
|
ApplyValue = (selected) =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
2023-01-12 22:58:40 +01:00
|
|
|
if (!AntiCheatSettings.Default.AckAntiCheat(
|
2022-12-19 22:47:10 +01:00
|
|
|
Controller.TitleWithVersion,
|
2023-01-12 22:58:40 +01:00
|
|
|
"Changing GPU frequency requires kernel access for a short period.",
|
|
|
|
|
"Leave the game if it uses anti-cheat protection."))
|
2022-12-19 22:47:10 +01:00
|
|
|
return null;
|
|
|
|
|
|
2022-12-19 23:36:22 +01:00
|
|
|
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
|
|
|
|
using (var sd = VangoghGPU.Open())
|
|
|
|
|
{
|
|
|
|
|
if (sd is null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2022-12-19 23:36:22 +01:00
|
|
|
if (selected == "Default")
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
|
|
|
|
sd.HardMinGfxClock = 200;
|
|
|
|
|
return selected;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-19 23:36:22 +01:00
|
|
|
sd.HardMinGfxClock = uint.Parse(selected.Replace("MHz", ""));
|
2022-12-19 22:47:10 +01:00
|
|
|
return selected;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|