/ src / Ryujinx.Graphics.Vulkan / RenderPassCacheKey.cs
RenderPassCacheKey.cs
 1  using System;
 2  using System.Linq;
 3  
 4  namespace Ryujinx.Graphics.Vulkan
 5  {
 6      internal readonly struct RenderPassCacheKey : IRefEquatable<RenderPassCacheKey>
 7      {
 8          private readonly TextureView _depthStencil;
 9          private readonly TextureView[] _colors;
10  
11          public RenderPassCacheKey(TextureView depthStencil, TextureView[] colors)
12          {
13              _depthStencil = depthStencil;
14              _colors = colors;
15          }
16  
17          public override int GetHashCode()
18          {
19              HashCode hc = new();
20  
21              hc.Add(_depthStencil);
22  
23              if (_colors != null)
24              {
25                  foreach (var color in _colors)
26                  {
27                      hc.Add(color);
28                  }
29              }
30  
31              return hc.ToHashCode();
32          }
33  
34          public bool Equals(ref RenderPassCacheKey other)
35          {
36              bool colorsNull = _colors == null;
37              bool otherNull = other._colors == null;
38              return other._depthStencil == _depthStencil &&
39                  colorsNull == otherNull &&
40                  (colorsNull || other._colors.SequenceEqual(_colors));
41          }
42      }
43  }