Compare commits

...

2 Commits

Author SHA1 Message Date
Steveice10
a772b073ec Support portable mode using the macOS app bundle. (#6147)
* Support portable mode using the macOS app bundle.

* Apply suggestion

Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com>

---------

Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com>
2024-01-20 03:09:51 +01:00
gdkchan
870d9599cc Change shader cache init wait method (#6131)
* Change shader cache init wait method

* Make field readonly
2024-01-18 14:17:38 -03:00
12 changed files with 31 additions and 23 deletions

View File

@@ -57,9 +57,6 @@ namespace ARMeilleure.Translation
private Thread[] _backgroundTranslationThreads;
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)
{
_allocator = allocator;
@@ -100,8 +97,6 @@ namespace ARMeilleure.Translation
{
if (Interlocked.Increment(ref _threadCount) == 1)
{
IsReadyForTranslation.WaitOne();
if (_ptc.State == PtcState.Enabled)
{
Debug.Assert(Functions.Count == 0);

View File

@@ -1,4 +1,3 @@
using ARMeilleure.Translation;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
@@ -916,7 +915,6 @@ namespace Ryujinx.Ava
{
Device.Gpu.SetGpuThread();
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
Translator.IsReadyForTranslation.Set();
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);

View File

@@ -63,6 +63,17 @@ namespace Ryujinx.Common.Configuration
string userProfilePath = Path.Combine(appDataPath, DefaultBaseDir);
string portablePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DefaultPortableDir);
// On macOS, check for a portable directory next to the app bundle as well.
if (OperatingSystem.IsMacOS() && !Directory.Exists(portablePath))
{
string bundlePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", ".."));
// Make sure we're actually running within an app bundle.
if (bundlePath.EndsWith(".app"))
{
portablePath = Path.GetFullPath(Path.Combine(bundlePath, "..", DefaultPortableDir));
}
}
if (Directory.Exists(portablePath))
{
BaseDirPath = portablePath;

View File

@@ -106,6 +106,8 @@ namespace Ryujinx.Graphics.Gpu
private long _modifiedSequence;
private readonly ulong _firstTimestamp;
private readonly ManualResetEvent _gpuReadyEvent;
/// <summary>
/// Creates a new instance of the GPU emulation context.
/// </summary>
@@ -121,6 +123,7 @@ namespace Ryujinx.Graphics.Gpu
Window = new Window(this);
HostInitalized = new ManualResetEvent(false);
_gpuReadyEvent = new ManualResetEvent(false);
SyncActions = 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.
/// </summary>
/// <returns>A sequence number for resource modification ordering</returns>
public long GetModifiedSequence()
internal long GetModifiedSequence()
{
return _modifiedSequence++;
}
@@ -225,7 +228,7 @@ namespace Ryujinx.Graphics.Gpu
/// Gets the value of the GPU timer.
/// </summary>
/// <returns>The current GPU timestamp</returns>
public ulong GetTimestamp()
internal ulong GetTimestamp()
{
// Guest timestamp will start at 0, instead of host value.
ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds) - _firstTimestamp;
@@ -262,6 +265,16 @@ namespace Ryujinx.Graphics.Gpu
{
physicalMemory.ShaderCache.Initialize(cancellationToken);
}
_gpuReadyEvent.Set();
}
/// <summary>
/// Waits until the GPU is ready to receive commands.
/// </summary>
public void WaitUntilGpuReady()
{
_gpuReadyEvent.WaitOne();
}
/// <summary>
@@ -399,6 +412,7 @@ namespace Ryujinx.Graphics.Gpu
{
GPFifo.Dispose();
HostInitalized.Dispose();
_gpuReadyEvent.Dispose();
// Has to be disposed before processing deferred actions, as it will produce some.
foreach (var physicalMemory in PhysicalMemoryRegistry.Values)

View File

@@ -161,7 +161,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
_graphicsShaderCache,
_computeShaderCache,
_diskCacheHostStorage,
ShaderCacheStateUpdate, cancellationToken);
ShaderCacheStateUpdate,
cancellationToken);
loader.LoadShaders();

View File

@@ -57,6 +57,8 @@ namespace Ryujinx.HLE.HOS
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);
}

View File

@@ -1,4 +1,3 @@
using ARMeilleure.Translation;
using CommandLine;
using LibHac.Tools.FsSystem;
using Ryujinx.Audio.Backends.SDL2;
@@ -710,9 +709,6 @@ namespace Ryujinx.Headless.SDL2
}
SetupProgressHandler();
Translator.IsReadyForTranslation.Reset();
ExecutionEntrypoint();
return true;

View File

@@ -1,4 +1,3 @@
using ARMeilleure.Translation;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Logging;
@@ -276,7 +275,6 @@ namespace Ryujinx.Headless.SDL2
{
Device.Gpu.SetGpuThread();
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
Translator.IsReadyForTranslation.Set();
while (_isActive)
{

View File

@@ -61,7 +61,6 @@ namespace Ryujinx.Tests.Cpu
_memory.Map(DataBaseAddress, Size, Size, MemoryMapFlags.Private);
_context = CpuContext.CreateExecutionContext();
Translator.IsReadyForTranslation.Set();
_cpuContext = new CpuContext(_memory, for64Bit: true);

View File

@@ -56,7 +56,6 @@ namespace Ryujinx.Tests.Cpu
_context = CpuContext.CreateExecutionContext();
_context.IsAarch32 = true;
Translator.IsReadyForTranslation.Set();
_cpuContext = new CpuContext(_memory, for64Bit: false);

View File

@@ -1,4 +1,3 @@
using ARMeilleure.Translation;
using Gtk;
using LibHac.Common;
using LibHac.Common.Keys;
@@ -931,8 +930,6 @@ namespace Ryujinx.Ui
_deviceExitStatus.Reset();
Translator.IsReadyForTranslation.Reset();
Thread windowThread = new(CreateGameWindow)
{
Name = "GUI.WindowThread",

View File

@@ -1,4 +1,3 @@
using ARMeilleure.Translation;
using Gdk;
using Gtk;
using Ryujinx.Common;
@@ -450,7 +449,6 @@ namespace Ryujinx.Ui
{
Device.Gpu.SetGpuThread();
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
Translator.IsReadyForTranslation.Set();
Renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);