forked from Mirror/Ryujinx
Change shader cache init wait method (#6131)
* Change shader cache init wait method * Make field readonly
This commit is contained in:
parent
2dbbc9bc05
commit
870d9599cc
11 changed files with 20 additions and 23 deletions
|
@ -57,9 +57,6 @@ namespace ARMeilleure.Translation
|
||||||
private Thread[] _backgroundTranslationThreads;
|
private Thread[] _backgroundTranslationThreads;
|
||||||
private volatile int _threadCount;
|
private volatile int _threadCount;
|
||||||
|
|
||||||
// FIXME: Remove this once the init logic of the emulator will be redone.
|
|
||||||
public static readonly ManualResetEvent IsReadyForTranslation = new(false);
|
|
||||||
|
|
||||||
public Translator(IJitMemoryAllocator allocator, IMemoryManager memory, bool for64Bits)
|
public Translator(IJitMemoryAllocator allocator, IMemoryManager memory, bool for64Bits)
|
||||||
{
|
{
|
||||||
_allocator = allocator;
|
_allocator = allocator;
|
||||||
|
@ -100,8 +97,6 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
if (Interlocked.Increment(ref _threadCount) == 1)
|
if (Interlocked.Increment(ref _threadCount) == 1)
|
||||||
{
|
{
|
||||||
IsReadyForTranslation.WaitOne();
|
|
||||||
|
|
||||||
if (_ptc.State == PtcState.Enabled)
|
if (_ptc.State == PtcState.Enabled)
|
||||||
{
|
{
|
||||||
Debug.Assert(Functions.Count == 0);
|
Debug.Assert(Functions.Count == 0);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using ARMeilleure.Translation;
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
@ -916,7 +915,6 @@ namespace Ryujinx.Ava
|
||||||
{
|
{
|
||||||
Device.Gpu.SetGpuThread();
|
Device.Gpu.SetGpuThread();
|
||||||
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
||||||
Translator.IsReadyForTranslation.Set();
|
|
||||||
|
|
||||||
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
|
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,8 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
private long _modifiedSequence;
|
private long _modifiedSequence;
|
||||||
private readonly ulong _firstTimestamp;
|
private readonly ulong _firstTimestamp;
|
||||||
|
|
||||||
|
private readonly ManualResetEvent _gpuReadyEvent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the GPU emulation context.
|
/// Creates a new instance of the GPU emulation context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -121,6 +123,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
Window = new Window(this);
|
Window = new Window(this);
|
||||||
|
|
||||||
HostInitalized = new ManualResetEvent(false);
|
HostInitalized = new ManualResetEvent(false);
|
||||||
|
_gpuReadyEvent = new ManualResetEvent(false);
|
||||||
|
|
||||||
SyncActions = new List<ISyncActionHandler>();
|
SyncActions = new List<ISyncActionHandler>();
|
||||||
SyncpointActions = new List<ISyncActionHandler>();
|
SyncpointActions = new List<ISyncActionHandler>();
|
||||||
|
@ -216,7 +219,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// Gets a sequence number for resource modification ordering. This increments on each call.
|
/// Gets a sequence number for resource modification ordering. This increments on each call.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A sequence number for resource modification ordering</returns>
|
/// <returns>A sequence number for resource modification ordering</returns>
|
||||||
public long GetModifiedSequence()
|
internal long GetModifiedSequence()
|
||||||
{
|
{
|
||||||
return _modifiedSequence++;
|
return _modifiedSequence++;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +228,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// Gets the value of the GPU timer.
|
/// Gets the value of the GPU timer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The current GPU timestamp</returns>
|
/// <returns>The current GPU timestamp</returns>
|
||||||
public ulong GetTimestamp()
|
internal ulong GetTimestamp()
|
||||||
{
|
{
|
||||||
// Guest timestamp will start at 0, instead of host value.
|
// Guest timestamp will start at 0, instead of host value.
|
||||||
ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds) - _firstTimestamp;
|
ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds) - _firstTimestamp;
|
||||||
|
@ -262,6 +265,16 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
{
|
{
|
||||||
physicalMemory.ShaderCache.Initialize(cancellationToken);
|
physicalMemory.ShaderCache.Initialize(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_gpuReadyEvent.Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Waits until the GPU is ready to receive commands.
|
||||||
|
/// </summary>
|
||||||
|
public void WaitUntilGpuReady()
|
||||||
|
{
|
||||||
|
_gpuReadyEvent.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -399,6 +412,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
{
|
{
|
||||||
GPFifo.Dispose();
|
GPFifo.Dispose();
|
||||||
HostInitalized.Dispose();
|
HostInitalized.Dispose();
|
||||||
|
_gpuReadyEvent.Dispose();
|
||||||
|
|
||||||
// Has to be disposed before processing deferred actions, as it will produce some.
|
// Has to be disposed before processing deferred actions, as it will produce some.
|
||||||
foreach (var physicalMemory in PhysicalMemoryRegistry.Values)
|
foreach (var physicalMemory in PhysicalMemoryRegistry.Values)
|
||||||
|
|
|
@ -161,7 +161,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
_graphicsShaderCache,
|
_graphicsShaderCache,
|
||||||
_computeShaderCache,
|
_computeShaderCache,
|
||||||
_diskCacheHostStorage,
|
_diskCacheHostStorage,
|
||||||
ShaderCacheStateUpdate, cancellationToken);
|
ShaderCacheStateUpdate,
|
||||||
|
cancellationToken);
|
||||||
|
|
||||||
loader.LoadShaders();
|
loader.LoadShaders();
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
public void Execute(IExecutionContext context, ulong codeAddress)
|
public void Execute(IExecutionContext context, ulong codeAddress)
|
||||||
{
|
{
|
||||||
|
// We must wait until shader cache is loaded, among other things, before executing CPU code.
|
||||||
|
_gpuContext.WaitUntilGpuReady();
|
||||||
_cpuContext.Execute(context, codeAddress);
|
_cpuContext.Execute(context, codeAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using ARMeilleure.Translation;
|
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
using LibHac.Tools.FsSystem;
|
using LibHac.Tools.FsSystem;
|
||||||
using Ryujinx.Audio.Backends.SDL2;
|
using Ryujinx.Audio.Backends.SDL2;
|
||||||
|
@ -710,9 +709,6 @@ namespace Ryujinx.Headless.SDL2
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupProgressHandler();
|
SetupProgressHandler();
|
||||||
|
|
||||||
Translator.IsReadyForTranslation.Reset();
|
|
||||||
|
|
||||||
ExecutionEntrypoint();
|
ExecutionEntrypoint();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using ARMeilleure.Translation;
|
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
using Ryujinx.Common.Configuration.Hid;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
|
@ -276,7 +275,6 @@ namespace Ryujinx.Headless.SDL2
|
||||||
{
|
{
|
||||||
Device.Gpu.SetGpuThread();
|
Device.Gpu.SetGpuThread();
|
||||||
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
||||||
Translator.IsReadyForTranslation.Set();
|
|
||||||
|
|
||||||
while (_isActive)
|
while (_isActive)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,7 +61,6 @@ namespace Ryujinx.Tests.Cpu
|
||||||
_memory.Map(DataBaseAddress, Size, Size, MemoryMapFlags.Private);
|
_memory.Map(DataBaseAddress, Size, Size, MemoryMapFlags.Private);
|
||||||
|
|
||||||
_context = CpuContext.CreateExecutionContext();
|
_context = CpuContext.CreateExecutionContext();
|
||||||
Translator.IsReadyForTranslation.Set();
|
|
||||||
|
|
||||||
_cpuContext = new CpuContext(_memory, for64Bit: true);
|
_cpuContext = new CpuContext(_memory, for64Bit: true);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ namespace Ryujinx.Tests.Cpu
|
||||||
|
|
||||||
_context = CpuContext.CreateExecutionContext();
|
_context = CpuContext.CreateExecutionContext();
|
||||||
_context.IsAarch32 = true;
|
_context.IsAarch32 = true;
|
||||||
Translator.IsReadyForTranslation.Set();
|
|
||||||
|
|
||||||
_cpuContext = new CpuContext(_memory, for64Bit: false);
|
_cpuContext = new CpuContext(_memory, for64Bit: false);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using ARMeilleure.Translation;
|
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Common.Keys;
|
using LibHac.Common.Keys;
|
||||||
|
@ -931,8 +930,6 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
_deviceExitStatus.Reset();
|
_deviceExitStatus.Reset();
|
||||||
|
|
||||||
Translator.IsReadyForTranslation.Reset();
|
|
||||||
|
|
||||||
Thread windowThread = new(CreateGameWindow)
|
Thread windowThread = new(CreateGameWindow)
|
||||||
{
|
{
|
||||||
Name = "GUI.WindowThread",
|
Name = "GUI.WindowThread",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using ARMeilleure.Translation;
|
|
||||||
using Gdk;
|
using Gdk;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
|
@ -450,7 +449,6 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
Device.Gpu.SetGpuThread();
|
Device.Gpu.SetGpuThread();
|
||||||
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
||||||
Translator.IsReadyForTranslation.Set();
|
|
||||||
|
|
||||||
Renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
|
Renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue