mirror of
https://github.com/nomi-san/parsec-vdd.git
synced 2026-08-07 13:50:45 +00:00
Add parent GPU option
This commit is contained in:
@@ -29,6 +29,14 @@ namespace ParsecVDisplay
|
||||
var modes = Display.ParseModes(e.Args[1]);
|
||||
ParsecVDD.SetCustomDisplayModes(modes);
|
||||
|
||||
if (e.Args.Length >= 3)
|
||||
{
|
||||
if (Enum.TryParse<ParsecVDD.ParentGPU>(e.Args[2], true, out var kind))
|
||||
{
|
||||
ParsecVDD.SetParentGPU(kind);
|
||||
}
|
||||
}
|
||||
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,14 @@
|
||||
<Label>Hz</Label>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="25,0,0,25">
|
||||
<TextBlock Text="Parent GPU:" FontSize="14" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center" />
|
||||
<ComboBox x:Name="xParentGPU" Width="80" FontSize="14" SelectedIndex="0" BorderBrush="Transparent" Background="Transparent" Margin="10,0,0,0">
|
||||
<ComboBoxItem Content="Auto" />
|
||||
<ComboBoxItem Content="AMD" />
|
||||
<ComboBoxItem Content="NVIDIA" />
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal" Margin="0,0,25,25">
|
||||
<local:Button Click="ApplyChanges" Width="120" Height="36" Foreground="White">
|
||||
<local:Button.Children>
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace ParsecVDisplay.Components
|
||||
public CustomPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
xParentGPU.Items.Clear();
|
||||
foreach (var item in Enum.GetValues(typeof(ParsecVDD.ParentGPU)))
|
||||
{
|
||||
xParentGPU.Items.Add(item.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyChanges(object sender, EventArgs e)
|
||||
@@ -44,15 +50,19 @@ namespace ParsecVDisplay.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (modes.Count > 0)
|
||||
ParsecVDD.ParentGPU parentGPU;
|
||||
bool validParentGPU = Enum.TryParse(xParentGPU.SelectedValue.ToString(), true, out parentGPU);
|
||||
|
||||
if (modes.Count > 0 && validParentGPU)
|
||||
{
|
||||
if (Helper.IsAdmin())
|
||||
{
|
||||
ParsecVDD.SetCustomDisplayModes(modes);
|
||||
ParsecVDD.SetParentGPU(parentGPU);
|
||||
}
|
||||
else
|
||||
{
|
||||
var args = $"-custom \"{Display.DumpModes(modes)}\"";
|
||||
var args = $"-custom \"{Display.DumpModes(modes)}\" \"{parentGPU}\"";
|
||||
if (Helper.RunAdminTask(args) == false)
|
||||
{
|
||||
MessageBox.Show("Could not set custom resolutions, access denied!",
|
||||
@@ -77,6 +87,9 @@ namespace ParsecVDisplay.Components
|
||||
TextBoxes[i + 1].Text = $"{modes[j].Height}";
|
||||
TextBoxes[i + 2].Text = $"{modes[j].Hz}";
|
||||
}
|
||||
|
||||
var parentGPU = ParsecVDD.GetParentGPU();
|
||||
xParentGPU.SelectedValue = parentGPU.ToString();
|
||||
}
|
||||
|
||||
private void Page_Unloaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -269,6 +269,54 @@ namespace ParsecVDisplay
|
||||
}
|
||||
}
|
||||
|
||||
public enum ParentGPU
|
||||
{
|
||||
Auto = 0,
|
||||
NVIDIA = 0x10DE,
|
||||
AMD = 0x1002,
|
||||
}
|
||||
|
||||
public static ParentGPU GetParentGPU()
|
||||
{
|
||||
using (var parameters = Registry.LocalMachine.OpenSubKey(
|
||||
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WUDF\\Services\\ParsecVDA\\Parameters",
|
||||
RegistryKeyPermissionCheck.ReadSubTree))
|
||||
{
|
||||
if (parameters != null)
|
||||
{
|
||||
object value = parameters.GetValue("PreferredRenderAdapterVendorId");
|
||||
if (value != null)
|
||||
{
|
||||
return (ParentGPU)Convert.ToInt32(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ParentGPU.Auto;
|
||||
}
|
||||
|
||||
// Requires admin perm
|
||||
public static void SetParentGPU(ParentGPU kind)
|
||||
{
|
||||
using (var parameters = Registry.LocalMachine.OpenSubKey(
|
||||
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WUDF\\Services\\ParsecVDA\\Parameters",
|
||||
RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
{
|
||||
if (parameters != null)
|
||||
{
|
||||
if (kind == ParentGPU.Auto)
|
||||
{
|
||||
parameters.DeleteValue("PreferredRenderAdapterVendorId", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters.SetValue("PreferredRenderAdapterVendorId",
|
||||
(uint)kind, RegistryValueKind.DWord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static unsafe class Native
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
|
||||
@@ -7,11 +7,11 @@ using System.Windows;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ParsecVDisplay")]
|
||||
[assembly: AssemblyTitle(ParsecVDisplay.App.NAME)]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ParsecVDisplay")]
|
||||
[assembly: AssemblyProduct(ParsecVDisplay.App.NAME)]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
Reference in New Issue
Block a user