Memory Changes part 2 (ryubing/ryujinx!123)

See merge request ryubing/ryujinx!123
This commit is contained in:
LotP
2025-08-25 17:44:15 -05:00
parent d499449f57
commit 50ab108ee1
90 changed files with 2133 additions and 1159 deletions

View File

@@ -242,22 +242,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <param name="rhs">Second struct</param>
/// <returns>True if equal, false otherwise</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool UnsafeEquals32Byte<T>(ref T lhs, ref T rhs) where T : unmanaged
private static bool UnsafeEquals32Byte<T>(Span<T> lhs, Span<T> rhs) where T : unmanaged
{
if (Vector256.IsHardwareAccelerated)
{
return Vector256.EqualsAll(
Unsafe.As<T, Vector256<uint>>(ref lhs),
Unsafe.As<T, Vector256<uint>>(ref rhs)
Unsafe.As<Span<T>, ReadOnlySpan<Vector256<uint>>>(ref lhs)[0],
Unsafe.As<Span<T>, ReadOnlySpan<Vector256<uint>>>(ref rhs)[0]
);
}
else
{
ref Vector128<uint> lhsVec = ref Unsafe.As<T, Vector128<uint>>(ref lhs);
ref Vector128<uint> rhsVec = ref Unsafe.As<T, Vector128<uint>>(ref rhs);
ReadOnlySpan<Vector128<uint>> lhsVec = Unsafe.As<Span<T>, ReadOnlySpan<Vector128<uint>>>(ref lhs);
ReadOnlySpan<Vector128<uint>> rhsVec = Unsafe.As<Span<T>, ReadOnlySpan<Vector128<uint>>>(ref rhs);
return Vector128.EqualsAll(lhsVec, rhsVec) &&
Vector128.EqualsAll(Unsafe.Add(ref lhsVec, 1), Unsafe.Add(ref rhsVec, 1));
return Vector128.EqualsAll(lhsVec[0], rhsVec[0]) &&
Vector128.EqualsAll(lhsVec[1], rhsVec[1]);
}
}
@@ -265,26 +265,26 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Updates blend enable. Respects current shadow mode.
/// </summary>
/// <param name="masks">Blend enable</param>
public void UpdateBlendEnable(ref Array8<Boolean32> enable)
public void UpdateBlendEnable(Span<Boolean32> enable)
{
SetMmeShadowRamControlMode shadow = ShadowMode;
ref Array8<Boolean32> state = ref _state.State.BlendEnable;
Span<Boolean32> state = _state.State.BlendEnable.AsSpan();
if (shadow.IsReplay())
{
enable = _state.ShadowState.BlendEnable;
state.CopyTo(enable);
}
if (!UnsafeEquals32Byte(ref enable, ref state))
if (!UnsafeEquals32Byte(enable, state))
{
state = enable;
enable.CopyTo(state);
_stateUpdater.ForceDirty(StateUpdater.BlendStateIndex);
}
if (shadow.IsTrack())
{
_state.ShadowState.BlendEnable = enable;
enable.CopyTo(state);
}
}
@@ -292,26 +292,26 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Updates color masks. Respects current shadow mode.
/// </summary>
/// <param name="masks">Color masks</param>
public void UpdateColorMasks(ref Array8<RtColorMask> masks)
public void UpdateColorMasks(Span<RtColorMask> masks)
{
SetMmeShadowRamControlMode shadow = ShadowMode;
ref Array8<RtColorMask> state = ref _state.State.RtColorMask;
Span<RtColorMask> state = _state.State.RtColorMask.AsSpan();
if (shadow.IsReplay())
{
masks = _state.ShadowState.RtColorMask;
state.CopyTo(masks);
}
if (!UnsafeEquals32Byte(ref masks, ref state))
if (!UnsafeEquals32Byte(masks, state))
{
state = masks;
masks.CopyTo(state);
_stateUpdater.ForceDirty(StateUpdater.RtColorMaskIndex);
}
if (shadow.IsTrack())
{
_state.ShadowState.RtColorMask = masks;
masks.CopyTo(state);
}
}