From 797d06cdb7e375da4deb1fe5061cddec1d60ed35 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 27 Aug 2022 22:21:11 +0200 Subject: [PATCH] Normalize bool HLSL types to use int-s as backing storage --- src/ComputeSharp.Core/Primitives/Bool/Bool.cs | 18 +- .../Primitives/Bool/Bool2.cs | 4 +- .../Primitives/Bool/Bool2.g.cs | 16 +- .../Primitives/Bool/Bool3.cs | 18 +- .../Primitives/Bool/Bool3.g.cs | 22 +- .../Primitives/Bool/Bool4.cs | 48 +- .../Primitives/Bool/Bool4.g.cs | 28 +- .../Primitives/Bool/BoolMxN.g.cs | 962 +++++++++--------- .../Primitives/MatrixType.ttinclude | 46 +- .../Primitives/VectorType.ttinclude | 19 +- 10 files changed, 615 insertions(+), 566 deletions(-) diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs index c6ec789c..774676c6 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs @@ -6,14 +6,14 @@ namespace ComputeSharp; /// /// A that can be used in place of the type in HLSL shaders. /// -[StructLayout(LayoutKind.Explicit, Size = sizeof(int), Pack = 4)] +[StructLayout(LayoutKind.Explicit, Size = 4, Pack = 4)] public readonly struct Bool { /// - /// The wrapped value for the current instance. + /// The wrapped value for the current instance. /// [FieldOffset(0)] - private readonly bool Value; + private readonly int Value; /// /// Creates a new instance for a given value. @@ -21,7 +21,7 @@ public readonly struct Bool /// . private Bool(bool value) { - Value = value; + Value = value ? 1 : 0; } /// @@ -39,20 +39,20 @@ public readonly struct Bool /// public override string ToString() { - return Value.ToString(); + return ((bool)this).ToString(); } /// public string ToString(IFormatProvider? formatProvider) { - return Value.ToString(); + return ((bool)this).ToString(formatProvider); } #if NET6_0_OR_GREATER /// public bool TryFormat(Span destination, out int charsWritten) { - return Value.TryFormat(destination, out charsWritten); + return ((bool)this).TryFormat(destination, out charsWritten); } #endif @@ -60,7 +60,7 @@ public readonly struct Bool /// Inverts the value represented by a given instance. /// /// The input instance. - public static Bool operator !(Bool x) => new(!x.Value); + public static Bool operator !(Bool x) => new(!(bool)x); /// /// Ands two values. @@ -107,7 +107,7 @@ public readonly struct Bool /// Converts a given instance to its corresponding value. /// /// The input instance. - public static implicit operator bool(Bool x) => x.Value; + public static implicit operator bool(Bool x) => x.Value != 0; /// /// Converts a value to a corresponding instance. diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs index 9e78758f..2257036a 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs @@ -14,8 +14,8 @@ public partial struct Bool2 /// The value to assign to the second vector component. public Bool2(bool x, bool y) { - this.x = x; - this.y = y; + this.x = x ? 1 : 0; + this.y = y ? 1 : 0; } /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs index d4e42c00..ca1d1688 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs @@ -20,10 +20,10 @@ public unsafe partial struct Bool2 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2), sizeof(Bool4)); [FieldOffset(0)] - private bool x; + private int x; [FieldOffset(4)] - private bool y; + private int y; /// /// Gets a reference to a specific component in the current instance. @@ -55,12 +55,12 @@ public unsafe partial struct Bool2 /// /// Gets a reference to the value representing the X component. /// - public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); + public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.x)), 1)); /// /// Gets a reference to the value representing the Y component. /// - public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); + public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.y)), 1)); /// /// Gets a readonly reference to the value with the components , . @@ -233,12 +233,12 @@ public unsafe partial struct Bool2 /// /// Gets a reference to the value representing the R component. /// - public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); + public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.x)), 1)); /// /// Gets a reference to the value representing the G component. /// - public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); + public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.y)), 1)); /// /// Gets a readonly reference to the value with the components , . @@ -414,9 +414,9 @@ public unsafe partial struct Bool2 public override readonly string ToString() { #if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}>"); + return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}>"); #else - return $"<{this.x}, {this.y}>"; + return $"<{this.x != 0}, {this.y != 0}>"; #endif } diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs index 8d861f35..35eee2fa 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs @@ -15,9 +15,9 @@ public partial struct Bool3 /// The value to assign to the third vector component. public Bool3(bool x, bool y, bool z) { - this.x = x; - this.y = y; - this.z = z; + this.x = x ? 1 : 0; + this.y = y ? 1 : 0; + this.z = z ? 1 : 0; } /// @@ -27,9 +27,9 @@ public partial struct Bool3 /// The value to assign to the third vector component. public Bool3(Bool2 xy, bool z) { - this.x = xy.X; - this.y = xy.Y; - this.z = z; + this.x = xy.X ? 1 : 0; + this.y = xy.Y ? 1 : 0; + this.z = z ? 1 : 0; } /// @@ -39,9 +39,9 @@ public partial struct Bool3 /// The value to assign to the second and thirt vector components. public Bool3(bool x, Bool2 yz) { - this.x = x; - this.y = yz.X; - this.z = yz.Y; + this.x = x ? 1 : 0; + this.y = yz.X ? 1 : 0; + this.z = yz.Y ? 1 : 0; } /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs index 1818699b..a1f145bb 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs @@ -20,13 +20,13 @@ public unsafe partial struct Bool3 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool3), sizeof(Bool4)); [FieldOffset(0)] - private bool x; + private int x; [FieldOffset(4)] - private bool y; + private int y; [FieldOffset(8)] - private bool z; + private int z; /// /// Gets a reference to a specific component in the current instance. @@ -63,17 +63,17 @@ public unsafe partial struct Bool3 /// /// Gets a reference to the value representing the X component. /// - public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); + public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.x)), 1)); /// /// Gets a reference to the value representing the Y component. /// - public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); + public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.y)), 1)); /// /// Gets a reference to the value representing the Z component. /// - public readonly ref bool Z => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.z), 1)); + public readonly ref bool Z => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.z)), 1)); /// /// Gets a readonly reference to the value with the components , . @@ -780,17 +780,17 @@ public unsafe partial struct Bool3 /// /// Gets a reference to the value representing the R component. /// - public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); + public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.x)), 1)); /// /// Gets a reference to the value representing the G component. /// - public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); + public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.y)), 1)); /// /// Gets a reference to the value representing the B component. /// - public readonly ref bool B => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.z), 1)); + public readonly ref bool B => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.z)), 1)); /// /// Gets a readonly reference to the value with the components , . @@ -1500,9 +1500,9 @@ public unsafe partial struct Bool3 public override readonly string ToString() { #if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}, {this.z}>"); + return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>"); #else - return $"<{this.x}, {this.y}, {this.z}>"; + return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>"; #endif } diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs index 050a9d0c..3694225d 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs @@ -16,10 +16,10 @@ public partial struct Bool4 /// The value to assign to the fourth vector component. public Bool4(bool x, bool y, bool z, bool w) { - this.x = x; - this.y = y; - this.z = z; - this.w = w; + this.x = x ? 1 : 0; + this.y = y ? 1 : 0; + this.z = z ? 1 : 0; + this.w = w ? 1 : 0; } /// @@ -30,10 +30,10 @@ public partial struct Bool4 /// The value to assign to the fourth vector component. public Bool4(Bool2 xy, bool z, bool w) { - this.x = xy.X; - this.y = xy.Y; - this.z = z; - this.w = w; + this.x = xy.X ? 1 : 0; + this.y = xy.Y ? 1 : 0; + this.z = z ? 1 : 0; + this.w = w ? 1 : 0; } /// @@ -44,10 +44,10 @@ public partial struct Bool4 /// The value to assign to the third and fourth vector components. public Bool4(bool x, bool y, Bool2 zw) { - this.x = x; - this.y = y; - this.z = zw.X; - this.w = zw.Y; + this.x = x ? 1 : 0; + this.y = y ? 1 : 0; + this.z = zw.X ? 1 : 0; + this.w = zw.Y ? 1 : 0; } /// @@ -57,10 +57,10 @@ public partial struct Bool4 /// The value to assign to the third and fourth vector components. public Bool4(Bool2 xy, Bool2 zw) { - this.x = xy.X; - this.y = xy.Y; - this.z = zw.X; - this.w = zw.Y; + this.x = xy.X ? 1 : 0; + this.y = xy.Y ? 1 : 0; + this.z = zw.X ? 1 : 0; + this.w = zw.Y ? 1 : 0; } /// @@ -70,10 +70,10 @@ public partial struct Bool4 /// The value to assign to the fourth vector component. public Bool4(Bool3 xyz, bool w) { - this.x = xyz.X; - this.y = xyz.Y; - this.z = xyz.Z; - this.w = w; + this.x = xyz.X ? 1 : 0; + this.y = xyz.Y ? 1 : 0; + this.z = xyz.Z ? 1 : 0; + this.w = w ? 1 : 0; } /// @@ -83,10 +83,10 @@ public partial struct Bool4 /// The value to assign to the second, third and fourth vector components. public Bool4(bool x, Bool3 yzw) { - this.x = x; - this.y = yzw.X; - this.z = yzw.Y; - this.w = yzw.Z; + this.x = x ? 1 : 0; + this.y = yzw.X ? 1 : 0; + this.z = yzw.Y ? 1 : 0; + this.w = yzw.Z ? 1 : 0; } /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs index 84270626..7b2aad24 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs @@ -20,16 +20,16 @@ public unsafe partial struct Bool4 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool4), sizeof(Bool4)); [FieldOffset(0)] - private bool x; + private int x; [FieldOffset(4)] - private bool y; + private int y; [FieldOffset(8)] - private bool z; + private int z; [FieldOffset(12)] - private bool w; + private int w; /// /// Gets a reference to a specific component in the current instance. @@ -71,22 +71,22 @@ public unsafe partial struct Bool4 /// /// Gets a reference to the value representing the X component. /// - public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); + public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.x)), 1)); /// /// Gets a reference to the value representing the Y component. /// - public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); + public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.y)), 1)); /// /// Gets a reference to the value representing the Z component. /// - public readonly ref bool Z => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.z), 1)); + public readonly ref bool Z => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.z)), 1)); /// /// Gets a reference to the value representing the W component. /// - public readonly ref bool W => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.w), 1)); + public readonly ref bool W => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.w)), 1)); /// /// Gets a readonly reference to the value with the components , . @@ -2107,22 +2107,22 @@ public unsafe partial struct Bool4 /// /// Gets a reference to the value representing the R component. /// - public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1)); + public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.x)), 1)); /// /// Gets a reference to the value representing the G component. /// - public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1)); + public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.y)), 1)); /// /// Gets a reference to the value representing the B component. /// - public readonly ref bool B => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.z), 1)); + public readonly ref bool B => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.z)), 1)); /// /// Gets a reference to the value representing the A component. /// - public readonly ref bool A => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.w), 1)); + public readonly ref bool A => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.w)), 1)); /// /// Gets a readonly reference to the value with the components , . @@ -4146,9 +4146,9 @@ public unsafe partial struct Bool4 public override readonly string ToString() { #if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}, {this.z}, {this.w}>"); + return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>"); #else - return $"<{this.x}, {this.y}, {this.z}, {this.w}>"; + return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>"; #endif } diff --git a/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs b/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs index 941c3221..954a4df4 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs @@ -19,7 +19,7 @@ public unsafe partial struct Bool1x1 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool1x1), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; /// /// Creates a new instance with the specified parameters. @@ -27,7 +27,7 @@ public unsafe partial struct Bool1x1 /// The value to assign to the component at position [1, 1]. public Bool1x1(bool m11) { - this.m11 = m11; + this.m11 = m11 ? 1 : 0; } /// @@ -67,7 +67,7 @@ public unsafe partial struct Bool1x1 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Creates a new value with the same value for all its components. @@ -77,7 +77,7 @@ public unsafe partial struct Bool1x1 { Bool1x1 matrix; - matrix.m11 = x; + matrix.m11 = x ? 1 : 0; return matrix; } @@ -145,10 +145,10 @@ public unsafe partial struct Bool1x2 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool1x2), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; /// /// Creates a new instance with the specified parameters. @@ -157,8 +157,8 @@ public unsafe partial struct Bool1x2 /// The value to assign to the component at position [1, 2]. public Bool1x2(bool m11, bool m12) { - this.m11 = m11; - this.m12 = m12; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; } /// @@ -198,12 +198,12 @@ public unsafe partial struct Bool1x2 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Creates a new value with the same value for all its components. @@ -213,8 +213,8 @@ public unsafe partial struct Bool1x2 { Bool1x2 matrix; - matrix.m11 = x; - matrix.m12 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; return matrix; } @@ -288,13 +288,13 @@ public unsafe partial struct Bool1x3 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool1x3), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; /// /// Creates a new instance with the specified parameters. @@ -304,9 +304,9 @@ public unsafe partial struct Bool1x3 /// The value to assign to the component at position [1, 3]. public Bool1x3(bool m11, bool m12, bool m13) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; } /// @@ -346,17 +346,17 @@ public unsafe partial struct Bool1x3 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Creates a new value with the same value for all its components. @@ -366,9 +366,9 @@ public unsafe partial struct Bool1x3 { Bool1x3 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; return matrix; } @@ -442,16 +442,16 @@ public unsafe partial struct Bool1x4 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool1x4), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m14; + private int m14; /// /// Creates a new instance with the specified parameters. @@ -462,10 +462,10 @@ public unsafe partial struct Bool1x4 /// The value to assign to the component at position [1, 4]. public Bool1x4(bool m11, bool m12, bool m13, bool m14) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m14 = m14; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m14 = m14 ? 1 : 0; } /// @@ -505,22 +505,22 @@ public unsafe partial struct Bool1x4 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [1, 4]. /// - public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m14), 1)); + public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m14)), 1)); /// /// Creates a new value with the same value for all its components. @@ -530,10 +530,10 @@ public unsafe partial struct Bool1x4 { Bool1x4 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m14 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m14 = x ? 1 : 0; return matrix; } @@ -607,10 +607,10 @@ public unsafe partial struct Bool2x1 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2x1), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m21; + private int m21; /// /// Creates a new instance with the specified parameters. @@ -619,8 +619,8 @@ public unsafe partial struct Bool2x1 /// The value to assign to the component at position [2, 1]. public Bool2x1(bool m11, bool m21) { - this.m11 = m11; - this.m21 = m21; + this.m11 = m11 ? 1 : 0; + this.m21 = m21 ? 1 : 0; } /// @@ -660,12 +660,12 @@ public unsafe partial struct Bool2x1 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Creates a new value with the same value for all its components. @@ -675,8 +675,8 @@ public unsafe partial struct Bool2x1 { Bool2x1 matrix; - matrix.m11 = x; - matrix.m21 = x; + matrix.m11 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; return matrix; } @@ -750,16 +750,16 @@ public unsafe partial struct Bool2x2 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2x2), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m21; + private int m21; [FieldOffset(12)] - private bool m22; + private int m22; /// /// Creates a new instance with the specified parameters. @@ -770,10 +770,10 @@ public unsafe partial struct Bool2x2 /// The value to assign to the component at position [2, 2]. public Bool2x2(bool m11, bool m12, bool m21, bool m22) { - this.m11 = m11; - this.m12 = m12; - this.m21 = m21; - this.m22 = m22; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; } /// @@ -783,10 +783,10 @@ public unsafe partial struct Bool2x2 /// The value to assign to the row at position [2]. public Bool2x2(Bool2 row1, Bool2 row2) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m21 = row2.X; - this.m22 = row2.Y; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; } /// @@ -826,22 +826,22 @@ public unsafe partial struct Bool2x2 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Creates a new value with the same value for all its components. @@ -851,10 +851,10 @@ public unsafe partial struct Bool2x2 { Bool2x2 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m21 = x; - matrix.m22 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; return matrix; } @@ -922,22 +922,22 @@ public unsafe partial struct Bool2x3 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2x3), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m21; + private int m21; [FieldOffset(16)] - private bool m22; + private int m22; [FieldOffset(20)] - private bool m23; + private int m23; /// /// Creates a new instance with the specified parameters. @@ -950,12 +950,12 @@ public unsafe partial struct Bool2x3 /// The value to assign to the component at position [2, 3]. public Bool2x3(bool m11, bool m12, bool m13, bool m21, bool m22, bool m23) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m23 = m23 ? 1 : 0; } /// @@ -965,12 +965,12 @@ public unsafe partial struct Bool2x3 /// The value to assign to the row at position [2]. public Bool2x3(Bool3 row1, Bool3 row2) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m13 = row1.Z; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m23 = row2.Z; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m13 = row1.Z ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m23 = row2.Z ? 1 : 0; } /// @@ -1010,32 +1010,32 @@ public unsafe partial struct Bool2x3 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [2, 3]. /// - public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m23), 1)); + public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m23)), 1)); /// /// Creates a new value with the same value for all its components. @@ -1045,12 +1045,12 @@ public unsafe partial struct Bool2x3 { Bool2x3 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m23 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m23 = x ? 1 : 0; return matrix; } @@ -1118,28 +1118,28 @@ public unsafe partial struct Bool2x4 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2x4), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m14; + private int m14; [FieldOffset(16)] - private bool m21; + private int m21; [FieldOffset(20)] - private bool m22; + private int m22; [FieldOffset(24)] - private bool m23; + private int m23; [FieldOffset(28)] - private bool m24; + private int m24; /// /// Creates a new instance with the specified parameters. @@ -1154,14 +1154,14 @@ public unsafe partial struct Bool2x4 /// The value to assign to the component at position [2, 4]. public Bool2x4(bool m11, bool m12, bool m13, bool m14, bool m21, bool m22, bool m23, bool m24) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m14 = m14; - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m24 = m24; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m14 = m14 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m23 = m23 ? 1 : 0; + this.m24 = m24 ? 1 : 0; } /// @@ -1171,14 +1171,14 @@ public unsafe partial struct Bool2x4 /// The value to assign to the row at position [2]. public Bool2x4(Bool4 row1, Bool4 row2) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m13 = row1.Z; - this.m14 = row1.W; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m23 = row2.Z; - this.m24 = row2.W; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m13 = row1.Z ? 1 : 0; + this.m14 = row1.W ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m23 = row2.Z ? 1 : 0; + this.m24 = row2.W ? 1 : 0; } /// @@ -1218,42 +1218,42 @@ public unsafe partial struct Bool2x4 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [1, 4]. /// - public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m14), 1)); + public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m14)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [2, 3]. /// - public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m23), 1)); + public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m23)), 1)); /// /// Gets a reference to the value representing the component at position [2, 4]. /// - public readonly ref bool M24 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m24), 1)); + public readonly ref bool M24 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m24)), 1)); /// /// Creates a new value with the same value for all its components. @@ -1263,14 +1263,14 @@ public unsafe partial struct Bool2x4 { Bool2x4 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m14 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m23 = x; - matrix.m24 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m14 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m23 = x ? 1 : 0; + matrix.m24 = x ? 1 : 0; return matrix; } @@ -1338,13 +1338,13 @@ public unsafe partial struct Bool3x1 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool3x1), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m21; + private int m21; [FieldOffset(8)] - private bool m31; + private int m31; /// /// Creates a new instance with the specified parameters. @@ -1354,9 +1354,9 @@ public unsafe partial struct Bool3x1 /// The value to assign to the component at position [3, 1]. public Bool3x1(bool m11, bool m21, bool m31) { - this.m11 = m11; - this.m21 = m21; - this.m31 = m31; + this.m11 = m11 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m31 = m31 ? 1 : 0; } /// @@ -1396,17 +1396,17 @@ public unsafe partial struct Bool3x1 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Creates a new value with the same value for all its components. @@ -1416,9 +1416,9 @@ public unsafe partial struct Bool3x1 { Bool3x1 matrix; - matrix.m11 = x; - matrix.m21 = x; - matrix.m31 = x; + matrix.m11 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; return matrix; } @@ -1492,22 +1492,22 @@ public unsafe partial struct Bool3x2 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool3x2), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m21; + private int m21; [FieldOffset(12)] - private bool m22; + private int m22; [FieldOffset(16)] - private bool m31; + private int m31; [FieldOffset(20)] - private bool m32; + private int m32; /// /// Creates a new instance with the specified parameters. @@ -1520,12 +1520,12 @@ public unsafe partial struct Bool3x2 /// The value to assign to the component at position [3, 2]. public Bool3x2(bool m11, bool m12, bool m21, bool m22, bool m31, bool m32) { - this.m11 = m11; - this.m12 = m12; - this.m21 = m21; - this.m22 = m22; - this.m31 = m31; - this.m32 = m32; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m32 = m32 ? 1 : 0; } /// @@ -1536,12 +1536,12 @@ public unsafe partial struct Bool3x2 /// The value to assign to the row at position [3]. public Bool3x2(Bool2 row1, Bool2 row2, Bool2 row3) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m31 = row3.X; - this.m32 = row3.Y; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m31 = row3.X ? 1 : 0; + this.m32 = row3.Y ? 1 : 0; } /// @@ -1581,32 +1581,32 @@ public unsafe partial struct Bool3x2 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [3, 2]. /// - public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m32), 1)); + public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m32)), 1)); /// /// Creates a new value with the same value for all its components. @@ -1616,12 +1616,12 @@ public unsafe partial struct Bool3x2 { Bool3x2 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m31 = x; - matrix.m32 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m32 = x ? 1 : 0; return matrix; } @@ -1689,31 +1689,31 @@ public unsafe partial struct Bool3x3 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool3x3), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m21; + private int m21; [FieldOffset(16)] - private bool m22; + private int m22; [FieldOffset(20)] - private bool m23; + private int m23; [FieldOffset(24)] - private bool m31; + private int m31; [FieldOffset(28)] - private bool m32; + private int m32; [FieldOffset(32)] - private bool m33; + private int m33; /// /// Creates a new instance with the specified parameters. @@ -1729,15 +1729,15 @@ public unsafe partial struct Bool3x3 /// The value to assign to the component at position [3, 3]. public Bool3x3(bool m11, bool m12, bool m13, bool m21, bool m22, bool m23, bool m31, bool m32, bool m33) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m31 = m31; - this.m32 = m32; - this.m33 = m33; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m23 = m23 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m32 = m32 ? 1 : 0; + this.m33 = m33 ? 1 : 0; } /// @@ -1748,15 +1748,15 @@ public unsafe partial struct Bool3x3 /// The value to assign to the row at position [3]. public Bool3x3(Bool3 row1, Bool3 row2, Bool3 row3) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m13 = row1.Z; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m23 = row2.Z; - this.m31 = row3.X; - this.m32 = row3.Y; - this.m33 = row3.Z; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m13 = row1.Z ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m23 = row2.Z ? 1 : 0; + this.m31 = row3.X ? 1 : 0; + this.m32 = row3.Y ? 1 : 0; + this.m33 = row3.Z ? 1 : 0; } /// @@ -1796,47 +1796,47 @@ public unsafe partial struct Bool3x3 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [2, 3]. /// - public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m23), 1)); + public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m23)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [3, 2]. /// - public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m32), 1)); + public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m32)), 1)); /// /// Gets a reference to the value representing the component at position [3, 3]. /// - public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m33), 1)); + public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m33)), 1)); /// /// Creates a new value with the same value for all its components. @@ -1846,15 +1846,15 @@ public unsafe partial struct Bool3x3 { Bool3x3 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m23 = x; - matrix.m31 = x; - matrix.m32 = x; - matrix.m33 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m23 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m32 = x ? 1 : 0; + matrix.m33 = x ? 1 : 0; return matrix; } @@ -1922,40 +1922,40 @@ public unsafe partial struct Bool3x4 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool3x4), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m14; + private int m14; [FieldOffset(16)] - private bool m21; + private int m21; [FieldOffset(20)] - private bool m22; + private int m22; [FieldOffset(24)] - private bool m23; + private int m23; [FieldOffset(28)] - private bool m24; + private int m24; [FieldOffset(32)] - private bool m31; + private int m31; [FieldOffset(36)] - private bool m32; + private int m32; [FieldOffset(40)] - private bool m33; + private int m33; [FieldOffset(44)] - private bool m34; + private int m34; /// /// Creates a new instance with the specified parameters. @@ -1974,18 +1974,18 @@ public unsafe partial struct Bool3x4 /// The value to assign to the component at position [3, 4]. public Bool3x4(bool m11, bool m12, bool m13, bool m14, bool m21, bool m22, bool m23, bool m24, bool m31, bool m32, bool m33, bool m34) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m14 = m14; - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m24 = m24; - this.m31 = m31; - this.m32 = m32; - this.m33 = m33; - this.m34 = m34; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m14 = m14 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m23 = m23 ? 1 : 0; + this.m24 = m24 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m32 = m32 ? 1 : 0; + this.m33 = m33 ? 1 : 0; + this.m34 = m34 ? 1 : 0; } /// @@ -1996,18 +1996,18 @@ public unsafe partial struct Bool3x4 /// The value to assign to the row at position [3]. public Bool3x4(Bool4 row1, Bool4 row2, Bool4 row3) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m13 = row1.Z; - this.m14 = row1.W; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m23 = row2.Z; - this.m24 = row2.W; - this.m31 = row3.X; - this.m32 = row3.Y; - this.m33 = row3.Z; - this.m34 = row3.W; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m13 = row1.Z ? 1 : 0; + this.m14 = row1.W ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m23 = row2.Z ? 1 : 0; + this.m24 = row2.W ? 1 : 0; + this.m31 = row3.X ? 1 : 0; + this.m32 = row3.Y ? 1 : 0; + this.m33 = row3.Z ? 1 : 0; + this.m34 = row3.W ? 1 : 0; } /// @@ -2047,62 +2047,62 @@ public unsafe partial struct Bool3x4 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [1, 4]. /// - public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m14), 1)); + public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m14)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [2, 3]. /// - public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m23), 1)); + public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m23)), 1)); /// /// Gets a reference to the value representing the component at position [2, 4]. /// - public readonly ref bool M24 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m24), 1)); + public readonly ref bool M24 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m24)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [3, 2]. /// - public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m32), 1)); + public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m32)), 1)); /// /// Gets a reference to the value representing the component at position [3, 3]. /// - public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m33), 1)); + public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m33)), 1)); /// /// Gets a reference to the value representing the component at position [3, 4]. /// - public readonly ref bool M34 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m34), 1)); + public readonly ref bool M34 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m34)), 1)); /// /// Creates a new value with the same value for all its components. @@ -2112,18 +2112,18 @@ public unsafe partial struct Bool3x4 { Bool3x4 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m14 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m23 = x; - matrix.m24 = x; - matrix.m31 = x; - matrix.m32 = x; - matrix.m33 = x; - matrix.m34 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m14 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m23 = x ? 1 : 0; + matrix.m24 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m32 = x ? 1 : 0; + matrix.m33 = x ? 1 : 0; + matrix.m34 = x ? 1 : 0; return matrix; } @@ -2191,16 +2191,16 @@ public unsafe partial struct Bool4x1 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool4x1), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m21; + private int m21; [FieldOffset(8)] - private bool m31; + private int m31; [FieldOffset(12)] - private bool m41; + private int m41; /// /// Creates a new instance with the specified parameters. @@ -2211,10 +2211,10 @@ public unsafe partial struct Bool4x1 /// The value to assign to the component at position [4, 1]. public Bool4x1(bool m11, bool m21, bool m31, bool m41) { - this.m11 = m11; - this.m21 = m21; - this.m31 = m31; - this.m41 = m41; + this.m11 = m11 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m41 = m41 ? 1 : 0; } /// @@ -2254,22 +2254,22 @@ public unsafe partial struct Bool4x1 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [4, 1]. /// - public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m41), 1)); + public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m41)), 1)); /// /// Creates a new value with the same value for all its components. @@ -2279,10 +2279,10 @@ public unsafe partial struct Bool4x1 { Bool4x1 matrix; - matrix.m11 = x; - matrix.m21 = x; - matrix.m31 = x; - matrix.m41 = x; + matrix.m11 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m41 = x ? 1 : 0; return matrix; } @@ -2356,28 +2356,28 @@ public unsafe partial struct Bool4x2 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool4x2), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m21; + private int m21; [FieldOffset(12)] - private bool m22; + private int m22; [FieldOffset(16)] - private bool m31; + private int m31; [FieldOffset(20)] - private bool m32; + private int m32; [FieldOffset(24)] - private bool m41; + private int m41; [FieldOffset(28)] - private bool m42; + private int m42; /// /// Creates a new instance with the specified parameters. @@ -2392,14 +2392,14 @@ public unsafe partial struct Bool4x2 /// The value to assign to the component at position [4, 2]. public Bool4x2(bool m11, bool m12, bool m21, bool m22, bool m31, bool m32, bool m41, bool m42) { - this.m11 = m11; - this.m12 = m12; - this.m21 = m21; - this.m22 = m22; - this.m31 = m31; - this.m32 = m32; - this.m41 = m41; - this.m42 = m42; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m32 = m32 ? 1 : 0; + this.m41 = m41 ? 1 : 0; + this.m42 = m42 ? 1 : 0; } /// @@ -2411,14 +2411,14 @@ public unsafe partial struct Bool4x2 /// The value to assign to the row at position [4]. public Bool4x2(Bool2 row1, Bool2 row2, Bool2 row3, Bool2 row4) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m31 = row3.X; - this.m32 = row3.Y; - this.m41 = row4.X; - this.m42 = row4.Y; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m31 = row3.X ? 1 : 0; + this.m32 = row3.Y ? 1 : 0; + this.m41 = row4.X ? 1 : 0; + this.m42 = row4.Y ? 1 : 0; } /// @@ -2458,42 +2458,42 @@ public unsafe partial struct Bool4x2 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [3, 2]. /// - public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m32), 1)); + public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m32)), 1)); /// /// Gets a reference to the value representing the component at position [4, 1]. /// - public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m41), 1)); + public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m41)), 1)); /// /// Gets a reference to the value representing the component at position [4, 2]. /// - public readonly ref bool M42 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m42), 1)); + public readonly ref bool M42 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m42)), 1)); /// /// Creates a new value with the same value for all its components. @@ -2503,14 +2503,14 @@ public unsafe partial struct Bool4x2 { Bool4x2 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m31 = x; - matrix.m32 = x; - matrix.m41 = x; - matrix.m42 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m32 = x ? 1 : 0; + matrix.m41 = x ? 1 : 0; + matrix.m42 = x ? 1 : 0; return matrix; } @@ -2578,40 +2578,40 @@ public unsafe partial struct Bool4x3 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool4x3), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m21; + private int m21; [FieldOffset(16)] - private bool m22; + private int m22; [FieldOffset(20)] - private bool m23; + private int m23; [FieldOffset(24)] - private bool m31; + private int m31; [FieldOffset(28)] - private bool m32; + private int m32; [FieldOffset(32)] - private bool m33; + private int m33; [FieldOffset(36)] - private bool m41; + private int m41; [FieldOffset(40)] - private bool m42; + private int m42; [FieldOffset(44)] - private bool m43; + private int m43; /// /// Creates a new instance with the specified parameters. @@ -2630,18 +2630,18 @@ public unsafe partial struct Bool4x3 /// The value to assign to the component at position [4, 3]. public Bool4x3(bool m11, bool m12, bool m13, bool m21, bool m22, bool m23, bool m31, bool m32, bool m33, bool m41, bool m42, bool m43) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m31 = m31; - this.m32 = m32; - this.m33 = m33; - this.m41 = m41; - this.m42 = m42; - this.m43 = m43; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m23 = m23 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m32 = m32 ? 1 : 0; + this.m33 = m33 ? 1 : 0; + this.m41 = m41 ? 1 : 0; + this.m42 = m42 ? 1 : 0; + this.m43 = m43 ? 1 : 0; } /// @@ -2653,18 +2653,18 @@ public unsafe partial struct Bool4x3 /// The value to assign to the row at position [4]. public Bool4x3(Bool3 row1, Bool3 row2, Bool3 row3, Bool3 row4) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m13 = row1.Z; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m23 = row2.Z; - this.m31 = row3.X; - this.m32 = row3.Y; - this.m33 = row3.Z; - this.m41 = row4.X; - this.m42 = row4.Y; - this.m43 = row4.Z; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m13 = row1.Z ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m23 = row2.Z ? 1 : 0; + this.m31 = row3.X ? 1 : 0; + this.m32 = row3.Y ? 1 : 0; + this.m33 = row3.Z ? 1 : 0; + this.m41 = row4.X ? 1 : 0; + this.m42 = row4.Y ? 1 : 0; + this.m43 = row4.Z ? 1 : 0; } /// @@ -2704,62 +2704,62 @@ public unsafe partial struct Bool4x3 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [2, 3]. /// - public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m23), 1)); + public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m23)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [3, 2]. /// - public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m32), 1)); + public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m32)), 1)); /// /// Gets a reference to the value representing the component at position [3, 3]. /// - public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m33), 1)); + public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m33)), 1)); /// /// Gets a reference to the value representing the component at position [4, 1]. /// - public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m41), 1)); + public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m41)), 1)); /// /// Gets a reference to the value representing the component at position [4, 2]. /// - public readonly ref bool M42 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m42), 1)); + public readonly ref bool M42 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m42)), 1)); /// /// Gets a reference to the value representing the component at position [4, 3]. /// - public readonly ref bool M43 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m43), 1)); + public readonly ref bool M43 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m43)), 1)); /// /// Creates a new value with the same value for all its components. @@ -2769,18 +2769,18 @@ public unsafe partial struct Bool4x3 { Bool4x3 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m23 = x; - matrix.m31 = x; - matrix.m32 = x; - matrix.m33 = x; - matrix.m41 = x; - matrix.m42 = x; - matrix.m43 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m23 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m32 = x ? 1 : 0; + matrix.m33 = x ? 1 : 0; + matrix.m41 = x ? 1 : 0; + matrix.m42 = x ? 1 : 0; + matrix.m43 = x ? 1 : 0; return matrix; } @@ -2848,52 +2848,52 @@ public unsafe partial struct Bool4x4 private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool4x4), sizeof(Bool4)); [FieldOffset(0)] - private bool m11; + private int m11; [FieldOffset(4)] - private bool m12; + private int m12; [FieldOffset(8)] - private bool m13; + private int m13; [FieldOffset(12)] - private bool m14; + private int m14; [FieldOffset(16)] - private bool m21; + private int m21; [FieldOffset(20)] - private bool m22; + private int m22; [FieldOffset(24)] - private bool m23; + private int m23; [FieldOffset(28)] - private bool m24; + private int m24; [FieldOffset(32)] - private bool m31; + private int m31; [FieldOffset(36)] - private bool m32; + private int m32; [FieldOffset(40)] - private bool m33; + private int m33; [FieldOffset(44)] - private bool m34; + private int m34; [FieldOffset(48)] - private bool m41; + private int m41; [FieldOffset(52)] - private bool m42; + private int m42; [FieldOffset(56)] - private bool m43; + private int m43; [FieldOffset(60)] - private bool m44; + private int m44; /// /// Creates a new instance with the specified parameters. @@ -2916,22 +2916,22 @@ public unsafe partial struct Bool4x4 /// The value to assign to the component at position [4, 4]. public Bool4x4(bool m11, bool m12, bool m13, bool m14, bool m21, bool m22, bool m23, bool m24, bool m31, bool m32, bool m33, bool m34, bool m41, bool m42, bool m43, bool m44) { - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m14 = m14; - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m24 = m24; - this.m31 = m31; - this.m32 = m32; - this.m33 = m33; - this.m34 = m34; - this.m41 = m41; - this.m42 = m42; - this.m43 = m43; - this.m44 = m44; + this.m11 = m11 ? 1 : 0; + this.m12 = m12 ? 1 : 0; + this.m13 = m13 ? 1 : 0; + this.m14 = m14 ? 1 : 0; + this.m21 = m21 ? 1 : 0; + this.m22 = m22 ? 1 : 0; + this.m23 = m23 ? 1 : 0; + this.m24 = m24 ? 1 : 0; + this.m31 = m31 ? 1 : 0; + this.m32 = m32 ? 1 : 0; + this.m33 = m33 ? 1 : 0; + this.m34 = m34 ? 1 : 0; + this.m41 = m41 ? 1 : 0; + this.m42 = m42 ? 1 : 0; + this.m43 = m43 ? 1 : 0; + this.m44 = m44 ? 1 : 0; } /// @@ -2943,22 +2943,22 @@ public unsafe partial struct Bool4x4 /// The value to assign to the row at position [4]. public Bool4x4(Bool4 row1, Bool4 row2, Bool4 row3, Bool4 row4) { - this.m11 = row1.X; - this.m12 = row1.Y; - this.m13 = row1.Z; - this.m14 = row1.W; - this.m21 = row2.X; - this.m22 = row2.Y; - this.m23 = row2.Z; - this.m24 = row2.W; - this.m31 = row3.X; - this.m32 = row3.Y; - this.m33 = row3.Z; - this.m34 = row3.W; - this.m41 = row4.X; - this.m42 = row4.Y; - this.m43 = row4.Z; - this.m44 = row4.W; + this.m11 = row1.X ? 1 : 0; + this.m12 = row1.Y ? 1 : 0; + this.m13 = row1.Z ? 1 : 0; + this.m14 = row1.W ? 1 : 0; + this.m21 = row2.X ? 1 : 0; + this.m22 = row2.Y ? 1 : 0; + this.m23 = row2.Z ? 1 : 0; + this.m24 = row2.W ? 1 : 0; + this.m31 = row3.X ? 1 : 0; + this.m32 = row3.Y ? 1 : 0; + this.m33 = row3.Z ? 1 : 0; + this.m34 = row3.W ? 1 : 0; + this.m41 = row4.X ? 1 : 0; + this.m42 = row4.Y ? 1 : 0; + this.m43 = row4.Z ? 1 : 0; + this.m44 = row4.W ? 1 : 0; } /// @@ -2998,82 +2998,82 @@ public unsafe partial struct Bool4x4 /// /// Gets a reference to the value representing the component at position [1, 1]. /// - public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m11), 1)); + public readonly ref bool M11 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m11)), 1)); /// /// Gets a reference to the value representing the component at position [1, 2]. /// - public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m12), 1)); + public readonly ref bool M12 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m12)), 1)); /// /// Gets a reference to the value representing the component at position [1, 3]. /// - public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m13), 1)); + public readonly ref bool M13 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m13)), 1)); /// /// Gets a reference to the value representing the component at position [1, 4]. /// - public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m14), 1)); + public readonly ref bool M14 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m14)), 1)); /// /// Gets a reference to the value representing the component at position [2, 1]. /// - public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m21), 1)); + public readonly ref bool M21 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m21)), 1)); /// /// Gets a reference to the value representing the component at position [2, 2]. /// - public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m22), 1)); + public readonly ref bool M22 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m22)), 1)); /// /// Gets a reference to the value representing the component at position [2, 3]. /// - public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m23), 1)); + public readonly ref bool M23 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m23)), 1)); /// /// Gets a reference to the value representing the component at position [2, 4]. /// - public readonly ref bool M24 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m24), 1)); + public readonly ref bool M24 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m24)), 1)); /// /// Gets a reference to the value representing the component at position [3, 1]. /// - public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m31), 1)); + public readonly ref bool M31 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m31)), 1)); /// /// Gets a reference to the value representing the component at position [3, 2]. /// - public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m32), 1)); + public readonly ref bool M32 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m32)), 1)); /// /// Gets a reference to the value representing the component at position [3, 3]. /// - public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m33), 1)); + public readonly ref bool M33 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m33)), 1)); /// /// Gets a reference to the value representing the component at position [3, 4]. /// - public readonly ref bool M34 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m34), 1)); + public readonly ref bool M34 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m34)), 1)); /// /// Gets a reference to the value representing the component at position [4, 1]. /// - public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m41), 1)); + public readonly ref bool M41 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m41)), 1)); /// /// Gets a reference to the value representing the component at position [4, 2]. /// - public readonly ref bool M42 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m42), 1)); + public readonly ref bool M42 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m42)), 1)); /// /// Gets a reference to the value representing the component at position [4, 3]. /// - public readonly ref bool M43 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m43), 1)); + public readonly ref bool M43 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m43)), 1)); /// /// Gets a reference to the value representing the component at position [4, 4]. /// - public readonly ref bool M44 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m44), 1)); + public readonly ref bool M44 => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m44)), 1)); /// /// Creates a new value with the same value for all its components. @@ -3083,22 +3083,22 @@ public unsafe partial struct Bool4x4 { Bool4x4 matrix; - matrix.m11 = x; - matrix.m12 = x; - matrix.m13 = x; - matrix.m14 = x; - matrix.m21 = x; - matrix.m22 = x; - matrix.m23 = x; - matrix.m24 = x; - matrix.m31 = x; - matrix.m32 = x; - matrix.m33 = x; - matrix.m34 = x; - matrix.m41 = x; - matrix.m42 = x; - matrix.m43 = x; - matrix.m44 = x; + matrix.m11 = x ? 1 : 0; + matrix.m12 = x ? 1 : 0; + matrix.m13 = x ? 1 : 0; + matrix.m14 = x ? 1 : 0; + matrix.m21 = x ? 1 : 0; + matrix.m22 = x ? 1 : 0; + matrix.m23 = x ? 1 : 0; + matrix.m24 = x ? 1 : 0; + matrix.m31 = x ? 1 : 0; + matrix.m32 = x ? 1 : 0; + matrix.m33 = x ? 1 : 0; + matrix.m34 = x ? 1 : 0; + matrix.m41 = x ? 1 : 0; + matrix.m42 = x ? 1 : 0; + matrix.m43 = x ? 1 : 0; + matrix.m44 = x ? 1 : 0; return matrix; } diff --git a/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude b/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude index 0802a8df..981a7ba7 100644 --- a/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude @@ -35,6 +35,8 @@ namespace ComputeSharp; void GenerateMatrixProperties(string typeName, int rows, int columns, int elementSize) { string elementTypeName = typeName.ToLower(); + bool isBoolType = elementTypeName == "bool"; + string fieldElementTypeName = isBoolType ? "int" : elementTypeName; string fullTypeName = $"{typeName}{rows}x{columns}"; string rowTypeName = columns > 1 ? $"{typeName}{columns}" : elementTypeName; List fieldNames = new List(); @@ -56,7 +58,7 @@ public unsafe partial struct <#=fullTypeName#> for (int j = 1; j <= columns; j++) { WriteLine($"[FieldOffset({((i - 1) * columns + j - 1) * elementSize})]"); - WriteLine($"private {elementTypeName} m{i}{j};"); + WriteLine($"private {fieldElementTypeName} m{i}{j};"); WriteLine(""); fieldNames.Add($"m{i}{j}"); @@ -79,7 +81,15 @@ public unsafe partial struct <#=fullTypeName#> foreach (string fieldName in fieldNames) { - WriteLine($"this.{fieldName} = {fieldName};"); + if (isBoolType) + { + // For bools, normalize from bool to int + WriteLine($"this.{fieldName} = {fieldName} ? 1 : 0;"); + } + else + { + WriteLine($"this.{fieldName} = {fieldName};"); + } } PopIndent(); @@ -113,7 +123,15 @@ public unsafe partial struct <#=fullTypeName#> for (int i = 1; i <= rows; i++) for (int j = 1; j <= columns; j++) { - WriteLine($"this.m{i}{j} = row{i}.{"XYZW"[j - 1]};"); + if (isBoolType) + { + // Also normalize bools here as well + WriteLine($"this.m{i}{j} = row{i}.{"XYZW"[j - 1]} ? 1 : 0;"); + } + else + { + WriteLine($"this.m{i}{j} = row{i}.{"XYZW"[j - 1]};"); + } } PopIndent(); @@ -165,7 +183,20 @@ public unsafe partial struct <#=fullTypeName#> /// /// Gets a reference to the value representing the component at position [<#=i#>, <#=j#>]. /// +<# + if (isBoolType) + { +#> + public readonly ref <#=elementTypeName#> M<#=i#><#=j#> => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.m<#=i#><#=j#>)), 1)); +<# + } + else + { +#> public readonly ref <#=elementTypeName#> M<#=i#><#=j#> => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m<#=i#><#=j#>), 1)); +<# + } +#> <# } @@ -187,7 +218,14 @@ public unsafe partial struct <#=fullTypeName#> for (int i = 1; i <= rows; i++) for (int j = 1; j <= columns; j++) { - WriteLine($"matrix.m{i}{j} = x;"); + if (isBoolType) + { + WriteLine($"matrix.m{i}{j} = x ? 1 : 0;"); + } + else + { + WriteLine($"matrix.m{i}{j} = x;"); + } } WriteLine(""); diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index 12ab6988..e97ca1ec 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -49,6 +49,8 @@ void GenerateVectorProperties(string typeName, int elementSize) { string elementTypeName = Regex.Match(typeName, @"^[A-Za-z]+").Value; string hlslElementTypeName = elementTypeName.ToLower(); + bool isBoolType = hlslElementTypeName == "bool"; + string fieldElementTypeName = isBoolType ? "int" : hlslElementTypeName; int i = int.Parse(Regex.Match(typeName, @"\d+$").Value); string formattable = elementTypeName == "Bool" ? "" : "ISpanFormattable"; @@ -96,7 +98,7 @@ public unsafe partial struct <#=typeName#> foreach (char name in "xyzw".Substring(0, i)) { WriteLine($"[FieldOffset({"xyzw".IndexOf(name) * elementSize})]"); - WriteLine($"private {hlslElementTypeName} {name};"); + WriteLine($"private {fieldElementTypeName} {name};"); WriteLine(""); } @@ -201,7 +203,16 @@ public unsafe partial struct <#=typeName#> // Property Write($"public readonly {refType} {propertyType} {propertyName} "); - WriteLine($"=> ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.{fieldName}), 1));"); + + if (isBoolType) + { + // For bool types, also reinterpret cast from int to bool (the backing field is int to ensure all 4 bytes are initialized) + WriteLine($"=> ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.As(ref Unsafe.AsRef(in this.{fieldName})), 1));"); + } + else + { + WriteLine($"=> ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.{fieldName}), 1));"); + } } else { @@ -233,9 +244,9 @@ public unsafe partial struct <#=typeName#> public override readonly string ToString() { #if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>"); + return string.Create(null, stackalloc char[32], $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c} != 0}}"))#>>"); #else - return $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>"; + return $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c} != 0}}"))#>>"; #endif } <#