mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-24 21:37:11 +02:00
Make PPTC state non-static (#4157)
* Make PPTC state non-static * DiskCacheLoadState can be null
This commit is contained in:
parent
08831eecf7
commit
fc4b7cba2c
21 changed files with 434 additions and 230 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue