aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Image/Pool.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-01-29 03:19:06 +0000
committerGitHub <noreply@github.com>2021-01-29 14:19:06 +1100
commitc30504e3b3bb64c44d993d6339f15ec6703a3c55 (patch)
tree91be94fc94dd52dcb8972f745559cf66f9dccb22 /Ryujinx.Graphics.Gpu/Image/Pool.cs
parent9eb0ab05c6e820e113b3c61cbacd9b085b2819c4 (diff)
Use a descriptor cache for faster pool invalidation. (#1977)
* Use a descriptor cache for faster pool invalidation. * Speed up comparison by casting to Vector256 Now we never need to worry about this ever again
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/Pool.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/Pool.cs26
1 files changed, 20 insertions, 6 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/Pool.cs b/Ryujinx.Graphics.Gpu/Image/Pool.cs
index c2c1a9a1..c5aef77f 100644
--- a/Ryujinx.Graphics.Gpu/Image/Pool.cs
+++ b/Ryujinx.Graphics.Gpu/Image/Pool.cs
@@ -8,14 +8,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary>
/// Represents a pool of GPU resources, such as samplers or textures.
/// </summary>
- /// <typeparam name="T">Type of the GPU resource</typeparam>
- abstract class Pool<T> : IDisposable
+ /// <typeparam name="T1">Type of the GPU resource</typeparam>
+ /// <typeparam name="T2">Type of the descriptor</typeparam>
+ abstract class Pool<T1, T2> : IDisposable where T2 : unmanaged
{
protected const int DescriptorSize = 0x20;
protected GpuContext Context;
- protected T[] Items;
+ protected T1[] Items;
+ protected T2[] DescriptorCache;
/// <summary>
/// The maximum ID value of resources on the pool (inclusive).
@@ -47,7 +49,8 @@ namespace Ryujinx.Graphics.Gpu.Image
ulong size = (ulong)(uint)count * DescriptorSize;
- Items = new T[count];
+ Items = new T1[count];
+ DescriptorCache = new T2[count];
Address = address;
Size = size;
@@ -56,12 +59,23 @@ namespace Ryujinx.Graphics.Gpu.Image
_modifiedDelegate = RegionModified;
}
+
+ /// <summary>
+ /// Gets the descriptor for a given ID.
+ /// </summary>
+ /// <param name="id">ID of the descriptor. This is effectively a zero-based index</param>
+ /// <returns>The descriptor</returns>
+ public T2 GetDescriptor(int id)
+ {
+ return Context.PhysicalMemory.Read<T2>(Address + (ulong)id * DescriptorSize);
+ }
+
/// <summary>
/// Gets the GPU resource with the given ID.
/// </summary>
/// <param name="id">ID of the resource. This is effectively a zero-based index</param>
/// <returns>The GPU resource with the given ID</returns>
- public abstract T Get(int id);
+ public abstract T1 Get(int id);
/// <summary>
/// Synchronizes host memory with guest memory.
@@ -97,7 +111,7 @@ namespace Ryujinx.Graphics.Gpu.Image
protected abstract void InvalidateRangeImpl(ulong address, ulong size);
- protected abstract void Delete(T item);
+ protected abstract void Delete(T1 item);
/// <summary>
/// Performs the disposal of all resources stored on the pool.