Compare commits
369 Commits
c8b12ee3ec
...
new-metal
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61303032f1 | ||
|
|
bff884a89c | ||
|
|
89f3c8235c | ||
|
|
f3545f5eae | ||
|
|
a335c8ff2b | ||
|
|
3aaeaf3540 | ||
|
|
e82a90993c | ||
|
|
f3dcb80a60 | ||
|
|
d4b9e06522 | ||
|
|
0945ea68fe | ||
|
|
d3c0971acf | ||
|
|
7bdae9e552 | ||
|
|
567b0a5027 | ||
|
|
a5f82a99a3 | ||
|
|
89c05ac239 | ||
|
|
fe4c77788f | ||
|
|
d23de14812 | ||
|
|
216261931e | ||
|
|
8c2f3ae8d2 | ||
|
|
a710bcd874 | ||
|
|
b941ef6bde | ||
|
|
b5e6f26296 | ||
|
|
c0d20f8689 | ||
|
|
4a81d9edc4 | ||
|
|
a05a9a33f1 | ||
|
|
b1e5262893 | ||
|
|
dce6b94841 | ||
|
|
51e85ed38b | ||
|
|
38b2cf9b83 | ||
|
|
e406b67690 | ||
|
|
2d522b1675 | ||
|
|
967887d050 | ||
|
|
3258a4bad1 | ||
|
|
058ce78d31 | ||
|
|
b988c0bc3d | ||
|
|
1fc96128fa | ||
|
|
4a11cc9c7a | ||
|
|
782299c123 | ||
|
|
e8de1156eb | ||
|
|
ceaa174859 | ||
|
|
7eaaeea999 | ||
|
|
d707273671 | ||
|
|
2a7375209e | ||
|
|
2e5ae70b91 | ||
|
|
6f24b88e88 | ||
|
|
5d59c552e7 | ||
|
|
341e4e5fb1 | ||
|
|
68146fa285 | ||
|
|
80bb95dfb9 | ||
|
|
5b88ea66ba | ||
|
|
9d3fc82484 | ||
|
|
8f6eceaa1f | ||
|
|
04bd1fa1ca | ||
|
|
c0dcb6c4f2 | ||
|
|
8bbfa86538 | ||
|
|
a0c67cab44 | ||
|
|
421ba5448a | ||
|
|
45c99dbfa8 | ||
|
|
a84ed6af0d | ||
|
|
0642df4909 | ||
|
|
d650538138 | ||
|
|
eeadf17f5c | ||
|
|
7bf0625075 | ||
|
|
5220ee1dc8 | ||
|
|
cb0a1ce48a | ||
|
|
ffb9040b3b | ||
|
|
40ea153616 | ||
|
|
4373610790 | ||
|
|
f5b82cd6dc | ||
|
|
0064afeb6a | ||
|
|
69bee52a89 | ||
|
|
159afd5d03 | ||
|
|
6229f3bb4c | ||
|
|
d42f0e5945 | ||
|
|
015f5d00b4 | ||
|
|
d9b322688c | ||
|
|
5e72eb8362 | ||
|
|
e0cd935c28 | ||
|
|
1f133040bd | ||
|
|
c399868ddf | ||
|
|
fcd2adecc5 | ||
|
|
b468569665 | ||
|
|
353a6ca4bb | ||
|
|
6188872a7c | ||
|
|
8411f69899 | ||
|
|
0bb0ecb599 | ||
|
|
8cbd44aecb | ||
|
|
d2f965885a | ||
|
|
29b6e8ac53 | ||
|
|
26da57cccd | ||
|
|
82b5f8e681 | ||
|
|
58527e02ee | ||
|
|
4d5b128a81 | ||
|
|
49a814a400 | ||
|
|
09546205b5 | ||
|
|
d2a4a9e9a7 | ||
|
|
d3f273cad1 | ||
|
|
60722a1837 | ||
|
|
549938e2b1 | ||
|
|
144397c3da | ||
|
|
2fb3c6975e | ||
|
|
879c93cf73 | ||
|
|
7d5b4c5d1d | ||
|
|
2860db198c | ||
|
|
4b53d18bef | ||
|
|
bbbc9e529d | ||
|
|
c160810bfc | ||
|
|
4f7b3fa058 | ||
|
|
36de337ac2 | ||
|
|
3b2beda27f | ||
|
|
de8e03c350 | ||
|
|
0b6bc12a65 | ||
|
|
16bc02ea2a | ||
|
|
97814b2852 | ||
|
|
a9633981a8 | ||
|
|
1af7dc4b68 | ||
|
|
d6dcc39131 | ||
|
|
4f699ef96a | ||
|
|
30f194e5c0 | ||
|
|
f1086afcdf | ||
|
|
dae0f3cded | ||
|
|
a1ab7fe6a2 | ||
|
|
fac2cbbbbf | ||
|
|
9b138a413c | ||
|
|
58eefa8bdf | ||
|
|
0ebc8bd1b8 | ||
|
|
becf828d0a | ||
|
|
d0e4adac36 | ||
|
|
197184657f | ||
|
|
74083083cd | ||
|
|
175cded85d | ||
|
|
c911db8309 | ||
|
|
3451fbbbad | ||
|
|
98ae46ba70 | ||
|
|
bf4232a35b | ||
|
|
c3e39a9c91 | ||
|
|
b8779c6e09 | ||
|
|
20cf1a08c1 | ||
|
|
dda746c0fb | ||
|
|
585bdc2b54 | ||
|
|
e49702965f | ||
|
|
8b5392ce9b | ||
|
|
9e61294671 | ||
|
|
5423ad9ae1 | ||
|
|
65bddcd475 | ||
|
|
36ac0414e2 | ||
|
|
51b4ffeb6c | ||
|
|
39bfd55958 | ||
|
|
e615d7d849 | ||
|
|
c883ebb645 | ||
|
|
24ab7788d8 | ||
|
|
9ab2cd94c1 | ||
|
|
4ee4e09358 | ||
|
|
a07975afec | ||
|
|
746c897206 | ||
|
|
fe4fa6f4db | ||
|
|
db24e0f6fe | ||
|
|
e9aee16a27 | ||
|
|
02f1e289e2 | ||
|
|
9ebf82f184 | ||
|
|
49e83335d1 | ||
|
|
f00cf8704f | ||
|
|
65da0569a3 | ||
|
|
d811532a9f | ||
|
|
a42c66e6d5 | ||
|
|
8be6b671b8 | ||
|
|
2e99df371f | ||
|
|
ac8af32744 | ||
|
|
a58568d036 | ||
|
|
7ed45d12db | ||
|
|
505f830556 | ||
|
|
43ad627d4f | ||
|
|
c5cca8a1a3 | ||
|
|
f7941a0a8b | ||
|
|
6cc4d46e8c | ||
|
|
18b852e05d | ||
|
|
41e6a04a23 | ||
|
|
881ab59177 | ||
|
|
327c1576f7 | ||
|
|
60ece6d9a1 | ||
|
|
58b42a1143 | ||
|
|
3be47ae4a9 | ||
|
|
6ab989ac54 | ||
|
|
9f01cce95f | ||
|
|
0abbbdc277 | ||
|
|
eb7ec713ec | ||
|
|
d5437f3dbf | ||
|
|
1c4e527ac2 | ||
|
|
af341f88df | ||
|
|
1ff81393be | ||
|
|
2cb5265c8e | ||
|
|
78553f31d9 | ||
|
|
60084f826e | ||
|
|
280efb2ed6 | ||
|
|
14607f4471 | ||
|
|
fd4fe01348 | ||
|
|
8f91b556af | ||
|
|
305a703d4a | ||
|
|
a2c0c11380 | ||
|
|
016df3b050 | ||
|
|
084b75a398 | ||
|
|
91aed4d0dd | ||
|
|
bea46ff9ce | ||
|
|
58fb8564a8 | ||
|
|
94e077ca27 | ||
|
|
a10b0230c3 | ||
|
|
c7dc9ba34e | ||
|
|
ad4db6b242 | ||
|
|
11c596a18a | ||
|
|
7f8d54d6dc | ||
|
|
90e3899c23 | ||
|
|
381f4ec091 | ||
|
|
b76f9105c8 | ||
|
|
486fd78eba | ||
|
|
38385bad30 | ||
|
|
27ece39dbe | ||
|
|
7a6c7196c8 | ||
|
|
765ca8e6c0 | ||
|
|
d5b98d6187 | ||
|
|
913f25b2a0 | ||
|
|
5d0ae23a0b | ||
|
|
dd5fb8bed9 | ||
|
|
2316f30de1 | ||
|
|
96eea9de23 | ||
|
|
9c5917912b | ||
|
|
efe575c9b2 | ||
|
|
ba4d6815ea | ||
|
|
9b99f55c4f | ||
|
|
5a6169b19d | ||
|
|
f30aa98ce5 | ||
|
|
149141594f | ||
|
|
b5f15de64f | ||
|
|
bc9a26bbf2 | ||
|
|
f3d314104f | ||
|
|
6324569dd2 | ||
|
|
2c474050f8 | ||
|
|
46cc993f9a | ||
|
|
c51c8bdae6 | ||
|
|
4f356b4117 | ||
|
|
15051d6e56 | ||
|
|
2587e1ff22 | ||
|
|
0d5292ff8c | ||
|
|
401ad1f983 | ||
|
|
3c1ef06151 | ||
|
|
95af212cfc | ||
|
|
4190abbbf5 | ||
|
|
c7b6e4cf80 | ||
|
|
96d884a15b | ||
|
|
f79ebd1141 | ||
|
|
7f65ec0b8c | ||
|
|
824321c88a | ||
|
|
91d1bb6c08 | ||
|
|
22d3fa068d | ||
|
|
d08218a809 | ||
|
|
b7414c1e4d | ||
|
|
a66ab905a9 | ||
|
|
2bef29b200 | ||
|
|
72eb47513c | ||
|
|
6095f14646 | ||
|
|
c3a9a0d625 | ||
|
|
18e1569941 | ||
|
|
362dc6eaea | ||
|
|
d66c39b64b | ||
|
|
de23abcf90 | ||
|
|
b2a0ca0e2b | ||
|
|
e3364b0fcc | ||
|
|
8a0dd491b9 | ||
|
|
ba05ed9552 | ||
|
|
b85721b738 | ||
|
|
9d7164a329 | ||
|
|
2f70337dca | ||
|
|
60c99e32b0 | ||
|
|
ebd2d82ff3 | ||
|
|
44bd12104b | ||
|
|
0df70db73c | ||
|
|
64e9dcee3d | ||
|
|
e353e3d3fc | ||
|
|
6a67822b3b | ||
|
|
65b7af6308 | ||
|
|
36fe41bffd | ||
|
|
e758e531c5 | ||
|
|
efa9d56a56 | ||
|
|
b95e1d288b | ||
|
|
48aba086e1 | ||
|
|
44f4d41cf8 | ||
|
|
b4f468c653 | ||
|
|
3117aeca7f | ||
|
|
987a42ce30 | ||
|
|
fc7f09624c | ||
|
|
e2445990a5 | ||
|
|
dc4305f1cf | ||
|
|
b7a0aefa80 | ||
|
|
7a99143a8a | ||
|
|
89d1caf30f | ||
|
|
de7b3e7dac | ||
|
|
94e15aa662 | ||
|
|
b157a8e549 | ||
|
|
6685041545 | ||
|
|
b8630b5c45 | ||
|
|
c0da3d68ca | ||
|
|
76bafe75f4 | ||
|
|
3c562d8906 | ||
|
|
df0dc4454b | ||
|
|
26ea1e6d37 | ||
|
|
e8d0212ec6 | ||
|
|
e7197877a2 | ||
|
|
dff9046f55 | ||
|
|
cb36036faa | ||
|
|
c4cf4895d8 | ||
|
|
b6116da940 | ||
|
|
fbcd9994c8 | ||
|
|
5d90932277 | ||
|
|
037157135e | ||
|
|
d45c7711ba | ||
|
|
b3629e3a8b | ||
|
|
c216028d00 | ||
|
|
02fbcfbadb | ||
|
|
a5c1b6a255 | ||
|
|
be1d099879 | ||
|
|
3529fcd592 | ||
|
|
3398977c97 | ||
|
|
fe62c794b9 | ||
|
|
2e3509f8e8 | ||
|
|
d65858be25 | ||
|
|
2a28950739 | ||
|
|
4587905cd8 | ||
|
|
9cc56a3bca | ||
|
|
b06afd1a1f | ||
|
|
7182ac7233 | ||
|
|
398b6cb60e | ||
|
|
c5522e3694 | ||
|
|
a3da70edc2 | ||
|
|
14999a1d51 | ||
|
|
94e699eeba | ||
|
|
b1785c0b14 | ||
|
|
84c90f8895 | ||
|
|
dc4d3078ef | ||
|
|
4b5c3d7fc6 | ||
|
|
5a802a550b | ||
|
|
7c31a411df | ||
|
|
8b9d6ffc94 | ||
|
|
4cde7a4125 | ||
|
|
c1ef270b9d | ||
|
|
2812f01643 | ||
|
|
7441d94f10 | ||
|
|
a8b4e643d0 | ||
|
|
a7908c187d | ||
|
|
25dba8da7c | ||
|
|
0edec0d3ff | ||
|
|
fb8749ce4e | ||
|
|
d36c285b79 | ||
|
|
179482e9cb | ||
|
|
671aff68a6 | ||
|
|
8bf33b3098 | ||
|
|
6a115becef | ||
|
|
ed445e001a | ||
|
|
93f31bd08a | ||
|
|
a60ecea4c3 | ||
|
|
ff0362063a | ||
|
|
e0ea464c40 | ||
|
|
05002ae234 | ||
|
|
dc60b76748 | ||
|
|
cc3c7901b6 | ||
|
|
15ad03bc04 | ||
|
|
1d01fbf6b1 | ||
|
|
1e835aa56f | ||
|
|
93e5ff0137 | ||
|
|
6d513cad1e | ||
|
|
cbad43b003 |
@@ -258,13 +258,13 @@ Global
|
||||
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ryujinx.Common.Configuration
|
||||
[JsonConverter(typeof(TypedStringEnumConverter<GraphicsBackend>))]
|
||||
public enum GraphicsBackend
|
||||
{
|
||||
Auto,
|
||||
Vulkan,
|
||||
OpenGl,
|
||||
Metal
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
private Pipeline _pipeline;
|
||||
private Window _window;
|
||||
|
||||
public uint ProgramCount { get; set; } = 0;
|
||||
|
||||
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||
public bool PreferThreading => true;
|
||||
@@ -102,6 +104,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
public IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info)
|
||||
{
|
||||
ProgramCount++;
|
||||
return new Program(this, _device, shaders, info.ResourceLayout, info.ComputeLocalSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,10 +137,10 @@ namespace Ryujinx.Graphics.Metal
|
||||
_requestedWidth = width;
|
||||
_requestedHeight = height;
|
||||
}
|
||||
|
||||
public void ChangeVSyncMode(bool vsyncEnabled)
|
||||
|
||||
public void ChangeVSyncMode(VSyncMode vSyncMode)
|
||||
{
|
||||
// _vsyncEnabled = vsyncEnabled;
|
||||
//_vSyncMode = vSyncMode;
|
||||
}
|
||||
|
||||
public void SetAntiAliasing(AntiAliasing effect)
|
||||
|
||||
@@ -22,8 +22,9 @@ namespace Ryujinx.Headless.SDL2.Metal
|
||||
GraphicsDebugLevel glLogLevel,
|
||||
AspectRatio aspectRatio,
|
||||
bool enableMouse,
|
||||
HideCursorMode hideCursorMode)
|
||||
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursorMode) { }
|
||||
HideCursorMode hideCursorMode,
|
||||
bool ignoreControllerApplet)
|
||||
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursorMode, ignoreControllerApplet) { }
|
||||
|
||||
public override SDL_WindowFlags GetWindowFlags() => SDL_WindowFlags.SDL_WINDOW_METAL;
|
||||
|
||||
|
||||
@@ -1,755 +0,0 @@
|
||||
using CommandLine;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Audio.Backends.SDL2;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||
using Ryujinx.Common.Configuration.Hid.Controller.Motion;
|
||||
using Ryujinx.Common.Configuration.Hid.Keyboard;
|
||||
using Ryujinx.Common.GraphicsDriver;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Logging.Targets;
|
||||
using Ryujinx.Common.SystemInterop;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.GAL.Multithreading;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.Graphics.Gpu.Shader;
|
||||
using Ryujinx.Graphics.Metal;
|
||||
using Ryujinx.Graphics.OpenGL;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
<<<<<<< HEAD
|
||||
using Ryujinx.Graphics.Vulkan.MoltenVK;
|
||||
using Ryujinx.Graphics.Metal;
|
||||
=======
|
||||
>>>>>>> 137f5970f (Vertex Input Attributes)
|
||||
using Ryujinx.Headless.SDL2.Metal;
|
||||
using Ryujinx.Headless.SDL2.OpenGL;
|
||||
using Ryujinx.Headless.SDL2.Vulkan;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.HLE;
|
||||
using Ryujinx.Input.SDL2;
|
||||
using Ryujinx.SDL2.Common;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using ConfigGamepadInputId = Ryujinx.Common.Configuration.Hid.Controller.GamepadInputId;
|
||||
using ConfigStickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||
|
||||
namespace Ryujinx.Headless.SDL2
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static string Version { get; private set; }
|
||||
|
||||
private static VirtualFileSystem _virtualFileSystem;
|
||||
private static ContentManager _contentManager;
|
||||
private static AccountManager _accountManager;
|
||||
private static LibHacHorizonManager _libHacHorizonManager;
|
||||
private static UserChannelPersistence _userChannelPersistence;
|
||||
private static InputManager _inputManager;
|
||||
private static Switch _emulationContext;
|
||||
private static WindowBase _window;
|
||||
private static WindowsMultimediaTimerResolution _windowsMultimediaTimerResolution;
|
||||
private static List<InputConfig> _inputConfiguration;
|
||||
private static bool _enableKeyboard;
|
||||
private static bool _enableMouse;
|
||||
|
||||
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Version = ReleaseInformation.Version;
|
||||
|
||||
// Make process DPI aware for proper window sizing on high-res screens.
|
||||
ForceDpiAware.Windows();
|
||||
|
||||
Console.Title = $"Ryujinx Console {Version} (Headless SDL2)";
|
||||
|
||||
if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
|
||||
{
|
||||
AutoResetEvent invoked = new(false);
|
||||
|
||||
// MacOS must perform SDL polls from the main thread.
|
||||
SDL2Driver.MainThreadDispatcher = action =>
|
||||
{
|
||||
invoked.Reset();
|
||||
|
||||
WindowBase.QueueMainThreadAction(() =>
|
||||
{
|
||||
action();
|
||||
|
||||
invoked.Set();
|
||||
});
|
||||
|
||||
invoked.WaitOne();
|
||||
};
|
||||
}
|
||||
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
MVKInitialization.InitializeResolver();
|
||||
}
|
||||
|
||||
Parser.Default.ParseArguments<Options>(args)
|
||||
.WithParsed(Load)
|
||||
.WithNotParsed(errors => errors.Output());
|
||||
}
|
||||
|
||||
private static InputConfig HandlePlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index)
|
||||
{
|
||||
if (inputId == null)
|
||||
{
|
||||
if (index == PlayerIndex.Player1)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Application, $"{index} not configured, defaulting to default keyboard.");
|
||||
|
||||
// Default to keyboard
|
||||
inputId = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Application, $"{index} not configured");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
IGamepad gamepad;
|
||||
|
||||
bool isKeyboard = true;
|
||||
|
||||
gamepad = _inputManager.KeyboardDriver.GetGamepad(inputId);
|
||||
|
||||
if (gamepad == null)
|
||||
{
|
||||
gamepad = _inputManager.GamepadDriver.GetGamepad(inputId);
|
||||
isKeyboard = false;
|
||||
|
||||
if (gamepad == null)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"{index} gamepad not found (\"{inputId}\")");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string gamepadName = gamepad.Name;
|
||||
|
||||
gamepad.Dispose();
|
||||
|
||||
InputConfig config;
|
||||
|
||||
if (inputProfileName == null || inputProfileName.Equals("default"))
|
||||
{
|
||||
if (isKeyboard)
|
||||
{
|
||||
config = new StandardKeyboardInputConfig
|
||||
{
|
||||
Version = InputConfig.CurrentVersion,
|
||||
Backend = InputBackendType.WindowKeyboard,
|
||||
Id = null,
|
||||
ControllerType = ControllerType.JoyconPair,
|
||||
LeftJoycon = new LeftJoyconCommonConfig<Key>
|
||||
{
|
||||
DpadUp = Key.Up,
|
||||
DpadDown = Key.Down,
|
||||
DpadLeft = Key.Left,
|
||||
DpadRight = Key.Right,
|
||||
ButtonMinus = Key.Minus,
|
||||
ButtonL = Key.E,
|
||||
ButtonZl = Key.Q,
|
||||
ButtonSl = Key.Unbound,
|
||||
ButtonSr = Key.Unbound,
|
||||
},
|
||||
|
||||
LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
|
||||
{
|
||||
StickUp = Key.W,
|
||||
StickDown = Key.S,
|
||||
StickLeft = Key.A,
|
||||
StickRight = Key.D,
|
||||
StickButton = Key.F,
|
||||
},
|
||||
|
||||
RightJoycon = new RightJoyconCommonConfig<Key>
|
||||
{
|
||||
ButtonA = Key.Z,
|
||||
ButtonB = Key.X,
|
||||
ButtonX = Key.C,
|
||||
ButtonY = Key.V,
|
||||
ButtonPlus = Key.Plus,
|
||||
ButtonR = Key.U,
|
||||
ButtonZr = Key.O,
|
||||
ButtonSl = Key.Unbound,
|
||||
ButtonSr = Key.Unbound,
|
||||
},
|
||||
|
||||
RightJoyconStick = new JoyconConfigKeyboardStick<Key>
|
||||
{
|
||||
StickUp = Key.I,
|
||||
StickDown = Key.K,
|
||||
StickLeft = Key.J,
|
||||
StickRight = Key.L,
|
||||
StickButton = Key.H,
|
||||
},
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isNintendoStyle = gamepadName.Contains("Nintendo");
|
||||
|
||||
config = new StandardControllerInputConfig
|
||||
{
|
||||
Version = InputConfig.CurrentVersion,
|
||||
Backend = InputBackendType.GamepadSDL2,
|
||||
Id = null,
|
||||
ControllerType = ControllerType.JoyconPair,
|
||||
DeadzoneLeft = 0.1f,
|
||||
DeadzoneRight = 0.1f,
|
||||
RangeLeft = 1.0f,
|
||||
RangeRight = 1.0f,
|
||||
TriggerThreshold = 0.5f,
|
||||
LeftJoycon = new LeftJoyconCommonConfig<ConfigGamepadInputId>
|
||||
{
|
||||
DpadUp = ConfigGamepadInputId.DpadUp,
|
||||
DpadDown = ConfigGamepadInputId.DpadDown,
|
||||
DpadLeft = ConfigGamepadInputId.DpadLeft,
|
||||
DpadRight = ConfigGamepadInputId.DpadRight,
|
||||
ButtonMinus = ConfigGamepadInputId.Minus,
|
||||
ButtonL = ConfigGamepadInputId.LeftShoulder,
|
||||
ButtonZl = ConfigGamepadInputId.LeftTrigger,
|
||||
ButtonSl = ConfigGamepadInputId.Unbound,
|
||||
ButtonSr = ConfigGamepadInputId.Unbound,
|
||||
},
|
||||
|
||||
LeftJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
||||
{
|
||||
Joystick = ConfigStickInputId.Left,
|
||||
StickButton = ConfigGamepadInputId.LeftStick,
|
||||
InvertStickX = false,
|
||||
InvertStickY = false,
|
||||
Rotate90CW = false,
|
||||
},
|
||||
|
||||
RightJoycon = new RightJoyconCommonConfig<ConfigGamepadInputId>
|
||||
{
|
||||
ButtonA = isNintendoStyle ? ConfigGamepadInputId.A : ConfigGamepadInputId.B,
|
||||
ButtonB = isNintendoStyle ? ConfigGamepadInputId.B : ConfigGamepadInputId.A,
|
||||
ButtonX = isNintendoStyle ? ConfigGamepadInputId.X : ConfigGamepadInputId.Y,
|
||||
ButtonY = isNintendoStyle ? ConfigGamepadInputId.Y : ConfigGamepadInputId.X,
|
||||
ButtonPlus = ConfigGamepadInputId.Plus,
|
||||
ButtonR = ConfigGamepadInputId.RightShoulder,
|
||||
ButtonZr = ConfigGamepadInputId.RightTrigger,
|
||||
ButtonSl = ConfigGamepadInputId.Unbound,
|
||||
ButtonSr = ConfigGamepadInputId.Unbound,
|
||||
},
|
||||
|
||||
RightJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
||||
{
|
||||
Joystick = ConfigStickInputId.Right,
|
||||
StickButton = ConfigGamepadInputId.RightStick,
|
||||
InvertStickX = false,
|
||||
InvertStickY = false,
|
||||
Rotate90CW = false,
|
||||
},
|
||||
|
||||
Motion = new StandardMotionConfigController
|
||||
{
|
||||
MotionBackend = MotionInputBackendType.GamepadDriver,
|
||||
EnableMotion = true,
|
||||
Sensitivity = 100,
|
||||
GyroDeadzone = 1,
|
||||
},
|
||||
Rumble = new RumbleConfigController
|
||||
{
|
||||
StrongRumble = 1f,
|
||||
WeakRumble = 1f,
|
||||
EnableRumble = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string profileBasePath;
|
||||
|
||||
if (isKeyboard)
|
||||
{
|
||||
profileBasePath = Path.Combine(AppDataManager.ProfilesDirPath, "keyboard");
|
||||
}
|
||||
else
|
||||
{
|
||||
profileBasePath = Path.Combine(AppDataManager.ProfilesDirPath, "controller");
|
||||
}
|
||||
|
||||
string path = Path.Combine(profileBasePath, inputProfileName + ".json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Input profile \"{inputProfileName}\" not found for \"{inputId}\"");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
config = JsonHelper.DeserializeFromFile(path, _serializerContext.InputConfig);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Input profile \"{inputProfileName}\" parsing failed for \"{inputId}\"");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
config.Id = inputId;
|
||||
config.PlayerIndex = index;
|
||||
|
||||
string inputTypeName = isKeyboard ? "Keyboard" : "Gamepad";
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} configured with {inputTypeName} \"{config.Id}\"");
|
||||
|
||||
// If both stick ranges are 0 (usually indicative of an outdated profile load) then both sticks will be set to 1.0.
|
||||
if (config is StandardControllerInputConfig controllerConfig)
|
||||
{
|
||||
if (controllerConfig.RangeLeft <= 0.0f && controllerConfig.RangeRight <= 0.0f)
|
||||
{
|
||||
controllerConfig.RangeLeft = 1.0f;
|
||||
controllerConfig.RangeRight = 1.0f;
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} stick range reset. Save the profile now to update your configuration");
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
static void Load(Options option)
|
||||
{
|
||||
AppDataManager.Initialize(option.BaseDataDir);
|
||||
|
||||
_virtualFileSystem = VirtualFileSystem.CreateInstance();
|
||||
_libHacHorizonManager = new LibHacHorizonManager();
|
||||
|
||||
_libHacHorizonManager.InitializeFsServer(_virtualFileSystem);
|
||||
_libHacHorizonManager.InitializeArpServer();
|
||||
_libHacHorizonManager.InitializeBcatServer();
|
||||
_libHacHorizonManager.InitializeSystemClients();
|
||||
|
||||
_contentManager = new ContentManager(_virtualFileSystem);
|
||||
_accountManager = new AccountManager(_libHacHorizonManager.RyujinxClient, option.UserProfile);
|
||||
_userChannelPersistence = new UserChannelPersistence();
|
||||
|
||||
_inputManager = new InputManager(new SDL2KeyboardDriver(), new SDL2GamepadDriver());
|
||||
|
||||
GraphicsConfig.EnableShaderCache = true;
|
||||
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
if (option.GraphicsBackend == GraphicsBackend.OpenGl)
|
||||
{
|
||||
option.GraphicsBackend = GraphicsBackend.Vulkan;
|
||||
Logger.Warning?.Print(LogClass.Application, "OpenGL is not supported on macOS, switching to Vulkan!");
|
||||
}
|
||||
}
|
||||
|
||||
IGamepad gamepad;
|
||||
|
||||
if (option.ListInputIds)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Application, "Input Ids:");
|
||||
|
||||
foreach (string id in _inputManager.KeyboardDriver.GamepadsIds)
|
||||
{
|
||||
gamepad = _inputManager.KeyboardDriver.GetGamepad(id);
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"- {id} (\"{gamepad.Name}\")");
|
||||
|
||||
gamepad.Dispose();
|
||||
}
|
||||
|
||||
foreach (string id in _inputManager.GamepadDriver.GamepadsIds)
|
||||
{
|
||||
gamepad = _inputManager.GamepadDriver.GetGamepad(id);
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"- {id} (\"{gamepad.Name}\")");
|
||||
|
||||
gamepad.Dispose();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (option.InputPath == null)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, "Please provide a file to load");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_inputConfiguration = new List<InputConfig>();
|
||||
_enableKeyboard = option.EnableKeyboard;
|
||||
_enableMouse = option.EnableMouse;
|
||||
|
||||
static void LoadPlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index)
|
||||
{
|
||||
InputConfig inputConfig = HandlePlayerConfiguration(inputProfileName, inputId, index);
|
||||
|
||||
if (inputConfig != null)
|
||||
{
|
||||
_inputConfiguration.Add(inputConfig);
|
||||
}
|
||||
}
|
||||
|
||||
LoadPlayerConfiguration(option.InputProfile1Name, option.InputId1, PlayerIndex.Player1);
|
||||
LoadPlayerConfiguration(option.InputProfile2Name, option.InputId2, PlayerIndex.Player2);
|
||||
LoadPlayerConfiguration(option.InputProfile3Name, option.InputId3, PlayerIndex.Player3);
|
||||
LoadPlayerConfiguration(option.InputProfile4Name, option.InputId4, PlayerIndex.Player4);
|
||||
LoadPlayerConfiguration(option.InputProfile5Name, option.InputId5, PlayerIndex.Player5);
|
||||
LoadPlayerConfiguration(option.InputProfile6Name, option.InputId6, PlayerIndex.Player6);
|
||||
LoadPlayerConfiguration(option.InputProfile7Name, option.InputId7, PlayerIndex.Player7);
|
||||
LoadPlayerConfiguration(option.InputProfile8Name, option.InputId8, PlayerIndex.Player8);
|
||||
LoadPlayerConfiguration(option.InputProfileHandheldName, option.InputIdHandheld, PlayerIndex.Handheld);
|
||||
|
||||
if (_inputConfiguration.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup logging level
|
||||
Logger.SetEnable(LogLevel.Debug, option.LoggingEnableDebug);
|
||||
Logger.SetEnable(LogLevel.Stub, !option.LoggingDisableStub);
|
||||
Logger.SetEnable(LogLevel.Info, !option.LoggingDisableInfo);
|
||||
Logger.SetEnable(LogLevel.Warning, !option.LoggingDisableWarning);
|
||||
Logger.SetEnable(LogLevel.Error, option.LoggingEnableError);
|
||||
Logger.SetEnable(LogLevel.Trace, option.LoggingEnableTrace);
|
||||
Logger.SetEnable(LogLevel.Guest, !option.LoggingDisableGuest);
|
||||
Logger.SetEnable(LogLevel.AccessLog, option.LoggingEnableFsAccessLog);
|
||||
|
||||
if (!option.DisableFileLog)
|
||||
{
|
||||
string logDir = AppDataManager.LogsDirPath;
|
||||
FileStream logFile = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(logDir))
|
||||
{
|
||||
logFile = FileLogTarget.PrepareLogFile(logDir);
|
||||
}
|
||||
|
||||
if (logFile != null)
|
||||
{
|
||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||
new FileLogTarget("file", logFile),
|
||||
1000,
|
||||
AsyncLogTargetOverflowAction.Block
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, "No writable log directory available. Make sure either the Logs directory, Application Data, or the Ryujinx directory is writable.");
|
||||
}
|
||||
}
|
||||
|
||||
// Setup graphics configuration
|
||||
GraphicsConfig.EnableShaderCache = !option.DisableShaderCache;
|
||||
GraphicsConfig.EnableTextureRecompression = option.EnableTextureRecompression;
|
||||
GraphicsConfig.ResScale = option.ResScale;
|
||||
GraphicsConfig.MaxAnisotropy = option.MaxAnisotropy;
|
||||
GraphicsConfig.ShadersDumpPath = option.GraphicsShadersDumpPath;
|
||||
GraphicsConfig.EnableMacroHLE = !option.DisableMacroHLE;
|
||||
|
||||
DriverUtilities.InitDriverConfig(option.BackendThreading == BackendThreading.Off);
|
||||
|
||||
while (true)
|
||||
{
|
||||
LoadApplication(option);
|
||||
|
||||
if (_userChannelPersistence.PreviousIndex == -1 || !_userChannelPersistence.ShouldRestart)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_userChannelPersistence.ShouldRestart = false;
|
||||
}
|
||||
|
||||
_inputManager.Dispose();
|
||||
}
|
||||
|
||||
private static void SetupProgressHandler()
|
||||
{
|
||||
if (_emulationContext.Processes.ActiveApplication.DiskCacheLoadState != null)
|
||||
{
|
||||
_emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged -= ProgressHandler;
|
||||
_emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged += ProgressHandler;
|
||||
}
|
||||
|
||||
_emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
|
||||
_emulationContext.Gpu.ShaderCacheStateChanged += ProgressHandler;
|
||||
}
|
||||
|
||||
private static void ProgressHandler<T>(T state, int current, int total) where T : Enum
|
||||
{
|
||||
string label = state switch
|
||||
{
|
||||
LoadState => $"PTC : {current}/{total}",
|
||||
ShaderCacheState => $"Shaders : {current}/{total}",
|
||||
_ => throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}"),
|
||||
};
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, label);
|
||||
}
|
||||
|
||||
private static WindowBase CreateWindow(Options options)
|
||||
{
|
||||
return options.GraphicsBackend switch
|
||||
{
|
||||
GraphicsBackend.Vulkan => new VulkanWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode),
|
||||
GraphicsBackend.Metal => new MetalWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableKeyboard, options.HideCursorMode),
|
||||
_ => new OpenGLWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode)
|
||||
};
|
||||
}
|
||||
|
||||
private static IRenderer CreateRenderer(Options options, WindowBase window)
|
||||
{
|
||||
if (options.GraphicsBackend == GraphicsBackend.Vulkan && window is VulkanWindow vulkanWindow)
|
||||
{
|
||||
string preferredGpuId = string.Empty;
|
||||
Vk api = Vk.GetApi();
|
||||
|
||||
if (!string.IsNullOrEmpty(options.PreferredGPUVendor))
|
||||
{
|
||||
string preferredGpuVendor = options.PreferredGPUVendor.ToLowerInvariant();
|
||||
var devices = VulkanRenderer.GetPhysicalDevices(api);
|
||||
|
||||
foreach (var device in devices)
|
||||
{
|
||||
if (device.Vendor.ToLowerInvariant() == preferredGpuVendor)
|
||||
{
|
||||
preferredGpuId = device.Id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new VulkanRenderer(
|
||||
api,
|
||||
(instance, vk) => new SurfaceKHR((ulong)(vulkanWindow.CreateWindowSurface(instance.Handle))),
|
||||
vulkanWindow.GetRequiredInstanceExtensions,
|
||||
preferredGpuId);
|
||||
}
|
||||
|
||||
if (options.GraphicsBackend == GraphicsBackend.Metal && window is MetalWindow metalWindow && OperatingSystem.IsMacOS())
|
||||
{
|
||||
return new MetalRenderer(metalWindow.GetLayer);
|
||||
}
|
||||
|
||||
return new OpenGLRenderer();
|
||||
}
|
||||
|
||||
private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options)
|
||||
{
|
||||
BackendThreading threadingMode = options.BackendThreading;
|
||||
|
||||
bool threadedGAL = threadingMode == BackendThreading.On || (threadingMode == BackendThreading.Auto && renderer.PreferThreading);
|
||||
|
||||
if (threadedGAL)
|
||||
{
|
||||
renderer = new ThreadedRenderer(renderer);
|
||||
}
|
||||
|
||||
HLEConfiguration configuration = new(_virtualFileSystem,
|
||||
_libHacHorizonManager,
|
||||
_contentManager,
|
||||
_accountManager,
|
||||
_userChannelPersistence,
|
||||
renderer,
|
||||
new SDL2HardwareDeviceDriver(),
|
||||
options.ExpandRAM ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB,
|
||||
window,
|
||||
options.SystemLanguage,
|
||||
options.SystemRegion,
|
||||
!options.DisableVSync,
|
||||
!options.DisableDockedMode,
|
||||
!options.DisablePTC,
|
||||
options.EnableInternetAccess,
|
||||
!options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
|
||||
options.FsGlobalAccessLogMode,
|
||||
options.SystemTimeOffset,
|
||||
options.SystemTimeZone,
|
||||
options.MemoryManagerMode,
|
||||
options.IgnoreMissingServices,
|
||||
options.AspectRatio,
|
||||
options.AudioVolume,
|
||||
options.UseHypervisor ?? true,
|
||||
options.MultiplayerLanInterfaceId,
|
||||
Common.Configuration.Multiplayer.MultiplayerMode.Disabled);
|
||||
|
||||
return new Switch(configuration);
|
||||
}
|
||||
|
||||
private static void ExecutionEntrypoint()
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
_windowsMultimediaTimerResolution = new WindowsMultimediaTimerResolution(1);
|
||||
}
|
||||
|
||||
DisplaySleep.Prevent();
|
||||
|
||||
_window.Initialize(_emulationContext, _inputConfiguration, _enableKeyboard, _enableMouse);
|
||||
|
||||
_window.Execute();
|
||||
|
||||
_emulationContext.Dispose();
|
||||
_window.Dispose();
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
_windowsMultimediaTimerResolution?.Dispose();
|
||||
_windowsMultimediaTimerResolution = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool LoadApplication(Options options)
|
||||
{
|
||||
string path = options.InputPath;
|
||||
|
||||
Logger.RestartTime();
|
||||
|
||||
WindowBase window = CreateWindow(options);
|
||||
IRenderer renderer = CreateRenderer(options, window);
|
||||
|
||||
_window = window;
|
||||
|
||||
_window.IsFullscreen = options.IsFullscreen;
|
||||
_window.DisplayId = options.DisplayId;
|
||||
_window.IsExclusiveFullscreen = options.IsExclusiveFullscreen;
|
||||
_window.ExclusiveFullscreenWidth = options.ExclusiveFullscreenWidth;
|
||||
_window.ExclusiveFullscreenHeight = options.ExclusiveFullscreenHeight;
|
||||
_window.AntiAliasing = options.AntiAliasing;
|
||||
_window.ScalingFilter = options.ScalingFilter;
|
||||
_window.ScalingFilterLevel = options.ScalingFilterLevel;
|
||||
|
||||
_emulationContext = InitializeEmulationContext(window, renderer, options);
|
||||
|
||||
SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
|
||||
|
||||
Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
|
||||
|
||||
if (romFsFiles.Length == 0)
|
||||
{
|
||||
romFsFiles = Directory.GetFiles(path, "*.romfs");
|
||||
}
|
||||
|
||||
if (romFsFiles.Length > 0)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
|
||||
|
||||
if (!_emulationContext.LoadCart(path, romFsFiles[0]))
|
||||
{
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
|
||||
|
||||
if (!_emulationContext.LoadCart(path))
|
||||
{
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
switch (Path.GetExtension(path).ToLowerInvariant())
|
||||
{
|
||||
case ".xci":
|
||||
Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
|
||||
|
||||
if (!_emulationContext.LoadXci(path))
|
||||
{
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ".nca":
|
||||
Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
|
||||
|
||||
if (!_emulationContext.LoadNca(path))
|
||||
{
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ".nsp":
|
||||
case ".pfs0":
|
||||
Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
|
||||
|
||||
if (!_emulationContext.LoadNsp(path))
|
||||
{
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.Info?.Print(LogClass.Application, "Loading as Homebrew.");
|
||||
try
|
||||
{
|
||||
if (!_emulationContext.LoadProgram(path))
|
||||
{
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, "The specified file is not supported by Ryujinx.");
|
||||
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Couldn't load '{options.InputPath}'. Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
|
||||
|
||||
_emulationContext.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SetupProgressHandler();
|
||||
ExecutionEntrypoint();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,14 +305,15 @@ namespace Ryujinx.UI.Common.Configuration
|
||||
|
||||
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;
|
||||
}
|
||||
// Any system running macOS should default to auto, so it uses Vulkan everywhere and Metal in games where it works well.
|
||||
if (OperatingSystem.IsMacOS())
|
||||
return GraphicsBackend.Auto;
|
||||
|
||||
return GraphicsBackend.OpenGl;
|
||||
}
|
||||
}
|
||||
// Any system 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.
|
||||
return VulkanRenderer.GetPhysicalDevices().Length > 0
|
||||
? GraphicsBackend.Vulkan
|
||||
: GraphicsBackend.OpenGl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using Gommon;
|
||||
using LibHac.Common;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem;
|
||||
@@ -142,6 +143,23 @@ namespace Ryujinx.Ava
|
||||
public ulong ApplicationId { get; private set; }
|
||||
public bool ScreenshotRequested { get; set; }
|
||||
|
||||
public bool ShouldInitMetal
|
||||
{
|
||||
get
|
||||
{
|
||||
return OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64 &&
|
||||
(
|
||||
(
|
||||
(
|
||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Auto &&
|
||||
RendererHost.KnownGreatMetalTitles.ContainsIgnoreCase(ApplicationId.ToString("X16"))
|
||||
) ||
|
||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Metal
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public AppHost(
|
||||
RendererHost renderer,
|
||||
InputManager inputManager,
|
||||
@@ -895,18 +913,22 @@ namespace Ryujinx.Ava
|
||||
|
||||
// Initialize Renderer.
|
||||
IRenderer renderer;
|
||||
GraphicsBackend backend = ConfigurationState.Instance.Graphics.GraphicsBackend;
|
||||
|
||||
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan)
|
||||
if (ShouldInitMetal)
|
||||
{
|
||||
renderer = new VulkanRenderer(
|
||||
#pragma warning disable CA1416 This call site is reachable on all platforms
|
||||
// The condition does a check for Mac, on top of checking if it's an ARM Mac. This isn't a problem.
|
||||
renderer = new MetalRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowMetal)!.CreateSurface);
|
||||
#pragma warning restore CA1416
|
||||
}
|
||||
else if (backend == GraphicsBackend.Vulkan || (backend == GraphicsBackend.Auto && !ShouldInitMetal))
|
||||
{
|
||||
renderer = VulkanRenderer.Create(
|
||||
ConfigurationState.Instance.Graphics.PreferredGpu,
|
||||
(RendererHost.EmbeddedWindow as EmbeddedWindowVulkan)!.CreateSurface,
|
||||
VulkanHelper.GetRequiredInstanceExtensions);
|
||||
}
|
||||
else if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Metal && OperatingSystem.IsMacOS())
|
||||
{
|
||||
renderer = new MetalRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowMetal).CreateSurface);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer = new OpenGLRenderer();
|
||||
@@ -1123,7 +1145,7 @@ namespace Ryujinx.Ava
|
||||
|
||||
public void InitStatus()
|
||||
{
|
||||
_viewModel.BackendText = ConfigurationState.Instance.Graphics.GraphicsBackend.Value switch
|
||||
_viewModel.BackendText = RendererHost.Backend switch
|
||||
{
|
||||
GraphicsBackend.Vulkan => "Vulkan",
|
||||
GraphicsBackend.OpenGl => "OpenGL",
|
||||
|
||||
@@ -19677,6 +19677,54 @@
|
||||
"zh_TW": "選擇模擬器將使用的圖形後端。\n\n只要驅動程式是最新的,Vulkan 對所有現代顯示卡來說都更好用。Vulkan 還能在所有 GPU 廠商上實現更快的著色器編譯 (減少卡頓)。\n\nOpenGL 在舊式 Nvidia GPU、Linux 上的舊式 AMD GPU 或 VRAM 較低的 GPU 上可能會取得更好的效果,不過著色器編譯的卡頓會更嚴重。\n\n如果不確定,請設定為 Vulkan。如果您的 GPU 使用最新的圖形驅動程式也不支援 Vulkan,請設定為 OpenGL。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "SettingsTabGraphicsBackendAuto",
|
||||
"Translations": {
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "Auto",
|
||||
"es_ES": "",
|
||||
"fr_FR": "",
|
||||
"he_IL": "",
|
||||
"it_IT": "",
|
||||
"ja_JP": "",
|
||||
"ko_KR": "",
|
||||
"no_NO": "",
|
||||
"pl_PL": "",
|
||||
"pt_BR": "",
|
||||
"ru_RU": "",
|
||||
"th_TH": "",
|
||||
"tr_TR": "",
|
||||
"uk_UA": "",
|
||||
"zh_CN": "",
|
||||
"zh_TW": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "SettingsTabGraphicsBackendAutoTooltip",
|
||||
"Translations": {
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "Uses Vulkan.\nOn an ARM Mac, and when playing a game that runs well under it, uses the Metal backend.",
|
||||
"es_ES": "",
|
||||
"fr_FR": "",
|
||||
"he_IL": "",
|
||||
"it_IT": "",
|
||||
"ja_JP": "",
|
||||
"ko_KR": "",
|
||||
"no_NO": "",
|
||||
"pl_PL": "",
|
||||
"pt_BR": "",
|
||||
"ru_RU": "",
|
||||
"th_TH": "",
|
||||
"tr_TR": "",
|
||||
"uk_UA": "",
|
||||
"zh_CN": "",
|
||||
"zh_TW": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "SettingsEnableTextureRecompression",
|
||||
"Translations": {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Gommon;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.UI.Common.Configuration;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Renderer
|
||||
{
|
||||
@@ -21,13 +23,60 @@ namespace Ryujinx.Ava.UI.Renderer
|
||||
{
|
||||
GraphicsBackend.OpenGl => new EmbeddedWindowOpenGL(),
|
||||
GraphicsBackend.Metal => new EmbeddedWindowMetal(),
|
||||
GraphicsBackend.Vulkan => new EmbeddedWindowVulkan(),
|
||||
GraphicsBackend.Vulkan or GraphicsBackend.Auto => new EmbeddedWindowVulkan(),
|
||||
_ => throw new NotSupportedException()
|
||||
};
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public static readonly string[] KnownGreatMetalTitles =
|
||||
[
|
||||
"01006A800016E000", // Smash Ultimate
|
||||
"0100000000010000", // Super Mario Odyessy
|
||||
"01008C0016544000", // Sea of Stars
|
||||
"01005CA01580E000", // Persona 5
|
||||
"010028600EBDA000", // Mario 3D World
|
||||
];
|
||||
|
||||
public GraphicsBackend Backend =>
|
||||
EmbeddedWindow switch
|
||||
{
|
||||
EmbeddedWindowVulkan => GraphicsBackend.Vulkan,
|
||||
EmbeddedWindowOpenGL => GraphicsBackend.OpenGl,
|
||||
EmbeddedWindowMetal => GraphicsBackend.Metal,
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
|
||||
public RendererHost(string titleId)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
switch (ConfigurationState.Instance.Graphics.GraphicsBackend.Value)
|
||||
{
|
||||
case GraphicsBackend.Auto:
|
||||
EmbeddedWindow =
|
||||
OperatingSystem.IsMacOS() &&
|
||||
RuntimeInformation.ProcessArchitecture == Architecture.Arm64 &&
|
||||
KnownGreatMetalTitles.ContainsIgnoreCase(titleId)
|
||||
? new EmbeddedWindowMetal()
|
||||
: new EmbeddedWindowVulkan();
|
||||
break;
|
||||
case GraphicsBackend.OpenGl:
|
||||
EmbeddedWindow = new EmbeddedWindowOpenGL();
|
||||
break;
|
||||
case GraphicsBackend.Metal:
|
||||
EmbeddedWindow = new EmbeddedWindowMetal();
|
||||
break;
|
||||
case GraphicsBackend.Vulkan:
|
||||
EmbeddedWindow = new EmbeddedWindowVulkan();
|
||||
break;
|
||||
}
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
EmbeddedWindow.WindowCreated += CurrentWindow_WindowCreated;
|
||||
|
||||
@@ -1938,7 +1938,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
PrepareLoadScreen();
|
||||
|
||||
RendererHostControl = new RendererHost();
|
||||
RendererHostControl = new RendererHost(application.Id.ToString("X16"));
|
||||
|
||||
AppHost = new AppHost(
|
||||
RendererHostControl,
|
||||
|
||||
@@ -120,11 +120,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMetalAvailable => OperatingSystem.IsMacOS();
|
||||
|
||||
public bool IsOpenGLAvailable => !OperatingSystem.IsMacOS();
|
||||
|
||||
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
||||
public bool IsAppleSiliconMac => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
||||
|
||||
public bool GameDirectoryChanged
|
||||
{
|
||||
@@ -254,7 +252,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
public bool IsCustomResolutionScaleActive => _resolutionScale == 4;
|
||||
public bool IsScalingFilterActive => _scalingFilter == (int)Ryujinx.Common.Configuration.ScalingFilter.Fsr;
|
||||
|
||||
public bool IsVulkanSelected => GraphicsBackendIndex == 0;
|
||||
public bool IsVulkanSelected =>
|
||||
GraphicsBackendIndex == 1 || (GraphicsBackendIndex == 0 && !OperatingSystem.IsMacOS());
|
||||
public bool UseHypervisor { get; set; }
|
||||
public bool DisableP2P { get; set; }
|
||||
|
||||
@@ -434,7 +433,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
if (devices.Length == 0)
|
||||
{
|
||||
IsVulkanAvailable = false;
|
||||
GraphicsBackendIndex = 1;
|
||||
GraphicsBackendIndex = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<CheckBox IsChecked="{Binding UseHypervisor}"
|
||||
IsVisible="{Binding IsHypervisorAvailable}"
|
||||
IsVisible="{Binding IsAppleSiliconMac}"
|
||||
ToolTip.Tip="{ext:Locale UseHypervisorTooltip}">
|
||||
<TextBlock Text="{ext:Locale SettingsTabSystemUseHypervisor}"
|
||||
ToolTip.Tip="{ext:Locale UseHypervisorTooltip}" />
|
||||
|
||||
@@ -33,18 +33,23 @@
|
||||
ToolTip.Tip="{ext:Locale SettingsTabGraphicsBackendTooltip}"
|
||||
Text="{ext:Locale SettingsTabGraphicsBackend}"
|
||||
Width="250" />
|
||||
<ComboBox Width="350"
|
||||
HorizontalContentAlignment="Left"
|
||||
ToolTip.Tip="{ext:Locale SettingsTabGraphicsBackendTooltip}"
|
||||
SelectedIndex="{Binding GraphicsBackendIndex}">
|
||||
<ComboBox
|
||||
Name="GraphicsBackendSelector"
|
||||
Width="350"
|
||||
HorizontalContentAlignment="Left"
|
||||
ToolTip.Tip="{ext:Locale SettingsTabGraphicsBackendTooltip}"
|
||||
SelectedIndex="{Binding GraphicsBackendIndex}">
|
||||
<ComboBoxItem IsVisible="{Binding IsVulkanAvailable}" ToolTip.Tip="{ext:Locale SettingsTabGraphicsBackendAutoTooltip}" >
|
||||
<TextBlock Text="{ext:Locale SettingsTabGraphicsBackendAuto}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem IsVisible="{Binding IsVulkanAvailable}">
|
||||
<TextBlock Text="Vulkan" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem IsEnabled="{Binding IsOpenGLAvailable}">
|
||||
<TextBlock Text="OpenGL" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem IsVisible="{Binding IsMetalAvailable}">
|
||||
<TextBlock Text="Metal" />
|
||||
<ComboBoxItem IsEnabled="{Binding IsAppleSiliconMac}">
|
||||
<TextBlock Text="Metal (ARM Mac only, Experimental)" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
@@ -56,34 +56,34 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
{
|
||||
switch (navItem.Tag.ToString())
|
||||
{
|
||||
case "UiPage":
|
||||
case nameof(UiPage):
|
||||
UiPage.ViewModel = ViewModel;
|
||||
NavPanel.Content = UiPage;
|
||||
break;
|
||||
case "InputPage":
|
||||
case nameof(InputPage):
|
||||
NavPanel.Content = InputPage;
|
||||
break;
|
||||
case "HotkeysPage":
|
||||
case nameof(HotkeysPage):
|
||||
NavPanel.Content = HotkeysPage;
|
||||
break;
|
||||
case "SystemPage":
|
||||
case nameof(SystemPage):
|
||||
SystemPage.ViewModel = ViewModel;
|
||||
NavPanel.Content = SystemPage;
|
||||
break;
|
||||
case "CpuPage":
|
||||
case nameof(CpuPage):
|
||||
NavPanel.Content = CpuPage;
|
||||
break;
|
||||
case "GraphicsPage":
|
||||
case nameof(GraphicsPage):
|
||||
NavPanel.Content = GraphicsPage;
|
||||
break;
|
||||
case "AudioPage":
|
||||
case nameof(AudioPage):
|
||||
NavPanel.Content = AudioPage;
|
||||
break;
|
||||
case "NetworkPage":
|
||||
case nameof(NetworkPage):
|
||||
NetworkPage.ViewModel = ViewModel;
|
||||
NavPanel.Content = NetworkPage;
|
||||
break;
|
||||
case "LoggingPage":
|
||||
case nameof(LoggingPage):
|
||||
NavPanel.Content = LoggingPage;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user