From dbd7fc092e3d565359408678bf922851e034d947 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 25 Aug 2022 03:29:59 +0200 Subject: [PATCH] Add bool bitwise operators to Bool type --- src/ComputeSharp.Core/Primitives/Bool/Bool.cs | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) 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. ///