/ src / Ryujinx.Graphics.Gpu / Shader / GpuChannelPoolState.cs
GpuChannelPoolState.cs
 1  using System;
 2  
 3  namespace Ryujinx.Graphics.Gpu.Shader
 4  {
 5      /// <summary>
 6      /// State used by the <see cref="GpuAccessor"/>.
 7      /// </summary>
 8      readonly struct GpuChannelPoolState : IEquatable<GpuChannelPoolState>
 9      {
10          /// <summary>
11          /// GPU virtual address of the texture pool.
12          /// </summary>
13          public readonly ulong TexturePoolGpuVa;
14  
15          /// <summary>
16          /// Maximum ID of the texture pool.
17          /// </summary>
18          public readonly int TexturePoolMaximumId;
19  
20          /// <summary>
21          /// Constant buffer slot where the texture handles are located.
22          /// </summary>
23          public readonly int TextureBufferIndex;
24  
25          /// <summary>
26          /// Creates a new GPU texture pool state.
27          /// </summary>
28          /// <param name="texturePoolGpuVa">GPU virtual address of the texture pool</param>
29          /// <param name="texturePoolMaximumId">Maximum ID of the texture pool</param>
30          /// <param name="textureBufferIndex">Constant buffer slot where the texture handles are located</param>
31          public GpuChannelPoolState(ulong texturePoolGpuVa, int texturePoolMaximumId, int textureBufferIndex)
32          {
33              TexturePoolGpuVa = texturePoolGpuVa;
34              TexturePoolMaximumId = texturePoolMaximumId;
35              TextureBufferIndex = textureBufferIndex;
36          }
37  
38          /// <summary>
39          /// Check if the pool states are equal.
40          /// </summary>
41          /// <param name="other">Pool state to compare with</param>
42          /// <returns>True if they are equal, false otherwise</returns>
43          public bool Equals(GpuChannelPoolState other)
44          {
45              return TexturePoolGpuVa == other.TexturePoolGpuVa &&
46                  TexturePoolMaximumId == other.TexturePoolMaximumId &&
47                  TextureBufferIndex == other.TextureBufferIndex;
48          }
49  
50          public override bool Equals(object obj)
51          {
52              return obj is GpuChannelPoolState state && Equals(state);
53          }
54  
55          public override int GetHashCode()
56          {
57              return HashCode.Combine(TexturePoolGpuVa, TexturePoolMaximumId, TextureBufferIndex);
58          }
59      }
60  }