using System; using System.Runtime.InteropServices; using NvAPIWrapper.Native.Interfaces; namespace NvAPIWrapper.Native.GPU.Structures { /// /// PhysicalGPUHandle is a reference to a physical GPU. Each GPU in a multi-GPU board will have its own handle. GPUs /// are assigned a handle even if they are not in use by the OS. /// [StructLayout(LayoutKind.Sequential)] public struct PhysicalGPUHandle : IHandle, IEquatable { /// /// Queryable number of physical GPUs /// public const int PhysicalGPUs = 32; /// /// Maximum number of physical GPUs /// public const int MaxPhysicalGPUs = 64; internal readonly IntPtr _MemoryAddress; /// public bool Equals(PhysicalGPUHandle other) { return _MemoryAddress.Equals(other._MemoryAddress); } /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return false; } return obj is PhysicalGPUHandle handle && Equals(handle); } /// public override int GetHashCode() { return _MemoryAddress.GetHashCode(); } /// public override string ToString() { return $"PhysicalGPUHandle #{MemoryAddress.ToInt64()}"; } /// public IntPtr MemoryAddress { get => _MemoryAddress; } /// public bool IsNull { get => _MemoryAddress == IntPtr.Zero; } /// /// Checks for equality between two objects of same type /// /// The first object /// The second object /// true, if both objects are equal, otherwise false public static bool operator ==(PhysicalGPUHandle left, PhysicalGPUHandle right) { return left.Equals(right); } /// /// Checks for inequality between two objects of same type /// /// The first object /// The second object /// true, if both objects are not equal, otherwise false public static bool operator !=(PhysicalGPUHandle left, PhysicalGPUHandle right) { return !left.Equals(right); } /// /// Gets default PhysicalGPUHandle with a null pointer /// public static PhysicalGPUHandle DefaultHandle { get => default(PhysicalGPUHandle); } } }