From 9920619ff6434ed950a9fe0067f8734e04a448eb Mon Sep 17 00:00:00 2001
From: LotP <22-lotp@users.noreply.git.ryujinx.app>
Date: Fri, 12 Dec 2025 14:28:54 -0600
Subject: [PATCH] fix pre-action crash
if a buffer is inherited, ignore it and remove it from the list.
fixes a crash when a buffer is inherited during a sync and the containing ranges have been modified to not fit in the old buffer.
---
src/Ryujinx.Graphics.Gpu/GpuContext.cs | 7 +++++--
src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs | 4 +++-
src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs | 11 +++++++++--
.../Synchronization/ISyncActionHandler.cs | 2 +-
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
index 17b554bc2..2eee73784 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -394,9 +394,12 @@ namespace Ryujinx.Graphics.Gpu
if (force || _pendingSync || (syncPoint && SyncpointActions.Count > 0))
{
- foreach (var action in SyncActions)
+ for (int i = 0; i < SyncActions.Count; i++)
{
- action.SyncPreAction(syncPoint);
+ if (SyncActions[i].SyncPreAction(syncPoint))
+ {
+ SyncActions.RemoveAt(i--);
+ }
}
foreach (var action in SyncpointActions)
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
index fe22b9e63..1f2ee1a47 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
@@ -411,7 +411,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// flushes often enough, which is determined by the flush balance.
///
///
- public void SyncPreAction(bool syncpoint)
+ public bool SyncPreAction(bool syncpoint)
{
if (syncpoint || NextSyncCopies())
{
@@ -421,6 +421,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_registeredBufferSync = _modifiedSync;
}
}
+
+ return true;
}
///
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index 46cad3e77..16fdb87d7 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -393,11 +393,16 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// This will copy any buffer ranges designated for pre-flushing.
///
/// True if the action is a guest syncpoint
- public void SyncPreAction(bool syncpoint)
+ public bool SyncPreAction(bool syncpoint)
{
+ if (_bufferInherited)
+ {
+ return true;
+ }
+
if (_referenceCount == 0)
{
- return;
+ return false;
}
if (BackingState.ShouldChangeBacking())
@@ -414,6 +419,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
_modifiedRanges?.GetRangesAtSync(Address, Size, _context.SyncNumber, _syncPreRangeAction);
}
}
+
+ return false;
}
void SyncPreRangeAction(ulong address, ulong size)
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/ISyncActionHandler.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/ISyncActionHandler.cs
index d470d2f07..b26ed8ad7 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/ISyncActionHandler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/ISyncActionHandler.cs
@@ -17,6 +17,6 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
/// Action to be performed immediately before sync is created.
///
/// True if the action is a guest syncpoint
- void SyncPreAction(bool syncpoint) { }
+ bool SyncPreAction(bool syncpoint) { return true; }
}
}