From 2c0977f6b33fdf58660c6b3dfdfece45378bc310 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 (ryubing/ryujinx!236)
See merge request ryubing/ryujinx!236
---
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 8b1277c47..7ee32e83d 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -404,9 +404,12 @@ namespace Ryujinx.Graphics.Gpu
if (force || _pendingSync || (syncPoint && SyncpointActions.Count > 0))
{
- foreach (ISyncActionHandler action in SyncActions)
+ for (int i = 0; i < SyncActions.Count; i++)
{
- action.SyncPreAction(syncPoint);
+ if (SyncActions[i].SyncPreAction(syncPoint))
+ {
+ SyncActions.RemoveAt(i--);
+ }
}
foreach (ISyncActionHandler 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 f04576c2a..3bf02f54d 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; }
}
}