/ src / Ryujinx.Graphics.Gpu / Memory / BufferBounds.cs
BufferBounds.cs
 1  using Ryujinx.Graphics.Shader;
 2  using Ryujinx.Memory.Range;
 3  using System;
 4  
 5  namespace Ryujinx.Graphics.Gpu.Memory
 6  {
 7      /// <summary>
 8      /// Memory range used for buffers.
 9      /// </summary>
10      readonly struct BufferBounds : IEquatable<BufferBounds>
11      {
12          /// <summary>
13          /// Physical memory ranges where the buffer is mapped.
14          /// </summary>
15          public MultiRange Range { get; }
16  
17          /// <summary>
18          /// Buffer usage flags.
19          /// </summary>
20          public BufferUsageFlags Flags { get; }
21  
22          /// <summary>
23          /// Indicates that the backing memory for the buffer does not exist.
24          /// </summary>
25          public bool IsUnmapped => Range.IsUnmapped;
26  
27          /// <summary>
28          /// Creates a new buffer region.
29          /// </summary>
30          /// <param name="range">Physical memory ranges where the buffer is mapped</param>
31          /// <param name="flags">Buffer usage flags</param>
32          public BufferBounds(MultiRange range, BufferUsageFlags flags = BufferUsageFlags.None)
33          {
34              Range = range;
35              Flags = flags;
36          }
37  
38          public override bool Equals(object obj)
39          {
40              return obj is BufferBounds bounds && Equals(bounds);
41          }
42  
43          public bool Equals(BufferBounds bounds)
44          {
45              return Range == bounds.Range && Flags == bounds.Flags;
46          }
47  
48          public bool Equals(ref BufferBounds bounds)
49          {
50              return Range == bounds.Range && Flags == bounds.Flags;
51          }
52  
53          public override int GetHashCode()
54          {
55              return HashCode.Combine(Range, Flags);
56          }
57      }
58  }