From e8ded454d599f927e5b58ab9df8e37833ca10a21 Mon Sep 17 00:00:00 2001 From: Andy Adshead Date: Wed, 23 Jan 2019 20:51:21 +0000 Subject: [PATCH] Profiler initial setup --- Ryujinx.Profiler/Profile.cs | 51 ++++++++++++++++++++++++ Ryujinx.Profiler/ProfileConfig.cs | 22 ++++++++++ Ryujinx.Profiler/Ryujinx.Profiler.csproj | 12 ++++++ Ryujinx.Profiler/Settings.cs | 13 ++++++ Ryujinx.sln | 6 +++ Ryujinx/Config.cs | 10 +++++ Ryujinx/Ryujinx.conf | 6 +++ Ryujinx/Ryujinx.csproj | 1 + 8 files changed, 121 insertions(+) create mode 100644 Ryujinx.Profiler/Profile.cs create mode 100644 Ryujinx.Profiler/ProfileConfig.cs create mode 100644 Ryujinx.Profiler/Ryujinx.Profiler.csproj create mode 100644 Ryujinx.Profiler/Settings.cs diff --git a/Ryujinx.Profiler/Profile.cs b/Ryujinx.Profiler/Profile.cs new file mode 100644 index 0000000000..a2c18d46a0 --- /dev/null +++ b/Ryujinx.Profiler/Profile.cs @@ -0,0 +1,51 @@ +using System; +using Ryujinx.Common.Logging; + +namespace Ryujinx.Profiler +{ + public class Profile + { + private static Profile ProfileInstance; + private static ProfilerSettings Settings; + + private static bool ProfilingEnabled() + { + if (!Settings.Enabled) + return false; + + if (ProfileInstance == null) + ProfileInstance = new Profile(); + return true; + } + + public static void Configure(ProfilerSettings settings) + { + Settings = settings; + } + + public static void Begin(ProfileConfig config) + { + if (!ProfilingEnabled()) + return; + Logger.PrintInfo(LogClass.Gpu, $"Begin {config.Name}"); + } + + public static void End(ProfileConfig config) + { + if (!ProfilingEnabled()) + return; + Logger.PrintInfo(LogClass.Gpu, $"End {config.Name}"); + } + + public static void Method(ProfileConfig config, Action method) + { + // If profiling is disabled just call the method + if (!ProfilingEnabled()) + method(); + + Begin(config); + method(); + End(config); + } + } +} diff --git a/Ryujinx.Profiler/ProfileConfig.cs b/Ryujinx.Profiler/ProfileConfig.cs new file mode 100644 index 0000000000..4aaacf1f13 --- /dev/null +++ b/Ryujinx.Profiler/ProfileConfig.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Ryujinx.Profiler +{ + public struct ProfileConfig + { + public string Name; + } + + public static class Profiles + { + public static class CPU + { + public static ProfileConfig Test = new ProfileConfig() + { + Name = "Test", + }; + } + } +} diff --git a/Ryujinx.Profiler/Ryujinx.Profiler.csproj b/Ryujinx.Profiler/Ryujinx.Profiler.csproj new file mode 100644 index 0000000000..4833752b3a --- /dev/null +++ b/Ryujinx.Profiler/Ryujinx.Profiler.csproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.1 + win10-x64;osx-x64;linux-x64 + + + + + + + diff --git a/Ryujinx.Profiler/Settings.cs b/Ryujinx.Profiler/Settings.cs new file mode 100644 index 0000000000..a023a21461 --- /dev/null +++ b/Ryujinx.Profiler/Settings.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Ryujinx.Profiler +{ + public class ProfilerSettings + { + public bool Enabled = true; + public bool FileDumpEnabled = false; + public string DumpLocation = ""; + } +} diff --git a/Ryujinx.sln b/Ryujinx.sln index 148224faa4..f413e8daeb 100644 --- a/Ryujinx.sln +++ b/Ryujinx.sln @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Luea", "Ryujinx.LLE\Luea.cs EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Common", "Ryujinx.Common\Ryujinx.Common.csproj", "{5FD4E4F6-8928-4B3C-BE07-28A675C17226}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.Profiler", "Ryujinx.Profiler\Ryujinx.Profiler.csproj", "{4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -69,6 +71,10 @@ Global {5FD4E4F6-8928-4B3C-BE07-28A675C17226}.Debug|Any CPU.Build.0 = Debug|Any CPU {5FD4E4F6-8928-4B3C-BE07-28A675C17226}.Release|Any CPU.ActiveCfg = Release|Any CPU {5FD4E4F6-8928-4B3C-BE07-28A675C17226}.Release|Any CPU.Build.0 = Release|Any CPU + {4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index d1139da924..8807357cfa 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -10,6 +10,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Reflection; +using Ryujinx.Profiler; namespace Ryujinx { @@ -62,6 +63,15 @@ namespace Ryujinx } } + + string profilePath = parser.Value("Profile_Dump_Path"); + Profile.Configure(new ProfilerSettings() + { + Enabled = Convert.ToBoolean(parser.Value("Profiling_Enabled")), + FileDumpEnabled = profilePath != "", + DumpLocation = profilePath, + }); + SystemLanguage SetLanguage = Enum.Parse(parser.Value("System_Language")); device.System.State.SetLanguage(SetLanguage); diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index c04d7b5ac9..fc221c490d 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -22,6 +22,12 @@ Logging_Enable_Error = true #Filtered log classes, seperated by ", ", eg. `Logging_Filtered_Classes = Loader, ServiceFS` Logging_Filtered_Classes = +#Enable profiling +Profiling_Enabled = true + +#Set profile file dump location, if blank file dumping disabled. (e.g. `ProfileDump.txt`) +Profile_Dump_Path = ProfileDump.txt + #System Language list: https://gist.github.com/HorrorTroll/b6e4a88d774c3c9b3bdf54d79a7ca43b #Change System Language System_Language = AmericanEnglish diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj index 1789ef2e9f..7554b6abfe 100644 --- a/Ryujinx/Ryujinx.csproj +++ b/Ryujinx/Ryujinx.csproj @@ -17,6 +17,7 @@ +