diff options
author | riperiperi <rhy3756547@hotmail.com> | 2023-05-01 20:05:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 16:05:12 -0300 |
commit | e18d258fa09379f31ca4310fbbe9e1869581d49f (patch) | |
tree | c8427df586f4385feef9b8d201a648aeb2afec1b /src/Ryujinx.Graphics.Gpu/GpuContext.cs | |
parent | 36f10df775cf0c678548b97346432095823dfd8a (diff) |
GPU: Pre-emptively flush textures that are flushed often (to imported memory when available) (#4711)1.1.741
* WIP texture pre-flush
Improve performance of TextureView GetData to buffer
Fix copy/sync ordering
Fix minor bug
Make this actually work
WIP host mapping stuff
* Fix usage flags
* message
* Cleanup 1
* Fix rebase
* Fix
* Improve pre-flush rules
* Fix pre-flush
* A lot of cleanup
* Use the host memory bits
* Select the correct memory type
* Cleanup TextureGroupHandle
* Missing comment
* Remove debugging logs
* Revert BufferHandle _value access modifier
* One interrupt action at a time.
* Support D32S8 to D24S8 conversion, safeguards
* Interrupt cannot happen in sync handle's lock
Waitable needs to be checked twice now, but this should stop it from deadlocking.
* Remove unused using
* Address some feedback
* Address feedback
* Address more feedback
* Address more feedback
* Improve sync rules
Should allow for faster sync in some cases.
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/GpuContext.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/GpuContext.cs | 40 |
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; |