diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs index 0afc912d..c6ec789c 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs @@ -56,6 +56,39 @@ public readonly struct Bool } #endif + /// + /// Inverts the value represented by a given instance. + /// + /// The input instance. + public static Bool operator !(Bool x) => new(!x.Value); + + /// + /// 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 Bool operator &(Bool left, Bool 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 Bool operator |(Bool left, Bool 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 Bool operator ^(Bool left, Bool right) => default; + /// /// Checks whether or not two instances represent the same value. /// @@ -70,12 +103,6 @@ public readonly struct Bool /// The right instance. public static bool operator !=(Bool left, Bool right) => left.Value != right.Value; - /// - /// Inverts the value represented by a given instance. - /// - /// The input instance. - public static Bool operator !(Bool x) => new(!x.Value); - /// /// Converts a given instance to its corresponding value. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs index 34d874b1..d4e42c00 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs @@ -430,6 +430,33 @@ public unsafe partial struct Bool2 /// 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. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs index 43b366c4..1818699b 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs @@ -1516,6 +1516,33 @@ public unsafe partial struct Bool3 /// 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 Bool3 operator !(Bool3 xyz) => 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 Bool3 operator &(Bool3 left, Bool3 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 Bool3 operator |(Bool3 left, Bool3 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 Bool3 operator ^(Bool3 left, Bool3 right) => default; + /// /// Compares two values to see if they are equal. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs index 13e9c565..84270626 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs @@ -4162,6 +4162,33 @@ public unsafe partial struct Bool4 /// 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 Bool4 operator !(Bool4 xyzw) => 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 Bool4 operator &(Bool4 left, Bool4 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 Bool4 operator |(Bool4 left, Bool4 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 Bool4 operator ^(Bool4 left, Bool4 right) => default; + /// /// Compares two values to see if they are equal. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs b/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs index e6160738..941c3221 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs @@ -89,6 +89,33 @@ public unsafe partial struct Bool1x1 /// 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 Bool1x1 operator !(Bool1x1 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool1x1 operator &(Bool1x1 left, Bool1x1 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 Bool1x1 operator |(Bool1x1 left, Bool1x1 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 Bool1x1 operator ^(Bool1x1 left, Bool1x1 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -199,6 +226,33 @@ public unsafe partial struct Bool1x2 /// 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 Bool1x2 operator !(Bool1x2 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool1x2 operator &(Bool1x2 left, Bool1x2 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 Bool1x2 operator |(Bool1x2 left, Bool1x2 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 Bool1x2 operator ^(Bool1x2 left, Bool1x2 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -326,6 +380,33 @@ public unsafe partial struct Bool1x3 /// 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 Bool1x3 operator !(Bool1x3 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool1x3 operator &(Bool1x3 left, Bool1x3 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 Bool1x3 operator |(Bool1x3 left, Bool1x3 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 Bool1x3 operator ^(Bool1x3 left, Bool1x3 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -464,6 +545,33 @@ public unsafe partial struct Bool1x4 /// 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 Bool1x4 operator !(Bool1x4 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool1x4 operator &(Bool1x4 left, Bool1x4 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 Bool1x4 operator |(Bool1x4 left, Bool1x4 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 Bool1x4 operator ^(Bool1x4 left, Bool1x4 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -580,6 +688,33 @@ public unsafe partial struct Bool2x1 /// 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 Bool2x1 operator !(Bool2x1 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool2x1 operator &(Bool2x1 left, Bool2x1 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 Bool2x1 operator |(Bool2x1 left, Bool2x1 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 Bool2x1 operator ^(Bool2x1 left, Bool2x1 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -731,6 +866,33 @@ public unsafe partial struct Bool2x2 /// 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 Bool2x2 operator !(Bool2x2 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool2x2 operator &(Bool2x2 left, Bool2x2 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 Bool2x2 operator |(Bool2x2 left, Bool2x2 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 Bool2x2 operator ^(Bool2x2 left, Bool2x2 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -900,6 +1062,33 @@ public unsafe partial struct Bool2x3 /// 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 Bool2x3 operator !(Bool2x3 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool2x3 operator &(Bool2x3 left, Bool2x3 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 Bool2x3 operator |(Bool2x3 left, Bool2x3 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 Bool2x3 operator ^(Bool2x3 left, Bool2x3 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -1093,6 +1282,33 @@ public unsafe partial struct Bool2x4 /// 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 Bool2x4 operator !(Bool2x4 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool2x4 operator &(Bool2x4 left, Bool2x4 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 Bool2x4 operator |(Bool2x4 left, Bool2x4 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 Bool2x4 operator ^(Bool2x4 left, Bool2x4 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -1214,6 +1430,33 @@ public unsafe partial struct Bool3x1 /// 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 Bool3x1 operator !(Bool3x1 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool3x1 operator &(Bool3x1 left, Bool3x1 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 Bool3x1 operator |(Bool3x1 left, Bool3x1 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 Bool3x1 operator ^(Bool3x1 left, Bool3x1 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -1390,6 +1633,33 @@ public unsafe partial struct Bool3x2 /// 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 Bool3x2 operator !(Bool3x2 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool3x2 operator &(Bool3x2 left, Bool3x2 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 Bool3x2 operator |(Bool3x2 left, Bool3x2 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 Bool3x2 operator ^(Bool3x2 left, Bool3x2 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -1596,6 +1866,33 @@ public unsafe partial struct Bool3x3 /// 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 Bool3x3 operator !(Bool3x3 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool3x3 operator &(Bool3x3 left, Bool3x3 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 Bool3x3 operator |(Bool3x3 left, Bool3x3 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 Bool3x3 operator ^(Bool3x3 left, Bool3x3 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -1838,6 +2135,33 @@ public unsafe partial struct Bool3x4 /// 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 Bool3x4 operator !(Bool3x4 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool3x4 operator &(Bool3x4 left, Bool3x4 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 Bool3x4 operator |(Bool3x4 left, Bool3x4 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 Bool3x4 operator ^(Bool3x4 left, Bool3x4 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -1970,6 +2294,33 @@ public unsafe partial struct Bool4x1 /// 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 Bool4x1 operator !(Bool4x1 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool4x1 operator &(Bool4x1 left, Bool4x1 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 Bool4x1 operator |(Bool4x1 left, Bool4x1 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 Bool4x1 operator ^(Bool4x1 left, Bool4x1 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -2171,6 +2522,33 @@ public unsafe partial struct Bool4x2 /// 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 Bool4x2 operator !(Bool4x2 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool4x2 operator &(Bool4x2 left, Bool4x2 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 Bool4x2 operator |(Bool4x2 left, Bool4x2 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 Bool4x2 operator ^(Bool4x2 left, Bool4x2 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -2414,6 +2792,33 @@ public unsafe partial struct Bool4x3 /// 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 Bool4x3 operator !(Bool4x3 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool4x3 operator &(Bool4x3 left, Bool4x3 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 Bool4x3 operator |(Bool4x3 left, Bool4x3 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 Bool4x3 operator ^(Bool4x3 left, Bool4x3 right) => default; + /// /// Compares two values to see if they are equal. /// @@ -2705,6 +3110,33 @@ public unsafe partial struct Bool4x4 /// 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 Bool4x4 operator !(Bool4x4 matrix) => default; + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 Bool4x4 operator &(Bool4x4 left, Bool4x4 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 Bool4x4 operator |(Bool4x4 left, Bool4x4 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 Bool4x4 operator ^(Bool4x4 left, Bool4x4 right) => default; + /// /// Compares two values to see if they are equal. /// diff --git a/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude b/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude index 552b6a55..0802a8df 100644 --- a/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude @@ -407,6 +407,38 @@ public unsafe partial struct <#=fullTypeName#> public static <#=fullTypeName#> operator ^(<#=fullTypeName#> left, UInt<#=rows#>x<#=columns#> right) => default; <# } + else if (typeName == "Bool") + { + WriteLine(""); +#> + /// + /// Ands two values. + /// + /// The value to and. + /// The value to combine. + /// The result of performing the 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 <#=fullTypeName#> operator &(<#=fullTypeName#> left, <#=fullTypeName#> 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 <#=fullTypeName#> operator |(<#=fullTypeName#> left, <#=fullTypeName#> 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 <#=fullTypeName#> operator ^(<#=fullTypeName#> left, <#=fullTypeName#> right) => default; +<# + } WriteLine(""); #> diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index e2258729..12ab6988 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -500,6 +500,40 @@ public unsafe partial struct <#=typeName#> public static <#=typeName#> operator ^(<#=typeName#> left, UInt<#=i#> right) => default; <# } + else if (elementTypeName == "Bool") + { + string argumentName = "xyzw".Substring(0, i); + + WriteLine(""); +#> + /// + /// 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 <#=typeName#> operator &(<#=typeName#> left, <#=typeName#> 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 <#=typeName#> operator |(<#=typeName#> left, <#=typeName#> 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 <#=typeName#> operator ^(<#=typeName#> left, <#=typeName#> right) => default; +<# + } WriteLine(""); #> diff --git a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs index 80dac267..9f2dc298 100644 --- a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs @@ -191,6 +191,52 @@ public partial class ShaderRewriterTests } } + [CombinatorialTestMethod] + [AllDevices] + public void BooleanHlslOperators(Device device) + { + int[] data = { 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + using ReadWriteBuffer buffer = device.Get().AllocateReadWriteBuffer(data); + + device.Get().For(1, new BooleanOperatorsShader(buffer)); + + int[] results = buffer.ToArray(); + + CollectionAssert.AreEqual( + expected: new[] { 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1 }, + actual: results); + } + + [AutoConstructor] + internal readonly partial struct BooleanOperatorsShader : IComputeShader + { + public readonly ReadWriteBuffer buffer; + + public void Execute() + { + bool4 a = new int4(buffer[0], buffer[1], buffer[2], buffer[3]) == 1; + bool4 b = new int4(buffer[4], buffer[5], buffer[6], buffer[7]) == 1; + + bool4 c = a & b; + bool4 d = a | b; + bool4 e = a ^ b; + + buffer[8] = c.X ? 1 : 0; + buffer[9] = c.Y ? 1 : 0; + buffer[10] = c.Z ? 1 : 0; + buffer[11] = c.W ? 1 : 0; + buffer[12] = d.X ? 1 : 0; + buffer[13] = d.Y ? 1 : 0; + buffer[14] = d.Z ? 1 : 0; + buffer[15] = d.W ? 1 : 0; + buffer[16] = e.X ? 1 : 0; + buffer[17] = e.Y ? 1 : 0; + buffer[18] = e.Z ? 1 : 0; + buffer[19] = e.W ? 1 : 0; + } + } + // See: https://github.com/Sergio0694/ComputeSharp/issues/259 [CombinatorialTestMethod] [AllDevices]