mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-17 23:06:29 +02:00
PPTC Profiles (#370)
Added functionality that allows ExeFS mods to compile to their own PPTC Profile and therefore store PTC data between sessions. The feature calculates the hash of the currently loaded ExeFS mods and stores the PPTC data in a profile that matches said hash, so you can have multiple ExeFS loadouts without causing issues. This includes different versions of the same mod as their hashes will be different. Using this PR should be seamless as the JIT Sparse PR already laid the groundwork for PPTC Profiles and this PR just allows ExeFS mods to load and store their own profiles besides the `default` profile. ❗❗❗ **WARNING!** ❗❗❗ **This will update your PPTC profile version, which means the PPTC profile will be invalidated if you try to run a PR/Build/Branch that does not include this change!** **This is only relevant for the default PPTC Profile, as any other profiles do not exist to older versions!**
This commit is contained in:
parent
9d28af935d
commit
7085bafa60
11 changed files with 299 additions and 28 deletions
|
@ -3,6 +3,7 @@ using ARMeilleure.CodeGen.Linking;
|
|||
using ARMeilleure.CodeGen.Unwinding;
|
||||
using ARMeilleure.Common;
|
||||
using ARMeilleure.Memory;
|
||||
using ARMeilleure.State;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
|
@ -30,8 +31,8 @@ namespace ARMeilleure.Translation.PTC
|
|||
{
|
||||
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
||||
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
||||
|
||||
private const uint InternalVersion = 6998; //! To be incremented manually for each change to the ARMeilleure project.
|
||||
|
||||
private const uint InternalVersion = 7007; //! To be incremented manually for each change to the ARMeilleure project.
|
||||
|
||||
private const string ActualDir = "0";
|
||||
private const string BackupDir = "1";
|
||||
|
@ -184,6 +185,36 @@ namespace ARMeilleure.Translation.PTC
|
|||
InitializeCarriers();
|
||||
}
|
||||
|
||||
private bool ContainsBlacklistedFunctions()
|
||||
{
|
||||
List<ulong> blacklist = Profiler.GetBlacklistedFunctions();
|
||||
bool containsBlacklistedFunctions = false;
|
||||
_infosStream.Seek(0L, SeekOrigin.Begin);
|
||||
bool foundBadFunction = false;
|
||||
|
||||
for (int index = 0; index < GetEntriesCount(); index++)
|
||||
{
|
||||
InfoEntry infoEntry = DeserializeStructure<InfoEntry>(_infosStream);
|
||||
foreach (ulong address in blacklist)
|
||||
{
|
||||
if (infoEntry.Address == address)
|
||||
{
|
||||
containsBlacklistedFunctions = true;
|
||||
Logger.Warning?.Print(LogClass.Ptc, "PPTC cache invalidated: Found blacklisted functions in PPTC cache");
|
||||
foundBadFunction = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundBadFunction)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return containsBlacklistedFunctions;
|
||||
}
|
||||
|
||||
private void PreLoad()
|
||||
{
|
||||
string fileNameActual = $"{CachePathActual}.cache";
|
||||
|
@ -532,7 +563,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
public void LoadTranslations(Translator translator)
|
||||
{
|
||||
if (AreCarriersEmpty())
|
||||
if (AreCarriersEmpty() || ContainsBlacklistedFunctions())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -835,10 +866,18 @@ namespace ARMeilleure.Translation.PTC
|
|||
while (profiledFuncsToTranslate.TryDequeue(out (ulong address, PtcProfiler.FuncProfile funcProfile) item))
|
||||
{
|
||||
ulong address = item.address;
|
||||
ExecutionMode executionMode = item.funcProfile.Mode;
|
||||
bool highCq = item.funcProfile.HighCq;
|
||||
|
||||
Debug.Assert(Profiler.IsAddressInStaticCodeRange(address));
|
||||
|
||||
TranslatedFunction func = translator.Translate(address, item.funcProfile.Mode, item.funcProfile.HighCq);
|
||||
TranslatedFunction func = translator.Translate(address, executionMode, highCq);
|
||||
|
||||
if (func == null)
|
||||
{
|
||||
Profiler.UpdateEntry(address, executionMode, true, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isAddressUnique = translator.Functions.TryAdd(address, func.GuestSize, func);
|
||||
|
||||
|
@ -885,7 +924,14 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
PtcStateChanged?.Invoke(PtcLoadingState.Loaded, _translateCount, _translateTotalCount);
|
||||
|
||||
Logger.Info?.Print(LogClass.Ptc, $"{_translateCount} of {_translateTotalCount} functions translated | Thread count: {degreeOfParallelism} in {sw.Elapsed.TotalSeconds} s");
|
||||
if (_translateCount == _translateTotalCount)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Ptc, $"{_translateCount} of {_translateTotalCount} functions translated | Thread count: {degreeOfParallelism} in {sw.Elapsed.TotalSeconds} s");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info?.Print(LogClass.Ptc, $"{_translateCount} of {_translateTotalCount} functions translated | {_translateTotalCount - _translateCount} function{(_translateTotalCount - _translateCount != 1 ? "s" : "")} blacklisted | Thread count: {degreeOfParallelism} in {sw.Elapsed.TotalSeconds} s");
|
||||
}
|
||||
|
||||
Thread preSaveThread = new(PreSave)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue