using System.Diagnostics; using System.Runtime.InteropServices; using ComputeSharp.Exceptions; namespace ComputeSharp { /// /// A that maps the HLSL type. /// [DebuggerDisplay("({X}, {Y}, {Z}, {W})")] [StructLayout(LayoutKind.Sequential, Size = sizeof(uint) * 4)] public partial struct UInt4 { /// /// Gets an value with all components set to 0. /// public static UInt4 Zero => 0; /// /// Gets an value with all components set to 1. /// public static UInt4 One => 1; /// /// Gets an value with the component set to 1, and the others to 0. /// public static UInt4 UnitX => new(1, 0, 0, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static UInt4 UnitY => new(0, 1, 0, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static UInt4 UnitZ => new(0, 0, 1, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static UInt4 UnitW => new(0, 0, 0, 1); /// /// Creates a new instance with the specified parameters. /// /// The value to assign to the first vector component. /// The value to assign to the second vector component. /// The value to assign to the third vector component. /// The value to assign to the fourth vector component. public UInt4(uint x, uint y, uint z, uint w) { X = x; Y = y; Z = z; W = w; } /// /// Gets or sets the value of the first vector component. /// public uint X { get; set; } /// /// Gets or sets the value of the second vector component. /// public uint Y { get; set; } /// /// Gets or sets the value of the third vector component. /// public uint Z { get; set; } /// /// Gets or sets the value of the fourth vector component. /// public uint W { get; set; } /// /// Gets or sets the value of the first color component. /// public uint R { get => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(R)}"); set => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(R)}"); } /// /// Gets or sets the value of the second color component. /// public uint G { get => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(G)}"); set => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(G)}"); } /// /// Gets or sets the value of the third color component. /// public uint B { get => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(B)}"); set => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(B)}"); } /// /// Gets or sets the value of the fourth color component. /// public uint A { get => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(A)}"); set => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(A)}"); } /// /// Gets or sets a specific component in the current instance. /// /// The index of the component to access. public uint this[int i] { get => throw new InvalidExecutionContextException($"{nameof(UInt4)}[uint]"); set => throw new InvalidExecutionContextException($"{nameof(UInt4)}[uint]"); } /// /// Creates a new value with the same value for all its components. /// /// The value to use for the components of the new instance. public static implicit operator UInt4(uint x) => new(x, x, x, x); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator Int4(UInt4 xyzw) => throw new InvalidExecutionContextException($"{nameof(UInt4)}.({nameof(Int4)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static implicit operator Float4(UInt4 xyzw) => throw new InvalidExecutionContextException($"{nameof(UInt4)}.({nameof(Float4)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static implicit operator Double4(UInt4 xyzw) => throw new InvalidExecutionContextException($"{nameof(UInt4)}.({nameof(Double4)})"); } }