From ac76fc326823cff83390b79d4e955c8909ab0d85 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 15 Mar 2021 22:14:01 +0100 Subject: [PATCH] Added bool negation operator to vector types --- src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs | 7 +++++++ src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs | 7 +++++++ src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs | 7 +++++++ src/ComputeSharp/Core/Primitives/VectorType.ttinclude | 5 +++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs index c5935638..55dc22ab 100644 --- a/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs +++ b/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs @@ -115,5 +115,12 @@ namespace ComputeSharp return sb.ToString(); } + + /// + /// Negates a value. + /// + /// The value to negate. + /// 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; } } diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs index 42a59fa3..1c4a4eb6 100644 --- a/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs +++ b/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs @@ -514,5 +514,12 @@ namespace ComputeSharp return sb.ToString(); } + + /// + /// Negates a value. + /// + /// The value to negate. + /// 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; } } diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs index f54edec5..208fd259 100644 --- a/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs +++ b/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs @@ -4129,5 +4129,12 @@ namespace ComputeSharp return sb.ToString(); } + + /// + /// Negates a value. + /// + /// The value to negate. + /// 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; } } diff --git a/src/ComputeSharp/Core/Primitives/VectorType.ttinclude b/src/ComputeSharp/Core/Primitives/VectorType.ttinclude index c248b560..6ed15886 100644 --- a/src/ComputeSharp/Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp/Core/Primitives/VectorType.ttinclude @@ -242,18 +242,19 @@ namespace ComputeSharp } // Generate the negation operator - if (elementTypeName != "Bool" && elementTypeName != "UInt") + if (elementTypeName != "UInt") { WriteLine(""); string argumentName = "xyzw".Substring(0, i); + string operatorName = elementTypeName == "Bool" ? "!" : "-"; #> /// /// Negates a value. /// /// The value to negate. /// 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#> <#=argumentName#>) => default; + public static <#=typeName#> operator <#=operatorName#>(<#=typeName#> <#=argumentName#>) => default; <# }