using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers; #endif #nullable enable #pragma warning disable CS0660, CS0661 namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)] public unsafe partial struct Bool2 { /// /// A private buffer to which the undefined properties will point to. /// private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2), sizeof(Bool4)); [FieldOffset(0)] private int x; [FieldOffset(4)] private int 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. [UnscopedRef] public ref bool this[int i] => ref *(bool*)UndefinedData; /// /// Gets a value with all components set to . /// public static Bool2 False => false; /// /// Gets a value with all components set to . /// public static Bool2 True => true; /// /// Gets a value with the component set to , and the others to . /// public static Bool2 TrueX => new(true, false); /// /// Gets a value with the component set to , and the others to . /// public static Bool2 TrueY => new(false, true); /// /// Gets a reference to the value representing the X component. /// [UnscopedRef] public ref bool X => ref Unsafe.As(ref this.x); /// /// Gets a reference to the value representing the Y component. /// [UnscopedRef] public ref bool Y => ref Unsafe.As(ref this.y); /// /// 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. [UnscopedRef] public readonly ref readonly Bool2 XX => ref *(Bool2*)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. [UnscopedRef] public ref Bool2 XY => ref *(Bool2*)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. [UnscopedRef] public ref Bool2 YX => ref *(Bool2*)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. [UnscopedRef] public readonly ref readonly Bool2 YY => ref *(Bool2*)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. [UnscopedRef] public readonly ref readonly Bool3 XXX => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 XXY => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 XYX => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 XYY => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 YXX => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 YXY => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 YYX => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 YYY => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool4 XXXX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XXXY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XXYX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XXYY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XYXX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XYXY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XYYX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 XYYY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YXXX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YXXY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YXYX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YXYY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YYXX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YYXY => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YYYX => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 YYYY => ref *(Bool4*)UndefinedData; /// /// Gets a reference to the value representing the R component. /// [UnscopedRef] public ref bool R => ref Unsafe.As(ref this.x); /// /// Gets a reference to the value representing the G component. /// [UnscopedRef] public ref bool G => ref Unsafe.As(ref this.y); /// /// 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. [UnscopedRef] public readonly ref readonly Bool2 RR => ref *(Bool2*)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. [UnscopedRef] public ref Bool2 RG => ref *(Bool2*)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. [UnscopedRef] public ref Bool2 GR => ref *(Bool2*)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. [UnscopedRef] public readonly ref readonly Bool2 GG => ref *(Bool2*)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. [UnscopedRef] public readonly ref readonly Bool3 RRR => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 RRG => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 RGR => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 RGG => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 GRR => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 GRG => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 GGR => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool3 GGG => ref *(Bool3*)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. [UnscopedRef] public readonly ref readonly Bool4 RRRR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RRRG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RRGR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RRGG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RGRR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RGRG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RGGR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 RGGG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GRRR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GRRG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GRGR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GRGG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GGRR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GGRG => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GGGR => ref *(Bool4*)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. [UnscopedRef] public readonly ref readonly Bool4 GGGG => ref *(Bool4*)UndefinedData; #if !SOURCE_GENERATOR /// public override readonly string ToString() { #if NET6_0_OR_GREATER return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}>"); #else return $"<{this.x != 0}, {this.y != 0}>"; #endif } #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 Bool2 operator !(Bool2 xy) => default; /// /// Ands two values. /// /// The value to and. /// The value to combine. /// The result of performing the bitwise and between 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 &(Bool2 left, Bool2 right) => default; /// /// Ors two values. /// /// The value to or. /// The value to combine. /// The result of performing the or between 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 |(Bool2 left, Bool2 right) => default; /// /// Xors two values. /// /// The value to xor. /// The value to combine. /// The result of performing the xor between 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 ^(Bool2 left, Bool2 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 ==(Bool2 left, Bool2 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 !=(Bool2 left, Bool2 right) => default; }