using System; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers; using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal; #endif #nullable enable #pragma warning disable CS0660, CS0661 namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)] public unsafe partial struct Double2 #if NET6_0_OR_GREATER : ISpanFormattable #endif { /// /// A private buffer to which the undefined properties will point to. /// private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Double2), sizeof(Double4)); [FieldOffset(0)] private double x; [FieldOffset(8)] private double y; /// /// Gets a reference to a specific component in the current instance. /// /// The index of the component to access. /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref double this[int i] => ref *(double*)UndefinedData; /// /// Gets a value with all components set to 0. /// public static Double2 Zero => 0; /// /// Gets a value with all components set to 1. /// public static Double2 One => 1; /// /// Gets a reference to the value representing the X component. /// public readonly ref double X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); /// /// Gets a reference to the value representing the Y component. /// public readonly ref double Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); /// /// Gets a readonly reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double2 XX => ref *(Double2*)UndefinedData; /// /// Gets a reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref Double2 XY => ref *(Double2*)UndefinedData; /// /// Gets a reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref Double2 YX => ref *(Double2*)UndefinedData; /// /// Gets a readonly reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double2 YY => ref *(Double2*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 XXX => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 XXY => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 XYX => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 XYY => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 YXX => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 YXY => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 YYX => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 YYY => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XXXX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XXXY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XXYX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XXYY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XYXX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XYXY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XYYX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 XYYY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YXXX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YXXY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YXYX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YXYY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YYXX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YYXY => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YYYX => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 YYYY => ref *(Double4*)UndefinedData; /// /// Gets a reference to the value representing the R component. /// public readonly ref double R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); /// /// Gets a reference to the value representing the G component. /// public readonly ref double G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); /// /// Gets a readonly reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double2 RR => ref *(Double2*)UndefinedData; /// /// Gets a reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref Double2 RG => ref *(Double2*)UndefinedData; /// /// Gets a reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref Double2 GR => ref *(Double2*)UndefinedData; /// /// Gets a readonly reference to the value with the components , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double2 GG => ref *(Double2*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 RRR => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 RRG => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 RGR => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 RGG => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 GRR => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 GRG => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 GGR => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double3 GGG => ref *(Double3*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RRRR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RRRG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RRGR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RRGG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RGRR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RGRG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RGGR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 RGGG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GRRR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GRRG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GRGR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GRGG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GGRR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GGRG => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GGGR => ref *(Double4*)UndefinedData; /// /// Gets a readonly reference to the value with the components , , , . /// /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public readonly ref readonly Double4 GGGG => ref *(Double4*)UndefinedData; #if !SOURCE_GENERATOR /// public override readonly string ToString() { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; #if NET6_0_OR_GREATER return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>"); #else return $"<{this.x}{separator} {this.y}>"; #endif } /// public readonly string ToString(string? format, IFormatProvider? formatProvider) { string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; return FormatInterpolatedStringHandler.Create( format, formatProvider, stackalloc char[64], $"<{this.x}{separator} {this.y}>"); } /// public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) { string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; return TryWriteFormatInterpolatedStringHandler.TryWrite( destination, format, provider, $"<{this.x}{separator} {this.y}>", out charsWritten); } #endif /// /// Negates a value. /// /// The value to negate. /// The negated value of . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Double2 operator -(Double2 xy) => default; /// /// Sums two values. /// /// The first value to sum. /// The second value to sum. /// The result of adding and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Double2 operator +(Double2 left, Double2 right) => default; /// /// Divides two values. /// /// The first value to divide. /// The second value to divide. /// The result of dividing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Double2 operator /(Double2 left, Double2 right) => default; /// /// Calculates the remainder of the division between two values. /// /// The first value to divide. /// The second value to divide. /// The remainder of dividing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Double2 operator %(Double2 left, Double2 right) => default; /// /// Multiplies two values. /// /// The first value to multiply. /// The second value to multiply. /// The result of multiplying and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Double2 operator *(Double2 left, Double2 right) => default; /// /// Subtracts two values. /// /// The first value to subtract. /// The second value to subtract. /// The result of subtracting and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Double2 operator -(Double2 left, Double2 right) => default; /// /// Compares two values to see if the first is greater than the second. /// /// The first value to compare. /// The second value to compare. /// The result of comparing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Bool2 operator >(Double2 left, Double2 right) => default; /// /// Compares two values to see if the first is greater than or equal to the second. /// /// The first value to compare. /// The second value to compare. /// The result of comparing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Bool2 operator >=(Double2 left, Double2 right) => default; /// /// Compares two values to see if the first is lower than the second. /// /// The first value to compare. /// The second value to compare. /// The result of comparing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Bool2 operator <(Double2 left, Double2 right) => default; /// /// Compares two values to see if the first is lower than or equal to the second. /// /// The first value to compare. /// The second value to compare. /// The result of comparing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Bool2 operator <=(Double2 left, Double2 right) => default; /// /// Compares two values to see if they are equal. /// /// The first value to compare. /// The second value to compare. /// The result of comparing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Bool2 operator ==(Double2 left, Double2 right) => default; /// /// Compares two values to see if they are not equal. /// /// The first value to compare. /// The second value to compare. /// The result of comparing and . /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior. public static Bool2 operator !=(Double2 left, Double2 right) => default; }