From e58b540c4e2a8df460e0e357e3f341842dd59a71 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 31 Dec 2019 00:22:58 -0300 Subject: Add XML documentation to Ryujinx.Graphics.Gpu.Memory --- Ryujinx.Graphics.Gpu/Memory/RangeList.cs | 82 +++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Memory/RangeList.cs') diff --git a/Ryujinx.Graphics.Gpu/Memory/RangeList.cs b/Ryujinx.Graphics.Gpu/Memory/RangeList.cs index 45f23cf3..52bcf9b4 100644 --- a/Ryujinx.Graphics.Gpu/Memory/RangeList.cs +++ b/Ryujinx.Graphics.Gpu/Memory/RangeList.cs @@ -3,17 +3,28 @@ using System.Collections.Generic; namespace Ryujinx.Graphics.Gpu.Memory { + /// + /// Lists of GPU resources with data on guest memory. + /// + /// Type of the GPU resource class RangeList where T : IRange { private const int ArrayGrowthSize = 32; private List _items; + /// + /// Creates a new GPU resources list. + /// public RangeList() { _items = new List(); } + /// + /// Adds a new item to the list. + /// + /// The item to be added public void Add(T item) { int index = BinarySearch(item.Address); @@ -26,6 +37,11 @@ namespace Ryujinx.Graphics.Gpu.Memory _items.Insert(index, item); } + /// + /// Removes a item from the list. + /// + /// The item to be removed + /// True if the item was removed, or false if it was not found public bool Remove(T item) { int index = BinarySearch(item.Address); @@ -58,11 +74,26 @@ namespace Ryujinx.Graphics.Gpu.Memory return false; } + /// + /// Gets the first item on the list overlapping in memory with the specified item. + /// Despite the name, this has no ordering guarantees of the returned item. + /// It only ensures that the item returned overlaps the specified item. + /// + /// Item to check for overlaps + /// The overlapping item, or the default value for the type if none found public T FindFirstOverlap(T item) { return FindFirstOverlap(item.Address, item.Size); } + /// + /// Gets the first item on the list overlapping the specified memory range. + /// Despite the name, this has no ordering guarantees of the returned item. + /// It only ensures that the item returned overlaps the specified memory range. + /// + /// Start address of the range + /// Size in bytes or the rangee + /// The overlapping item, or the default value for the type if none found public T FindFirstOverlap(ulong address, ulong size) { int index = BinarySearch(address, size); @@ -75,11 +106,24 @@ namespace Ryujinx.Graphics.Gpu.Memory return _items[index]; } + /// + /// Gets all items overlapping with the specified item in memory. + /// + /// Item to check for overlaps + /// Output array where matches will be written. It is automatically resized to fit the results + /// The number of overlapping items found public int FindOverlaps(T item, ref T[] output) { return FindOverlaps(item.Address, item.Size, ref output); } + /// + /// Gets all items on the list overlapping the specified memory range. + /// + /// Start address of the range + /// Size in bytes or the rangee + /// Output array where matches will be written. It is automatically resized to fit the results + /// The number of overlapping items found public int FindOverlaps(ulong address, ulong size, ref T[] output) { int outputIndex = 0; @@ -110,19 +154,36 @@ namespace Ryujinx.Graphics.Gpu.Memory return outputIndex; } + /// + /// Gets all items overlapping with the specified item in memory. + /// This method only returns correct results if none of the items on the list overlaps with + /// each other. If that is not the case, this method should not be used. + /// This method is faster than the regular method to find all overlaps. + /// + /// Item to check for overlaps + /// Output array where matches will be written. It is automatically resized to fit the results + /// The number of overlapping items found public int FindOverlapsNonOverlapping(T item, ref T[] output) { return FindOverlapsNonOverlapping(item.Address, item.Size, ref output); } + /// + /// Gets all items on the list overlapping the specified memory range. + /// This method only returns correct results if none of the items on the list overlaps with + /// each other. If that is not the case, this method should not be used. + /// This method is faster than the regular method to find all overlaps. + /// + /// Start address of the range + /// Size in bytes or the rangee + /// Output array where matches will be written. It is automatically resized to fit the results + /// The number of overlapping items found public int FindOverlapsNonOverlapping(ulong address, ulong size, ref T[] output) { // This is a bit faster than FindOverlaps, but only works // when none of the items on the list overlaps with each other. int outputIndex = 0; - ulong endAddress = address + size; - int index = BinarySearch(address, size); if (index >= 0) @@ -147,6 +208,12 @@ namespace Ryujinx.Graphics.Gpu.Memory return outputIndex; } + /// + /// Gets all items on the list with the specified memory address. + /// + /// Address to find + /// Output array where matches will be written. It is automatically resized to fit the results + /// The number of matches found public int FindOverlaps(ulong address, ref T[] output) { int index = BinarySearch(address); @@ -181,6 +248,11 @@ namespace Ryujinx.Graphics.Gpu.Memory return outputIndex; } + /// + /// Performs binary search on the internal list of items. + /// + /// Address to find + /// List index of the item, or complement index of nearest item with lower value on the list private int BinarySearch(ulong address) { int left = 0; @@ -212,6 +284,12 @@ namespace Ryujinx.Graphics.Gpu.Memory return ~left; } + /// + /// Performs binary search for items overlapping a given memory range. + /// + /// Start address of the range + /// Size of the range in bytes + /// List index of the item, or complement index of nearest item with lower value on the list private int BinarySearch(ulong address, ulong size) { int left = 0; -- cgit v1.2.3