aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-01-18 14:17:38 -0300
committerGitHub <noreply@github.com>2024-01-18 14:17:38 -0300
commit870d9599cc056e515dd63620fd10bf9fee4992ee (patch)
tree419862e34e111e69c6bf5acdfb96f026e75c8729 /src/Ryujinx.Graphics.Gpu
parent2dbbc9bc05998baa94d7b1953d9e0ffc7f1651f8 (diff)
Change shader cache init wait method (#6131)
* Change shader cache init wait method * Make field readonly
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu')
-rw-r--r--src/Ryujinx.Graphics.Gpu/GpuContext.cs18
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs3
2 files changed, 18 insertions, 3 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
index a50852b0..aaf03ff7 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -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)
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index af682e42..0b17af8b 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -161,7 +161,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
_graphicsShaderCache,
_computeShaderCache,
_diskCacheHostStorage,
- ShaderCacheStateUpdate, cancellationToken);
+ ShaderCacheStateUpdate,
+ cancellationToken);
loader.LoadShaders();