mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-20 04:05:46 +00:00
Memory Changes part 2 (ryubing/ryujinx!123)
See merge request ryubing/ryujinx!123
This commit is contained in:
@@ -72,7 +72,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
/// </summary>
|
||||
class BufferModifiedRangeList : NonOverlappingRangeList<BufferModifiedRange>
|
||||
{
|
||||
private new const int BackingInitialSize = 8;
|
||||
private const int BackingInitialSize = 8;
|
||||
|
||||
private readonly GpuContext _context;
|
||||
private readonly Buffer _parent;
|
||||
@@ -80,6 +80,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
private BufferMigration _source;
|
||||
private BufferModifiedRangeList _migrationTarget;
|
||||
|
||||
private List<RangeItem<BufferModifiedRange>> _overlaps;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the modified range list has any entries or not.
|
||||
@@ -106,6 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
_context = context;
|
||||
_parent = parent;
|
||||
_flushAction = flushAction;
|
||||
_overlaps = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -295,23 +298,24 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
/// <param name="rangeAction">The action to call for each modified range</param>
|
||||
public void GetRanges(ulong address, ulong size, Action<ulong, ulong> rangeAction)
|
||||
{
|
||||
List<RangeItem<BufferModifiedRange>> overlaps = [];
|
||||
|
||||
// We use the non-span method here because keeping the lock will cause a deadlock.
|
||||
Lock.EnterReadLock();
|
||||
|
||||
_overlaps.Clear();
|
||||
|
||||
(RangeItem<BufferModifiedRange> first, RangeItem<BufferModifiedRange> last) = FindOverlaps(address, size);
|
||||
|
||||
RangeItem<BufferModifiedRange> current = first;
|
||||
while (last != null && current != last.Next)
|
||||
{
|
||||
overlaps.Add(current);
|
||||
_overlaps.Add(current);
|
||||
current = current.Next;
|
||||
}
|
||||
Lock.ExitReadLock();
|
||||
|
||||
for (int i = 0; i < overlaps.Count; i++)
|
||||
for (int i = 0; i < _overlaps.Count; i++)
|
||||
{
|
||||
BufferModifiedRange overlap = overlaps[i].Value;
|
||||
BufferModifiedRange overlap = _overlaps[i].Value;
|
||||
rangeAction(overlap.Address, overlap.Size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static BufferStage FromUsage(BufferUsageFlags flags)
|
||||
{
|
||||
if (flags.HasFlag(BufferUsageFlags.Write))
|
||||
if ((flags & BufferUsageFlags.Write) == BufferUsageFlags.Write)
|
||||
{
|
||||
return BufferStage.StorageWrite;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static BufferStage FromUsage(TextureUsageFlags flags)
|
||||
{
|
||||
if (flags.HasFlag(TextureUsageFlags.ImageStore))
|
||||
if ((flags & TextureUsageFlags.ImageStore) == TextureUsageFlags.ImageStore)
|
||||
{
|
||||
return BufferStage.StorageWrite;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -104,9 +105,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
/// <param name="scale">Scale value</param>
|
||||
public void UpdateRenderScale(int index, float scale)
|
||||
{
|
||||
if (_data.RenderScale[1 + index].X != scale)
|
||||
Span<Vector4<float>> renderScaleSpan = _data.RenderScale.AsSpan();
|
||||
|
||||
if (renderScaleSpan[1 + index].X != scale)
|
||||
{
|
||||
_data.RenderScale[1 + index].X = scale;
|
||||
renderScaleSpan[1 + index].X = scale;
|
||||
DirtyRenderScale(1 + index, 1);
|
||||
}
|
||||
}
|
||||
@@ -133,11 +136,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
/// <param name="isBgra">True if the format is BGRA< false otherwise</param>
|
||||
public void SetRenderTargetIsBgra(int index, bool isBgra)
|
||||
{
|
||||
bool isBgraChanged = _data.FragmentIsBgra[index].X != 0 != isBgra;
|
||||
Span<Vector4<int>> fragmentIsBgraSpan = _data.FragmentIsBgra.AsSpan();
|
||||
|
||||
bool isBgraChanged = fragmentIsBgraSpan[index].X != 0 != isBgra;
|
||||
|
||||
if (isBgraChanged)
|
||||
{
|
||||
_data.FragmentIsBgra[index].X = isBgra ? 1 : 0;
|
||||
fragmentIsBgraSpan[index].X = isBgra ? 1 : 0;
|
||||
DirtyFragmentIsBgra(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user