Add XML documentation to Ryujinx.Graphics.Gpu.Image

This commit is contained in:
gdkchan 2019-12-29 20:26:37 -03:00 committed by Thog
parent 53bbc1311f
commit 32764f9560
24 changed files with 1133 additions and 61 deletions

View file

@ -7,17 +7,31 @@ using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Image
{
/// <summary>
/// Texture pool.
/// </summary>
class TexturePool : Pool<Texture>
{
public LinkedListNode<TexturePool> CacheNode { get; set; }
private int _sequenceNumber;
public TexturePool(
GpuContext context,
ulong address,
int maximumId) : base(context, address, maximumId) { }
/// <summary>
/// Intrusive linked list node used on the texture pool cache.
/// </summary>
public LinkedListNode<TexturePool> CacheNode { get; set; }
/// <summary>
/// Constructs a new instance of the texture pool.
/// </summary>
/// <param name="context">GPU context that the texture pool belongs to</param>
/// <param name="address">Address of the texture pool in guest memory</param>
/// <param name="maximumId">Maximum texture ID of the texture pool (equal to maximum textures minus one)</param>
public TexturePool(GpuContext context, ulong address, int maximumId) : base(context, address, maximumId) { }
/// <summary>
/// Gets the texture with the given ID.
/// </summary>
/// <param name="id">ID of the texture. This is effectively a zero-based index</param>
/// <returns>The texture with the given ID</returns>
public override Texture Get(int id)
{
if ((uint)id >= Items.Length)
@ -62,6 +76,11 @@ namespace Ryujinx.Graphics.Gpu.Image
return texture;
}
/// <summary>
/// Gets the texture descriptor from a given texture ID.
/// </summary>
/// <param name="id">ID of the texture. This is effectively a zero-based index</param>
/// <returns>The texture descriptor</returns>
public TextureDescriptor GetDescriptor(int id)
{
ulong address = Address + (ulong)(uint)id * DescriptorSize;
@ -71,6 +90,11 @@ namespace Ryujinx.Graphics.Gpu.Image
return MemoryMarshal.Cast<byte, TextureDescriptor>(data)[0];
}
/// <summary>
/// Implementation of the texture pool range invalidation.
/// </summary>
/// <param name="address">Start address of the range of the texture pool</param>
/// <param name="size">Size of the range being invalidated</param>
protected override void InvalidateRangeImpl(ulong address, ulong size)
{
ulong endAddress = address + size;
@ -101,6 +125,11 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
/// <summary>
/// Gets texture information from a texture descriptor.
/// </summary>
/// <param name="descriptor">The texture descriptor</param>
/// <returns>The texture information</returns>
private TextureInfo GetInfo(TextureDescriptor descriptor)
{
ulong address = Context.MemoryManager.Translate(descriptor.UnpackAddress());
@ -172,6 +201,13 @@ namespace Ryujinx.Graphics.Gpu.Image
swizzleA);
}
/// <summary>
/// Gets the texture depth-stencil mode, based on the swizzle components of each color channel.
/// The depth-stencil mode is determined based on how the driver sets those parameters.
/// </summary>
/// <param name="format">The format of the texture</param>
/// <param name="components">The texture swizzle components</param>
/// <returns>The depth-stencil mode</returns>
private static DepthStencilMode GetDepthStencilMode(Format format, params SwizzleComponent[] components)
{
// R = Depth, G = Stencil.
@ -205,12 +241,22 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
/// <summary>
/// Checks if the swizzle component is equal to the red or green channels.
/// </summary>
/// <param name="component">The swizzle component to check</param>
/// <returns>True if the swizzle component is equal to the red or blue, false otherwise</returns>
private static bool IsRG(SwizzleComponent component)
{
return component == SwizzleComponent.Red ||
component == SwizzleComponent.Green;
}
/// <summary>
/// Decrements the reference count of the texture.
/// This indicates that the texture pool is not using it anymore.
/// </summary>
/// <param name="item">The texture to be deleted</param>
protected override void Delete(Texture item)
{
item?.DecrementReferenceCount();