diff options
author | riperiperi <rhy3756547@hotmail.com> | 2021-01-29 03:19:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 14:19:06 +1100 |
commit | c30504e3b3bb64c44d993d6339f15ec6703a3c55 (patch) | |
tree | 91be94fc94dd52dcb8972f745559cf66f9dccb22 /Ryujinx.Graphics.Gpu/Image/SamplerPool.cs | |
parent | 9eb0ab05c6e820e113b3c61cbacd9b085b2819c4 (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/SamplerPool.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/SamplerPool.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs b/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs index ca13a7d6..1395aea2 100644 --- a/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs +++ b/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs @@ -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; |