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
This commit is contained in:
riperiperi 2021-01-29 03:19:06 +00:00 committed by GitHub
parent 9eb0ab05c6
commit c30504e3b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 22 deletions

View file

@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary>
/// Sampler pool.
/// </summary>
class SamplerPool : Pool<Sampler>
class SamplerPool : Pool<Sampler, SamplerDescriptor>
{
private int _sequenceNumber;
@ -38,11 +38,13 @@ namespace Ryujinx.Graphics.Gpu.Image
if (sampler == null)
{
SamplerDescriptor descriptor = Context.PhysicalMemory.Read<SamplerDescriptor>(Address + (ulong)id * DescriptorSize);
SamplerDescriptor descriptor = GetDescriptor(id);
sampler = new Sampler(Context, descriptor);
Items[id] = sampler;
DescriptorCache[id] = descriptor;
}
return sampler;
@ -65,6 +67,14 @@ namespace Ryujinx.Graphics.Gpu.Image
if (sampler != null)
{
SamplerDescriptor descriptor = GetDescriptor(id);
// If the descriptors are the same, the sampler is still valid.
if (descriptor.Equals(ref DescriptorCache[id]))
{
continue;
}
sampler.Dispose();
Items[id] = null;