using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using TerraFX.Interop;
namespace ComputeSharp.Graphics
{
///
/// A locally unique identifier for a graphics device.
///
public readonly struct Luid : IEquatable
{
#pragma warning disable CS0649
private readonly uint lowPart;
private readonly int highPart;
#pragma warning restore
///
/// Creates a new instance from a raw value.
///
/// The input value.
/// A instance with the same value.
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe Luid FromLUID(LUID luid)
{
return *(Luid*)&luid;
}
///
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Luid other)
{
return
this.lowPart == other.lowPart &&
this.highPart == other.highPart;
}
///
[Pure]
public override bool Equals(object? other)
{
return other is Luid luid && Equals(luid);
}
///
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
{
return HashCode.Combine(this.lowPart, this.highPart);
}
///
[Pure]
public override string ToString()
{
return (((long)this.highPart) << 32 | this.lowPart).ToString();
}
///
/// Check whether two values are equal.
///
/// The first value to compare.
/// The second value to compare.
/// Whether and are the same.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Luid a, Luid b)
{
return a.Equals(b);
}
///
/// Check whether two values are different.
///
/// The first value to compare.
/// The second value to compare.
/// Whether and are different.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Luid a, Luid b)
{
return !a.Equals(b);
}
}
}