Revert "misc: chore: Remove redundant code"

This reverts commit 05a88ccc94.
This commit is contained in:
KeatonTheBot 2025-03-15 20:00:22 -05:00
parent 7960ea643f
commit efd5a104b6
109 changed files with 412 additions and 271 deletions

View file

@ -6,7 +6,7 @@ using System.Linq;
namespace Ryujinx.Graphics.Vulkan
{
class SyncManager(VulkanRenderer gd, Device device)
class SyncManager
{
private class SyncHandle
{
@ -23,10 +23,19 @@ namespace Ryujinx.Graphics.Vulkan
private ulong _firstHandle;
private readonly List<SyncHandle> _handles = [];
private readonly VulkanRenderer _gd;
private readonly Device _device;
private readonly List<SyncHandle> _handles;
private ulong _flushId;
private long _waitTicks;
public SyncManager(VulkanRenderer gd, Device device)
{
_gd = gd;
_device = device;
_handles = [];
}
public void RegisterFlush()
{
_flushId++;
@ -36,17 +45,17 @@ namespace Ryujinx.Graphics.Vulkan
{
ulong flushId = _flushId;
MultiFenceHolder waitable = new();
if (strict || gd.InterruptAction == null)
if (strict || _gd.InterruptAction == null)
{
gd.FlushAllCommands();
gd.CommandBufferPool.AddWaitable(waitable);
_gd.FlushAllCommands();
_gd.CommandBufferPool.AddWaitable(waitable);
}
else
{
// Don't flush commands, instead wait for the current command buffer to finish.
// If this sync is waited on before the command buffer is submitted, interrupt the gpu thread and flush it manually.
gd.CommandBufferPool.AddInUseWaitable(waitable);
_gd.CommandBufferPool.AddInUseWaitable(waitable);
}
SyncHandle handle = new()
@ -79,7 +88,7 @@ namespace Ryujinx.Graphics.Vulkan
if (handle.ID > lastHandle)
{
bool signaled = handle.Signalled || handle.Waitable.WaitForFences(gd.Api, device, 0);
bool signaled = handle.Signalled || handle.Waitable.WaitForFences(_gd.Api, _device, 0);
if (signaled)
{
lastHandle = handle.ID;
@ -125,11 +134,11 @@ namespace Ryujinx.Graphics.Vulkan
if (result.NeedsFlush(_flushId))
{
gd.InterruptAction(() =>
_gd.InterruptAction(() =>
{
if (result.NeedsFlush(_flushId))
{
gd.FlushAllCommands();
_gd.FlushAllCommands();
}
});
}
@ -141,7 +150,7 @@ namespace Ryujinx.Graphics.Vulkan
return;
}
bool signaled = result.Signalled || result.Waitable.WaitForFences(gd.Api, device, 1000000000);
bool signaled = result.Signalled || result.Waitable.WaitForFences(_gd.Api, _device, 1000000000);
if (!signaled)
{
@ -173,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan
break;
}
bool signaled = first.Waitable.WaitForFences(gd.Api, device, 0);
bool signaled = first.Waitable.WaitForFences(_gd.Api, _device, 0);
if (signaled)
{
// Delete the sync object.