diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2022-01-09 16:28:48 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-09 13:28:48 -0300 |
| commit | cda659955ced1b16839cdd1e7fea1ef6f8d99041 (patch) | |
| tree | 41d0d7a705f9feb7b43c9e5bac14dafee7878220 /Ryujinx.Graphics.Gpu/GpuContext.cs | |
| parent | 4864648e727c6f526e3b65478f222c15468f6074 (diff) | |
Texture Sync, incompatible overlap handling, data flush improvements. (#2971)
* Initial test for texture sync
* WIP new texture flushing setup
* Improve rules for incompatible overlaps
Fixes a lot of issues with Unreal Engine games. Still a few minor issues (some caused by dma fast path?) Needs docs and cleanup.
* Cleanup, improvements
Improve rules for fast DMA
* Small tweak to group together flushes of overlapping handles.
* Fixes, flush overlapping texture data for ASTC and BC4/5 compressed textures.
Fixes the new Life is Strange game.
* Flush overlaps before init data, fix 3d texture size/overlap stuff
* Fix 3D Textures, faster single layer flush
Note: nosy people can no longer merge this with Vulkan. (unless they are nosy enough to implement the new backend methods)
* Remove unused method
* Minor cleanup
* More cleanup
* Use the More Fun and Hopefully No Driver Bugs method for getting compressed tex too
This one's for metro
* Address feedback, ASTC+ETC to FormatClass
* Change offset to use Span slice rather than IntPtr Add
* Fix this too
Diffstat (limited to 'Ryujinx.Graphics.Gpu/GpuContext.cs')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/GpuContext.cs | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.Gpu/GpuContext.cs b/Ryujinx.Graphics.Gpu/GpuContext.cs index 034c8fcb..5c9af383 100644 --- a/Ryujinx.Graphics.Gpu/GpuContext.cs +++ b/Ryujinx.Graphics.Gpu/GpuContext.cs @@ -52,13 +52,20 @@ namespace Ryujinx.Graphics.Gpu internal ulong SyncNumber { get; private set; } /// <summary> - /// Actions to be performed when a CPU waiting sync point is triggered. + /// Actions to be performed when a CPU waiting syncpoint or barrier 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> 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; } + + /// <summary> /// Queue with deferred actions that must run on the render thread. /// </summary> internal Queue<Action> DeferredActions { get; } @@ -79,6 +86,7 @@ namespace Ryujinx.Graphics.Gpu public event Action<ShaderCacheState, int, int> ShaderCacheStateChanged; private readonly Lazy<Capabilities> _caps; + private Thread _gpuThread; /// <summary> /// Creates a new instance of the GPU emulation context. @@ -97,6 +105,7 @@ namespace Ryujinx.Graphics.Gpu HostInitalized = new ManualResetEvent(false); SyncActions = new List<Action>(); + SyncpointActions = new List<Action>(); DeferredActions = new Queue<Action>(); @@ -185,6 +194,23 @@ namespace Ryujinx.Graphics.Gpu } /// <summary> + /// Sets the current thread as the main GPU thread. + /// </summary> + public void SetGpuThread() + { + _gpuThread = Thread.CurrentThread; + } + + /// <summary> + /// Checks if the current thread is the GPU thread. + /// </summary> + /// <returns>True if the thread is the GPU thread, false otherwise</returns> + public bool IsGpuThread() + { + return _gpuThread == Thread.CurrentThread; + } + + /// <summary> /// Processes the queue of shaders that must save their binaries to the disk cache. /// </summary> public void ProcessShaderCacheQueue() @@ -209,18 +235,27 @@ namespace Ryujinx.Graphics.Gpu /// 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> - public void RegisterSyncAction(Action action) + /// <param name="syncpointOnly">True if the sync action should only run when syncpoints are incremented</param> + public void RegisterSyncAction(Action action, bool syncpointOnly = false) { - SyncActions.Add(action); + if (syncpointOnly) + { + SyncpointActions.Add(action); + } + else + { + SyncActions.Add(action); + } } /// <summary> /// 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> - public void CreateHostSyncIfNeeded() + /// <param name="syncpoint">True if host sync is being created by a syncpoint</param> + public void CreateHostSyncIfNeeded(bool syncpoint) { - if (SyncActions.Count > 0) + if (SyncActions.Count > 0 || (syncpoint && SyncpointActions.Count > 0)) { Renderer.CreateSync(SyncNumber); @@ -231,7 +266,13 @@ namespace Ryujinx.Graphics.Gpu action(); } + foreach (Action action in SyncpointActions) + { + action(); + } + SyncActions.Clear(); + SyncpointActions.Clear(); } } |
