aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/GpuContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/GpuContext.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/GpuContext.cs40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
index 91758863..bab62b95 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -60,14 +60,14 @@ namespace Ryujinx.Graphics.Gpu
/// If there are more than 0 items when this happens, a host sync object will be generated for the given <see cref="SyncNumber"/>,
/// and the SyncNumber will be incremented.
/// </summary>
- internal List<Action> SyncActions { get; }
+ internal List<ISyncActionHandler> SyncActions { get; }
/// <summary>
/// Actions to be performed when a CPU waiting syncpoint is triggered.
/// If there are more than 0 items when this happens, a host sync object will be generated for the given <see cref="SyncNumber"/>,
/// and the SyncNumber will be incremented.
/// </summary>
- internal List<Action> SyncpointActions { get; }
+ internal List<ISyncActionHandler> SyncpointActions { get; }
/// <summary>
/// Buffer migrations that are currently in-flight. These are checked whenever sync is created to determine if buffer migration
@@ -114,8 +114,8 @@ namespace Ryujinx.Graphics.Gpu
HostInitalized = new ManualResetEvent(false);
- SyncActions = new List<Action>();
- SyncpointActions = new List<Action>();
+ SyncActions = new List<ISyncActionHandler>();
+ SyncpointActions = new List<ISyncActionHandler>();
BufferMigrations = new List<BufferMigration>();
DeferredActions = new Queue<Action>();
@@ -296,9 +296,9 @@ namespace Ryujinx.Graphics.Gpu
/// Registers an action to be performed the next time a syncpoint is incremented.
/// This will also ensure a host sync object is created, and <see cref="SyncNumber"/> is incremented.
/// </summary>
- /// <param name="action">The action to be performed on sync object creation</param>
+ /// <param name="action">The resource with action to be performed on sync object creation</param>
/// <param name="syncpointOnly">True if the sync action should only run when syncpoints are incremented</param>
- public void RegisterSyncAction(Action action, bool syncpointOnly = false)
+ internal void RegisterSyncAction(ISyncActionHandler action, bool syncpointOnly = false)
{
if (syncpointOnly)
{
@@ -315,10 +315,13 @@ namespace Ryujinx.Graphics.Gpu
/// Creates a host sync object if there are any pending sync actions. The actions will then be called.
/// If no actions are present, a host sync object is not created.
/// </summary>
- /// <param name="syncpoint">True if host sync is being created by a syncpoint</param>
- /// <param name="strict">True if the sync should signal as soon as possible</param>
- public void CreateHostSyncIfNeeded(bool syncpoint, bool strict)
+ /// <param name="flags">Modifiers for how host sync should be created</param>
+ internal void CreateHostSyncIfNeeded(HostSyncFlags flags)
{
+ bool syncpoint = flags.HasFlag(HostSyncFlags.Syncpoint);
+ bool strict = flags.HasFlag(HostSyncFlags.Strict);
+ bool force = flags.HasFlag(HostSyncFlags.Force);
+
if (BufferMigrations.Count > 0)
{
ulong currentSyncNumber = Renderer.GetCurrentSync();
@@ -336,24 +339,17 @@ namespace Ryujinx.Graphics.Gpu
}
}
- if (_pendingSync || (syncpoint && SyncpointActions.Count > 0))
+ if (force || _pendingSync || (syncpoint && SyncpointActions.Count > 0))
{
Renderer.CreateSync(SyncNumber, strict);
- SyncNumber++;
-
- foreach (Action action in SyncActions)
- {
- action();
- }
+ SyncActions.ForEach(action => action.SyncPreAction(syncpoint));
+ SyncpointActions.ForEach(action => action.SyncPreAction(syncpoint));
- foreach (Action action in SyncpointActions)
- {
- action();
- }
+ SyncNumber++;
- SyncActions.Clear();
- SyncpointActions.Clear();
+ SyncActions.RemoveAll(action => action.SyncAction(syncpoint));
+ SyncpointActions.RemoveAll(action => action.SyncAction(syncpoint));
}
_pendingSync = false;