Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU: Remove CPU region handle containers #4817

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ARMeilleure.Memory;
using Ryujinx.Cpu.Tracking;
using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
Expand Down Expand Up @@ -822,21 +821,21 @@ public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection)
}

/// <inheritdoc/>
public CpuRegionHandle BeginTracking(ulong address, ulong size, int id)
public RegionHandle BeginTracking(ulong address, ulong size, int id)
{
return new CpuRegionHandle(Tracking.BeginTracking(address, size, id));
return Tracking.BeginTracking(address, size, id);
}

/// <inheritdoc/>
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
{
return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id));
return Tracking.BeginGranularTracking(address, size, handles, granularity, id);
}

/// <inheritdoc/>
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
{
return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id));
return Tracking.BeginSmartGranularTracking(address, size, granularity, id);
}

/// <summary>
Expand Down
9 changes: 4 additions & 5 deletions src/Ryujinx.Cpu/IVirtualMemoryManagerTracked.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Ryujinx.Cpu.Tracking;
using Ryujinx.Memory;
using Ryujinx.Memory;
using Ryujinx.Memory.Tracking;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -30,7 +29,7 @@ public interface IVirtualMemoryManagerTracked : IVirtualMemoryManager
/// <param name="size">Size of the region</param>
/// <param name="id">Handle ID</param>
/// <returns>The memory tracking handle</returns>
CpuRegionHandle BeginTracking(ulong address, ulong size, int id);
RegionHandle BeginTracking(ulong address, ulong size, int id);

/// <summary>
/// Obtains a memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with.
Expand All @@ -41,7 +40,7 @@ public interface IVirtualMemoryManagerTracked : IVirtualMemoryManager
/// <param name="granularity">Desired granularity of write tracking</param>
/// <param name="id">Handle ID</param>
/// <returns>The memory tracking handle</returns>
CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id);
MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id);

/// <summary>
/// Obtains a smart memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with.
Expand All @@ -51,6 +50,6 @@ public interface IVirtualMemoryManagerTracked : IVirtualMemoryManager
/// <param name="granularity">Desired granularity of write tracking</param>
/// <param name="id">Handle ID</param>
/// <returns>The memory tracking handle</returns>
CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id);
SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id);
}
}
13 changes: 6 additions & 7 deletions src/Ryujinx.Cpu/Jit/MemoryManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ARMeilleure.Memory;
using Ryujinx.Cpu.Tracking;
using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
Expand Down Expand Up @@ -629,21 +628,21 @@ public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection)
}

/// <inheritdoc/>
public CpuRegionHandle BeginTracking(ulong address, ulong size, int id)
public RegionHandle BeginTracking(ulong address, ulong size, int id)
{
return new CpuRegionHandle(Tracking.BeginTracking(address, size, id));
return Tracking.BeginTracking(address, size, id);
}

/// <inheritdoc/>
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
{
return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id));
return Tracking.BeginGranularTracking(address, size, handles, granularity, id);
}

/// <inheritdoc/>
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
{
return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id));
return Tracking.BeginSmartGranularTracking(address, size, granularity, id);
}

/// <inheritdoc/>
Expand Down
13 changes: 6 additions & 7 deletions src/Ryujinx.Cpu/Jit/MemoryManagerHostMapped.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ARMeilleure.Memory;
using Ryujinx.Cpu.Tracking;
using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
Expand Down Expand Up @@ -706,21 +705,21 @@ public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection)
}

/// <inheritdoc/>
public CpuRegionHandle BeginTracking(ulong address, ulong size, int id)
public RegionHandle BeginTracking(ulong address, ulong size, int id)
{
return new CpuRegionHandle(Tracking.BeginTracking(address, size, id));
return Tracking.BeginTracking(address, size, id);
}

/// <inheritdoc/>
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
{
return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id));
return Tracking.BeginGranularTracking(address, size, handles, granularity, id);
}

/// <inheritdoc/>
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
{
return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id));
return Tracking.BeginSmartGranularTracking(address, size, granularity, id);
}

/// <summary>
Expand Down
28 changes: 0 additions & 28 deletions src/Ryujinx.Cpu/Tracking/CpuMultiRegionHandle.cs

This file was deleted.

37 changes: 0 additions & 37 deletions src/Ryujinx.Cpu/Tracking/CpuRegionHandle.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Ryujinx.Cpu/Tracking/CpuSmartMultiRegionHandle.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Ryujinx.Graphics.Gpu/Image/Pool.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Ryujinx.Cpu.Tracking;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Memory.Tracking;
using System;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -40,7 +40,7 @@ abstract class Pool<T1, T2> : IDisposable where T2 : unmanaged
/// </summary>
public ulong Size { get; }

private readonly CpuMultiRegionHandle _memoryTracking;
private readonly MultiRegionHandle _memoryTracking;
private readonly Action<ulong, ulong> _modifiedDelegate;

private int _modifiedSequenceOffset;
Expand Down
22 changes: 11 additions & 11 deletions src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Ryujinx.Common.Memory;
using Ryujinx.Cpu.Tracking;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Texture;
using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -255,7 +255,7 @@ public bool CheckDirty(Texture texture, bool consume)
{
TextureGroupHandle group = _handles[baseHandle + i];

foreach (CpuRegionHandle handle in group.Handles)
foreach (RegionHandle handle in group.Handles)
{
if (handle.Dirty)
{
Expand Down Expand Up @@ -296,7 +296,7 @@ public void SynchronizeMemory(Texture texture)
bool handleDirty = false;
bool handleUnmapped = false;

foreach (CpuRegionHandle handle in group.Handles)
foreach (RegionHandle handle in group.Handles)
{
if (handle.Dirty)
{
Expand Down Expand Up @@ -703,7 +703,7 @@ public void SignalModifying(Texture texture, bool bound)
/// <param name="group">The group to register an action for</param>
public void RegisterAction(TextureGroupHandle group)
{
foreach (CpuRegionHandle handle in group.Handles)
foreach (RegionHandle handle in group.Handles)
{
handle.RegisterAction((address, size) => FlushAction(group, address, size));
}
Expand Down Expand Up @@ -985,7 +985,7 @@ private void DirtyAction(TextureGroupHandle groupHandle)
/// <param name="address">The start address of the tracked region</param>
/// <param name="size">The size of the tracked region</param>
/// <returns>A CpuRegionHandle covering the given range</returns>
private CpuRegionHandle GenerateHandle(ulong address, ulong size)
private RegionHandle GenerateHandle(ulong address, ulong size)
{
return _physicalMemory.BeginTracking(address, size, ResourceKind.Texture);
}
Expand All @@ -1005,7 +1005,7 @@ private TextureGroupHandle GenerateHandles(int viewStart, int views)
int endOffset = _allOffsets[viewEnd] + _sliceSizes[lastLevel];
int size = endOffset - offset;

var result = new List<CpuRegionHandle>();
var result = new List<RegionHandle>();

for (int i = 0; i < TextureRange.Count; i++)
{
Expand Down Expand Up @@ -1050,7 +1050,7 @@ private TextureGroupHandle GenerateHandles(int viewStart, int views)
views,
result.ToArray());

foreach (CpuRegionHandle handle in result)
foreach (RegionHandle handle in result)
{
handle.RegisterDirtyEvent(() => DirtyAction(groupHandle));
}
Expand Down Expand Up @@ -1248,7 +1248,7 @@ private void ReplaceHandles(TextureGroupHandle[] handles, bool rangeChanged)
continue;
}

foreach (CpuRegionHandle handle in groupHandle.Handles)
foreach (RegionHandle handle in groupHandle.Handles)
{
bool hasMatch = false;

Expand All @@ -1270,7 +1270,7 @@ private void ReplaceHandles(TextureGroupHandle[] handles, bool rangeChanged)
}
else
{
foreach (CpuRegionHandle handle in groupHandle.Handles)
foreach (RegionHandle handle in groupHandle.Handles)
{
handle.Reprotect();
}
Expand Down Expand Up @@ -1303,7 +1303,7 @@ private void RecalculateHandleRegions(bool rangeChanged = false)
if (!(_hasMipViews || _hasLayerViews))
{
// Single dirty region.
var cpuRegionHandles = new CpuRegionHandle[TextureRange.Count];
var cpuRegionHandles = new RegionHandle[TextureRange.Count];
int count = 0;

for (int i = 0; i < TextureRange.Count; i++)
Expand All @@ -1322,7 +1322,7 @@ private void RecalculateHandleRegions(bool rangeChanged = false)

var groupHandle = new TextureGroupHandle(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles);

foreach (CpuRegionHandle handle in cpuRegionHandles)
foreach (RegionHandle handle in cpuRegionHandles)
{
handle.RegisterDirtyEvent(() => DirtyAction(groupHandle));
}
Expand Down
10 changes: 5 additions & 5 deletions src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Ryujinx.Cpu.Tracking;
using Ryujinx.Graphics.Gpu.Synchronization;
using Ryujinx.Graphics.Gpu.Synchronization;
using Ryujinx.Memory.Tracking;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -85,7 +85,7 @@ class TextureGroupHandle : ISyncActionHandler, IDisposable
/// <summary>
/// The CPU memory tracking handles that cover this handle.
/// </summary>
public CpuRegionHandle[] Handles { get; }
public RegionHandle[] Handles { get; }

/// <summary>
/// True if a texture overlapping this handle has been modified. Is set false when the flush action is called.
Expand Down Expand Up @@ -127,7 +127,7 @@ class TextureGroupHandle : ISyncActionHandler, IDisposable
int firstLevel,
int baseSlice,
int sliceCount,
CpuRegionHandle[] handles)
RegionHandle[] handles)
{
_group = group;
_firstLayer = firstLayer;
Expand Down Expand Up @@ -642,7 +642,7 @@ public bool OverlapsWith(int offset, int size)
/// </summary>
public void Dispose()
{
foreach (CpuRegionHandle handle in Handles)
foreach (RegionHandle handle in Handles)
{
handle.Dispose();
}
Expand Down