using System;
using System.Runtime.InteropServices;
using NvAPIWrapper.Native.Interfaces;
namespace NvAPIWrapper.Native.GPU.Structures
{
///
/// LogicalGPUHandle is a reference to one or more physical GPUs acting as a single logical device. A single GPU will
/// have a single logical GPU handle and a single physical GPU handle. Two GPUs acting in an SLI configuration will
/// have a single logical GPU handle and two physical GPU handles.
///
[StructLayout(LayoutKind.Sequential)]
public struct LogicalGPUHandle : IHandle, IEquatable
{
///
/// Maximum number of logical GPUs
///
public const int MaxLogicalGPUs = 64;
internal readonly IntPtr _MemoryAddress;
///
public bool Equals(LogicalGPUHandle other)
{
return _MemoryAddress.Equals(other._MemoryAddress);
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is LogicalGPUHandle handle && Equals(handle);
}
///
public override int GetHashCode()
{
return _MemoryAddress.GetHashCode();
}
///
public override string ToString()
{
return $"LogicalGPUHandle #{MemoryAddress.ToInt64()}";
}
///
/// 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 ==(LogicalGPUHandle left, LogicalGPUHandle 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 !=(LogicalGPUHandle left, LogicalGPUHandle right)
{
return !left.Equals(right);
}
///
public IntPtr MemoryAddress
{
get => _MemoryAddress;
}
///
public bool IsNull
{
get => _MemoryAddress == IntPtr.Zero;
}
}
}