forked from Mirror/Ryujinx
shader cache: Fix Linux boot issues (#1709)
* shader cache: Fix Linux boot issues This rollback the init logic back to previous state, and replicate the way PTC handle initialization. * shader cache: set default state of ready for translation event to false * Fix cpu unit tests
This commit is contained in:
parent
cc60ba9d22
commit
863edae328
7 changed files with 48 additions and 60 deletions
|
@ -31,6 +31,9 @@ namespace ARMeilleure.Translation
|
|||
|
||||
private volatile int _threadCount;
|
||||
|
||||
// FIXME: Remove this once the init logic of the emulator will be redone
|
||||
public static ManualResetEvent IsReadyForTranslation = new ManualResetEvent(false);
|
||||
|
||||
public Translator(IJitMemoryAllocator allocator, IMemoryManager memory)
|
||||
{
|
||||
_memory = memory;
|
||||
|
@ -83,6 +86,8 @@ namespace ARMeilleure.Translation
|
|||
{
|
||||
if (Interlocked.Increment(ref _threadCount) == 1)
|
||||
{
|
||||
IsReadyForTranslation.WaitOne();
|
||||
|
||||
if (Ptc.State == PtcState.Enabled)
|
||||
{
|
||||
Ptc.MakeAndSaveTranslations(_funcs, _memory, _jumpTable);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Engine;
|
||||
using Ryujinx.Graphics.Gpu.Engine.GPFifo;
|
||||
|
@ -19,11 +18,6 @@ namespace Ryujinx.Graphics.Gpu
|
|||
/// </summary>
|
||||
public ManualResetEvent HostInitalized { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event signaled when the gpu context is ready to be used.
|
||||
/// </summary>
|
||||
public ManualResetEvent ReadyEvent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Host renderer.
|
||||
/// </summary>
|
||||
|
@ -93,20 +87,16 @@ namespace Ryujinx.Graphics.Gpu
|
|||
_caps = new Lazy<Capabilities>(Renderer.GetCapabilities);
|
||||
|
||||
HostInitalized = new ManualResetEvent(false);
|
||||
ReadyEvent = new ManualResetEvent(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the GPU emulation context.
|
||||
/// Initialize the GPU shader cache.
|
||||
/// </summary>
|
||||
/// <param name="logLevel">The log level required.</param>
|
||||
public void Initialize(GraphicsDebugLevel logLevel)
|
||||
public void InitializeShaderCache()
|
||||
{
|
||||
HostInitalized.WaitOne();
|
||||
|
||||
Renderer.Initialize(logLevel);
|
||||
Methods.ShaderCache.Initialize();
|
||||
ReadyEvent.Set();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -142,7 +132,6 @@ namespace Ryujinx.Graphics.Gpu
|
|||
Renderer.Dispose();
|
||||
GPFifo.Dispose();
|
||||
HostInitalized.Dispose();
|
||||
ReadyEvent.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -503,8 +503,6 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
Ptc.Initialize(TitleIdText, DisplayVersion, _device.System.EnablePtc && !modified);
|
||||
|
||||
_device.Gpu.ReadyEvent.WaitOne();
|
||||
|
||||
ProgramLoader.LoadNsos(_device.System.KernelContext, metaData, executables: programs);
|
||||
}
|
||||
|
||||
|
@ -602,9 +600,7 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
// Explicitly null titleid to disable the shader cache
|
||||
Graphics.Gpu.GraphicsConfig.TitleId = null;
|
||||
|
||||
_device.Gpu.HostInitalized.Set();
|
||||
_device.Gpu.ReadyEvent.WaitOne();
|
||||
|
||||
ProgramLoader.LoadNsos(_device.System.KernelContext, metaData, executables: executable);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ARMeilleure.State;
|
||||
using ARMeilleure.Translation;
|
||||
using NUnit.Framework;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.Memory;
|
||||
|
@ -54,6 +55,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
_memory.Map(CodeBaseAddress, 0, Size * 2);
|
||||
|
||||
_context = CpuContext.CreateExecutionContext();
|
||||
Translator.IsReadyForTranslation.Set();
|
||||
|
||||
_cpuContext = new CpuContext(_memory);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ARMeilleure.State;
|
||||
using ARMeilleure.Translation;
|
||||
using NUnit.Framework;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.Memory;
|
||||
|
@ -52,6 +53,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
|
||||
_context = CpuContext.CreateExecutionContext();
|
||||
_context.IsAarch32 = true;
|
||||
Translator.IsReadyForTranslation.Set();
|
||||
|
||||
_cpuContext = new CpuContext(_memory);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ARMeilleure.Translation.PTC;
|
||||
using ARMeilleure.Translation;
|
||||
using ARMeilleure.Translation.PTC;
|
||||
using Gdk;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
@ -199,6 +200,20 @@ namespace Ryujinx.Ui
|
|||
Gtk.Application.Invoke(delegate
|
||||
{
|
||||
parent.Present();
|
||||
|
||||
|
||||
string titleNameSection = string.IsNullOrWhiteSpace(_device.Application.TitleName) ? string.Empty
|
||||
: $" - {_device.Application.TitleName}";
|
||||
|
||||
string titleVersionSection = string.IsNullOrWhiteSpace(_device.Application.DisplayVersion) ? string.Empty
|
||||
: $" v{_device.Application.DisplayVersion}";
|
||||
|
||||
string titleIdSection = string.IsNullOrWhiteSpace(_device.Application.TitleIdText) ? string.Empty
|
||||
: $" ({_device.Application.TitleIdText.ToUpper()})";
|
||||
|
||||
string titleArchSection = _device.Application.TitleIs64Bit ? " (64-bit)" : " (32-bit)";
|
||||
|
||||
parent.Title = $"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
|
||||
});
|
||||
|
||||
Thread renderLoopThread = new Thread(Render)
|
||||
|
@ -314,13 +329,16 @@ namespace Ryujinx.Ui
|
|||
parent.Present();
|
||||
GraphicsContext.MakeCurrent(WindowInfo);
|
||||
|
||||
_device.Gpu.Initialize(_glLogLevel);
|
||||
_device.Gpu.Renderer.Initialize(_glLogLevel);
|
||||
|
||||
// Make sure the first frame is not transparent.
|
||||
GL.ClearColor(OpenTK.Color.Black);
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
SwapBuffers();
|
||||
|
||||
_device.Gpu.InitializeShaderCache();
|
||||
Translator.IsReadyForTranslation.Set();
|
||||
|
||||
while (IsActive)
|
||||
{
|
||||
if (IsStopped)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using ARMeilleure.Translation;
|
||||
using ARMeilleure.Translation.PTC;
|
||||
using Gtk;
|
||||
using LibHac.Common;
|
||||
|
@ -39,7 +40,6 @@ namespace Ryujinx.Ui
|
|||
public static GlRenderer GlWidget => _glWidget;
|
||||
|
||||
private static AutoResetEvent _deviceExitStatus = new AutoResetEvent(false);
|
||||
private static AutoResetEvent _widgetInitEvent = new AutoResetEvent(false);
|
||||
|
||||
private static ListStore _tableStore;
|
||||
|
||||
|
@ -435,30 +435,6 @@ namespace Ryujinx.Ui
|
|||
}
|
||||
}
|
||||
|
||||
_widgetInitEvent.Reset();
|
||||
|
||||
#if MACOS_BUILD
|
||||
CreateGameWindow(device);
|
||||
#else
|
||||
Thread windowThread = new Thread(() =>
|
||||
{
|
||||
CreateGameWindow(device);
|
||||
})
|
||||
{
|
||||
Name = "GUI.WindowThread"
|
||||
};
|
||||
|
||||
windowThread.Start();
|
||||
#endif
|
||||
|
||||
_widgetInitEvent.WaitOne();
|
||||
|
||||
// Make sure the widget get initialized by forcing an update of GTK
|
||||
while (Application.EventsPending())
|
||||
{
|
||||
Application.RunIteration();
|
||||
}
|
||||
|
||||
Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
|
||||
|
||||
if (Directory.Exists(path))
|
||||
|
@ -519,24 +495,26 @@ namespace Ryujinx.Ui
|
|||
return;
|
||||
}
|
||||
|
||||
string titleNameSection = string.IsNullOrWhiteSpace(device.Application.TitleName) ? string.Empty
|
||||
: $" - {device.Application.TitleName}";
|
||||
|
||||
string titleVersionSection = string.IsNullOrWhiteSpace(device.Application.DisplayVersion) ? string.Empty
|
||||
: $" v{device.Application.DisplayVersion}";
|
||||
|
||||
string titleIdSection = string.IsNullOrWhiteSpace(device.Application.TitleIdText) ? string.Empty
|
||||
: $" ({device.Application.TitleIdText.ToUpper()})";
|
||||
|
||||
string titleArchSection = device.Application.TitleIs64Bit ? " (64-bit)" : " (32-bit)";
|
||||
|
||||
Title = $"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
|
||||
|
||||
_emulationContext = device;
|
||||
_gamePath = path;
|
||||
|
||||
_deviceExitStatus.Reset();
|
||||
|
||||
Translator.IsReadyForTranslation.Reset();
|
||||
#if MACOS_BUILD
|
||||
CreateGameWindow(device);
|
||||
#else
|
||||
Thread windowThread = new Thread(() =>
|
||||
{
|
||||
CreateGameWindow(device);
|
||||
})
|
||||
{
|
||||
Name = "GUI.WindowThread"
|
||||
};
|
||||
|
||||
windowThread.Start();
|
||||
#endif
|
||||
|
||||
_gameLoaded = true;
|
||||
_stopEmulation.Sensitive = true;
|
||||
|
||||
|
@ -559,7 +537,7 @@ namespace Ryujinx.Ui
|
|||
_windowsMultimediaTimerResolution = new WindowsMultimediaTimerResolution(1);
|
||||
}
|
||||
|
||||
_glWidget = new GlRenderer(device, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
||||
_glWidget = new GlRenderer(_emulationContext, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
||||
|
||||
Application.Invoke(delegate
|
||||
{
|
||||
|
@ -576,8 +554,6 @@ namespace Ryujinx.Ui
|
|||
}
|
||||
});
|
||||
|
||||
_widgetInitEvent.Set();
|
||||
|
||||
_glWidget.WaitEvent.WaitOne();
|
||||
|
||||
_glWidget.Start();
|
||||
|
|
Reference in a new issue