mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-03 01:41:04 +02:00
River 2 : HLE: Use per-program ownership for PTC disk caches
This PR threads process/program identity into PTC disk cache initialization so cache ownership is selected from the launched process rather than global/shared application state.
Previously, the PTC initialization path only propagated loose title/version information into the CPU layer. That was mostly fine for a single launched application, but will introduce many problems once multiple programs can be launched during the same session, given later processes could inherit cache identity from the first loaded application.
To address this issue, this PR introduces a `PtcCacheInfo` payload and applies it through the process context, CPU context, translator, and PTC initialization paths. Cache ownership is now resolved once the kernel process PID is known and includes:
- PID
- Program ID / Title ID
- Application ID
- Program index
- Display version
- Process kind
- Cache selector
`PtcCacheInfo` now owns its default title/application/version values, and `Ptc` uses that cache info directly instead of mirroring title/version fields internally.
The persistent cache key itself does remains title/version/selector based rather than PID based, so caches remain reusable across launches while still being selected from the correct process context. PID is only used for diagnostics and ownership tracing in logs.
Additional PTC logging has also been added to report cache ownership and selected paths during PTC initialization, Profiling info load/save and translation cache load/save
Both the PTC and profiler internal versions were bumped (a bunch of times lol).
(cherry picked from commit 7101f52c01)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using ARMeilleure.Translation.PTC;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
@@ -8,6 +9,7 @@ using Ryujinx.Cpu.Nce;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.HLE.HOS.Kernel;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -18,8 +20,10 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
private readonly ITickSource _tickSource;
|
||||
private readonly GpuContext _gpu;
|
||||
private readonly string _titleIdText;
|
||||
private readonly ulong _programId;
|
||||
private readonly byte _programIndex;
|
||||
private readonly string _displayVersion;
|
||||
private readonly ProcessKind _processKind;
|
||||
private readonly bool _diskCacheEnabled;
|
||||
private readonly string _diskCacheSelector;
|
||||
private readonly ulong _codeAddress;
|
||||
@@ -30,8 +34,10 @@ namespace Ryujinx.HLE.HOS
|
||||
public ArmProcessContextFactory(
|
||||
ITickSource tickSource,
|
||||
GpuContext gpu,
|
||||
string titleIdText,
|
||||
ulong programId,
|
||||
byte programIndex,
|
||||
string displayVersion,
|
||||
ProcessKind processKind,
|
||||
bool diskCacheEnabled,
|
||||
string diskCacheSelector,
|
||||
ulong codeAddress,
|
||||
@@ -39,8 +45,10 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
_tickSource = tickSource;
|
||||
_gpu = gpu;
|
||||
_titleIdText = titleIdText;
|
||||
_programId = programId;
|
||||
_programIndex = programIndex;
|
||||
_displayVersion = displayVersion;
|
||||
_processKind = processKind;
|
||||
_diskCacheEnabled = diskCacheEnabled;
|
||||
_diskCacheSelector = diskCacheSelector;
|
||||
_codeAddress = codeAddress;
|
||||
@@ -160,8 +168,18 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
|
||||
string cacheSelector = _diskCacheSelector ?? "default";
|
||||
string programIdText = _programId == 0 ? string.Empty : $"{_programId:x16}";
|
||||
string applicationIdText = _programId == 0 ? string.Empty : $"{_programId & ~0xFul:x16}";
|
||||
PtcCacheInfo cacheInfo = new(
|
||||
pid,
|
||||
programIdText,
|
||||
applicationIdText,
|
||||
_programIndex,
|
||||
_displayVersion,
|
||||
_processKind.ToString(),
|
||||
cacheSelector);
|
||||
|
||||
DiskCacheLoadState = processContext.Initialize(_titleIdText, _displayVersion, _diskCacheEnabled, _codeAddress, _codeSize, cacheSelector);
|
||||
DiskCacheLoadState = processContext.Initialize(cacheInfo, _diskCacheEnabled, _codeAddress, _codeSize);
|
||||
|
||||
return processContext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user