Enable D3D exclusive fullscreen by default

This commit is contained in:
pizzaboxer 2023-06-26 21:36:07 +01:00
parent 14a1872674
commit 670790a023
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 32 additions and 61 deletions

View File

@ -22,9 +22,9 @@ namespace Bloxstrap.Singletons
public static IReadOnlyDictionary<string, string> RenderingModes => new Dictionary<string, string>
{
{ "Automatic", "" },
{ "Vulkan", "FFlagDebugGraphicsPreferVulkan" },
{ "Direct3D 11", "FFlagDebugGraphicsPreferD3D11" },
{ "Direct3D 10", "FFlagDebugGraphicsPreferD3D11FL10" },
{ "Vulkan", "FFlagDebugGraphicsPreferVulkan" },
{ "OpenGL", "FFlagDebugGraphicsPreferOpenGL" }
};
@ -101,6 +101,22 @@ namespace Bloxstrap.Singletons
}
}
// this will set the flag to the corresponding value if the condition is true
// if the condition is not true, the flag will be erased
public void SetValueIf(bool condition, string key, object? value)
{
if (condition)
SetValue(key, value);
else if (GetValue(key) is not null)
SetValue(key, null);
}
public void SetValueOnce(string key, object? value)
{
if (GetValue(key) is null)
SetValue(key, value);
}
// this returns null if the fflag doesn't exist
public string? GetValue(string key)
{
@ -114,42 +130,13 @@ namespace Bloxstrap.Singletons
return null;
}
public void SetRenderingMode(string value)
{
foreach (var mode in RenderingModes)
{
if (mode.Key != "Automatic")
SetValue(mode.Value, null);
}
if (value != "Automatic")
SetValue(RenderingModes[value], "True");
if (value == "Vulkan")
SetValue("FFlagRenderVulkanFixMinimizeWindow", "True");
else if (GetValue("FFlagRenderVulkanFixMinimizeWindow") is not null)
SetValue("FFlagRenderVulkanFixMinimizeWindow", null);
}
public override void Load()
{
base.Load();
// set to 9999 by default if it doesnt already exist
if (GetValue("DFIntTaskSchedulerTargetFps") is null)
SetValue("DFIntTaskSchedulerTargetFps", 9999);
if (GetValue("FFlagDebugGraphicsPreferVulkan") == "True" && GetValue("FFlagRenderVulkanFixMinimizeWindow") is null)
SetValue("FFlagRenderVulkanFixMinimizeWindow", "True");
// exclusive fullscreen requires direct3d 10/11 to work
if (App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False")
{
if (!(App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11") == "True" || App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11FL10") == "True"))
{
SetRenderingMode("Direct3D 11");
}
}
SetValueOnce("DFIntTaskSchedulerTargetFps", 9999);
SetValueOnce("FFlagHandleAltEnterFullscreenManually", "False");
}
public override void Save()

View File

@ -40,26 +40,19 @@ namespace Bloxstrap.UI.Menu.ViewModels
return "Automatic";
}
set => App.FastFlags.SetRenderingMode(value);
}
// this flag has to be set to false to work, weirdly enough
public bool ExclusiveFullscreenEnabled
{
get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False";
set
{
App.FastFlags.SetValue("FFlagHandleAltEnterFullscreenManually", value ? "False" : null);
if (value)
foreach (var mode in RenderingModes)
{
if (!(App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11") == "True" || App.FastFlags.GetValue("FFlagDebugGraphicsPreferD3D11FL10") == "True"))
{
App.FastFlags.SetRenderingMode("Direct3D 11");
}
OnPropertyChanged(nameof(SelectedRenderingMode));
if (mode.Key != "Automatic")
App.FastFlags.SetValue(mode.Value, null);
}
if (value == "Automatic")
return;
App.FastFlags.SetValue(RenderingModes[value], "True");
App.FastFlags.SetValueIf(value == "Vulkan", "FFlagRenderVulkanFixMinimizeWindow", "True");
}
}

View File

@ -98,15 +98,6 @@
</ui:CardControl.Header>
<ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding RenderingModes.Keys, Mode=OneTime}" Text="{Binding SelectedRenderingMode, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Enable exclusive fullscreen" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Enables using Alt + Enter to enter exclusive fullscreen. This will force enable Direct3D." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ExclusiveFullscreenEnabled, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>