mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-28 13:20:46 -07:00
Make PPTC state non-static (#4157)
* Make PPTC state non-static * DiskCacheLoadState can be null
This commit is contained in:
@ -35,5 +35,27 @@ namespace Ryujinx.Cpu
|
||||
/// <param name="address">Address of the region to be invalidated</param>
|
||||
/// <param name="size">Size of the region to be invalidated</param>
|
||||
void InvalidateCacheRegion(ulong address, ulong size);
|
||||
|
||||
/// <summary>
|
||||
/// Loads cached code from disk for a given application.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the execution engine is recompiling guest code, this can be used to load cached code from disk.
|
||||
/// </remarks>
|
||||
/// <param name="titleIdText">Title ID of the application in padded hex form</param>
|
||||
/// <param name="displayVersion">Version of the application</param>
|
||||
/// <param name="enabled">True if the cache should be loaded from disk if it exists, false otherwise</param>
|
||||
/// <returns>Disk cache load progress reporter and manager</returns>
|
||||
IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that code has been loaded into guest memory, and that it might be executed in the future.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Some execution engines might use this information to cache recompiled code on disk or to ensure it can be executed.
|
||||
/// </remarks>
|
||||
/// <param name="address">CPU virtual address where the code starts</param>
|
||||
/// <param name="size">Size of the code range in bytes</param>
|
||||
void PrepareCodeRange(ulong address, ulong size);
|
||||
}
|
||||
}
|
||||
|
20
Ryujinx.Cpu/IDiskCacheState.cs
Normal file
20
Ryujinx.Cpu/IDiskCacheState.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Cpu
|
||||
{
|
||||
/// <summary>
|
||||
/// Disk cache load state report and management interface.
|
||||
/// </summary>
|
||||
public interface IDiskCacheLoadState
|
||||
{
|
||||
/// <summary>
|
||||
/// Event used to report the cache load progress.
|
||||
/// </summary>
|
||||
event Action<LoadState, int, int> StateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the disk cache load process.
|
||||
/// </summary>
|
||||
void Cancel();
|
||||
}
|
||||
}
|
@ -37,5 +37,17 @@ namespace Ryujinx.Cpu.Jit
|
||||
{
|
||||
_translator.InvalidateJitCacheRegion(address, size);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled)
|
||||
{
|
||||
return new JitDiskCacheLoadState(_translator.LoadDiskCache(titleIdText, displayVersion, enabled));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void PrepareCodeRange(ulong address, ulong size)
|
||||
{
|
||||
_translator.PrepareCodeRange(address, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs
Normal file
38
Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using ARMeilleure.Translation.PTC;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Cpu.Jit
|
||||
{
|
||||
public class JitDiskCacheLoadState : IDiskCacheLoadState
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public event Action<LoadState, int, int> StateChanged;
|
||||
|
||||
private readonly IPtcLoadState _loadState;
|
||||
|
||||
public JitDiskCacheLoadState(IPtcLoadState loadState)
|
||||
{
|
||||
loadState.PtcStateChanged += LoadStateChanged;
|
||||
_loadState = loadState;
|
||||
}
|
||||
|
||||
private void LoadStateChanged(PtcLoadingState newState, int current, int total)
|
||||
{
|
||||
LoadState state = newState switch
|
||||
{
|
||||
PtcLoadingState.Start => LoadState.Unloaded,
|
||||
PtcLoadingState.Loading => LoadState.Loading,
|
||||
PtcLoadingState.Loaded => LoadState.Loaded,
|
||||
_ => throw new ArgumentException($"Invalid load state \"{newState}\".")
|
||||
};
|
||||
|
||||
StateChanged?.Invoke(state, current, total);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Cancel()
|
||||
{
|
||||
_loadState.Continue();
|
||||
}
|
||||
}
|
||||
}
|
12
Ryujinx.Cpu/LoadState.cs
Normal file
12
Ryujinx.Cpu/LoadState.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Cpu
|
||||
{
|
||||
/// <summary>
|
||||
/// Load state.
|
||||
/// </summary>
|
||||
public enum LoadState
|
||||
{
|
||||
Unloaded,
|
||||
Loading,
|
||||
Loaded
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user