aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMutantAura <44103205+MutantAura@users.noreply.github.com>2023-11-18 20:42:45 +0000
committerGitHub <noreply@github.com>2023-11-18 17:42:45 -0300
commitaa96dcb1bede3693877e2f1eca3e169d8ee13ef1 (patch)
tree0eb8e9d4f894d624e360e0f1dc1340007a77ba75
parent82a638230e4b10c099d8517b8ef7b602f22a6887 (diff)
misc: Default to Vulkan if available or running on macOS (#5913)1.1.1090
* Addition of default backend check. Vulkan is preferred if available or macOS. * import ordering format fix * Update src/Ryujinx/Program.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> * remove redundant load types --------- Co-authored-by: gdkchan <gab.dark.100@gmail.com>
-rw-r--r--src/Ryujinx.Ui.Common/Configuration/ConfigurationLoadResult.cs9
-rw-r--r--src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs23
-rw-r--r--src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj1
-rw-r--r--src/Ryujinx/Program.cs44
4 files changed, 16 insertions, 61 deletions
diff --git a/src/Ryujinx.Ui.Common/Configuration/ConfigurationLoadResult.cs b/src/Ryujinx.Ui.Common/Configuration/ConfigurationLoadResult.cs
deleted file mode 100644
index 71366ba7..00000000
--- a/src/Ryujinx.Ui.Common/Configuration/ConfigurationLoadResult.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Ryujinx.Ui.Common.Configuration
-{
- public enum ConfigurationLoadResult
- {
- Success = 0,
- NotLoaded = 1,
- MigratedFromPreVulkan = 1 << 8,
- }
-}
diff --git a/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs
index c79fa56c..b017d384 100644
--- a/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs
+++ b/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs
@@ -5,6 +5,7 @@ using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Common.Logging;
+using Ryujinx.Graphics.Vulkan;
using Ryujinx.Ui.Common.Configuration.System;
using Ryujinx.Ui.Common.Configuration.Ui;
using Ryujinx.Ui.Common.Helper;
@@ -763,7 +764,7 @@ namespace Ryujinx.Ui.Common.Configuration
Graphics.ResScaleCustom.Value = 1.0f;
Graphics.MaxAnisotropy.Value = -1.0f;
Graphics.AspectRatio.Value = AspectRatio.Fixed16x9;
- Graphics.GraphicsBackend.Value = OperatingSystem.IsMacOS() ? GraphicsBackend.Vulkan : GraphicsBackend.OpenGl;
+ Graphics.GraphicsBackend.Value = DefaultGraphicsBackend();
Graphics.PreferredGpu.Value = "";
Graphics.ShadersDumpPath.Value = "";
Logger.EnableDebug.Value = false;
@@ -907,7 +908,7 @@ namespace Ryujinx.Ui.Common.Configuration
};
}
- public ConfigurationLoadResult Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
+ public void Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
{
bool configurationFileUpdated = false;
@@ -916,12 +917,8 @@ namespace Ryujinx.Ui.Common.Configuration
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default.");
LoadDefault();
-
- return ConfigurationLoadResult.NotLoaded;
}
- ConfigurationLoadResult result = ConfigurationLoadResult.Success;
-
if (configurationFileFormat.Version < 2)
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 2.");
@@ -1336,8 +1333,6 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileFormat.GraphicsBackend = GraphicsBackend.OpenGl;
- result |= ConfigurationLoadResult.MigratedFromPreVulkan;
-
configurationFileUpdated = true;
}
@@ -1535,8 +1530,18 @@ namespace Ryujinx.Ui.Common.Configuration
Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
}
+ }
+
+ private static GraphicsBackend DefaultGraphicsBackend()
+ {
+ // Any system running macOS or returning any amount of valid Vulkan devices should default to Vulkan.
+ // Checks for if the Vulkan version and featureset is compatible should be performed within VulkanRenderer.
+ if (OperatingSystem.IsMacOS() || VulkanRenderer.GetPhysicalDevices().Length > 0)
+ {
+ return GraphicsBackend.Vulkan;
+ }
- return result;
+ return GraphicsBackend.OpenGl;
}
private static void LogValueChange<T>(ReactiveEventArgs<T> eventArgs, string valueName)
diff --git a/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj b/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj
index 7aff09ff..74331fde 100644
--- a/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj
+++ b/src/Ryujinx.Ui.Common/Ryujinx.Ui.Common.csproj
@@ -62,6 +62,7 @@
<ItemGroup>
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
<ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
+ <ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
</ItemGroup>
</Project>
diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs
index afb6a992..597d00f3 100644
--- a/src/Ryujinx/Program.cs
+++ b/src/Ryujinx/Program.cs
@@ -177,8 +177,6 @@ namespace Ryujinx
? appDataConfigurationPath
: null;
- bool showVulkanPrompt = false;
-
if (ConfigurationPath == null)
{
// No configuration, we load the default values and save it to disk
@@ -186,26 +184,17 @@ namespace Ryujinx
ConfigurationState.Instance.LoadDefault();
ConfigurationState.Instance.ToFileFormat().SaveConfig(ConfigurationPath);
-
- showVulkanPrompt = true;
}
else
{
if (ConfigurationFileFormat.TryLoad(ConfigurationPath, out ConfigurationFileFormat configurationFileFormat))
{
- ConfigurationLoadResult result = ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath);
-
- if ((result & ConfigurationLoadResult.MigratedFromPreVulkan) != 0)
- {
- showVulkanPrompt = true;
- }
+ ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath);
}
else
{
ConfigurationState.Instance.LoadDefault();
- showVulkanPrompt = true;
-
Logger.Warning?.PrintMsg(LogClass.Application, $"Failed to load config! Loading the default config instead.\nFailed config location {ConfigurationPath}");
}
}
@@ -216,12 +205,10 @@ namespace Ryujinx
if (CommandLineState.OverrideGraphicsBackend.ToLower() == "opengl")
{
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
- showVulkanPrompt = false;
}
else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan")
{
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
- showVulkanPrompt = false;
}
}
@@ -343,35 +330,6 @@ namespace Ryujinx
}, TaskContinuationOptions.OnlyOnFaulted);
}
- if (showVulkanPrompt)
- {
- var buttonTexts = new Dictionary<int, string>()
- {
- { 0, "Yes (Vulkan)" },
- { 1, "No (OpenGL)" },
- };
-
- ResponseType response = GtkDialog.CreateCustomDialog(
- "Ryujinx - Default graphics backend",
- "Use Vulkan as default graphics backend?",
- "Ryujinx now supports the Vulkan API. " +
- "Vulkan greatly improves shader compilation performance, " +
- "and fixes some graphical glitches; however, since it is a new feature, " +
- "you may experience some issues that did not occur with OpenGL.\n\n" +
- "Note that you will also lose any existing shader cache the first time you start a game " +
- "on version 1.1.200 onwards, because Vulkan required changes to the shader cache that makes it incompatible with previous versions.\n\n" +
- "Would you like to set Vulkan as the default graphics backend? " +
- "You can change this at any time on the settings window.",
- buttonTexts,
- MessageType.Question);
-
- ConfigurationState.Instance.Graphics.GraphicsBackend.Value = response == 0
- ? GraphicsBackend.Vulkan
- : GraphicsBackend.OpenGl;
-
- ConfigurationState.Instance.ToFileFormat().SaveConfig(ConfigurationPath);
- }
-
Application.Run();
}