mirror of
https://github.com/Ryujinx-NX/Ryujinx.git
synced 2024-11-14 21:17:43 -07:00
Only flush commands when creating sync on Intel/AMD (windows) (#2165)
This commit is contained in:
parent
98ed81e4cd
commit
0d27802902
@ -34,6 +34,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
public static bool SupportsViewportSwizzle => _supportsViewportSwizzle.Value;
|
public static bool SupportsViewportSwizzle => _supportsViewportSwizzle.Value;
|
||||||
public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value;
|
public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value;
|
||||||
public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia;
|
public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia;
|
||||||
|
public static bool RequiresSyncFlush => _gpuVendor.Value == GpuVendor.Amd || _gpuVendor.Value == GpuVendor.Intel;
|
||||||
|
|
||||||
public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value;
|
public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value;
|
||||||
public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value;
|
public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value;
|
||||||
|
@ -15,8 +15,9 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ulong _firstHandle = 0;
|
private ulong _firstHandle = 0;
|
||||||
|
private ClientWaitSyncFlags _syncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit;
|
||||||
|
|
||||||
private List<SyncHandle> Handles = new List<SyncHandle>();
|
private List<SyncHandle> _handles = new List<SyncHandle>();
|
||||||
|
|
||||||
public void Create(ulong id)
|
public void Create(ulong id)
|
||||||
{
|
{
|
||||||
@ -26,12 +27,16 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
Handle = GL.FenceSync(SyncCondition.SyncGpuCommandsComplete, WaitSyncFlags.None)
|
Handle = GL.FenceSync(SyncCondition.SyncGpuCommandsComplete, WaitSyncFlags.None)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (HwCapabilities.RequiresSyncFlush)
|
||||||
|
{
|
||||||
// Force commands to flush up to the syncpoint.
|
// Force commands to flush up to the syncpoint.
|
||||||
GL.ClientWaitSync(handle.Handle, ClientWaitSyncFlags.SyncFlushCommandsBit, 0);
|
GL.ClientWaitSync(handle.Handle, ClientWaitSyncFlags.SyncFlushCommandsBit, 0);
|
||||||
|
}
|
||||||
|
|
||||||
lock (Handles)
|
lock (_handles)
|
||||||
{
|
{
|
||||||
Handles.Add(handle);
|
_handles.Add(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,14 +44,14 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
{
|
{
|
||||||
SyncHandle result = null;
|
SyncHandle result = null;
|
||||||
|
|
||||||
lock (Handles)
|
lock (_handles)
|
||||||
{
|
{
|
||||||
if ((long)(_firstHandle - id) > 0)
|
if ((long)(_firstHandle - id) > 0)
|
||||||
{
|
{
|
||||||
return; // The handle has already been signalled or deleted.
|
return; // The handle has already been signalled or deleted.
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SyncHandle handle in Handles)
|
foreach (SyncHandle handle in _handles)
|
||||||
{
|
{
|
||||||
if (handle.ID == id)
|
if (handle.ID == id)
|
||||||
{
|
{
|
||||||
@ -65,7 +70,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitSyncStatus syncResult = GL.ClientWaitSync(result.Handle, ClientWaitSyncFlags.None, 1000000000);
|
WaitSyncStatus syncResult = GL.ClientWaitSync(result.Handle, _syncFlags, 1000000000);
|
||||||
|
|
||||||
if (syncResult == WaitSyncStatus.TimeoutExpired)
|
if (syncResult == WaitSyncStatus.TimeoutExpired)
|
||||||
{
|
{
|
||||||
@ -82,24 +87,24 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
SyncHandle first = null;
|
SyncHandle first = null;
|
||||||
lock (Handles)
|
lock (_handles)
|
||||||
{
|
{
|
||||||
first = Handles.FirstOrDefault();
|
first = _handles.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first == null) break;
|
if (first == null) break;
|
||||||
|
|
||||||
WaitSyncStatus syncResult = GL.ClientWaitSync(first.Handle, ClientWaitSyncFlags.None, 0);
|
WaitSyncStatus syncResult = GL.ClientWaitSync(first.Handle, _syncFlags, 0);
|
||||||
|
|
||||||
if (syncResult == WaitSyncStatus.AlreadySignaled)
|
if (syncResult == WaitSyncStatus.AlreadySignaled)
|
||||||
{
|
{
|
||||||
// Delete the sync object.
|
// Delete the sync object.
|
||||||
lock (Handles)
|
lock (_handles)
|
||||||
{
|
{
|
||||||
lock (first)
|
lock (first)
|
||||||
{
|
{
|
||||||
_firstHandle = first.ID + 1;
|
_firstHandle = first.ID + 1;
|
||||||
Handles.RemoveAt(0);
|
_handles.RemoveAt(0);
|
||||||
GL.DeleteSync(first.Handle);
|
GL.DeleteSync(first.Handle);
|
||||||
first.Handle = IntPtr.Zero;
|
first.Handle = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
@ -114,9 +119,9 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
lock (Handles)
|
lock (_handles)
|
||||||
{
|
{
|
||||||
foreach (SyncHandle handle in Handles)
|
foreach (SyncHandle handle in _handles)
|
||||||
{
|
{
|
||||||
lock (handle)
|
lock (handle)
|
||||||
{
|
{
|
||||||
@ -125,7 +130,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Handles.Clear();
|
_handles.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user